void Syncer::CheckLocalStorage (const QStringList& paths, const QString& baseDir) { BaseDir_ = baseDir; Paths_ = paths; std::sort (Paths_.begin (), Paths_.end ()); connect (DM_, SIGNAL (gotFiles (QList<DriveItem>)), this, SLOT (handleGotFiles (QList<DriveItem>))); DM_->RefreshListing (); }
void DriveManager::RequestFiles (const QString& key) { QString str = QString ("https://www.googleapis.com/drive/v2/files?access_token=%1") .arg (key); QNetworkRequest request (str); request.setHeader (QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded"); QNetworkReply *reply = Core::Instance ().GetProxy ()-> GetNetworkAccessManager ()->get (request); connect (reply, SIGNAL (finished ()), this, SLOT (handleGotFiles ())); }
void Syncer::handleGotFiles (const QList<DriveItem>& files) { Items_ = files; disconnect (DM_, SIGNAL (gotFiles (QList<DriveItem>)), this, SLOT (handleGotFiles (QList<DriveItem>))); const QString& rootName = QFileInfo (BaseDir_).fileName (); DriveItem rootItem; bool found = false; for (const auto& item : files) { if (!item.ParentIsRoot_ || !item.IsFolder_ || item.Name_ != rootName || item.Labels_ & DriveItem::ILRemoved) continue; rootItem = item; found = true; Items_.removeOne (rootItem); break; } if (!found) { connect (DM_, SIGNAL (gotNewItem (DriveItem)), this, SLOT (handleGotNewItem (DriveItem))); RealPathQueue_ << BaseDir_; DM_->CreateDirectory (rootName); } else { if (QFileInfo (BaseDir_).exists ()) RealPath2Item_ [BaseDir_] = rootItem; else DM_->MoveEntryToTrash (rootItem.Id_); ContinueLocalStorageChecking (); } }