mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-16 19:31:02 +01:00
Make sure Google Drive is connected when converting URLs.
This commit is contained in:
parent
a55cbc838f
commit
9ce8cf59d6
@ -65,7 +65,9 @@ QStandardItem* GoogleDriveService::CreateRootItem() {
|
||||
void GoogleDriveService::LazyPopulate(QStandardItem* item) {
|
||||
switch (item->data(InternetModel::Role_Type).toInt()) {
|
||||
case InternetModel::Type_Service:
|
||||
Connect();
|
||||
if (!client_->is_authenticated()) {
|
||||
Connect();
|
||||
}
|
||||
library_model_->Init();
|
||||
model()->merged_model()->AddSubModel(item->index(), library_sort_model_);
|
||||
break;
|
||||
@ -110,6 +112,17 @@ void GoogleDriveService::ConnectFinished(google_drive::ConnectResponse* response
|
||||
ListFilesForMimeType("application/x-flac"); // FLAC
|
||||
}
|
||||
|
||||
void GoogleDriveService::EnsureConnected() {
|
||||
if (client_->is_authenticated()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QEventLoop loop;
|
||||
connect(client_, SIGNAL(Authenticated()), &loop, SLOT(quit()));
|
||||
Connect();
|
||||
loop.exec();
|
||||
}
|
||||
|
||||
void GoogleDriveService::FilesFound(const QList<google_drive::File>& files) {
|
||||
foreach (const google_drive::File& file, files) {
|
||||
MaybeAddFileToDatabase(file);
|
||||
@ -183,6 +196,7 @@ void GoogleDriveService::ReadTagsFinished(TagReaderClient::ReplyType* reply,
|
||||
}
|
||||
|
||||
QUrl GoogleDriveService::GetStreamingUrlFromSongId(const QString& id) {
|
||||
EnsureConnected();
|
||||
QScopedPointer<google_drive::GetFileResponse> response(client_->GetFile(id));
|
||||
|
||||
QEventLoop loop;
|
||||
|
@ -46,6 +46,7 @@ class GoogleDriveService : public InternetService {
|
||||
|
||||
private:
|
||||
void Connect();
|
||||
void EnsureConnected();
|
||||
void RefreshAuthorisation(const QString& refresh_token);
|
||||
void MaybeAddFileToDatabase(const google_drive::File& file);
|
||||
void ListFilesForMimeType(const QString& mime_type);
|
||||
|
Loading…
Reference in New Issue
Block a user