示例#1
0
文件: copy.cpp 项目: vicr123/thefile
copy::copy(QStringList source, QString dest, bool deleteOriginal, MainWindow *parent) : QObject(parent)
{
    this->source = source;
    this->dest = dest;

    progressBar = new QProgressBar();

    QThread *thread = new QThread;
    copyWorker *worker = new copyWorker(source, dest, deleteOriginal);
    worker->moveToThread(thread);
    //connect(worker, SIGNAL (error(QString)), this, SLOT (errorString(QString)));
    connect(thread, SIGNAL (started()), worker, SLOT (process()));
    connect(worker, SIGNAL (finished()), thread, SLOT (quit()));
    connect(worker, SIGNAL (finished()), worker, SLOT (deleteLater()));
    connect(thread, SIGNAL (finished()), thread, SLOT (deleteLater()));
    connect(worker, SIGNAL(finished()), this, SLOT(copyFinished()));
    connect(worker, SIGNAL(progress(quint64,quint64,QString,QString)), this, SLOT(progress(quint64,quint64,QString,QString)));
    window = new transferWindow();
    connect(window, SIGNAL(cancelTransfer()), worker, SLOT(cancelTransfer()));
    connect(this, SIGNAL(prog(qint64,qint64,QString,QString)), window, SLOT(prog(qint64,qint64,QString,QString)));
    connect(worker, SIGNAL(fileConflict(QString)), window, SLOT(fileConflict(QString)));
    connect(window, SIGNAL(continueTransfer(copyWorker::continueTransferOptions,bool)), worker, SLOT(continueTransfer(copyWorker::continueTransferOptions,bool)));
    window->show();
    thread->start();

    //transferWin->show();
    //int rowIndex = transferWin->table->rowCount();
    //transferWin->table->setRowCount(transferWin->table->rowCount() + 1);
    //transferWin->table->setCellWidget(rowIndex, 2, progressBar);

}
示例#2
0
MailMessageClient::MailMessageClient(QObject* parent)
    : QObject(parent),
      adaptor(new QtopiaIpcAdaptor("QPE/QMailMessageServer", this))
{
    QtopiaIpcAdaptor::connect(this, SIGNAL(statusChanged(QMailMessageServer::Operation,QString,QString)),
                              adaptor, MESSAGE(statusChanged(QMailMessageServer::Operation, QString, QString)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(retrievalTotal(uint)),
                              adaptor, MESSAGE(retrievalTotal(uint)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(retrievalProgress(uint)),
                              adaptor, MESSAGE(retrievalProgress(uint)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(sendTotal(uint)),
                              adaptor, MESSAGE(sendTotal(uint)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(sendProgress(uint)),
                              adaptor, MESSAGE(sendProgress(uint)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(sendCompleted()), 
                              adaptor, MESSAGE(sendCompleted()));
    QtopiaIpcAdaptor::connect(this, SIGNAL(messageSent(QMailMessageId)), 
                              adaptor, MESSAGE(messageSent(QMailMessageId)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(errorOccurred(QMailAccountId,QString,int)),
                              adaptor, MESSAGE(errorOccurred(QMailAccountId, QString, int)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(newCountChanged(QMailMessageCountMap)),
                              adaptor, MESSAGE(newCountChanged(QMailMessageCountMap)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(partialMessageRetrieved(QMailMessageMetaData)),
                              adaptor, MESSAGE(partialMessageRetrieved(QMailMessageMetaData)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(messageRetrieved(QMailMessageMetaData)),
                              adaptor, MESSAGE(messageRetrieved(QMailMessageMetaData)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(partialRetrievalCompleted()),
                              adaptor, MESSAGE(partialRetrievalCompleted()));
    QtopiaIpcAdaptor::connect(this, SIGNAL(retrievalCompleted()),
                              adaptor, MESSAGE(retrievalCompleted()));
    QtopiaIpcAdaptor::connect(this, SIGNAL(searchTotal(uint)),
                              adaptor, MESSAGE(searchTotal(uint)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(searchProgress(uint)),
                              adaptor, MESSAGE(searchProgress(uint)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(matchingMessageIds(QMailMessageIdList)), 
                              adaptor, MESSAGE(matchingMessageIds(QMailMessageIdList)));
    QtopiaIpcAdaptor::connect(this, SIGNAL(searchCompleted()), 
                              adaptor, MESSAGE(searchCompleted()));
    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(cancelSearch()),
                              this, SIGNAL(cancelSearch()));

    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(send(QMailMessageIdList)),
                              this, SIGNAL(send(QMailMessageIdList)));
    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(retrieve(QMailAccountId, bool)),
                              this, SIGNAL(retrieve(QMailAccountId, bool)));
    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(completeRetrieval(QMailMessageIdList)),
                              this, SIGNAL(completeRetrieval(QMailMessageIdList)));
    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(cancelTransfer()),
                              this, SIGNAL(cancelTransfer()));
    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(acknowledgeNewMessages(QMailMessageTypeList)),
                              this, SIGNAL(acknowledgeNewMessages(QMailMessageTypeList)));
    QtopiaIpcAdaptor::connect(adaptor, MESSAGE(searchMessages(QMailMessageKey, QString)),
                              this, SIGNAL(searchMessages(QMailMessageKey, QString)));
}
示例#3
0
void FileTransferInstance::pressFromHtml(QString code)
{
    if (state == tsFinished || state == tsCanceled)
        return;

    if (direction == ToxFile::SENDING)
    {
        if (code == "btnA")
            cancelTransfer();
        else if (code == "btnB")
            pauseResumeSend();
    } else {
        if (code == "btnA")
            rejectRecvRequest();
        else if (code == "btnB")
        {
            if (state == tsPending)
                acceptRecvRequest();
            else
                pauseResumeRecv();
        }
    }
}
示例#4
0
void KSircIODCC::sirc_receive(QString str)
{
  // Parse the string to find out what type it is.
  // Note the order here.  
  // Most people tend to receive files, so let's
  // parse the byte xfered messages first since there's lot's of them.
  // The we get lots of send bytexfer messages so parse them second.
  // Then we look at the one time start/stop messages.  They only arrive 
  // once in a long long time (compared to the byte messages) so if it takes
  // a few extra clock cycles to find them, who cares?
  if(str.find("DCC GET read:", 0) != -1){
    //
    // Find the filename first
    //
    int pos1 = 18; // String starts at 20, fixed length.
    int pos2 = str.find(" ", pos1);
    if(pos2 < 0)
      return;
    QString filename = str.mid(pos1, pos2 - pos1);
    //
    // Does the DCCInfo exist? If not, exit now.
    //
    DCCInfo *stat = DCCStatus[filename];
    if(stat == 0){
      proc->getWindowList()["!default"]->sirc_receive(
					"*E* DCC Premature Close");
      //      proc->getWindowList()["!default"]->sirc_receive(str);
      return;
    }
    //
    // Find the number of bytes transfered.
    //
    pos1 = pos2 + 8; // Next string is 8 characters after the next the filename
    pos2 = str.length();
    int bytesXfer = str.mid(pos1, pos2-pos1).toInt();
    //
    // Only update the display for 1% intervals.
    // LastSize + 1%Size must be less than the total xfered bytes.
    //
    if(bytesXfer > (stat->LastSize + stat->PercentSize)){
      ASSERT(stat->PercentSize > 0); // We devide by this!
      ASSERT(bytesXfer > 0); // Setting progress back to 0 screws it up
      DlgList[filename]->setValue(bytesXfer/(stat->PercentSize));
      stat->LastSize = bytesXfer;
    }
  }
  else if(str.find("DCC SEND write:", 0) != -1){
    //
    // Find the filename, it's first byte is fixed at 22.
    //
    int pos1 = 20; // Starting bye is fixed.
    int pos2 = str.find(" ", pos1);
    if(pos2 < 0)
      return;
    QString filename = str.mid(pos1, pos2 - pos1);
    // 
    // Let's get and make sure DCCInfo holds the right status info.
    //
    DCCInfo *stat = DCCStatus[filename];
    if(stat == 0){
      proc->getWindowList()["!default"]->sirc_receive(
					 "*E* DCC Premature Close - flushing buffers"
					 );
      //      proc->getWindowList()["!default"]->sirc_receive(str);
      return;
    }
    //
    // Fine the bytesXfered.  Start is 8 bytes after end of filename. 
    // No error checking since pos2 is > 0 therefor pos1 is > 0.
    // and string is not 0 length, therefor pos2 is > 0.
    //
    pos1 = pos2 + 8;
    pos2 = str.length();
    int bytesXfer = str.mid(pos1, pos2-pos1).toInt();
    //
    // We're in progress now, check to see if that's out status and set it so
    //
    if(stat->inProgress == FALSE){
      stat->inProgress = TRUE;
      DlgList[filename]->setTopText("DCC Sending: " + filename);      
    }
    //
    // Don't update except for 1 percent intervals.
    //
    if(bytesXfer > (stat->LastSize + stat->PercentSize)){
      ASSERT(stat->PercentSize > 0); // We devide by this!
      ASSERT(bytesXfer >= 0); // Setting progress back to 0 screws it up
      DlgList[filename]->setValue(bytesXfer/(stat->PercentSize));
      stat->LastSize = bytesXfer;
    }
  }
  else if(str.find("DCC SEND (", 0) != -1){
    int pos1 = str.find("SEND") + 6;
    int pos2 = str.find(")", pos1);
    if((pos1 < 0) || (pos2 < 0)){
      cerr << "FILENAME Pos1/Pos2 " << pos1 << '/' << pos2 << endl;
      return;
    }
    QString filename = str.mid(pos1, pos2 - pos1);
    pos1 = str.find("(size: ") + 7;
    pos2 = str.find(")", pos1);
    if((pos1 < 0) || (pos2 < 0)){
      cerr << "SIZE Pos1/Pos2 " << pos1 << '/' << pos2 << endl;
      return;
    }
    QString size = str.mid(pos1, pos2-pos1);
    int fileSize = size.toInt(); // Bytes per step
    if(fileSize >= 100){
      fileSize /= 100;
    }
    else{
      fileSize = 1;
    }
    pos1 = str.find(" from ") + 6;
    pos2 = str.find(" ", pos1);
    if((pos1 < 0) || (pos2 < 0)){
      cerr << "FROM Pos1/Pos2 " << pos1 << '/' << pos2 << endl;
      return;
    }
    QString nick = str.mid(pos1, pos2 - pos1);
    // Setup info structure before xfer list in case they press cancel.
    DCCInfo *stat = new("DCCInfo") DCCInfo;
    stat->LastSize = 0;
    stat->PercentSize = fileSize;
    stat->nick = nick;
    stat->cancelMessage = "/dcc close get " + nick + " " + filename + "\n";
    stat->inProgress = FALSE;
    DCCStatus.insert(filename, stat);
    // Setup and make xfer dialog.
    DlgList.insert(filename, new("KSProgress") KSProgress());
    DlgList[filename]->setID(filename);
    DlgList[filename]->setRange(0,100);
    DlgList[filename]->setTopText("DCC Receving: " + filename);
    DlgList[filename]->setBotText("Size: " + size);
    connect(DlgList[filename], SIGNAL(cancel(QString)),
	    this, SLOT(cancelTransfer(QString)));
    // Add file to pending list, and show it if needed
    pending->fileListing()->insertItem(nick + " offered " + filename);
    pending->fileListing()->setCurrentItem(pending->fileListing()->count()-1);
    if(pending->isVisible() == FALSE)
      pending->show();
  }
  else if(str.find("Sent DCC SEND", 0) != -1){
    // Message for form: *D* Sent DCC SEND request to nick (file,size)
    //    cerr << "Got: " << str << endl;
    // Find the users nick
    int pos1 = str.find("request to ") + 11;
    int pos2 = str.find(" ", pos1);
    if((pos1 < 0) || (pos2 < 0)){
      cerr << "NICK Pos1/Pos2 " << pos1 << '/' << pos2 << endl;
      return;
    }
    QString nick = str.mid(pos1, pos2 - pos1);
    // Find the filename
    pos1 = str.find("(",pos2) + 1; // Start from last offset
    pos2 = str.find(",", pos1);    // until the comma
    if((pos1 < 0) || (pos2 < 0)){
      cerr << "FILENAME Pos1/Pos2 " << pos1 << '/' << pos2 << endl;
      return;
    }
    QString filename = str.mid(pos1, pos2-pos1);
    // Find the size
    pos1 = pos2 + 1; // size start is right after comma
    pos2 = str.find(")", pos1); // look for last )
    if((pos1 < 0) || (pos2 < 0)){
      cerr << "SIZE Pos1/Pos2 " << pos1 << '/' << pos2 << endl;
      return;
    }
    QString size = str.mid(pos1, pos2-pos1);
    int fileSize = size.toInt(); // Bytes per step
    if(fileSize >= 100){
      fileSize /= 100;
    }
    else{
      fileSize = 1;
    }
    // Create status structure
    DCCInfo *stat = new("DCCInfo") DCCInfo;
    stat->LastSize = 0;
    stat->PercentSize = fileSize;
    stat->nick = nick;
    stat->cancelMessage = "/dcc close send " + nick + " " + filename + "\n";
    stat->inProgress = FALSE;
    DCCStatus.insert(filename, stat);
    // Create transfer status window
    DlgList.insert(filename, new("KSProgress") KSProgress());
    DlgList[filename]->setID(filename);
    DlgList[filename]->setRange(0,100);
    DlgList[filename]->setTopText("DCC Pending Send: " + filename);
    DlgList[filename]->setBotText("Size: " + size);
    DlgList[filename]->show();
    connect(DlgList[filename], SIGNAL(cancel(QString)),
	    this, SLOT(cancelTransfer(QString)));
  }
  else if(str.find("DCC transfer with") != -1){
    int pos1 = str.find(" (", 0)+2;
    int pos2 = str.find(")", pos1);
    QString filename = str.mid(pos1, pos2-pos1);
    delete DlgList[filename];
    DlgList.remove(filename);
    delete DCCStatus[filename];
    DCCStatus.remove(filename);
  }
  else{
    proc->getWindowList()["!default"]->sirc_receive(str);
  }
  
}