diff --git a/OpenBoard.pro b/OpenBoard.pro index 17fb4e75a..f82e6408b 100644 --- a/OpenBoard.pro +++ b/OpenBoard.pro @@ -76,7 +76,6 @@ FORMS += resources/forms/mainWindow.ui \ resources/forms/documents.ui \ resources/forms/blackoutWidget.ui \ resources/forms/trapFlash.ui \ - resources/forms/youTubePublishingDialog.ui \ resources/forms/capturePublishing.ui \ resources/forms/intranetPodcastPublishingDialog.ui diff --git a/resources/etc/OpenBoard.config b/resources/etc/OpenBoard.config index ce77e232e..d64ba0eff 100644 --- a/resources/etc/OpenBoard.config +++ b/resources/etc/OpenBoard.config @@ -132,7 +132,6 @@ UsePDFMerger=true [Podcast] AudioRecordingDevice=Default FramesPerSecond=10 -PublishToYouTube=false QuickTimeQuality=High VideoSize=Medium WindowsMediaBitsPerSecond=1700000 @@ -152,7 +151,3 @@ PrivateBrowsing=false SearchEngineUrl=https://www.qwant.com/?q=%1 ShowPageImediatelyOnMirroredScreen=false UseExternalBrowser=false - -[YouTube] -CredentialsPersistence=false -UserEMail= diff --git a/resources/forms/CMakeLists.txt b/resources/forms/CMakeLists.txt index 547ea5411..7e8d6f08a 100644 --- a/resources/forms/CMakeLists.txt +++ b/resources/forms/CMakeLists.txt @@ -8,5 +8,4 @@ target_sources(${PROJECT_NAME} PRIVATE mainWindow.ui preferences.ui trapFlash.ui - youTubePublishingDialog.ui ) diff --git a/resources/forms/youTubePublishingDialog.ui b/resources/forms/youTubePublishingDialog.ui deleted file mode 100644 index e6a78c79d..000000000 --- a/resources/forms/youTubePublishingDialog.ui +++ /dev/null @@ -1,170 +0,0 @@ - - - YouTubePublishingDialog - - - Qt::WindowModal - - - - 0 - 0 - 540 - 534 - - - - Publish Podcast to YouTube - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Title - - - - - - - 60 - - - - - - - Description - - - - - - - - 0 - 0 - - - - - 0 - 168 - - - - - - - - Keywords - - - - - - - OpenBoard - - - - - - - Category - - - - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 20 - 40 - - - - - - - - YouTube Username - - - - - - - - - - YouTube Password - - - - - - - QLineEdit::Password - - - - - - - <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> -<html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-family:'Lucida Grande'; font-size:10pt;">By clicking 'Upload,' you certify that you own all rights to the content or that you are authorized by the owner to make the content publicly available on YouTube, and that it otherwise complies with the YouTube Terms of Service located at </span><a href="http://www.youtube.com/t/terms"><span style=" font-family:'Lucida Grande'; font-size:10pt; text-decoration: underline; color:#0000ff;">http://www.youtube.com/t/terms</span></a></p></body></html> - - - true - - - true - - - Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse - - - - - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - - Restore credentials on reboot - - - true - - - - - - - - - - - diff --git a/src/core/UBApplication.cpp b/src/core/UBApplication.cpp index fef848639..9b420eabf 100644 --- a/src/core/UBApplication.cpp +++ b/src/core/UBApplication.cpp @@ -63,7 +63,6 @@ #include "ui_mainWindow.h" -#include "frameworks/UBCryptoUtils.h" #include "tools/UBToolsManager.h" #include "UBDisplayManager.h" @@ -171,8 +170,6 @@ UBApplication::~UBApplication() UBSettings::destroy(); - UBCryptoUtils::destroy(); - UBToolsManager::destroy(); if(mApplicationTranslator != NULL){ diff --git a/src/core/UBSettings.cpp b/src/core/UBSettings.cpp index 645063e53..017dbf094 100644 --- a/src/core/UBSettings.cpp +++ b/src/core/UBSettings.cpp @@ -34,7 +34,6 @@ #include "frameworks/UBPlatformUtils.h" #include "frameworks/UBFileSystemUtils.h" -#include "frameworks/UBCryptoUtils.h" #include "UB.h" #include "UBSetting.h" @@ -432,14 +431,13 @@ void UBSettings::init() podcastWindowsMediaBitsPerSecond = new UBSetting(this, "Podcast", "WindowsMediaBitsPerSecond", 1700000); podcastQuickTimeQuality = new UBSetting(this, "Podcast", "QuickTimeQuality", "High"); - podcastPublishToYoutube = new UBSetting(this, "Podcast", "PublishToYouTube", false); - youTubeUserEMail = new UBSetting(this, "YouTube", "UserEMail", ""); - youTubeCredentialsPersistence = new UBSetting(this,"YouTube", "CredentialsPersistence",false); - communityUser = new UBSetting(this, "Community", "Username", ""); communityPsw = new UBSetting(this, "Community", "Password", ""); communityCredentialsPersistence = new UBSetting(this,"Community", "CredentialsPersistence",false); + proxyUser = new UBSetting(this, "Proxy", "UserName", ""); + proxyPsw = new UBSetting(this, "Proxy", "Password", ""); + QStringList uris = UBToolsManager::manager()->allToolIDs(); favoritesNativeToolUris = new UBSetting(this, "App", "FavoriteToolURIs", uris); @@ -1312,75 +1310,35 @@ QNetworkProxy* UBSettings::httpProxy() proxy->setHostName(mAppSettings->value("Proxy/HostName").toString()); proxy->setPort(mAppSettings->value("Proxy/Port", 1080).toInt()); - proxy->setUser(mAppSettings->value("Proxy/UserName").toString()); - proxy->setPassword(mAppSettings->value("Proxy/Password").toString()); + proxy->setUser(proxyUser->get().toString()); + proxy->setPassword(proxyPsw->get().toString()); } return proxy; } -void UBSettings::setPassword(const QString& id, const QString& password) -{ - QString encrypted = UBCryptoUtils::instance()->symetricEncrypt(password); - - mUserSettings->setValue(QString("Vault/") + id, encrypted); -} - - -void UBSettings::removePassword(const QString& id) -{ - mUserSettings->remove(QString("Vault/") + id); -} - - -QString UBSettings::password(const QString& id) -{ - QString encrypted = mUserSettings->value(QString("Vault/") + id).toString(); - - QString result = ""; - - if (encrypted.length() > 0) - result = UBCryptoUtils::instance()->symetricDecrypt(encrypted); - - return result; -} - - QString UBSettings::proxyUsername() { - QString idUsername = "http.proxy.user"; - return password(idUsername); + return proxyUser->get().toString(); } void UBSettings::setProxyUsername(const QString& username) { - QString idUsername = "http.proxy.user"; - - if (username.length() > 0) - setPassword(idUsername, username); - else - removePassword(idUsername); + proxyUser->set(QVariant(username)); } QString UBSettings::proxyPassword() { - QString idPassword = "http.proxy.pass"; - return password(idPassword); + return proxyPsw->get().toString(); } void UBSettings::setProxyPassword(const QString& password) { - QString idPassword = "http.proxy.pass"; - - if (password.length() > 0) - setPassword(idPassword, password); - else - removePassword(idPassword); - + proxyPsw->set(QVariant(password)); } QString UBSettings::communityUsername() @@ -1459,10 +1417,8 @@ void UBSettings::cleanNonPersistentSettings() communityUser->set(QVariant("")); } - if(!youTubeCredentialsPersistence->get().toBool()){ - removePassword(youTubeUserEMail->get().toString()); - youTubeUserEMail->set(QVariant("")); - } + proxyUser->set(QVariant("")); + proxyPsw->set(QVariant("")); } /** diff --git a/src/core/UBSettings.h b/src/core/UBSettings.h index 53a608833..727ad75ab 100644 --- a/src/core/UBSettings.h +++ b/src/core/UBSettings.h @@ -110,10 +110,6 @@ class UBSettings : public QObject bool isItalicFont(); void setItalicFont(bool italic); - void setPassword(const QString& id, const QString& password); - QString password(const QString& id); - void removePassword(const QString& id); - QString proxyUsername(); void setProxyUsername(const QString& username); QString proxyPassword(); @@ -376,10 +372,6 @@ class UBSettings : public QObject UBSetting* podcastAudioRecordingDevice; UBSetting* podcastQuickTimeQuality; - UBSetting* podcastPublishToYoutube; - UBSetting* youTubeUserEMail; - UBSetting* youTubeCredentialsPersistence; - UBSetting* podcastPublishToIntranet; UBSetting* intranetPodcastPublishingUrl; UBSetting* intranetPodcastAuthor; @@ -412,6 +404,9 @@ class UBSettings : public QObject UBSetting* communityPsw; UBSetting* communityCredentialsPersistence; + UBSetting* proxyUser; + UBSetting* proxyPsw; + UBSetting* pageSize; UBSetting* KeyboardLocale; diff --git a/src/frameworks/CMakeLists.txt b/src/frameworks/CMakeLists.txt index aab3eb7be..0e4ce3f1c 100644 --- a/src/frameworks/CMakeLists.txt +++ b/src/frameworks/CMakeLists.txt @@ -3,8 +3,6 @@ target_sources(openboard PRIVATE UBBase32.h UBCoreGraphicsScene.cpp UBCoreGraphicsScene.h - UBCryptoUtils.cpp - UBCryptoUtils.h UBFileSystemUtils.cpp UBFileSystemUtils.h UBGeometryUtils.cpp diff --git a/src/frameworks/UBCryptoUtils.cpp b/src/frameworks/UBCryptoUtils.cpp deleted file mode 100644 index b5497cdc6..000000000 --- a/src/frameworks/UBCryptoUtils.cpp +++ /dev/null @@ -1,188 +0,0 @@ -/* - * Copyright (C) 2015-2022 Département de l'Instruction Publique (DIP-SEM) - * - * Copyright (C) 2013 Open Education Foundation - * - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour - * l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of OpenBoard. - * - * OpenBoard is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * OpenBoard is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenBoard. If not, see . - */ - - - - -#include "UBCryptoUtils.h" - -#include - -#include "core/memcheck.h" - -UBCryptoUtils* UBCryptoUtils::sInstance(0); -QString UBCryptoUtils::sAESKey("9ecHaspud9uD9ste5erAchehefrup3echej-caje6&thestawacuk=h#F3jet3aF"); -QString UBCryptoUtils::sAESSalt("6f0083e0-a90c-11de-ac21-0002a5d5c51b"); - -UBCryptoUtils* UBCryptoUtils::instance() -{ - if(!sInstance) - sInstance = new UBCryptoUtils(UBApplication::staticMemoryCleaner); - - return sInstance; -} - -void UBCryptoUtils::destroy() -{ - if (sInstance) - delete sInstance; - sInstance = NULL; -} - - -UBCryptoUtils::UBCryptoUtils(QObject * pParent) - : QObject(pParent) -{ - aesInit(); -} - - -UBCryptoUtils::~UBCryptoUtils() -{ - // TODO UB 4.x aes destroy -#if OPENSSL_VERSION_NUMBER >= 10100000L - EVP_CIPHER_CTX_free(mAesEncryptContext); - EVP_CIPHER_CTX_free(mAesDecryptContext); -#endif -} - - -QString UBCryptoUtils::symetricEncrypt(const QString& clear) -{ - QByteArray clearData = clear.toUtf8(); - - int cipheredLength = clearData.length() + AES_BLOCK_SIZE; - int paddingLength = 0; - unsigned char *ciphertext = (unsigned char *)malloc(cipheredLength); - -#if OPENSSL_VERSION_NUMBER >= 10100000L - if(!EVP_EncryptInit_ex(mAesEncryptContext, NULL, NULL, NULL, NULL)){ -#else - if(!EVP_EncryptInit_ex(&mAesEncryptContext, NULL, NULL, NULL, NULL)){ -#endif - free(ciphertext); - return QString(); - } - -#if OPENSSL_VERSION_NUMBER >= 10100000L - if(!EVP_EncryptUpdate(mAesEncryptContext, ciphertext, &cipheredLength, (unsigned char *)clearData.data(), clearData.length())){ -#else - if(!EVP_EncryptUpdate(&mAesEncryptContext, ciphertext, &cipheredLength, (unsigned char *)clearData.data(), clearData.length())){ -#endif - free(ciphertext); - return QString(); - } - - /* update ciphertext with the final remaining bytes */ -#if OPENSSL_VERSION_NUMBER >= 10100000L - if(!EVP_EncryptFinal_ex(mAesEncryptContext, ciphertext + cipheredLength, &paddingLength)){ -#else - if(!EVP_EncryptFinal_ex(&mAesEncryptContext, ciphertext + cipheredLength, &paddingLength)){ -#endif - free(ciphertext); - return QString(); - } - - QByteArray cipheredData((const char *)ciphertext, cipheredLength + paddingLength); - - free(ciphertext); - - return QString::fromLatin1(cipheredData.toBase64()); -} - - -QString UBCryptoUtils::symetricDecrypt(const QString& encrypted) -{ - QByteArray encryptedData = QByteArray::fromBase64(encrypted.toLatin1()); - - int encryptedLength = encryptedData.length(); - int paddingLength = 0; - unsigned char *plaintext = (unsigned char *)malloc(encryptedLength); - -#if OPENSSL_VERSION_NUMBER >= 10100000L - if(!EVP_DecryptInit_ex(mAesDecryptContext, NULL, NULL, NULL, NULL)){ -#else - if(!EVP_DecryptInit_ex(&mAesDecryptContext, NULL, NULL, NULL, NULL)){ -#endif - free(plaintext); - return QString(); - } - -#if OPENSSL_VERSION_NUMBER >= 10100000L - if(!EVP_DecryptUpdate(mAesDecryptContext, plaintext, &encryptedLength, (const unsigned char *)encryptedData.data(), encryptedData.length())){ -#else - if(!EVP_DecryptUpdate(&mAesDecryptContext, plaintext, &encryptedLength, (const unsigned char *)encryptedData.data(), encryptedData.length())){ -#endif - free(plaintext); - return QString(); - } - -#if OPENSSL_VERSION_NUMBER >= 10100000L - if(!EVP_DecryptFinal_ex(mAesDecryptContext, plaintext + encryptedLength, &paddingLength)){ -#else - if(!EVP_DecryptFinal_ex(&mAesDecryptContext, plaintext + encryptedLength, &paddingLength)){ -#endif - free(plaintext); - return QString(); - } - - int len = encryptedLength + paddingLength; - QByteArray clearData((const char *)plaintext, len); - - free(plaintext); - - return QString::fromUtf8(clearData);; -} - - -void UBCryptoUtils::aesInit() -{ - int i, nrounds = 5; - unsigned char key[32], iv[32]; - unsigned char *key_data = (unsigned char *)sAESKey.toLatin1().data(); - int key_data_len = sAESKey.length(); - - i = EVP_BytesToKey(EVP_aes_256_cbc(), EVP_sha1(), (unsigned char *)sAESSalt.toLatin1().data(), key_data, - key_data_len, nrounds, key, iv); - - if (i != 32) - { - qWarning() << QString("Key size is %1 bits - should be 256 bits").arg(i); - return; - } - -#if OPENSSL_VERSION_NUMBER >= 10100000L - mAesEncryptContext = EVP_CIPHER_CTX_new(); - EVP_EncryptInit_ex(mAesEncryptContext, EVP_aes_256_cbc(), NULL, key, iv); - mAesDecryptContext = EVP_CIPHER_CTX_new(); - EVP_DecryptInit_ex(mAesDecryptContext, EVP_aes_256_cbc(), NULL, key, iv); -#else - EVP_CIPHER_CTX_init(&mAesEncryptContext); - EVP_EncryptInit_ex(&mAesEncryptContext, EVP_aes_256_cbc(), NULL, key, iv); - EVP_CIPHER_CTX_init(&mAesDecryptContext); - EVP_DecryptInit_ex(&mAesDecryptContext, EVP_aes_256_cbc(), NULL, key, iv); -#endif -} diff --git a/src/frameworks/UBCryptoUtils.h b/src/frameworks/UBCryptoUtils.h deleted file mode 100644 index bf084f8ea..000000000 --- a/src/frameworks/UBCryptoUtils.h +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (C) 2015-2022 Département de l'Instruction Publique (DIP-SEM) - * - * Copyright (C) 2013 Open Education Foundation - * - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour - * l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of OpenBoard. - * - * OpenBoard is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * OpenBoard is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenBoard. If not, see . - */ - - - - -#ifndef UBCRYPTOUTILS_H_ -#define UBCRYPTOUTILS_H_ - -#include -#include - -#include "core/UBApplication.h" - - -class UBCryptoUtils : public QObject -{ - Q_OBJECT; - - public: - - static UBCryptoUtils* instance(); - static void destroy(); - - - QString symetricEncrypt(const QString& clear); - QString symetricDecrypt(const QString& encrypted); - - private: - - UBCryptoUtils(QObject * pParent = 0); - virtual ~UBCryptoUtils(); - - static UBCryptoUtils* sInstance; - static QString sAESKey; - static QString sAESSalt; - - void aesInit(); - -#if OPENSSL_VERSION_NUMBER >= 10100000L - EVP_CIPHER_CTX *mAesEncryptContext; - EVP_CIPHER_CTX *mAesDecryptContext; -#else - EVP_CIPHER_CTX mAesEncryptContext; - EVP_CIPHER_CTX mAesDecryptContext; -#endif - -}; - -#endif /* UBCRYPTOUTILS_H_ */ diff --git a/src/frameworks/frameworks.pri b/src/frameworks/frameworks.pri index 74d6edbbe..4fa797f56 100644 --- a/src/frameworks/frameworks.pri +++ b/src/frameworks/frameworks.pri @@ -5,7 +5,6 @@ HEADERS += src/frameworks/UBGeometryUtils.h \ src/frameworks/UBStringUtils.h \ src/frameworks/UBVersion.h \ src/frameworks/UBCoreGraphicsScene.h \ - src/frameworks/UBCryptoUtils.h \ src/frameworks/UBBase32.h SOURCES += src/frameworks/UBGeometryUtils.cpp \ @@ -14,7 +13,6 @@ SOURCES += src/frameworks/UBGeometryUtils.cpp \ src/frameworks/UBStringUtils.cpp \ src/frameworks/UBVersion.cpp \ src/frameworks/UBCoreGraphicsScene.cpp \ - src/frameworks/UBCryptoUtils.cpp \ src/frameworks/UBBase32.cpp diff --git a/src/podcast/CMakeLists.txt b/src/podcast/CMakeLists.txt index ca7087809..fb7968d7d 100644 --- a/src/podcast/CMakeLists.txt +++ b/src/podcast/CMakeLists.txt @@ -7,8 +7,6 @@ target_sources(${PROJECT_NAME} PRIVATE UBPodcastRecordingPalette.h intranet/UBIntranetPodcastPublisher.cpp intranet/UBIntranetPodcastPublisher.h - youtube/UBYouTubePublisher.cpp - youtube/UBYouTubePublisher.h ) if(WIN32) diff --git a/src/podcast/UBPodcastController.cpp b/src/podcast/UBPodcastController.cpp index 442972898..5dfa96ec4 100644 --- a/src/podcast/UBPodcastController.cpp +++ b/src/podcast/UBPodcastController.cpp @@ -51,7 +51,6 @@ #include "UBAbstractVideoEncoder.h" -#include "podcast/youtube/UBYouTubePublisher.h" #include "podcast/intranet/UBIntranetPodcastPublisher.h" #include "UBPodcastRecordingPalette.h" @@ -98,7 +97,6 @@ UBPodcastController::UBPodcastController(QObject* pParent) , mSmallVideoSizeAction(0) , mMediumVideoSizeAction(0) , mFullVideoSizeAction(0) - , mYoutubePublicationAction(0) , mIntranetPublicationAction(0) { connect(UBApplication::applicationController, SIGNAL(mainModeChanged(UBApplicationController::MainMode)), @@ -174,7 +172,6 @@ void UBPodcastController::updateActionState() } } - UBSettings::settings()->podcastPublishToYoutube->set(mYoutubePublicationAction && mYoutubePublicationAction->isChecked()); UBSettings::settings()->podcastPublishToIntranet->set(mIntranetPublicationAction && mIntranetPublicationAction->isChecked()); } @@ -693,12 +690,6 @@ void UBPodcastController::encodingFinished(bool ok) UBIntranetPodcastPublisher* intranet = new UBIntranetPodcastPublisher(this); // Self destroyed intranet->publishVideo(mVideoEncoder->videoFileName(), elapsedRecordingMs()); } - - if (mYoutubePublicationAction && mYoutubePublicationAction->isChecked()) - { - UBYouTubePublisher* youTube = new UBYouTubePublisher(this); // Self destroyed - youTube->uploadVideo(mVideoEncoder->videoFileName()); - } } } else @@ -943,12 +934,6 @@ QList UBPodcastController::podcastPublicationActions() mPodcastPublicationActions << mIntranetPublicationAction; - mYoutubePublicationAction = new QAction(tr("Publish to Youtube"), this); - mYoutubePublicationAction->setCheckable(true); - mYoutubePublicationAction->setChecked(UBSettings::settings()->podcastPublishToYoutube->get().toBool()); - - mPodcastPublicationActions << mYoutubePublicationAction; - foreach(QAction* publicationAction, mPodcastPublicationActions) { connect(publicationAction, SIGNAL(toggled(bool)), this, SLOT(actionToggled(bool))); diff --git a/src/podcast/UBPodcastController.h b/src/podcast/UBPodcastController.h index 975857670..bb7d22ee6 100644 --- a/src/podcast/UBPodcastController.h +++ b/src/podcast/UBPodcastController.h @@ -182,7 +182,6 @@ class UBPodcastController : public QObject QList mPodcastPublicationActions; - QAction *mYoutubePublicationAction; QAction *mIntranetPublicationAction; QString mPodcastRecordingPath; diff --git a/src/podcast/podcast.pri b/src/podcast/podcast.pri index 556d5d6b8..30a1d70a9 100644 --- a/src/podcast/podcast.pri +++ b/src/podcast/podcast.pri @@ -2,13 +2,11 @@ HEADERS += src/podcast/UBPodcastController.h \ src/podcast/UBAbstractVideoEncoder.h \ src/podcast/UBPodcastRecordingPalette.h \ - src/podcast/youtube/UBYouTubePublisher.h \ src/podcast/intranet/UBIntranetPodcastPublisher.h \ SOURCES += src/podcast/UBPodcastController.cpp \ src/podcast/UBAbstractVideoEncoder.cpp \ src/podcast/UBPodcastRecordingPalette.cpp \ - src/podcast/youtube/UBYouTubePublisher.cpp \ src/podcast/intranet/UBIntranetPodcastPublisher.cpp \ win32 { diff --git a/src/podcast/youtube/UBYouTubePublisher.cpp b/src/podcast/youtube/UBYouTubePublisher.cpp deleted file mode 100644 index c1e66cd37..000000000 --- a/src/podcast/youtube/UBYouTubePublisher.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/* - * Copyright (C) 2015-2022 Département de l'Instruction Publique (DIP-SEM) - * - * Copyright (C) 2013 Open Education Foundation - * - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour - * l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of OpenBoard. - * - * OpenBoard is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * OpenBoard is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenBoard. If not, see . - */ - - - - -#include "UBYouTubePublisher.h" - - - -#include "frameworks/UBFileSystemUtils.h" - -#include "core/UBApplication.h" -#include "core/UBSettings.h" -#include "core/UBSetting.h" - -#include "gui/UBMainWindow.h" - -#include "network/UBNetworkAccessManager.h" -#include "network/UBServerXMLHttpRequest.h" - -#include "core/memcheck.h" - -// API key linked to account dev.mnemis@gmail.com -const QString UBYouTubePublisher::sYouTubeDeveloperKey("AI39si62ga82stA4YBr5JjkfuRsFT-QyC4UYsFn7yYQFMe_dzg8xOc0r91BOhxSEhEr0gdWJGNnDsYbv9wvpyROd2Yre-6Zh7g"); - -UBYouTubePublisher::UBYouTubePublisher(QObject* pParent) - : QObject(pParent) - , mAuthRequest(0) - , mUploadRequest(0) -{ - // NOOP -} - - -UBYouTubePublisher::~UBYouTubePublisher() -{ - // NOOP -} - - -void UBYouTubePublisher::uploadVideo(const QString& videoFilePath) -{ - mVideoFilePath = videoFilePath; - - UBYouTubePublishingDialog pub(videoFilePath, UBApplication::mainWindow); - - pub.title->setText(QFileInfo(mVideoFilePath).completeBaseName()); - pub.keywords->setText(qApp->applicationName()); - - QString defaultEMail = UBSettings::settings()->youTubeUserEMail->get().toString(); - pub.email->setText(defaultEMail); - - QString defaultPassword = UBSettings::settings()->password(defaultEMail); - pub.password->setText(defaultPassword); - - if (pub.exec() == QDialog::Accepted) - { - mTitle = pub.title->text(); - mDescription = pub.description->toPlainText(); - mCategories << pub.category->itemData(pub.category->currentIndex()).toString(); - mKeywords = pub.keywords->text(); - - QString email = pub.email->text(); - UBSettings::settings()->youTubeUserEMail->set(email); - - QString password = pub.password->text(); - - UBSettings::settings()->setPassword(email, password); - - postClientLoginRequest(email, password); - } - else - { - deleteLater(); - } -} - - -void UBYouTubePublisher::postClientLoginRequest(const QString& userName, const QString& password) -{ - QString mUserName = userName; - - QUrl url("https://www.google.com/youtube/accounts/ClientLogin"); - - mAuthRequest = new UBServerXMLHttpRequest(UBNetworkAccessManager::defaultAccessManager() - , "application/x-www-form-urlencoded"); // destroyed in postClientLoginResponse - - connect(mAuthRequest, SIGNAL(finished(bool, const QByteArray&)), this, SLOT(postClientLoginResponse(bool, const QByteArray&))); - - mAuthRequest->addHeader("X-GData-Key", sYouTubeDeveloperKey); - - QString payload = QString("Email=%1&Passwd=%2&service=youtube&source=%3") - .arg(userName) - .arg(password) - .arg(qApp->applicationName()); - - mAuthRequest->post(url, payload.toUtf8()); - -} - - -void UBYouTubePublisher::postClientLoginResponse(bool success, const QByteArray& pPayload) -{ - Q_UNUSED(success); - mAuthToken = ""; - - QString auth = QString::fromUtf8(pPayload); - - if (auth.contains("Auth=")) - { - QStringList lines = auth.split("\n"); - - foreach(QString line, lines) - { - if(line.startsWith("Auth=")) - { - mAuthToken = line.replace("Auth=", ""); - break; - } - } - } - - mAuthRequest->deleteLater(); - mAuthRequest = 0; - - if(mAuthToken.length() == 0) - { - UBApplication::showMessage(tr("YouTube authentication failed.")); - // success = false; - deleteLater(); - } - else - { - qDebug() << "Retreived youtube auth token" << mAuthToken; - postVideoUploadRequest(); - } -} - - -void UBYouTubePublisher::postVideoUploadRequest() -{ - /* - * POST /feeds/api/users/default/uploads HTTP/1.1 - Host: gdata.youtube.com - Authorization: GoogleLogin auth= - GData-Version: 2 - X-GData-Client: - X-GData-Key: key= - Slug: - Content-Type: multipart/related; boundary="" - Content-Length: - Connection: close - - -- - Content-Type: application/atom+xml; charset=UTF-8 - - API_XML_request - -- - Content-Type: - Content-Transfer-Encoding: binary - - - ---- - */ - - QFile videoFile(mVideoFilePath); - - if(!videoFile.open(QIODevice::ReadOnly)) - { - qWarning() << "Cannot open file" << mVideoFilePath << "for upload to youtube"; - return; - } - - QUrl url("http://uploads.gdata.youtube.com/feeds/api/users/default/uploads"); - - QString boundary = "---------------------------f93dcbA3"; - QString contentType = QString("multipart/related; boundary=\"%1\"").arg(boundary); - - mUploadRequest = new UBServerXMLHttpRequest(UBNetworkAccessManager::defaultAccessManager() - , contentType); // destroyed in postVideoUploadResponse - - mUploadRequest->setVerbose(true); - connect(mUploadRequest, SIGNAL(progress(qint64, qint64)), this, SLOT(progress(qint64, qint64))); - - connect(mUploadRequest, SIGNAL(finished(bool, const QByteArray&)), this, SLOT(postVideoUploadResponse(bool, const QByteArray&))); - - mUploadRequest->addHeader("X-GData-Key", "key=" + sYouTubeDeveloperKey); - mUploadRequest->addHeader("Authorization", QString("GoogleLogin auth=%1").arg(mAuthToken)); - mUploadRequest->addHeader("GData-Version", "2"); - - QFileInfo fi(mVideoFilePath); - mUploadRequest->addHeader("Slug", fi.fileName()); - mUploadRequest->addHeader("Connection", "close"); // do we really ned that ? - - QByteArray payload; - - payload.append(QString("\n--" + boundary + "\n").toUtf8()) - .append(QString("Content-Type: application/atom+xml; charset=UTF-8\n\n").toUtf8()) - .append(youtubeMetadata().toUtf8()); - - payload.append(QString("\n--" + boundary + "\n").toUtf8()); - - QString videoMimeType = UBFileSystemUtils::mimeTypeFromFileName(mVideoFilePath); - - payload.append((QString("Content-Type: %1\n").arg(videoMimeType)).toUtf8()) - .append(QString("Content-Transfer-Encoding: binary\n\n").toUtf8()); - - payload.append(videoFile.readAll()); - - payload.append(QString("\n--" + boundary + "--\n").toUtf8()); - - mUploadRequest->post(url, payload); -} - - -void UBYouTubePublisher::postVideoUploadResponse(bool success, const QByteArray& pPayload) -{ - mUploadRequest->deleteLater(); - - if(success) - { - UBApplication::showMessage("The video has been uploaded to youtube", false); - } - else - { - qWarning() << "error uploading video to youtube" << QString::fromUtf8(pPayload); - - UBApplication::showMessage(tr("Error while uploading video to YouTube (%1)").arg(QString::fromUtf8(pPayload)), false); - } - - deleteLater(); -} - - -QString UBYouTubePublisher::youtubeMetadata() -{ - QString workingTitle; - - if (mTitle.length() > 0) - { - workingTitle = mTitle; - } - else - { - workingTitle = QFileInfo(mVideoFilePath).completeBaseName(); - } - - QString metadata; - - metadata += "\n"; - metadata += "\n"; - metadata += " \n"; - metadata += QString(" %1\n").arg(workingTitle); - - QString workingDescription = mDescription; - - if (workingDescription.length() > 4900) - { - workingDescription = workingDescription.left(4900) + "..."; - } - - workingDescription += "\n\nhttp://www.openboard.org"; - - if(workingDescription.length() == 0) - { - workingDescription = workingTitle; - } - - metadata += QString(" %1\n").arg(workingDescription); - - foreach(QString cat, mCategories) - { - metadata += QString(" %1\n").arg(cat); - } - - if (mKeywords.length() > 0) - { - metadata += QString(" %1\n").arg(mKeywords); - } - - metadata += " \n"; - metadata += ""; - - return metadata; - -} - - -void UBYouTubePublisher::progress (qint64 bytesSent, qint64 bytesTotal ) -{ - int percentage = (((qreal)bytesSent / (qreal)bytesTotal ) * 100); - - UBApplication::showMessage(tr("Upload to YouTube in progress %1 %").arg(percentage), percentage < 100); -} - - - -UBYouTubePublishingDialog::UBYouTubePublishingDialog(const QString& videoFilePath, QWidget *parent) - : QDialog(parent) -{ - Q_UNUSED(videoFilePath); - - Ui::YouTubePublishingDialog::setupUi(this); - - QMap cats = categories(); - - category->clear(); - int index = 0; - foreach(QString cat, cats.keys()) - { - category->addItem(cats.value(cat), cat); - if(cat == "Education") - category->setCurrentIndex(index); - - index++; - } - - connect(dialogButtons, SIGNAL(accepted()), this, SLOT(accept())); - connect(dialogButtons, SIGNAL(rejected()), this, SLOT(reject())); - - connect(title, SIGNAL(textChanged(const QString&)), this, SLOT(updateUIState(const QString&))); - connect(description, SIGNAL(textChanged()), this, SLOT(updateUIState())); - connect(keywords, SIGNAL(textChanged(const QString&)), this, SLOT(updateUIState(const QString&))); - - connect(email, SIGNAL(textChanged(const QString&)), this, SLOT(updateUIState(const QString&))); - connect(password, SIGNAL(textChanged(const QString&)), this, SLOT(updateUIState(const QString&))); - connect(youtubeCredentialsPersistence,SIGNAL(clicked()), this, SLOT(updateCredentialPersistenceState())); - - dialogButtons->button(QDialogButtonBox::Ok)->setEnabled(false); - dialogButtons->button(QDialogButtonBox::Ok)->setText(tr("Upload")); - - UBSettings* settings = UBSettings::settings(); - - email->setText(settings->youTubeUserEMail->get().toString()); - password->setText(settings->password(email->text())); - - youtubeCredentialsPersistence->setChecked(UBSettings::settings()->youTubeCredentialsPersistence->get().toBool()); - updatePersistanceEnableState(); -} - - -void UBYouTubePublishingDialog::updateCredentialPersistenceState() -{ - UBSettings::settings()->youTubeCredentialsPersistence->set(QVariant(youtubeCredentialsPersistence->checkState())); -} - -void UBYouTubePublishingDialog::updatePersistanceEnableState() -{ - bool enabled = email->text().length() || password->text().length(); - youtubeCredentialsPersistence->setEnabled(enabled); - youtubeCredentialsPersistence->setStyleSheet(enabled ? "color:black;" : "color : lightgrey;"); -} - -void UBYouTubePublishingDialog::updateUIState(const QString& string) -{ - Q_UNUSED(string); - - bool ok = title->text().length() > 0 - && description->toPlainText().length() > 0 - && keywords->text().length() > 0 - && email->text().length() > 0 - && password->text().length() > 0; - - dialogButtons->button(QDialogButtonBox::Ok)->setEnabled(ok); - updatePersistanceEnableState(); -} - - -QMap UBYouTubePublishingDialog::categories() -{ - // TODO UB 4.x download localized list from - // http://code.google.com/apis/youtube/2.0/reference.html#Localized_Category_Lists - - QMap cats; - - cats.insert("Autos", tr("Autos & Vehicles")); - cats.insert("Music", tr("Music")); - cats.insert("Animals", tr("Pets & Animals")); - cats.insert("Sports", tr("Sports")); - cats.insert("Travel", tr("Travel & Events")); - cats.insert("Games", tr("Gaming")); - cats.insert("Comedy", tr("Comedy")); - cats.insert("People", tr("People & Blogs")); - cats.insert("News", tr("News & Politics")); - cats.insert("Entertainment", tr("Entertainment")); - cats.insert("Education", tr("Education")); - cats.insert("Howto", tr("Howto & Style")); - cats.insert("Nonprofit", tr("Nonprofits & Activism")); - cats.insert("Tech", tr("Science & Technology")); - - return cats; -} - diff --git a/src/podcast/youtube/UBYouTubePublisher.h b/src/podcast/youtube/UBYouTubePublisher.h deleted file mode 100644 index 91ee48f45..000000000 --- a/src/podcast/youtube/UBYouTubePublisher.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (C) 2015-2022 Département de l'Instruction Publique (DIP-SEM) - * - * Copyright (C) 2013 Open Education Foundation - * - * Copyright (C) 2010-2013 Groupement d'Intérêt Public pour - * l'Education Numérique en Afrique (GIP ENA) - * - * This file is part of OpenBoard. - * - * OpenBoard is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, version 3 of the License, - * with a specific linking exception for the OpenSSL project's - * "OpenSSL" library (or with modified versions of it that use the - * same license as the "OpenSSL" library). - * - * OpenBoard is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with OpenBoard. If not, see . - */ - - - - -#ifndef UBYOUTUBEPUBLISHER_H_ -#define UBYOUTUBEPUBLISHER_H_ - -#include - -#include "ui_youTubePublishingDialog.h" - -class UBServerXMLHttpRequest; - -class UBYouTubePublisher : public QObject -{ - Q_OBJECT; - - public: - UBYouTubePublisher(QObject* pParent = 0); - virtual ~UBYouTubePublisher(); - - public slots: - - void uploadVideo(const QString& videoFilePath); - - signals: - - void postClientLoginRequestFinished(bool success, const QString& authToken); - - private slots: - - void postClientLoginRequest(const QString& userName, const QString& password); - void postClientLoginResponse(bool success, const QByteArray& pPayload); - - void postVideoUploadRequest(); - void postVideoUploadResponse(bool success, const QByteArray& pPayload); - void progress(qint64 bytesSent, qint64 bytesTotal); - - private: - - QString youtubeMetadata(); - - static const QString sYouTubeDeveloperKey; - - QString mVideoFilePath; - QString mAuthToken; - QString mUserName; - - QString mTitle; - QString mDescription; - QString mKeywords; - QStringList mCategories; - - UBServerXMLHttpRequest *mAuthRequest; - UBServerXMLHttpRequest *mUploadRequest; - -}; - - -class UBYouTubePublishingDialog : public QDialog, public Ui::YouTubePublishingDialog -{ - Q_OBJECT; - - public: - UBYouTubePublishingDialog(const QString& videoFilePath, QWidget *parent = 0); - ~UBYouTubePublishingDialog(){}; - - private: - QMap categories(); - void updatePersistanceEnableState(); - - private slots: - void updateUIState(const QString& = QString("")); - void updateCredentialPersistenceState(); - -}; - -#endif /* UBYOUTUBEPUBLISHER_H_ */