mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 03:27:40 +01:00
Remove Ubuntu One support.
http://blog.canonical.com/2014/04/02/shutting-down-ubuntu-one-file-services/
This commit is contained in:
parent
a471789a59
commit
30d1c2f8db
@ -187,11 +187,6 @@ optional_component(GOOGLE_DRIVE ON "Google Drive support"
|
||||
DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999"
|
||||
)
|
||||
|
||||
optional_component(UBUNTU_ONE ON "Ubuntu One file support"
|
||||
DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS
|
||||
DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999"
|
||||
)
|
||||
|
||||
optional_component(DROPBOX ON "Dropbox support"
|
||||
DEPENDS "Google sparsehash" SPARSEHASH_INCLUDE_DIRS
|
||||
DEPENDS "Taglib 1.8" "TAGLIB_VERSION VERSION_GREATER 1.7.999"
|
||||
|
@ -114,11 +114,6 @@ TagLib::ByteVector CloudStream::readBlock(ulong length) {
|
||||
QString("bytes=%1-%2").arg(start).arg(end).toUtf8());
|
||||
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute,
|
||||
QNetworkRequest::AlwaysNetwork);
|
||||
// The Ubuntu One server applies the byte range to the gzipped data, rather
|
||||
// than the raw data so we must disable compression.
|
||||
if (url_.host() == "files.one.ubuntu.com") {
|
||||
request.setRawHeader("Accept-Encoding", "identity");
|
||||
}
|
||||
|
||||
QNetworkReply* reply = network_->get(request);
|
||||
connect(reply, SIGNAL(sslErrors(QList<QSslError>)),
|
||||
|
@ -1085,22 +1085,6 @@ optional_source(HAVE_GOOGLE_DRIVE
|
||||
internet/googledrivesettingspage.ui
|
||||
)
|
||||
|
||||
# Ubuntu One file support
|
||||
optional_source(HAVE_UBUNTU_ONE
|
||||
SOURCES
|
||||
internet/ubuntuoneauthenticator.cpp
|
||||
internet/ubuntuoneservice.cpp
|
||||
internet/ubuntuonesettingspage.cpp
|
||||
internet/ubuntuoneurlhandler.cpp
|
||||
HEADERS
|
||||
internet/ubuntuoneauthenticator.h
|
||||
internet/ubuntuoneservice.h
|
||||
internet/ubuntuonesettingspage.h
|
||||
internet/ubuntuoneurlhandler.h
|
||||
UI
|
||||
internet/ubuntuonesettingspage.ui
|
||||
)
|
||||
|
||||
# Dropbox support
|
||||
optional_source(HAVE_DROPBOX
|
||||
SOURCES
|
||||
|
@ -41,7 +41,6 @@
|
||||
#cmakedefine HAVE_SKYDRIVE
|
||||
#cmakedefine HAVE_SPARKLE
|
||||
#cmakedefine HAVE_SPOTIFY_DOWNLOADER
|
||||
#cmakedefine HAVE_UBUNTU_ONE
|
||||
#cmakedefine HAVE_VK
|
||||
#cmakedefine HAVE_WIIMOTEDEV
|
||||
#cmakedefine IMOBILEDEVICE_USES_UDIDS
|
||||
|
@ -41,9 +41,6 @@
|
||||
#ifdef HAVE_GOOGLE_DRIVE
|
||||
#include "googledriveservice.h"
|
||||
#endif
|
||||
#ifdef HAVE_UBUNTU_ONE
|
||||
#include "ubuntuoneservice.h"
|
||||
#endif
|
||||
#ifdef HAVE_DROPBOX
|
||||
#include "dropboxservice.h"
|
||||
#endif
|
||||
@ -101,9 +98,6 @@ InternetModel::InternetModel(Application* app, QObject* parent)
|
||||
#ifdef HAVE_SKYDRIVE
|
||||
AddService(new SkydriveService(app, this));
|
||||
#endif
|
||||
#ifdef HAVE_UBUNTU_ONE
|
||||
AddService(new UbuntuOneService(app, this));
|
||||
#endif
|
||||
#ifdef HAVE_VK
|
||||
AddService(new VkService(app, this));
|
||||
#endif
|
||||
|
@ -1,135 +0,0 @@
|
||||
#include "ubuntuoneauthenticator.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <QCoreApplication>
|
||||
#include <QDateTime>
|
||||
#include <QHostInfo>
|
||||
#include <QStringList>
|
||||
|
||||
#include <qjson/parser.h>
|
||||
|
||||
#include "core/closure.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/network.h"
|
||||
#include "core/timeconstants.h"
|
||||
|
||||
namespace {
|
||||
static const char* kUbuntuOneEndpoint =
|
||||
"https://login.ubuntu.com/api/1.0/authentications";
|
||||
static const char* kTokenNameTemplate = "Ubuntu One @ %1 [%2]";
|
||||
static const char* kOAuthSSOFinishedEndpoint =
|
||||
"https://one.ubuntu.com/oauth/sso-finished-so-get-tokens/";
|
||||
static const char* kOAuthHeaderPrefix = "OAuth realm=\"\", ";
|
||||
}
|
||||
|
||||
UbuntuOneAuthenticator::UbuntuOneAuthenticator(QObject* parent)
|
||||
: QObject(parent),
|
||||
network_(new NetworkAccessManager(this)),
|
||||
success_(false) {}
|
||||
|
||||
void UbuntuOneAuthenticator::StartAuthorisation(const QString& email,
|
||||
const QString& password) {
|
||||
QUrl url(kUbuntuOneEndpoint);
|
||||
url.addQueryItem("ws.op", "authenticate");
|
||||
QString token_name = QString(kTokenNameTemplate).arg(
|
||||
QHostInfo::localHostName(), QCoreApplication::applicationName());
|
||||
url.addQueryItem("token_name", token_name);
|
||||
|
||||
QByteArray authentication =
|
||||
QString(email + ":" + password).toAscii().toBase64();
|
||||
QString authorisation =
|
||||
QString("Basic %1").arg(QString::fromAscii(authentication));
|
||||
|
||||
QNetworkRequest request(url);
|
||||
request.setRawHeader("Authorization", authorisation.toAscii());
|
||||
request.setRawHeader("Accept", "application/json");
|
||||
|
||||
QNetworkReply* reply = network_->get(request);
|
||||
NewClosure(reply, SIGNAL(finished()), this,
|
||||
SLOT(AuthorisationFinished(QNetworkReply*)), reply);
|
||||
|
||||
qLog(Debug) << url;
|
||||
qLog(Debug) << authorisation;
|
||||
}
|
||||
|
||||
void UbuntuOneAuthenticator::AuthorisationFinished(QNetworkReply* reply) {
|
||||
reply->deleteLater();
|
||||
|
||||
QByteArray data = reply->readAll();
|
||||
qLog(Debug) << data;
|
||||
|
||||
QJson::Parser parser;
|
||||
bool ok = false;
|
||||
QVariant json = parser.parse(data, &ok);
|
||||
if (!ok) {
|
||||
qLog(Error) << "Failed to authenticate to Ubuntu One:"
|
||||
<< parser.errorString();
|
||||
emit Finished();
|
||||
return;
|
||||
}
|
||||
|
||||
QVariantMap auth_info = json.toMap();
|
||||
consumer_key_ = auth_info["consumer_key"].toString();
|
||||
consumer_secret_ = auth_info["consumer_secret"].toString();
|
||||
token_ = auth_info["token"].toString();
|
||||
token_secret_ = auth_info["token_secret"].toString();
|
||||
|
||||
CopySSOTokens();
|
||||
}
|
||||
|
||||
QByteArray UbuntuOneAuthenticator::GenerateAuthorisationHeader(
|
||||
const QString& consumer_key, const QString& consumer_secret,
|
||||
const QString& token, const QString& token_secret) {
|
||||
typedef QPair<QString, QString> Param;
|
||||
QString timestamp = QString::number(time(nullptr));
|
||||
QList<Param> parameters;
|
||||
parameters << Param("oauth_nonce", QString::number(qrand()))
|
||||
<< Param("oauth_timestamp", timestamp)
|
||||
<< Param("oauth_version", "1.0")
|
||||
<< Param("oauth_consumer_key", consumer_key)
|
||||
<< Param("oauth_token", token)
|
||||
<< Param("oauth_signature_method", "PLAINTEXT");
|
||||
qSort(parameters.begin(), parameters.end());
|
||||
QStringList encoded_params;
|
||||
for (const Param& p : parameters) {
|
||||
encoded_params << QString("%1=%2").arg(p.first, p.second);
|
||||
}
|
||||
|
||||
QString signing_key = consumer_secret + "&" + token_secret;
|
||||
QByteArray signature = QUrl::toPercentEncoding(signing_key);
|
||||
|
||||
// Construct authorisation header
|
||||
parameters << Param("oauth_signature", signature);
|
||||
QStringList header_params;
|
||||
for (const Param& p : parameters) {
|
||||
header_params << QString("%1=\"%2\"").arg(p.first, p.second);
|
||||
}
|
||||
QString authorisation_header = header_params.join(", ");
|
||||
authorisation_header.prepend(kOAuthHeaderPrefix);
|
||||
|
||||
return authorisation_header.toAscii();
|
||||
}
|
||||
|
||||
QByteArray UbuntuOneAuthenticator::GenerateAuthorisationHeader() {
|
||||
return GenerateAuthorisationHeader(consumer_key_, consumer_secret_, token_,
|
||||
token_secret_);
|
||||
}
|
||||
|
||||
void UbuntuOneAuthenticator::CopySSOTokens() {
|
||||
QUrl url(kOAuthSSOFinishedEndpoint);
|
||||
QNetworkRequest request(url);
|
||||
request.setRawHeader("Authorization", GenerateAuthorisationHeader());
|
||||
request.setRawHeader("Accept", "application/json");
|
||||
|
||||
QNetworkReply* reply = network_->get(request);
|
||||
NewClosure(reply, SIGNAL(finished()), this,
|
||||
SLOT(CopySSOTokensFinished(QNetworkReply*)), reply);
|
||||
}
|
||||
|
||||
void UbuntuOneAuthenticator::CopySSOTokensFinished(QNetworkReply* reply) {
|
||||
reply->deleteLater();
|
||||
qLog(Debug) << reply->readAll();
|
||||
success_ = true;
|
||||
emit Finished();
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
#ifndef UBUNTUONEAUTHENTICATOR_H
|
||||
#define UBUNTUONEAUTHENTICATOR_H
|
||||
|
||||
#include <QObject>
|
||||
|
||||
class QNetworkReply;
|
||||
class NetworkAccessManager;
|
||||
|
||||
class UbuntuOneAuthenticator : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit UbuntuOneAuthenticator(QObject* parent = nullptr);
|
||||
void StartAuthorisation(const QString& email, const QString& password);
|
||||
|
||||
bool success() const { return success_; }
|
||||
QString consumer_key() const { return consumer_key_; }
|
||||
QString consumer_secret() const { return consumer_secret_; }
|
||||
QString token() const { return token_; }
|
||||
QString token_secret() const { return token_secret_; }
|
||||
|
||||
static QByteArray GenerateAuthorisationHeader(const QString& consumer_key,
|
||||
const QString& consumer_secret,
|
||||
const QString& token,
|
||||
const QString& token_secret);
|
||||
|
||||
signals:
|
||||
void Finished();
|
||||
|
||||
private slots:
|
||||
void AuthorisationFinished(QNetworkReply* reply);
|
||||
void CopySSOTokensFinished(QNetworkReply* reply);
|
||||
|
||||
private:
|
||||
void CopySSOTokens();
|
||||
QByteArray GenerateAuthorisationHeader();
|
||||
|
||||
private:
|
||||
NetworkAccessManager* network_;
|
||||
|
||||
bool success_;
|
||||
|
||||
QString consumer_key_;
|
||||
QString consumer_secret_;
|
||||
|
||||
QString token_;
|
||||
QString token_secret_;
|
||||
};
|
||||
|
||||
#endif // UBUNTUONEAUTHENTICATOR_H
|
@ -1,183 +0,0 @@
|
||||
#include "ubuntuoneservice.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QSettings>
|
||||
#include <QSortFilterProxyModel>
|
||||
|
||||
#include <qjson/parser.h>
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/closure.h"
|
||||
#include "core/database.h"
|
||||
#include "core/logging.h"
|
||||
#include "core/mergedproxymodel.h"
|
||||
#include "core/network.h"
|
||||
#include "core/player.h"
|
||||
#include "core/timeconstants.h"
|
||||
#include "core/utilities.h"
|
||||
#include "globalsearch/globalsearch.h"
|
||||
#include "globalsearch/librarysearchprovider.h"
|
||||
#include "internet/internetmodel.h"
|
||||
#include "internet/ubuntuoneauthenticator.h"
|
||||
#include "internet/ubuntuoneurlhandler.h"
|
||||
#include "library/librarybackend.h"
|
||||
#include "playlist/playlist.h"
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
const char* UbuntuOneService::kServiceName = "Ubuntu One";
|
||||
const char* UbuntuOneService::kSettingsGroup = "Ubuntu One";
|
||||
|
||||
namespace {
|
||||
static const char* kFileStorageEndpoint =
|
||||
"https://one.ubuntu.com/api/file_storage/v1";
|
||||
static const char* kVolumesEndpoint =
|
||||
"https://one.ubuntu.com/api/file_storage/v1/volumes";
|
||||
static const char* kContentRoot = "https://files.one.ubuntu.com";
|
||||
static const char* kServiceId = "ubuntu_one";
|
||||
}
|
||||
|
||||
UbuntuOneService::UbuntuOneService(Application* app, InternetModel* parent)
|
||||
: CloudFileService(app, parent, kServiceName, kServiceId,
|
||||
QIcon(":/providers/ubuntuone.png"),
|
||||
SettingsDialog::Page_UbuntuOne) {
|
||||
app_->player()->RegisterUrlHandler(new UbuntuOneUrlHandler(this, this));
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
if (s.contains("consumer_key")) {
|
||||
consumer_key_ = s.value("consumer_key").toString();
|
||||
consumer_secret_ = s.value("consumer_secret").toString();
|
||||
token_ = s.value("token").toString();
|
||||
token_secret_ = s.value("token_secret").toString();
|
||||
}
|
||||
}
|
||||
|
||||
bool UbuntuOneService::has_credentials() const {
|
||||
return !consumer_key_.isEmpty();
|
||||
}
|
||||
|
||||
void UbuntuOneService::Connect() {
|
||||
if (has_credentials()) {
|
||||
RequestVolumeList();
|
||||
} else {
|
||||
ShowSettingsDialog();
|
||||
}
|
||||
}
|
||||
|
||||
QByteArray UbuntuOneService::GenerateAuthorisationHeader() {
|
||||
return UbuntuOneAuthenticator::GenerateAuthorisationHeader(
|
||||
consumer_key_, consumer_secret_, token_, token_secret_);
|
||||
}
|
||||
|
||||
void UbuntuOneService::AuthenticationFinished(
|
||||
UbuntuOneAuthenticator* authenticator) {
|
||||
authenticator->deleteLater();
|
||||
if (!authenticator->success()) {
|
||||
return;
|
||||
}
|
||||
|
||||
consumer_key_ = authenticator->consumer_key();
|
||||
consumer_secret_ = authenticator->consumer_secret();
|
||||
token_ = authenticator->token();
|
||||
token_secret_ = authenticator->token_secret();
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(kSettingsGroup);
|
||||
s.setValue("consumer_key", consumer_key_);
|
||||
s.setValue("consumer_secret", consumer_secret_);
|
||||
s.setValue("token", token_);
|
||||
s.setValue("token_secret", token_secret_);
|
||||
|
||||
RequestVolumeList();
|
||||
}
|
||||
|
||||
QNetworkReply* UbuntuOneService::SendRequest(const QUrl& url) {
|
||||
QNetworkRequest request(url);
|
||||
request.setRawHeader("Authorization", GenerateAuthorisationHeader());
|
||||
request.setRawHeader("Accept", "application/json");
|
||||
|
||||
return network_->get(request);
|
||||
}
|
||||
|
||||
void UbuntuOneService::RequestVolumeList() {
|
||||
QUrl volumes_url(kVolumesEndpoint);
|
||||
QNetworkReply* reply = SendRequest(volumes_url);
|
||||
NewClosure(reply, SIGNAL(finished()), this,
|
||||
SLOT(VolumeListRequestFinished(QNetworkReply*)), reply);
|
||||
}
|
||||
|
||||
void UbuntuOneService::VolumeListRequestFinished(QNetworkReply* reply) {
|
||||
reply->deleteLater();
|
||||
|
||||
QJson::Parser parser;
|
||||
QVariantList result = parser.parse(reply).toList();
|
||||
for (const QVariant& v : result) {
|
||||
RequestFileList(v.toMap()["node_path"].toString());
|
||||
}
|
||||
}
|
||||
|
||||
void UbuntuOneService::RequestFileList(const QString& path) {
|
||||
QUrl files_url(QString(kFileStorageEndpoint) + path);
|
||||
files_url.addQueryItem("include_children", "true");
|
||||
|
||||
qLog(Debug) << "Sending files request" << files_url;
|
||||
QNetworkReply* files_reply = SendRequest(files_url);
|
||||
NewClosure(files_reply, SIGNAL(finished()), this,
|
||||
SLOT(FileListRequestFinished(QNetworkReply*)), files_reply);
|
||||
}
|
||||
|
||||
void UbuntuOneService::FileListRequestFinished(QNetworkReply* reply) {
|
||||
reply->deleteLater();
|
||||
QJson::Parser parser;
|
||||
QVariantMap result = parser.parse(reply).toMap();
|
||||
|
||||
QVariantList children = result["children"].toList();
|
||||
for (const QVariant& c : children) {
|
||||
QVariantMap child = c.toMap();
|
||||
if (child["kind"].toString() == "file") {
|
||||
QString content_path = child["content_path"].toString();
|
||||
QUrl content_url(kContentRoot);
|
||||
content_url.setPath(content_path);
|
||||
QUrl service_url;
|
||||
service_url.setScheme("ubuntuonefile");
|
||||
service_url.setPath(content_path);
|
||||
|
||||
Song metadata;
|
||||
metadata.set_url(service_url);
|
||||
metadata.set_etag(child["hash"].toString());
|
||||
metadata.set_mtime(QDateTime::fromString(child["when_changed"].toString(),
|
||||
Qt::ISODate).toTime_t());
|
||||
metadata.set_ctime(QDateTime::fromString(child["when_created"].toString(),
|
||||
Qt::ISODate).toTime_t());
|
||||
metadata.set_filesize(child["size"].toInt());
|
||||
metadata.set_title(child["path"].toString().mid(1));
|
||||
MaybeAddFileToDatabase(
|
||||
metadata, GuessMimeTypeForFile(child["path"].toString().mid(1)),
|
||||
content_url, GenerateAuthorisationHeader());
|
||||
} else {
|
||||
RequestFileList(child["resource_path"].toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QUrl UbuntuOneService::GetStreamingUrlFromSongId(const QString& song_id) {
|
||||
QUrl url(kContentRoot);
|
||||
url.setPath(song_id);
|
||||
url.setFragment(GenerateAuthorisationHeader());
|
||||
return url;
|
||||
}
|
||||
|
||||
void UbuntuOneService::ShowCoverManager() {
|
||||
if (!cover_manager_) {
|
||||
cover_manager_.reset(new AlbumCoverManager(app_, library_backend_));
|
||||
cover_manager_->Init();
|
||||
connect(cover_manager_.get(), SIGNAL(AddToPlaylist(QMimeData*)),
|
||||
SLOT(AddToPlaylist(QMimeData*)));
|
||||
}
|
||||
cover_manager_->show();
|
||||
}
|
||||
|
||||
void UbuntuOneService::AddToPlaylist(QMimeData* mime) {
|
||||
playlist_manager_->current()->dropMimeData(mime, Qt::CopyAction, -1, 0,
|
||||
QModelIndex());
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
#ifndef UBUNTUONESERVICE_H
|
||||
#define UBUNTUONESERVICE_H
|
||||
|
||||
#include "internet/cloudfileservice.h"
|
||||
|
||||
#include "core/tagreaderclient.h"
|
||||
|
||||
class QNetworkReply;
|
||||
class UbuntuOneAuthenticator;
|
||||
|
||||
class UbuntuOneService : public CloudFileService {
|
||||
Q_OBJECT
|
||||
public:
|
||||
UbuntuOneService(Application* app, InternetModel* parent);
|
||||
|
||||
static const char* kServiceName;
|
||||
static const char* kSettingsGroup;
|
||||
|
||||
QUrl GetStreamingUrlFromSongId(const QString& song_id);
|
||||
|
||||
private slots:
|
||||
void AuthenticationFinished(UbuntuOneAuthenticator* authenticator);
|
||||
void FileListRequestFinished(QNetworkReply* reply);
|
||||
void ShowCoverManager();
|
||||
void AddToPlaylist(QMimeData* mime);
|
||||
void VolumeListRequestFinished(QNetworkReply* reply);
|
||||
|
||||
private:
|
||||
void Connect();
|
||||
QNetworkReply* SendRequest(const QUrl& url);
|
||||
void RequestVolumeList();
|
||||
void RequestFileList(const QString& path);
|
||||
bool has_credentials() const;
|
||||
|
||||
private:
|
||||
QByteArray GenerateAuthorisationHeader();
|
||||
|
||||
QString consumer_key_;
|
||||
QString consumer_secret_;
|
||||
QString token_;
|
||||
QString token_secret_;
|
||||
};
|
||||
|
||||
#endif // UBUNTUONESERVICE_H
|
@ -1,86 +0,0 @@
|
||||
#include "ubuntuonesettingspage.h"
|
||||
|
||||
#include "ui_ubuntuonesettingspage.h"
|
||||
|
||||
#include "core/application.h"
|
||||
#include "core/closure.h"
|
||||
#include "core/logging.h"
|
||||
#include "internet/internetmodel.h"
|
||||
#include "internet/ubuntuoneauthenticator.h"
|
||||
#include "internet/ubuntuoneservice.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
|
||||
UbuntuOneSettingsPage::UbuntuOneSettingsPage(SettingsDialog* parent)
|
||||
: SettingsPage(parent),
|
||||
ui_(new Ui::UbuntuOneSettingsPage),
|
||||
service_(dialog()->app()->internet_model()->Service<UbuntuOneService>()),
|
||||
authenticated_(false) {
|
||||
ui_->setupUi(this);
|
||||
|
||||
ui_->login_state->AddCredentialField(ui_->username);
|
||||
ui_->login_state->AddCredentialField(ui_->password);
|
||||
ui_->login_state->AddCredentialGroup(ui_->login_container);
|
||||
|
||||
connect(ui_->login_state, SIGNAL(LogoutClicked()), SLOT(LogoutClicked()));
|
||||
connect(ui_->login_state, SIGNAL(LoginClicked()), SLOT(LoginClicked()));
|
||||
connect(ui_->login_button, SIGNAL(clicked()), SLOT(LoginClicked()));
|
||||
}
|
||||
|
||||
void UbuntuOneSettingsPage::Load() {
|
||||
QSettings s;
|
||||
s.beginGroup(UbuntuOneService::kSettingsGroup);
|
||||
|
||||
const QString user_email = s.value("user_email").toString();
|
||||
if (!user_email.isEmpty()) {
|
||||
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedIn, user_email);
|
||||
ui_->username->setText(user_email);
|
||||
}
|
||||
}
|
||||
|
||||
void UbuntuOneSettingsPage::Save() {}
|
||||
|
||||
void UbuntuOneSettingsPage::LoginClicked() {
|
||||
const QString username = ui_->username->text();
|
||||
const QString password = ui_->password->text();
|
||||
ui_->password->clear();
|
||||
|
||||
UbuntuOneAuthenticator* authenticator = new UbuntuOneAuthenticator;
|
||||
authenticator->StartAuthorisation(username, password);
|
||||
NewClosure(authenticator, SIGNAL(Finished()), this,
|
||||
SLOT(Connected(UbuntuOneAuthenticator*)), authenticator);
|
||||
NewClosure(authenticator, SIGNAL(Finished()), service_,
|
||||
SLOT(AuthenticationFinished(UbuntuOneAuthenticator*)),
|
||||
authenticator);
|
||||
|
||||
ui_->login_state->SetLoggedIn(LoginStateWidget::LoginInProgress);
|
||||
}
|
||||
|
||||
void UbuntuOneSettingsPage::LogoutClicked() {
|
||||
QSettings s;
|
||||
s.beginGroup(UbuntuOneService::kSettingsGroup);
|
||||
s.remove("user_email");
|
||||
s.remove("consumer_key");
|
||||
s.remove("consumer_secret");
|
||||
s.remove("token");
|
||||
s.remove("token_secret");
|
||||
|
||||
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedOut);
|
||||
}
|
||||
|
||||
void UbuntuOneSettingsPage::Connected(UbuntuOneAuthenticator* authenticator) {
|
||||
if (!authenticator->success()) {
|
||||
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedOut);
|
||||
QMessageBox::warning(this, tr("Authentication failed"),
|
||||
tr("Your username or password was incorrect."));
|
||||
return;
|
||||
}
|
||||
|
||||
ui_->login_state->SetLoggedIn(LoginStateWidget::LoggedIn,
|
||||
ui_->username->text());
|
||||
authenticated_ = true;
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(UbuntuOneService::kSettingsGroup);
|
||||
s.setValue("user_email", ui_->username->text());
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
#ifndef UBUNTUONESETTINGSPAGE_H
|
||||
#define UBUNTUONESETTINGSPAGE_H
|
||||
|
||||
#include "ui/settingspage.h"
|
||||
|
||||
class UbuntuOneAuthenticator;
|
||||
class UbuntuOneService;
|
||||
class Ui_UbuntuOneSettingsPage;
|
||||
|
||||
class UbuntuOneSettingsPage : public SettingsPage {
|
||||
Q_OBJECT
|
||||
public:
|
||||
UbuntuOneSettingsPage(SettingsDialog* parent = nullptr);
|
||||
|
||||
void Load();
|
||||
void Save();
|
||||
|
||||
private slots:
|
||||
void LoginClicked();
|
||||
void LogoutClicked();
|
||||
void Connected(UbuntuOneAuthenticator* authenticator);
|
||||
|
||||
private:
|
||||
Ui_UbuntuOneSettingsPage* ui_;
|
||||
UbuntuOneService* service_;
|
||||
|
||||
bool authenticated_;
|
||||
};
|
||||
|
||||
#endif // UBUNTUONESETTINGSPAGE_H
|
@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>UbuntuOneSettingsPage</class>
|
||||
<widget class="QWidget" name="UbuntuOneSettingsPage">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>569</width>
|
||||
<height>491</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Ubuntu One</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../data/data.qrc">
|
||||
<normaloff>:/providers/ubuntuone.png</normaloff>:/providers/ubuntuone.png</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Clementine can play music that you have uploaded to Ubuntu One</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LoginStateWidget" name="login_state" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="login_container">
|
||||
<property name="title">
|
||||
<string>Account details</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Ubuntu One username</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="username"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="login_button">
|
||||
<property name="text">
|
||||
<string>Login</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Ubuntu One password</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="password">
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string><a href="https://one.ubuntu.com/auth/login">Create a new account or reset your password</a></string>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>LoginStateWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>widgets/loginstatewidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>username</tabstop>
|
||||
<tabstop>password</tabstop>
|
||||
<tabstop>login_button</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../../data/data.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
</ui>
|
@ -1,13 +0,0 @@
|
||||
#include "ubuntuoneurlhandler.h"
|
||||
|
||||
#include "ubuntuoneservice.h"
|
||||
|
||||
UbuntuOneUrlHandler::UbuntuOneUrlHandler(UbuntuOneService* service,
|
||||
QObject* parent)
|
||||
: UrlHandler(parent), service_(service) {}
|
||||
|
||||
UrlHandler::LoadResult UbuntuOneUrlHandler::StartLoading(const QUrl& url) {
|
||||
QString file_id = url.path();
|
||||
QUrl real_url = service_->GetStreamingUrlFromSongId(file_id);
|
||||
return LoadResult(url, LoadResult::TrackAvailable, real_url);
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
#ifndef UBUNTUONEURLHANDLER_H
|
||||
#define UBUNTUONEURLHANDLER_H
|
||||
|
||||
#include "core/urlhandler.h"
|
||||
|
||||
class UbuntuOneService;
|
||||
|
||||
class UbuntuOneUrlHandler : public UrlHandler {
|
||||
Q_OBJECT
|
||||
public:
|
||||
UbuntuOneUrlHandler(UbuntuOneService* service, QObject* parent = nullptr);
|
||||
|
||||
QString scheme() const { return "ubuntuonefile"; }
|
||||
QIcon icon() const { return QIcon(":providers/ubuntuone.png"); }
|
||||
LoadResult StartLoading(const QUrl& url);
|
||||
|
||||
private:
|
||||
UbuntuOneService* service_;
|
||||
};
|
||||
|
||||
#endif // UBUNTUONEURLHANDLER_H
|
@ -41,7 +41,6 @@
|
||||
#include "internet/soundcloudsettingspage.h"
|
||||
#include "internet/spotifysettingspage.h"
|
||||
#include "internet/subsonicsettingspage.h"
|
||||
#include "internet/ubuntuonesettingspage.h"
|
||||
#include "library/librarysettingspage.h"
|
||||
#include "playlist/playlistview.h"
|
||||
#include "podcasts/podcastsettingspage.h"
|
||||
@ -64,10 +63,6 @@
|
||||
#include "internet/googledrivesettingspage.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UBUNTU_ONE
|
||||
#include "internet/ubuntuonesettingspage.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DROPBOX
|
||||
#include "internet/dropboxsettingspage.h"
|
||||
#endif
|
||||
@ -169,10 +164,6 @@ SettingsDialog::SettingsDialog(Application* app, BackgroundStreams* streams,
|
||||
AddPage(Page_GoogleDrive, new GoogleDriveSettingsPage(this), providers);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UBUNTU_ONE
|
||||
AddPage(Page_UbuntuOne, new UbuntuOneSettingsPage(this), providers);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DROPBOX
|
||||
AddPage(Page_Dropbox, new DropboxSettingsPage(this), providers);
|
||||
#endif
|
||||
|
@ -81,7 +81,6 @@ class SettingsDialog : public QDialog {
|
||||
Page_Subsonic,
|
||||
Page_Podcasts,
|
||||
Page_GoogleDrive,
|
||||
Page_UbuntuOne,
|
||||
Page_Dropbox,
|
||||
Page_Skydrive,
|
||||
Page_Box,
|
||||
|
Loading…
x
Reference in New Issue
Block a user