~ubuntu-branches/ubuntu/karmic/psi/karmic

« back to all changes in this revision

Viewing changes to src/filetransdlg.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jan Niehusmann
  • Date: 2008-08-28 18:46:52 UTC
  • mfrom: (1.2.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20080828184652-iiik12dl91nq7cdi
Tags: 0.12-2
Uploading to unstable (Closes: Bug#494352)

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
#include "psicon.h"
27
27
#include "psiaccount.h"
28
28
#include "userlist.h"
29
 
#include "common.h"
30
29
#include "iconwidget.h"
31
30
#include "s5b.h"
32
31
#include "busywidget.h"
33
32
#include "filetransfer.h"
34
33
#include "accountscombobox.h"
35
 
#include "profiles.h"
36
34
#include "psiiconset.h"
37
35
#include "msgmle.h"
38
36
#include "jidutil.h"
39
37
#include "psitooltip.h"
40
38
#include "psicontactlist.h"
41
39
#include "accountlabel.h"
 
40
#include "psioptions.h"
 
41
#include "fileutil.h"
42
42
 
43
43
typedef Q_UINT64 LARGE_TYPE;
44
44
 
446
446
 
447
447
void FileTransferHandler::trySend()
448
448
{
 
449
        // Since trySend comes from singleShot which is an "uncancelable"
 
450
        //   action, we should protect that d->ft is valid, for good measure
 
451
        if(!d->ft)
 
452
                return;
 
453
 
 
454
        // When FileTransfer emits error, you are not allowed to call
 
455
        //   dataSizeNeeded() afterwards.  Simetime ago, we changed to using
 
456
        //   QueuedConnection for error() signal delivery (see mapSignals()).
 
457
        //   This made it possible to call dataSizeNeeded by accident between
 
458
        //   the error() signal emit and the ft_error() slot invocation.  To
 
459
        //   work around this problem, we'll check to see if the FileTransfer
 
460
        //   is internally active by checking if s5bConnection() is null.
 
461
        //   FIXME: this probably breaks other file transfer methods, whenever
 
462
        //   we get those.  Probably we need a real fix in Iris..
 
463
        if(!d->ft->s5bConnection())
 
464
                return;
 
465
 
449
466
        int blockSize = d->ft->dataSizeNeeded();
450
467
        QByteArray a(blockSize, 0);
451
468
        int r = 0;
585
602
                        QTimer::singleShot(0, this, SLOT(reject()));
586
603
                        return;
587
604
                }
588
 
                
589
 
                option.lastPath = fi.dirPath();
 
605
 
 
606
                FileUtil::setLastUsedSavePath(fi.dirPath());
590
607
                le_fname->setText(QDir::convertSeparators(fi.filePath()));
591
608
                lb_size->setText(tr("%1 byte(s)").arg(fi.size())); // TODO: large file support
592
609
        }
753
770
 
754
771
void FileRequestDlg::chooseFile()
755
772
{
756
 
        while(1) {
757
 
                if(option.lastPath.isEmpty())
758
 
                        option.lastPath = QDir::homeDirPath();
759
 
                QString str = QFileDialog::getOpenFileName(this, tr("Choose a file"), option.lastPath, tr("All files (*)"));
760
 
                if(!str.isEmpty()) {
761
 
                        QFileInfo fi(str);
762
 
                        if(!fi.exists()) {
763
 
                                QMessageBox::information(this, tr("Error"), tr("The file specified does not exist."));
764
 
                                continue;
765
 
                        }
766
 
                        option.lastPath = fi.dirPath();
767
 
                        le_fname->setText(QDir::convertSeparators(fi.filePath()));
768
 
                        lb_size->setText(tr("%1 byte(s)").arg(fi.size())); // TODO: large file support
769
 
                }
770
 
                break;
 
773
        QString str = FileUtil::getOpenFileName(this,
 
774
                                                tr("Choose a file"),
 
775
                                                tr("All files (*)"));
 
776
        if (!str.isEmpty()) {
 
777
                QFileInfo fi(str);
 
778
                le_fname->setText(QDir::convertSeparators(fi.filePath()));
 
779
                lb_size->setText(tr("%1 byte(s)").arg(fi.size())); // TODO: large file support
771
780
        }
772
781
}
773
782
 
808
817
        }
809
818
        else {
810
819
                QString fname, savename;
811
 
                if(option.lastSavePath.isEmpty())
812
 
                        option.lastSavePath = QDir::homeDirPath();
813
 
                fname = QFileDialog::getSaveFileName(this, tr("Save As"), QDir(option.lastSavePath).filePath(d->fileName), tr("All files (*)"));
 
820
                fname = FileUtil::getSaveFileName(this,
 
821
                                                  tr("Save As"),
 
822
                                                  d->fileName,
 
823
                                                  tr("All files (*)"));
814
824
                if(fname.isEmpty())
815
825
                        return;
816
826
                QFileInfo fi(fname);
817
 
                option.lastSavePath = fi.dirPath();
818
827
                savename = fname + ".part";
819
828
                fname = fi.fileName();
820
829
 
1533
1542
                                }
1534
1543
                        }
1535
1544
 
1536
 
                        pa->playSound(option.onevent[eFTComplete]);
 
1545
                        pa->playSound(PsiOptions::instance()->getOption("options.ui.notifications.sounds.completed-file-transfer").toString());
1537
1546
                }
1538
1547
        }
1539
1548
};