示例#1
0
void TimeSync::getNTPTime()
{
    QUdpSocket sock;
    sock.connectToHost("0.pool.ntp.org",123);
    if(!sock.waitForConnected(1000))return;
    QByteArray data(48,char(0)); *(reinterpret_cast<qint32 *>(&data.data()[0]))=4194959577;
    if(sock.write(data)<0||!sock.waitForReadyRead(3000)||sock.bytesAvailable()!=48)return;
    data=sock.readAll();
    quint32 seconds=qToBigEndian(*(reinterpret_cast<quint32 *>(&data.data()[40])));
    quint32 fraction=qToBigEndian(*(reinterpret_cast<quint32 *>(&data.data()[44])));
    quint32 newTime=QDateTime::fromMSecsSinceEpoch(seconds*1000ll+fraction*1000ll/0x100000000ll-2208988800000ll).toTime_t();

    if(newTime<1451606400 || newTime>4000000000){
        QThread::msleep(500);
        emit startSync();
        return;
    }
    qint32 tempTimeShift=qint64(newTime)-qint64(QDateTime::currentDateTime().toTime_t());

    if(timeShift!=0)tempTimeShift=qint32((qint64(timeShift)+qint64(tempTimeShift))/2);

    if(tempTimeShift>3600 || tempTimeShift<-3600){
        static bool showMessage=true;
        if(showMessage)emit warningMessage(julyTr("TIME_SYNC_ERROR","Your clock is not set. Please close the Qt Bitcoin Trader and set the clock. Changing time at Qt Bitcoin Trader enabled can cause errors and damage the keys."));
        showMessage=false;
    }
    else
        timeShift.fetchAndStoreOrdered(tempTimeShift);

    getNTPTimeRetryCount++;
    if(getNTPTimeRetryCount<3)emit startSync();
}
示例#2
0
void ownCloudFolder::slotCSyncFinished()
{
    if (_csync->error())
        qDebug() << "    * owncloud csync thread finished with error";
    else
        qDebug() << "    * owncloud csync thread finished successfully";

#ifndef USE_WATCHER
    if( _csync->hasLocalChanges( _lastWalkedFiles ) ) {
        qDebug() << "Last walked files: " << _lastWalkedFiles << " against " << _csync->walkedFiles();
        qDebug() << "*** Local changes, lets do a full sync!" ;
        _localCheckOnly = false;
        _pollTimerCnt = 0;
        _lastWalkedFiles = -1;
        QTimer::singleShot( 0, this, SLOT(startSync( QStringList() )));
    } else {
        qDebug() << "     *** Finalize, pollTimerCounter is "<< _pollTimerCnt ;
        _lastWalkedFiles = _csync->walkedFiles();
    // TODO delete thread
    }
#endif
    emit syncFinished(_csync->error() ?
                          SyncResult(SyncResult::Error)
                        : SyncResult(SyncResult::Success));

}
示例#3
0
SysCacheDaemon::SysCacheDaemon(QObject *parent) : QObject(parent){
  curSock = 0; //no local socket connected yet
  server = new QLocalServer(this);
    //server->setMaxPendingConnections(10); //should go through them pretty fast, no need for more
    connect(server, SIGNAL(newConnection()), this, SLOT(checkForConnections()));
  DATA = new DB(this);
    QTimer::singleShot(300000, DATA, SLOT(startSync()) ); //wait five minutes to start the initial sync
}
示例#4
0
void NicerConnection::start() {
  async([this] {
    startSync();
  });
  std::future_status status = start_promise_.get_future().wait_for(std::chrono::seconds(5));
  if (status == std::future_status::timeout) {
    ELOG_WARN("%s Start timed out", toLog());
  }
}
示例#5
0
TimeSync::TimeSync() : QObject()
{
    started=0;
    startTime=QDateTime::currentDateTime().toTime_t();
    timeShift=0;
    additionalTimer=0;
    getNTPTimeRetryCount=0;

    dateUpdateThread=new QThread;
    connect(dateUpdateThread,SIGNAL(started()),this,SLOT(runThread()));
    connect(this,SIGNAL(finishThread()),dateUpdateThread,SLOT(quit()));
    connect(this,SIGNAL(startSync()),this,SLOT(getNTPTime()));
    this->moveToThread(dateUpdateThread);
    dateUpdateThread->start();
}
示例#6
0
void SyncEngine::startSync()
{
    if (_journal->exists()) {
        QVector< SyncJournalDb::PollInfo > pollInfos = _journal->getPollInfos();
        if (!pollInfos.isEmpty()) {
            qDebug() << "Finish Poll jobs before starting a sync";
            CleanupPollsJob *job = new CleanupPollsJob(pollInfos, _account,
                                                       _journal, _localPath, this);
            connect(job, SIGNAL(finished()), this, SLOT(startSync()));
            connect(job, SIGNAL(aborted(QString)), this, SLOT(slotCleanPollsJobAborted(QString)));
            job->start();
            return;
        }
    }

    Q_ASSERT(!_syncRunning);
    _syncRunning = true;

    Q_ASSERT(_csync_ctx);

    if (!QDir(_localPath).exists()) {
        // No _tr, it should only occur in non-mirall
        emit csyncError("Unable to find local sync folder.");
        finalize(false);
        return;
    }

    // Check free size on disk first.
    const qint64 minFree = criticalFreeSpaceLimit();
    const qint64 freeBytes = Utility::freeDiskSpace(_localPath);
    if (freeBytes >= 0) {
        qDebug() << "There are" << freeBytes << "bytes available at" << _localPath
                 << "and at least" << minFree << "are required";
        if (freeBytes < minFree) {
            emit csyncError(tr("Only %1 are available, need at least %2 to start").arg(
                                Utility::octetsToString(freeBytes),
                                Utility::octetsToString(minFree)));
            finalize(false);
            return;
        }
    } else {
        qDebug() << "Could not determine free space available at" << _localPath;
    }

    _syncedItems.clear();
    _syncItemMap.clear();
    _needsUpdate = false;

    csync_resume(_csync_ctx);

    int fileRecordCount = -1;
    if (!_journal->exists()) {
        qDebug() << "=====sync looks new (no DB exists)";
    } else {
        qDebug() << "=====sync with existing DB";
    }

    qDebug() <<  "=====Using Qt" << qVersion();
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
    qDebug() <<  "=====Using SSL library version"
             <<  QSslSocket::sslLibraryVersionString().toUtf8().data();
#endif

    fileRecordCount = _journal->getFileRecordCount(); // this creates the DB if it does not exist yet

    if( fileRecordCount == -1 ) {
        qDebug() << "No way to create a sync journal!";
        emit csyncError(tr("Unable to initialize a sync journal."));
        finalize(false);
        return;
        // database creation error!
    }

    _csync_ctx->read_remote_from_db = true;

    // This tells csync to never read from the DB if it is empty
    // thereby speeding up the initial discovery significantly.
    _csync_ctx->db_is_empty = (fileRecordCount == 0);

    auto selectiveSyncBlackList = _journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList);
    bool usingSelectiveSync = (!selectiveSyncBlackList.isEmpty());
    qDebug() << (usingSelectiveSync ? "====Using Selective Sync" : "====NOT Using Selective Sync");

    csync_set_userdata(_csync_ctx, this);

    _stopWatch.start();

    qDebug() << "#### Discovery start #################################################### >>";

    _discoveryMainThread = new DiscoveryMainThread(account());
    _discoveryMainThread->setParent(this);
    connect(this, SIGNAL(finished(bool)), _discoveryMainThread, SLOT(deleteLater()));
    qDebug() << "=====Server" << account()->serverVersion()
             <<  QString("rootEtagChangesNotOnlySubFolderEtags=%1").arg(account()->rootEtagChangesNotOnlySubFolderEtags());
    if (account()->rootEtagChangesNotOnlySubFolderEtags()) {
        connect(_discoveryMainThread, SIGNAL(etag(QString)), this, SLOT(slotRootEtagReceived(QString)));
    } else {
        connect(_discoveryMainThread, SIGNAL(etagConcatenation(QString)), this, SLOT(slotRootEtagReceived(QString)));
    }

    DiscoveryJob *discoveryJob = new DiscoveryJob(_csync_ctx);
    discoveryJob->_selectiveSyncBlackList = selectiveSyncBlackList;
    discoveryJob->_selectiveSyncWhiteList =
        _journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList);
    discoveryJob->_newBigFolderSizeLimit = _newBigFolderSizeLimit;
    discoveryJob->moveToThread(&_thread);
    connect(discoveryJob, SIGNAL(finished(int)), this, SLOT(slotDiscoveryJobFinished(int)));
    connect(discoveryJob, SIGNAL(folderDiscovered(bool,QString)),
            this, SIGNAL(folderDiscovered(bool,QString)));

    connect(discoveryJob, SIGNAL(newBigFolder(QString)),
            this, SIGNAL(newBigFolder(QString)));


    // This is used for the DiscoveryJob to be able to request the main thread/
    // to read in directory contents.
    qDebug() << Q_FUNC_INFO << _remotePath << _remoteUrl;
    _discoveryMainThread->setupHooks( discoveryJob, _remotePath);

    // Starts the update in a seperate thread
    QMetaObject::invokeMethod(discoveryJob, "start", Qt::QueuedConnection);
}
示例#7
0
void ownCloudFolder::startSync()
{
    startSync( QStringList() );
}
示例#8
0
void SyncEngine::startSync()
{
    if (_journal->exists()) {
        QVector< SyncJournalDb::PollInfo > pollInfos = _journal->getPollInfos();
        if (!pollInfos.isEmpty()) {
            qDebug() << "Finish Poll jobs before starting a sync";
            CleanupPollsJob *job = new CleanupPollsJob(pollInfos, _account,
                                                       _journal, _localPath, this);
            connect(job, SIGNAL(finished()), this, SLOT(startSync()));
            connect(job, SIGNAL(aborted(QString)), this, SLOT(slotCleanPollsJobAborted(QString)));
            job->start();
            return;
        }
    }

    Q_ASSERT(!_syncRunning);
    _syncRunning = true;

    Q_ASSERT(_csync_ctx);

    if (!QDir(_localPath).exists()) {
        // No _tr, it should only occur in non-mirall
        emit csyncError("Unable to find local sync directory.");
        finalize();
        return;
    }

    _syncedItems.clear();
    _syncItemMap.clear();
    _needsUpdate = false;

    csync_resume(_csync_ctx);

    int fileRecordCount = -1;
    if (!_journal->exists()) {
        qDebug() << "=====sync looks new (no DB exists)";
    } else {
        qDebug() << "=====sync with existing DB";
    }

    qDebug() <<  "=====Using Qt" << qVersion();
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
    qDebug() <<  "=====Using SSL library version"
             <<  QSslSocket::sslLibraryVersionString().toUtf8().data();
#endif

    fileRecordCount = _journal->getFileRecordCount(); // this creates the DB if it does not exist yet

    if( fileRecordCount == -1 ) {
        qDebug() << "No way to create a sync journal!";
        emit csyncError(tr("Unable to initialize a sync journal."));
        finalize();
        return;
        // database creation error!
    }

    _csync_ctx->read_remote_from_db = true;

    // This tells csync to never read from the DB if it is empty
    // thereby speeding up the initial discovery significantly.
    _csync_ctx->db_is_empty = (fileRecordCount == 0);

    auto selectiveSyncBlackList = _journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncBlackList);
    bool usingSelectiveSync = (!selectiveSyncBlackList.isEmpty());
    qDebug() << (usingSelectiveSync ? "====Using Selective Sync" : "====NOT Using Selective Sync");
    if (fileRecordCount >= 0 && fileRecordCount < 50 && !usingSelectiveSync) {
        qDebug() << "===== Activating recursive PROPFIND (currently" << fileRecordCount << "file records)";
        bool no_recursive_propfind = false;
        csync_set_module_property(_csync_ctx, "no_recursive_propfind", &no_recursive_propfind);
    } else {
        bool no_recursive_propfind = true;
        csync_set_module_property(_csync_ctx, "no_recursive_propfind", &no_recursive_propfind);
    }

    csync_set_userdata(_csync_ctx, this);
    _account->credentials()->syncContextPreStart(_csync_ctx);

    // csync_set_auth_callback( _csync_ctx, getauth );
    //csync_set_log_level( 11 ); don't set the loglevel here, it shall be done by folder.cpp or owncloudcmd.cpp
    int timeout = OwncloudPropagator::httpTimeout();
    csync_set_module_property(_csync_ctx, "timeout", &timeout);

    _stopWatch.start();

    qDebug() << "#### Discovery start #################################################### >>";

    _discoveryMainThread = new DiscoveryMainThread(account());
    _discoveryMainThread->setParent(this);
    connect(this, SIGNAL(finished()), _discoveryMainThread, SLOT(deleteLater()));
    connect(_discoveryMainThread, SIGNAL(etagConcatenation(QString)), this, SLOT(slotRootEtagReceived(QString)));


    DiscoveryJob *discoveryJob = new DiscoveryJob(_csync_ctx);
    discoveryJob->_selectiveSyncBlackList = selectiveSyncBlackList;
    discoveryJob->_selectiveSyncWhiteList =
        _journal->getSelectiveSyncList(SyncJournalDb::SelectiveSyncWhiteList);
    discoveryJob->_newSharedFolderSizeLimit = _newSharedFolderSizeLimit;
    discoveryJob->moveToThread(&_thread);
    connect(discoveryJob, SIGNAL(finished(int)), this, SLOT(slotDiscoveryJobFinished(int)));
    connect(discoveryJob, SIGNAL(folderDiscovered(bool,QString)),
            this, SIGNAL(folderDiscovered(bool,QString)));

    connect(discoveryJob, SIGNAL(newSharedFolder(QString)),
            this, SIGNAL(newSharedFolder(QString)));


    // This is used for the DiscoveryJob to be able to request the main thread/
    // to read in directory contents.
    qDebug() << Q_FUNC_INFO << _remotePath << _remoteUrl;
    _discoveryMainThread->setupHooks( discoveryJob, _remotePath);

    // Starts the update in a seperate thread
    QMetaObject::invokeMethod(discoveryJob, "start", Qt::QueuedConnection);
}
示例#9
0
void 
CTimeSliceDoc::grabLoop()
{
   //
   // For framerate calculation
   //
   struct _timeb timeLast;
   struct _timeb timeGrab;

   ::_ftime( &timeLast );

   //
   // List of camerainfo objects for our panning pattern
   //
   std::deque< CameraInfo > queueCamInfoDisplay;

   int	 iFreeBufferIndex  = 0;
   int	 iFramesAtEnd	   = m_iFramesAtEnd;

   int   iScrollModeBuffersLeft = -1;

   //
   // The set of ring buffers we are using. 0 or 1.
   //
   int	 iInitialBufferSet = 0;

   int	 iDisplayingTimesliceIndex = 0;
   

   startSync();

   //
   // The main grab loop.
   //
   while( m_bContinueGrab )
   {
      grabAndCheckSync();
      updateBitmaps();      

      if( !m_bContinueGrab )
      {
	 break;
      }
      
      unsigned nCamera;
      unsigned nImage;


      if( !m_bSliceEvent )
      {
         //
         // We are not in a slice event, just grabbing images.
         //
         m_stateSlice = RUNNING;

         ASSERT( queueCamInfoDisplay.size() == 0 );

         if( !m_bScrollMode )
         {
            //
            // Copy the image into one of our buffer slots just in case we need 
            // it later for saving.
            //
            m_iInitialBufferIndex = 
               ( m_iInitialBufferIndex + 1 ) % m_iInitialBufferedImages;

            //
            // just get the panning view to display camera 0
            //
            CameraInfo cameraInfo = m_arCameraInfo[ 0 ];
            
            ::memcpy( 
               m_arpInitialBuffers[ iInitialBufferSet ][ m_iInitialBufferIndex ],
               cameraInfo.m_imageProcessed.pData,
               cameraInfo.m_imageProcessed.iRowInc * 
               cameraInfo.m_imageProcessed.iRows );
         
            cameraInfo.m_pTimesliceImageBuffer = 
               m_arpInitialBuffers[ iInitialBufferSet ][ m_iInitialBufferIndex ];

            //
            // push the image onto the list (stack?) - this will immediately be 
            // popped off when the image is about to be displayed.
            //
            queueCamInfoDisplay.push_back( cameraInfo );
         }
         else
         {
            //
            // Scroll mode grabbing.  Buffer images from all cameras.
            //
            ASSERT( m_arpScrollModeBuffers != NULL );
            
            m_iScrollModeTimeSliceBuffer = 
               ( m_iScrollModeTimeSliceBuffer + 1 ) % SCROLL_MODE_BUFFERS;

            for( nCamera = 0; nCamera < m_uiNumCameras; nCamera++ )
            {               
               ::memcpy(
                  m_arpScrollModeBuffers[ nCamera ][ m_iScrollModeTimeSliceBuffer ],
                  m_arCameraInfo[ nCamera ].m_imageProcessed.pData,
                  m_arCameraInfo[ nCamera ].m_imageProcessed.iRowInc * 
                  m_arCameraInfo[ nCamera ].m_imageProcessed.iRows );               
            }

            CameraInfo info = m_arCameraInfo[ m_iScrollModeCamera ];
            info.m_pTimesliceImageBuffer = 
               m_arpScrollModeBuffers[ m_iScrollModeCamera ][ m_iScrollModeTimeSliceBuffer ];
            queueCamInfoDisplay.push_back( info );
         }
      }
      else
      {
         //
         // In timeslice mode. 
         //
	 switch( m_stateSlice )
	 {
	 case RUNNING:
	    {
               if( !m_bScrollMode )
               {                  
                  m_stateSlice = GRABBING_TIMESLICE;

                  CameraInfo cameraInfo = m_arCameraInfo[ 0 ];
                  cameraInfo.m_pTimesliceImageBuffer = cameraInfo.m_imageProcessed.pData;
                  queueCamInfoDisplay.push_back( cameraInfo );
                  
                  //
                  // Clear the last bunch of saved images
                  //
                  m_listSavingCameraInfo.clear();
                  
                  //
                  // Save the buffered images - just copy everything besides the
                  // image pointer from the current image - this is a bit of a cheat.
                  //
                  CameraInfo info = m_arCameraInfo[ 0 ];
                  
                  for( int i = 0; i < m_iInitialBufferedImages; i++ )
                  {
                     int iIndex = 
                        ( m_iInitialBufferIndex + i + 1 ) % m_iInitialBufferedImages;
                     
                     info.m_pTimesliceImageBuffer = 
                        m_arpInitialBuffers[ iInitialBufferSet ][ iIndex ];
                     
                     m_listSavingCameraInfo.push_back( info );
                  }
                  
                  //
                  // Use the other initial buffer set now.
                  //
                  iInitialBufferSet = ( iInitialBufferSet + 1 ) % 2;
               }
               else
               {
                  // Scroll mode.
                  ASSERT( m_arpScrollModeBuffers != NULL );

                  //
                  // Buffer this image too.
                  //
                  m_iScrollModeTimeSliceBuffer = 
                     ( m_iScrollModeTimeSliceBuffer + 1 ) % SCROLL_MODE_BUFFERS;
                  
                  for( nCamera = 0; nCamera < m_uiNumCameras; nCamera++ )
                  {
                     ::memcpy(
                        m_arpScrollModeBuffers[ nCamera ][ m_iScrollModeTimeSliceBuffer ],
                        m_arCameraInfo[ nCamera ].m_imageProcessed.pData,
                        m_arCameraInfo[ nCamera ].m_imageProcessed.iRowInc * 
                        m_arCameraInfo[ nCamera ].m_imageProcessed.iRows );                 
                  }

                  //
                  // Continue to display the selected camera.
                  //
                  CameraInfo info = m_arCameraInfo[ m_iScrollModeCamera ];
                  info.m_pTimesliceImageBuffer = 
                     m_arpScrollModeBuffers[ m_iScrollModeCamera ][ m_iScrollModeTimeSliceBuffer ];
                  queueCamInfoDisplay.push_back( info );

                  //
                  // Set up for next step.
                  //
                  m_iScrollModeLoc = m_iScrollModeTimeSliceBuffer;                  
                  m_stateSlice = SCROLLMODE_GRABBING;                  
                  iScrollModeBuffersLeft = SCROLL_MODE_BUFFERS / 2;
               }
	    }
	    break;
	    

	 case GRABBING_TIMESLICE:
	    {
	       CameraInfo cameraInfo;
	       
	       for( int iPan = 0; iPan < m_iNumberOfPanCycles; iPan++ )
	       {
		  //
		  // forward pan
		  //
		  for( nCamera = 0; nCamera < m_uiNumCameras; nCamera++ )
		  {
		     cameraInfo = m_arCameraInfo[ nCamera ];
		     
		     ::memcpy( 
			m_arpImageBuffers[ iFreeBufferIndex ],
			cameraInfo.m_imageProcessed.pData,
                        cameraInfo.m_imageProcessed.iRowInc * 
                        cameraInfo.m_imageProcessed.iRows );
		     
		     cameraInfo.m_pTimesliceImageBuffer = 
			m_arpImageBuffers[ iFreeBufferIndex ];
		     
		     iFreeBufferIndex++;
		     ASSERT( iFreeBufferIndex < m_iTotalExtraImageBuffers );
		     
		     for( nImage = 0; nImage < (unsigned)m_iFramesPerCameraPanning; nImage++ )
		     {		     
			queueCamInfoDisplay.push_back( cameraInfo );

			m_listSavingCameraInfo.push_back( cameraInfo );
		     }
		  }	    
		  
		  //
		  // pause at end
		  //
		  for( nImage = 0; nImage < (unsigned)m_iFramesForEndCamera; nImage++ )
		  {
		     queueCamInfoDisplay.push_back( cameraInfo );

		     m_listSavingCameraInfo.push_back( cameraInfo );
		  }
		  
		  //
		  // backward pan
		  //
		  for( int iCamera = m_uiNumCameras - 1; iCamera >= 0; iCamera-- )
		  {
		     cameraInfo = m_arCameraInfo[ iCamera ];
		     
		     ::memcpy( 
			m_arpImageBuffers[ iFreeBufferIndex ],
                        cameraInfo.m_imageProcessed.pData,
                        cameraInfo.m_imageProcessed.iRowInc * 
                        cameraInfo.m_imageProcessed.iRows );
		     
		     cameraInfo.m_pTimesliceImageBuffer = 
			m_arpImageBuffers[ iFreeBufferIndex ];
		     
		     iFreeBufferIndex++;
		     ASSERT( iFreeBufferIndex < m_iTotalExtraImageBuffers );
		     
		     for( nImage = 0; nImage < (unsigned)m_iFramesPerCameraPanning; nImage++ )
		     {
			queueCamInfoDisplay.push_back( cameraInfo );
			m_listSavingCameraInfo.push_back( cameraInfo );
		     }
		  }
	       }
	       
	       m_stateSlice = GRABBING_DELAYED;
	       
	       break;
	    }


	 case GRABBING_DELAYED:
	    {	       
	       CameraInfo  cameraInfo = m_arCameraInfo[ 0 ];

	       ASSERT( iFreeBufferIndex < m_iTotalExtraImageBuffers );
	       
	       ::memcpy( 
		  m_arpImageBuffers[ iFreeBufferIndex ],
                  cameraInfo.m_imageProcessed.pData,
                  cameraInfo.m_imageProcessed.iRowInc * 
                  cameraInfo.m_imageProcessed.iRows );
	       
	       cameraInfo.m_pTimesliceImageBuffer = 
		  m_arpImageBuffers[ iFreeBufferIndex ];
	       
	       iFreeBufferIndex++;	       
	       
	       queueCamInfoDisplay.push_back( cameraInfo );

	       m_listSavingCameraInfo.push_back( cameraInfo );
	       
	       iFramesAtEnd--;
	       
	       if( iFramesAtEnd == 0 )
	       {
		  m_stateSlice = DISPLAYING_DELAYED;
	       }
	       
	       break;
	    }


	 case DISPLAYING_DELAYED:

	    if( queueCamInfoDisplay.size() == 1 )
	    {
	       //
	       // Reset to starting state.
	       //
	       iFreeBufferIndex     = 0;
	       iFramesAtEnd	    = m_iFramesAtEnd;

	       
	       m_stateSlice	  = DISPLAYING_TIMESLICE;
	       iDisplayingTimesliceIndex  = 0;
	    }

	    break;

	 case DISPLAYING_TIMESLICE:
	    {
	       ASSERT( m_listSavingCameraInfo.size() > 0 );

	       iDisplayingTimesliceIndex = 
		  ( iDisplayingTimesliceIndex + 1 ) % (int)m_listSavingCameraInfo.size();

	       CameraInfo info = 
		  m_listSavingCameraInfo.at( iDisplayingTimesliceIndex );

	       queueCamInfoDisplay.push_back( info );
	    }

	    break;


         case SCROLLMODE_GRABBING:
            {
               m_iScrollModeTimeSliceBuffer = 
                  ( m_iScrollModeTimeSliceBuffer + 1 ) % SCROLL_MODE_BUFFERS;

               for( nCamera = 0; nCamera < m_uiNumCameras; nCamera++ )
               {
                  ::memcpy(
                     m_arpScrollModeBuffers[ nCamera ][ m_iScrollModeTimeSliceBuffer ],
                     m_arCameraInfo[ nCamera ].m_imageProcessed.pData,
                     m_arCameraInfo[ nCamera ].m_imageProcessed.iRowInc * 
                     m_arCameraInfo[ nCamera ].m_imageProcessed.iRows );                
               }

               iScrollModeBuffersLeft--;

               if( iScrollModeBuffersLeft == 0 )
               {
                  m_stateSlice = SCROLLMODE_SCROLLING;
               }

               //
               // Just display the images we're grabbing.
               //
               CameraInfo info = m_arCameraInfo[ m_iScrollModeCamera ];
               info.m_pTimesliceImageBuffer = 
                  m_arpScrollModeBuffers[ m_iScrollModeCamera ][ m_iScrollModeTimeSliceBuffer ];
               queueCamInfoDisplay.push_back( info );
            }
            break;


         case SCROLLMODE_SCROLLING:
            {               
               ASSERT( iScrollModeBuffersLeft == 0 );
               ASSERT( m_iScrollModeLoc >= 0 );
               ASSERT( m_iScrollModeLoc < SCROLL_MODE_BUFFERS );
               ASSERT( m_iScrollModeCamera >= 0 );
               ASSERT( m_iScrollModeCamera < (signed)m_uiNumCameras );
               ASSERT( m_arpScrollModeBuffers[ m_iScrollModeCamera ][
                  m_iScrollModeLoc ] != NULL );
               
               CameraInfo info = m_arCameraInfo[ m_iScrollModeCamera ];
               info.m_pTimesliceImageBuffer = 
                  m_arpScrollModeBuffers[ m_iScrollModeCamera ][ m_iScrollModeLoc ];
               queueCamInfoDisplay.push_back( info );
            }
            break;

	 default:
	    ASSERT( FALSE );
	 }

      }

      //
      // Unlock this set of images.
      //
      for( nCamera = 0; nCamera < m_uiNumCameras; nCamera++ )
      {
         CameraInfo& camera = m_arCameraInfo[ nCamera ];

         camera.m_error = ::flycaptureUnlock(
            camera.m_context, camera.m_image.uiBufferIndex );
      }



      ASSERT( queueCamInfoDisplay.size() > 0 );
      
      m_cameraInfoTimeSlice = queueCamInfoDisplay.front();
      queueCamInfoDisplay.pop_front();



      //
      // Update frame rate.
      //
      ::_ftime( &timeGrab );

      double dGrabTime = 
	    (double)( timeGrab.time * 1000 + timeGrab.millitm ) - 
	            ( timeLast.time * 1000 + timeLast.millitm );

      if( dGrabTime != 0 )
      {	 
	 // Calculate our framerate using a running average.
	 m_dFrameRate = 0.95 * m_dFrameRate + 0.05 * ( 1000.0 / dGrabTime );
	 
	 timeLast = timeGrab;
      }

      updateViews();
   }
   
   ::SetEvent( m_eventGrabFinished );
}
示例#10
0
 SyncServer::SyncServer(asio::io_service& io)   {
     endpoint = asio::ip::tcp::endpoint(asio::ip::tcp::v4(), SEND_PORT);
     startSync(io);
 }
示例#11
0
void SyncEngine::startSync()
{
    if (_journal->exists()) {
        QVector< SyncJournalDb::PollInfo > pollInfos = _journal->getPollInfos();
        if (!pollInfos.isEmpty()) {
            qDebug() << "Finish Poll jobs before starting a sync";
            CleanupPollsJob *job = new CleanupPollsJob(pollInfos, AccountManager::instance()->account(),
                                                       _journal, _localPath, this);
            connect(job, SIGNAL(finished()), this, SLOT(startSync()));
            connect(job, SIGNAL(aborted(QString)), this, SLOT(slotCleanPollsJobAborted(QString)));
            job->start();
            return;
        }
    }

    Q_ASSERT(!_syncRunning);
    _syncRunning = true;

    Q_ASSERT(_csync_ctx);

    if (!QDir(_localPath).exists()) {
        // No _tr, it should only occur in non-mirall
        emit csyncError("Unable to find local sync directory.");
        finalize();
        return;
    }

    _syncedItems.clear();
    _syncItemMap.clear();
    _needsUpdate = false;

    csync_resume(_csync_ctx);

    int fileRecordCount = -1;
    if (!_journal->exists()) {
        qDebug() << "=====sync looks new (no DB exists)";
    } else {
        qDebug() << "=====sync with existing DB";
    }

    qDebug() <<  "=====Using Qt" << qVersion();
#if QT_VERSION >= QT_VERSION_CHECK(5,0,0)
    qDebug() <<  "=====Using SSL library version"
             <<  QSslSocket::sslLibraryVersionString().toUtf8().data();
#endif
    // Note that this seems to output the OpenSSL build version not runtime version:
    qDebug() <<  "=====Using" << ne_version_string();

    fileRecordCount = _journal->getFileRecordCount(); // this creates the DB if it does not exist yet
    bool isUpdateFrom_1_5 = _journal->isUpdateFrom_1_5();

    if( fileRecordCount == -1 ) {
        qDebug() << "No way to create a sync journal!";
        emit csyncError(tr("Unable to initialize a sync journal."));
        finalize();
        return;
        // database creation error!
    }

    if (fileRecordCount >= 1 && isUpdateFrom_1_5) {
        qDebug() << "detected update from 1.5" << fileRecordCount << isUpdateFrom_1_5;
        // Disable the read from DB to be sure to re-read all the fileid and etags.
        csync_set_read_from_db(_csync_ctx, false);
    } else {
        csync_set_read_from_db(_csync_ctx, true);
    }

    bool usingSelectiveSync = (!_selectiveSyncBlackList.isEmpty());
    qDebug() << (usingSelectiveSync ? "====Using Selective Sync" : "====NOT Using Selective Sync");
    if (fileRecordCount >= 0 && fileRecordCount < 50 && !usingSelectiveSync) {
        qDebug() << "===== Activating recursive PROPFIND (currently" << fileRecordCount << "file records)";
        bool no_recursive_propfind = false;
        csync_set_module_property(_csync_ctx, "no_recursive_propfind", &no_recursive_propfind);
    } else {
        bool no_recursive_propfind = true;
        csync_set_module_property(_csync_ctx, "no_recursive_propfind", &no_recursive_propfind);
    }

    csync_set_userdata(_csync_ctx, this);
    // TODO: This should be a part of this method, but we don't have
    // any way to get "session_key" module property from csync. Had we
    // have it, then we could keep this code and remove it from
    // AbstractCredentials implementations.
    if (Account *account = AccountManager::instance()->account()) {
        account->credentials()->syncContextPreStart(_csync_ctx);
    } else {
        qDebug() << Q_FUNC_INFO << "No default Account object, huh?";
    }
    // if (_lastAuthCookies.length() > 0) {
    //     // Stuff cookies inside csync, then we can avoid the intermediate HTTP 401 reply
    //     // when https://github.com/owncloud/core/pull/4042 is merged.
    //     QString cookiesAsString;
    //     foreach(QNetworkCookie c, _lastAuthCookies) {
    //         cookiesAsString += c.name();
    //         cookiesAsString += '=';
    //         cookiesAsString += c.value();
    //         cookiesAsString += "; ";
    //     }
    //     csync_set_module_property(_csync_ctx, "session_key", cookiesAsString.to
    // }

    // csync_set_auth_callback( _csync_ctx, getauth );
    //csync_set_log_level( 11 ); don't set the loglevel here, it shall be done by folder.cpp or owncloudcmd.cpp
    int timeout = OwncloudPropagator::httpTimeout();
    csync_set_module_property(_csync_ctx, "timeout", &timeout);


    _stopWatch.start();

    qDebug() << "#### Discovery start #################################################### >>";

    DiscoveryJob *job = new DiscoveryJob(_csync_ctx);
    job->_selectiveSyncBlackList = _selectiveSyncBlackList;
    job->moveToThread(&_thread);
    connect(job, SIGNAL(finished(int)), this, SLOT(slotDiscoveryJobFinished(int)));
    connect(job, SIGNAL(folderDiscovered(bool,QString)),
            this, SIGNAL(folderDiscovered(bool,QString)));
    QMetaObject::invokeMethod(job, "start", Qt::QueuedConnection);
}
示例#12
0
errno_t phantom_sync_write_sector( phantom_disk_partition_t *p, const void *to, long sectorNo, int nSectors )
{
    return startSync( p, (void *)to, sectorNo, nSectors, 1 );
}
示例#13
0
errno_t phantom_sync_read_sector( phantom_disk_partition_t *p, void *to, long sectorNo, int nSectors )
{
    return startSync( p, to, sectorNo, nSectors, 0 );
}
示例#14
0
errno_t phantom_sync_write_block( phantom_disk_partition_t *p, const void *to, long blockNo, int nBlocks )
{
    int m = PAGE_SIZE/p->block_size;
    return startSync( p, (void *)to, blockNo*m, nBlocks*m, 1 );
}
示例#15
0
errno_t phantom_sync_read_block( phantom_disk_partition_t *p, void *to, long blockNo, int nBlocks )
{
    int m = PAGE_SIZE/p->block_size;
    return startSync( p, to, blockNo*m, nBlocks*m, 0 );
}