Exemplo n.º 1
0
void SyncSystem::recvSendFileResult(const QString &filename, const QDateTime &mtime, int result)
{
  //sync has been stopped, ignore what the server is sending
  if(m_SyncState == e_Idle)
    return;

  if( !result )
  {
    m_FileErrors++;
    qWarning() << "[SyncSystem.sendFile] copy of file failed: " << filename;
    SyncRuleFlags_e flags = e_NoFlags;
    if(GetSyncRulesForPath(filename)->CheckFile(filename.toLower(), flags))
    {
      bool binary = flags == e_Binary || flags == e_BinaryExecutable;
      addTodo(filename, binary, false, false, true);
      emit signalFileStatus(filename, mtime, false);
    }
  }
  else
  {
    m_FilesCopied++;
    QMap<QString, FileTodo>::iterator erase = m_NameToInfo.find(filename);
    Q_ASSERT(erase != m_NameToInfo.end());
    if(erase != m_NameToInfo.end())
    {
      m_BytesInTransit -= erase.value().m_Size;
      m_NameToInfo.erase(erase);
      emit signalFileStatus(filename, mtime, true);
    }
  }
  emit signalFilesCopied(m_FilesCopied, m_FilesPendingCopy, m_FileErrors);
  updateSyncState();
}
Exemplo n.º 2
0
//////////////////////////////////////////////////////////////////////////
/// This function is called when a full scan is completed.
/// 
/// A full scan is completed if the user stopped the scan, if we scanned 
/// through the directory structure or we lost connection to the server.
/// It will delete and reset the scanner, stop the scan dir timer and 
/// update the sync system state.
//////////////////////////////////////////////////////////////////////////
void SyncSystem::scanComplete()
{
  delete m_Scanner;
  m_Scanner = NULL;
  updateSyncState();
  m_ScanDirTimer->stop();
}
Exemplo n.º 3
0
void WalletStatusBar::walletOpened() {
  showMessage(tr("Wallet opened"), TEMP_MESSAGE_DURATION);
  m_encryptionStatusIconLabel->show();
  m_syncStatusIconLabel->show();
  updateEncryptedState(m_cryptoNoteAdapter->getNodeAdapter()->getWalletAdapter()->isEncrypted());
  updateSyncState(true);
}
Exemplo n.º 4
0
void WalletStatusBar::synchronizationCompleted() {
  if (m_checkSyncStateTimerId == -1) {
    m_checkSyncStateTimerId = startTimer(MSECS_IN_MINUTE);
  }

  m_walletIsSynchronized = true;
  updateStatusDescription();
  updateSyncState(true);
}
Exemplo n.º 5
0
void WalletStatusBar::updateStyle() {
  IWalletAdapter* walletAdapter = m_cryptoNoteAdapter->getNodeAdapter()->getWalletAdapter();
  if (m_syncMovie->state() == QMovie::Running) {
    m_syncMovie->stop();
  }

  m_syncMovie->setFileName(Settings::instance().getCurrentStyle().getWalletSyncGifFile());
  if (walletAdapter->isOpen()) {
    updateEncryptedState(walletAdapter->isEncrypted());
    updateSyncState(m_walletIsSynchronized);
  }

  setStyleSheet(Settings::instance().getCurrentStyle().makeStyleSheet(STATUS_BAR_STYLE_SHEET_TEMPLATE));
}
Exemplo n.º 6
0
void WalletStatusBar::synchronizationProgressUpdated(quint32 _current, quint32 _total) {
  if (m_checkSyncStateTimerId != -1) {
    killTimer(m_checkSyncStateTimerId);
    m_checkSyncStateTimerId = -1;
  }

  quint64 currentDateTime = QDateTime::currentDateTimeUtc().toMSecsSinceEpoch() / 1000;
  quint64 lastBlockTimestamp = m_nodeStateModel->index(0, NodeStateModel::COLUMN_LAST_LOCAL_BLOCK_TIMESTAMP).data(NodeStateModel::ROLE_LAST_LOCAL_BLOCK_TIMESTAMP).value<quint64>();
  quint64 timeDiff = currentDateTime - lastBlockTimestamp;
  QString formattedTimeDiff = lastBlockTimestamp > 0 ? formatTimeDiff(timeDiff) : tr("unknown");
  QString blockchainAge = lastBlockTimestamp > 0 ? QStringLiteral("%1 ago").arg(formattedTimeDiff) : QStringLiteral("%1").arg(formattedTimeDiff);

  m_walletIsSynchronized = false;
  //m_syncStatusLabel->setText(tr("Synchronization: %1/%2 (%3)").arg(_current).arg(_total).arg(blockchainAge));
  m_syncStatusLabel->setText(tr("Synchronization: %1/%2").arg(_current).arg(_total));
  updateSyncState(false);
}
Exemplo n.º 7
0
void SyncSystem::recvStatFileReply(const QString &filename, const QDateTime &mtime)
{
  //sync has been stopped, ignore what the server is sending
  if(m_SyncState == e_Idle)
    return;
  //find the unresolved file in the map
  QMap<QString,ScannerBase::FileInfo>::iterator iUnresolved = m_UnresolvedFiles.find( filename );
  if( iUnresolved == m_UnresolvedFiles.end() )
  {
    qCritical() << "[SyncSystem.Error]  *** Internal error: " << filename << " missing from unresolved list";
    return;
  }

  //check if the mtimes are similar (cant do exact comparison due to different OSes having somewhat different resolutions)
  if(!mtime.isValid() ||  abs(iUnresolved.value().mtime.secsTo(mtime)) > 1 ) 
  {
    addTodo(filename, iUnresolved.value().binary, iUnresolved.value().executable, false);
  }

  m_UnresolvedFiles.erase( iUnresolved );
  m_FilesResolved++;
  emit signalFileStats(m_FilesResolved, m_FilesPendingStat);
  updateSyncState();
}
Exemplo n.º 8
0
void SyncSystem::slotLostSync(QString error)
{
  qInformation() << "FilesystemWatcher lost sync " << error;
  m_LostSyncTimer->start(s_ResyncTimeout);
  updateSyncState();
}