ChatClient::ChatClient(QObject *parent) : QXmppClient(parent) , d(new ChatClientPrivate) { bool check; Q_UNUSED(check); check = connect(this, SIGNAL(connected()), this, SLOT(_q_connected())); Q_ASSERT(check); check = connect(this, SIGNAL(error(QXmppClient::Error)), this, SLOT(_q_error(QXmppClient::Error))); Q_ASSERT(check); check = connect(this, SIGNAL(messageReceived(QXmppMessage)), this, SLOT(_q_messageReceived(QXmppMessage))); Q_ASSERT(check); // DNS lookups check = connect(&d->dns, SIGNAL(finished()), this, SLOT(_q_dnsLookupFinished())); Q_ASSERT(check); // service discovery d->discoManager = findExtension<QXmppDiscoveryManager>(); check = connect(d->discoManager, SIGNAL(infoReceived(QXmppDiscoveryIq)), this, SLOT(_q_discoveryInfoReceived(QXmppDiscoveryIq))); Q_ASSERT(check); check = connect(d->discoManager, SIGNAL(itemsReceived(QXmppDiscoveryIq)), this, SLOT(_q_discoveryItemsReceived(QXmppDiscoveryIq))); Q_ASSERT(check); // server time d->timeManager = findExtension<QXmppEntityTimeManager>(); check = connect(d->timeManager, SIGNAL(timeReceived(QXmppEntityTimeIq)), this, SLOT(_q_timeReceived(QXmppEntityTimeIq))); Q_ASSERT(check); // file transfers transferManager()->setSupportedMethods(QXmppTransferJob::SocksMethod); // multimedia calls callManager(); // diagnostics diagnosticManager(); qDebug("ChatClient 0x%llx created", reinterpret_cast<qint64>(this)); chatClients.append(this); theClientObserver()->clientCreated(this); }
// To add a new file transfer thread int FileTransferServer::addTransferThread(const std::string& srcUser, const std::string& srcMachineName, const std::string& srcUserKey, const std::string& destUser, const std::string& destMachineName, const FMS_Data::CpFileOptions& options) { updateData(); // update datas and get the vishnu transfer id int direction; if (vishnu::ifLocalTransferInvolved(srcMachineName, destMachineName, direction)) { mfileTransfer.setStatus(vishnu::TRANSFER_WAITING_CLIENT_RESPONSE); updateDatabaseRecord(); if (destUser.empty()) { std::string tmp = mfileTransfer.getSourceFilePath(); mfileTransfer.setSourceFilePath(srcUser+"@"+srcMachineName+":"+tmp); } else { std::string tmp = mfileTransfer.getDestinationFilePath(); mfileTransfer.setDestinationFilePath(destUser+"@"+destMachineName+":"+tmp); } LOG("[INFO] request transfer from client size", 1); return 0; } FMS_Data::CpFileOptions optionsCopy(options); int timeout (0); //FIXE: get timeout from config // if (options.getTrCommand() == vishnu::UNDEFINED_TRANSFER_MANAGER) { // std::string sessionId = msessionServer.getAttribut("where sessionkey='"+FileTransferServer::getDatabaseInstance()->escapeData((msessionServer.getData()).getSessionKey())+"'", "vsessionid"); // std::string query="SELECT users.numuserid,users_numuserid,vsessionid from users,vsession " // " WHERE vsession.users_numuserid=users.numuserid " // " AND vsessionid='"+ FileTransferServer::getDatabaseInstance()->escapeData(sessionId)+"'"; // boost::scoped_ptr<DatabaseResult> dbResult(FileTransferServer::getDatabaseInstance()->getResult(query)); // if (dbResult->getNbTuples() != 0) { // std::string numuserId= dbResult->getFirstElement(); // OptionValueServer optionValueServer; // optionsCopy.setTrCommand(optionValueServer.getOptionValueForUser(numuserId, TRANSFERCMD_OPT)); // timeout = optionValueServer.getOptionValueForUser(numuserId, TRANSFER_TIMEOUT_OPT); // } // } boost::scoped_ptr<FileTransferCommand> transferManager( FileTransferCommand::getTransferManager(optionsCopy, timeout)); boost::scoped_ptr<SSHFile> srcFileServer( new SSHFile(msessionServer, mfileTransfer.getSourceFilePath(), srcMachineName, srcUser, "", srcUserKey, "", FileTransferServer::getSSHPort(), FileTransferServer::getSSHCommand(), transferManager->getLocation())); mfileTransfer.setTrCommand(optionsCopy.getTrCommand()); mfileTransfer.setStatus(vishnu::TRANSFER_INPROGRESS); //INPPROGRESS if (! srcFileServer->exists() || ! srcFileServer->getErrorMsg().empty()) { mfileTransfer.setStatus(vishnu::TRANSFER_FAILED); mfileTransfer.setSize(0); mfileTransfer.setStartTime(0); mfileTransfer.setErrorMsg(srcFileServer->getErrorMsg()); updateDatabaseRecord(); throw FMSVishnuException(ERRCODE_RUNTIME_ERROR,srcFileServer->getErrorMsg()); } mfileTransfer.setSize(srcFileServer->getSize()); mfileTransfer.setStartTime(0); if ( srcUser==destUser && srcMachineName == destMachineName && mfileTransfer.getSourceFilePath() == mfileTransfer.getDestinationFilePath()) { mfileTransfer.setStatus(vishnu::TRANSFER_FAILED); //failed mfileTransfer.setErrorMsg("same source and destination"); updateDatabaseRecord(); throw FMSVishnuException(ERRCODE_RUNTIME_ERROR, "same source and destination "); } // create a TransferExec instance TransferExec transferExec(msessionServer, srcUser, srcMachineName, mfileTransfer.getSourceFilePath(), srcUserKey, destUser, destMachineName, mfileTransfer.getDestinationFilePath(), mfileTransfer.getTransferId()); updateDatabaseRecord(); // create the thread to perform the copy if (mtransferType == File::copy) { mthread = boost::thread(&FileTransferServer::copy, this, transferExec, transferManager->getCommand()); } else if (mtransferType == File::move) { mthread = boost::thread(&FileTransferServer::move, this, transferExec, transferManager->getCommand()); } return 0; }