// Aggiornamento delle statistiche di invio void DuktoProtocol::updateStatus() { if (mIsSending) transferStatusUpdate((int)((float)(mSentData) / (float)(mTotalSize) * 100)); else if (mIsReceiving) transferStatusUpdate((int)((float)(mTotalReceivedData) / (float)(mTotalSize) * 100)); }
// Aggiornamento delle statistiche di invio void DuktoProtocol::updateStatus() { if (mIsSending) emit transferStatusUpdate(mTotalSize, mSentData); else if (mIsReceiving) emit transferStatusUpdate(mTotalSize, mTotalReceivedData); }
GuiBehind::GuiBehind(DuktoWindow* view) : QObject(NULL), mView(view), mShowBackTimer(NULL), mPeriodicHelloTimer(NULL), mClipboard(NULL), mMiniWebServer(NULL), mSettings(NULL), mDestBuddy(NULL), mUpdatesChecker(NULL) { // Status variables mView->setGuiBehindReference(this); setCurrentTransferProgress(0); setTextSnippetSending(false); setShowUpdateBanner(false); // Clipboard object mClipboard = QApplication::clipboard(); connect(mClipboard, SIGNAL(dataChanged()), this, SLOT(clipboardChanged())); clipboardChanged(); // Add "Me" entry mBuddiesList.addMeElement(); // Add "Ip" entry mBuddiesList.addIpElement(); // Settings mSettings = new Settings(this); // Mini web server mMiniWebServer = new MiniWebServer(NETWORK_PORT + 1); // Destination buddy mDestBuddy = new DestinationBuddy(this); // Change current folder QDir::setCurrent(mSettings->currentPath()); // Set current theme color mTheme.setThemeColor(mSettings->themeColor()); // Init buddy list view->rootContext()->setContextProperty("buddiesListData", &mBuddiesList); view->rootContext()->setContextProperty("recentListData", &mRecentList); view->rootContext()->setContextProperty("ipAddressesData", &mIpAddresses); view->rootContext()->setContextProperty("guiBehind", this); view->rootContext()->setContextProperty("destinationBuddy", mDestBuddy); view->rootContext()->setContextProperty("theme", &mTheme); // Register protocol signals connect(&mDuktoProtocol, SIGNAL(peerListAdded(Peer)), this, SLOT(peerListAdded(Peer))); connect(&mDuktoProtocol, SIGNAL(peerListRemoved(Peer)), this, SLOT(peerListRemoved(Peer))); connect(&mDuktoProtocol, SIGNAL(receiveFileStart(QString)), this, SLOT(receiveFileStart(QString))); connect(&mDuktoProtocol, SIGNAL(transferStatusUpdate(qint64,qint64)), this, SLOT(transferStatusUpdate(qint64,qint64))); connect(&mDuktoProtocol, SIGNAL(receiveFileComplete(QStringList*,qint64)), this, SLOT(receiveFileComplete(QStringList*,qint64))); connect(&mDuktoProtocol, SIGNAL(receiveTextComplete(QString*,qint64)), this, SLOT(receiveTextComplete(QString*,qint64))); connect(&mDuktoProtocol, SIGNAL(sendFileComplete(QStringList*)), this, SLOT(sendFileComplete(QStringList*))); connect(&mDuktoProtocol, SIGNAL(sendFileError(int)), this, SLOT(sendFileError(int))); connect(&mDuktoProtocol, SIGNAL(receiveFileCancelled()), this, SLOT(receiveFileCancelled())); connect(&mDuktoProtocol, SIGNAL(sendFileAborted()), this, SLOT(sendFileAborted())); // Register other signals connect(this, SIGNAL(remoteDestinationAddressChanged()), this, SLOT(remoteDestinationAddressHandler())); // Say "hello" mDuktoProtocol.setPorts(NETWORK_PORT, NETWORK_PORT); mDuktoProtocol.initialize(); mDuktoProtocol.sayHello(QHostAddress::Broadcast); // Periodic "hello" timer mPeriodicHelloTimer = new QTimer(this); connect(mPeriodicHelloTimer, SIGNAL(timeout()), this, SLOT(periodicHello())); mPeriodicHelloTimer->start(60000); // Load GUI view->setSource(QUrl("qrc:/qml/dukto/Dukto.qml")); //view->setSource(QUrl::fromLocalFile("c:/users/emanuele/documenti/dukto/qml/dukto/Dukto.qml")); #ifndef Q_WS_S60 view->restoreGeometry(mSettings->windowGeometry()); #endif // Start random rotate mShowBackTimer = new QTimer(this); connect(mShowBackTimer, SIGNAL(timeout()), this, SLOT(showRandomBack())); qsrand(QDateTime::currentDateTime().toTime_t());; mShowBackTimer->start(10000); // Enqueue check for updates mUpdatesChecker = new UpdatesChecker(); connect(mUpdatesChecker, SIGNAL(updatesAvailable()), this, SLOT(showUpdatesMessage())); QTimer::singleShot(2000, mUpdatesChecker, SLOT(start())); // TEMP // Peer p(QHostAddress("172.16.3.3"), "Pippo at Pluto (Macintosh)"); // Peer p(QHostAddress("172.16.3.3"), "NomeUtenteMoltoLungoCheNonCiSta at IlMioPcCheHaUnNomeImpensabilmenteLungo (Macintosh)", 4644); // peerListAdded(p); }