some fixes on mac for issue 1164

preferencesAboutTextFull
Claudio Valerio 12 years ago
parent 241e770f7e
commit 9aa114857a
  1. 41
      src/podcast/youtube/UBYouTubePublisher.cpp

@ -94,16 +94,16 @@ void UBYouTubePublisher::postClientLoginRequest(const QString& userName, const Q
QUrl url("https://www.google.com/youtube/accounts/ClientLogin"); QUrl url("https://www.google.com/youtube/accounts/ClientLogin");
mAuthRequest = new UBServerXMLHttpRequest(UBNetworkAccessManager::defaultAccessManager() mAuthRequest = new UBServerXMLHttpRequest(UBNetworkAccessManager::defaultAccessManager()
, "application/x-www-form-urlencoded"); // destroyed in postClientLoginResponse , "application/x-www-form-urlencoded"); // destroyed in postClientLoginResponse
connect(mAuthRequest, SIGNAL(finished(bool, const QByteArray&)), this, SLOT(postClientLoginResponse(bool, const QByteArray&))); connect(mAuthRequest, SIGNAL(finished(bool, const QByteArray&)), this, SLOT(postClientLoginResponse(bool, const QByteArray&)));
mAuthRequest->addHeader("X-GData-Key", sYouTubeDeveloperKey); mAuthRequest->addHeader("X-GData-Key", sYouTubeDeveloperKey);
QString payload = QString("Email=%1&Passwd=%2&service=youtube&source=%3") QString payload = QString("Email=%1&Passwd=%2&service=youtube&source=%3")
.arg(userName) .arg(userName)
.arg(password) .arg(password)
.arg(tr("OpenSankore")); .arg(tr("OpenSankore"));
mAuthRequest->post(url, payload.toUtf8()); mAuthRequest->post(url, payload.toUtf8());
@ -125,8 +125,8 @@ void UBYouTubePublisher::postClientLoginResponse(bool success, const QByteArray&
{ {
if(line.startsWith("Auth=")) if(line.startsWith("Auth="))
{ {
mAuthToken = line.replace("Auth=", ""); mAuthToken = line.replace("Auth=", "");
break; break;
} }
} }
} }
@ -137,7 +137,7 @@ void UBYouTubePublisher::postClientLoginResponse(bool success, const QByteArray&
if(mAuthToken.length() == 0) if(mAuthToken.length() == 0)
{ {
UBApplication::showMessage(tr("YouTube authentication failed.")); UBApplication::showMessage(tr("YouTube authentication failed."));
// success = false; // success = false;
deleteLater(); deleteLater();
} }
else else
@ -188,7 +188,7 @@ void UBYouTubePublisher::postVideoUploadRequest()
QString contentType = QString("multipart/related; boundary=\"%1\"").arg(boundary); QString contentType = QString("multipart/related; boundary=\"%1\"").arg(boundary);
mUploadRequest = new UBServerXMLHttpRequest(UBNetworkAccessManager::defaultAccessManager() mUploadRequest = new UBServerXMLHttpRequest(UBNetworkAccessManager::defaultAccessManager()
, contentType); // destroyed in postVideoUploadResponse , contentType); // destroyed in postVideoUploadResponse
mUploadRequest->setVerbose(true); mUploadRequest->setVerbose(true);
connect(mUploadRequest, SIGNAL(progress(qint64, qint64)), this, SLOT(progress(qint64, qint64))); connect(mUploadRequest, SIGNAL(progress(qint64, qint64)), this, SLOT(progress(qint64, qint64)));
@ -206,15 +206,15 @@ void UBYouTubePublisher::postVideoUploadRequest()
QByteArray payload; QByteArray payload;
payload.append(QString("\n--" + boundary + "\n").toUtf8()) payload.append(QString("\n--" + boundary + "\n").toUtf8())
.append(QString("Content-Type: application/atom+xml; charset=UTF-8\n\n").toUtf8()) .append(QString("Content-Type: application/atom+xml; charset=UTF-8\n\n").toUtf8())
.append(youtubeMetadata().toUtf8()); .append(youtubeMetadata().toUtf8());
payload.append(QString("\n--" + boundary + "\n").toUtf8()); payload.append(QString("\n--" + boundary + "\n").toUtf8());
QString videoMimeType = UBFileSystemUtils::mimeTypeFromFileName(mVideoFilePath); QString videoMimeType = UBFileSystemUtils::mimeTypeFromFileName(mVideoFilePath);
payload.append((QString("Content-Type: %1\n").arg(videoMimeType)).toUtf8()) payload.append((QString("Content-Type: %1\n").arg(videoMimeType)).toUtf8())
.append(QString("Content-Transfer-Encoding: binary\n\n").toUtf8()); .append(QString("Content-Transfer-Encoding: binary\n\n").toUtf8());
payload.append(videoFile.readAll()); payload.append(videoFile.readAll());
@ -340,7 +340,13 @@ UBYouTubePublishingDialog::UBYouTubePublishingDialog(const QString& videoFilePat
dialogButtons->button(QDialogButtonBox::Ok)->setEnabled(false); dialogButtons->button(QDialogButtonBox::Ok)->setEnabled(false);
dialogButtons->button(QDialogButtonBox::Ok)->setText(tr("Upload")); 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()); youtubeCredentialsPersistence->setChecked(UBSettings::settings()->youTubeCredentialsPersistence->get().toBool());
updatePersistanceEnableState();
} }
@ -353,20 +359,21 @@ void UBYouTubePublishingDialog::updatePersistanceEnableState()
{ {
bool enabled = email->text().length() || password->text().length(); bool enabled = email->text().length() || password->text().length();
youtubeCredentialsPersistence->setEnabled(enabled); youtubeCredentialsPersistence->setEnabled(enabled);
youtubeCredentialsPersistence->setStyleSheet(enabled ? "color:black;" : "color lightgray;"); youtubeCredentialsPersistence->setStyleSheet(enabled ? "color:black;" : "color : lightgrey;");
} }
void UBYouTubePublishingDialog::updateUIState(const QString& string) void UBYouTubePublishingDialog::updateUIState(const QString& string)
{ {
Q_UNUSED(string); Q_UNUSED(string);
bool ok = title->text().length() > 0 bool ok = title->text().length() > 0
&& description->toPlainText().length() > 0 && description->toPlainText().length() > 0
&& keywords->text().length() > 0 && keywords->text().length() > 0
&& email->text().length() > 0 && email->text().length() > 0
&& password->text().length() > 0; && password->text().length() > 0;
dialogButtons->button(QDialogButtonBox::Ok)->setEnabled(ok); dialogButtons->button(QDialogButtonBox::Ok)->setEnabled(ok);
updatePersistanceEnableState();
} }

Loading…
Cancel
Save