author | Stepan777 <stepik-777@mail.ru> |
Thu, 09 Aug 2012 01:24:38 +0400 | |
changeset 7528 | f8cf277dca36 |
parent 7507 | 3032a5739fe1 |
child 7531 | 0adcad8714c4 |
permissions | -rw-r--r-- |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
1 |
/* |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
4 |
* |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
8 |
* |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
13 |
* |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
17 |
*/ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
18 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
19 |
#include <QLineEdit> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
20 |
#include <QDialogButtonBox> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
21 |
#include <QPushButton> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
22 |
#include <QGridLayout> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
23 |
#include <QCheckBox> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
24 |
#include <QLabel> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
25 |
#include <QFrame> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
26 |
#include <QPlainTextEdit> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
27 |
#include <QSslError> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
28 |
#include <QUrl> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
29 |
#include <QNetworkAccessManager> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
30 |
#include <QNetworkRequest> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
31 |
#include <QNetworkReply> |
7507 | 32 |
#include <QMessageBox> |
33 |
#include <QRegExp> |
|
34 |
#include <QRegExpValidator> |
|
35 |
#include <QMessageBox> |
|
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
36 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
37 |
#include "upload_video.h" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
38 |
#include "hwconsts.h" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
39 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
40 |
// User-agent string used in http requests. |
7528
f8cf277dca36
FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
7507
diff
changeset
|
41 |
// Don't make it a global varibale - crash on linux because of cVersionString |
f8cf277dca36
FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
7507
diff
changeset
|
42 |
#define USER_AGENT ("Hedgewars-QtFrontend/" + *cVersionString).toAscii() |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
43 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
44 |
// This is developer key obtained from http://code.google.com/apis/youtube/dashboard/ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
45 |
// If you are reusing this code outside Hedgewars, don't use this developer key, |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
46 |
// obtain you own at http://code.google.com/apis/youtube/dashboard/ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
47 |
static const QByteArray devKey = "AI39si5pKjxR0XgNIlmrEFF-LyYD31rps4g2O5dZTxLgD0fvJ2rHxrMrNFY8FYTZrzeI3VlaFVQLKfFnSBugvdZmy8vFzRDefQ"; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
48 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
49 |
HWUploadVideoDialog::HWUploadVideoDialog(QWidget* parent, const QString &filename, QNetworkAccessManager* netManager) : QDialog(parent) |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
50 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
51 |
this->filename = filename; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
52 |
this->netManager = netManager; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
53 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
54 |
setWindowTitle(tr("Upload video")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
55 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
56 |
// Google requires us to display this, see https://developers.google.com/youtube/terms |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
57 |
QString GoogleNotice = |
7507 | 58 |
"By clicking 'upload,' you certify that you own all rights to the content or that " |
59 |
"you are authorized by the owner to make the content publicly available on YouTube, " |
|
60 |
"and that it otherwise complies with the YouTube Terms of Service located at " |
|
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
61 |
"http://www.youtube.com/t/terms."; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
62 |
|
7507 | 63 |
// youtube doesn't understand this characters, even when they are properly escaped |
64 |
// (either with CDATA or with < or >) |
|
65 |
QRegExp rx("[^<>]*"); |
|
66 |
||
67 |
int row = 0; |
|
68 |
||
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
69 |
QGridLayout * layout = new QGridLayout(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
70 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
71 |
QLabel * lbLabel = new QLabel(this); |
7507 | 72 |
lbLabel->setWordWrap(true); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
73 |
lbLabel->setText(QLabel::tr( |
7507 | 74 |
"Please provide either the YouTube account name " |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
75 |
"or the email address associated with the Google Account.")); |
7507 | 76 |
layout->addWidget(lbLabel, row++, 0, 1, 2); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
77 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
78 |
lbLabel = new QLabel(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
79 |
lbLabel->setText(QLabel::tr("Account name (or email): ")); |
7507 | 80 |
layout->addWidget(lbLabel, row, 0); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
81 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
82 |
leAccount = new QLineEdit(this); |
7507 | 83 |
layout->addWidget(leAccount, row++, 1); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
84 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
85 |
lbLabel = new QLabel(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
86 |
lbLabel->setText(QLabel::tr("Password: ")); |
7507 | 87 |
layout->addWidget(lbLabel, row, 0); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
88 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
89 |
lePassword = new QLineEdit(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
90 |
lePassword->setEchoMode(QLineEdit::Password); |
7507 | 91 |
layout->addWidget(lePassword, row++, 1); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
92 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
93 |
cbSave = new QCheckBox(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
94 |
cbSave->setText(QCheckBox::tr("Save account name and password")); |
7507 | 95 |
layout->addWidget(cbSave, row++, 0, 1, 2); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
96 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
97 |
QFrame * hr = new QFrame(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
98 |
hr->setFrameStyle(QFrame::HLine); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
99 |
hr->setLineWidth(3); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
100 |
hr->setFixedHeight(10); |
7507 | 101 |
layout->addWidget(hr, row++, 0, 1, 2); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
102 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
103 |
lbLabel = new QLabel(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
104 |
lbLabel->setText(QLabel::tr("Video title: ")); |
7507 | 105 |
layout->addWidget(lbLabel, row, 0); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
106 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
107 |
leTitle = new QLineEdit(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
108 |
leTitle->setText(filename); |
7528
f8cf277dca36
FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
7507
diff
changeset
|
109 |
leTitle->setValidator(new QRegExpValidator(rx, leTitle)); |
7507 | 110 |
layout->addWidget(leTitle, row++, 1); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
111 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
112 |
lbLabel = new QLabel(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
113 |
lbLabel->setText(QLabel::tr("Video description: ")); |
7507 | 114 |
layout->addWidget(lbLabel, row++, 0, 1, 2); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
115 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
116 |
teDescription = new QPlainTextEdit(this); |
7507 | 117 |
layout->addWidget(teDescription, row++, 0, 1, 2); |
118 |
||
119 |
lbLabel = new QLabel(this); |
|
120 |
lbLabel->setText(QLabel::tr("Tags (comma separated): ")); |
|
121 |
layout->addWidget(lbLabel, row, 0); |
|
122 |
||
123 |
leTags = new QLineEdit(this); |
|
124 |
leTags->setText("hedgewars"); |
|
125 |
leTags->setMaxLength(500); |
|
7528
f8cf277dca36
FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
7507
diff
changeset
|
126 |
leTags->setValidator(new QRegExpValidator(rx, leTags)); |
7507 | 127 |
layout->addWidget(leTags, row++, 1); |
128 |
||
129 |
cbPrivate = new QCheckBox(this); |
|
130 |
cbPrivate->setText(QCheckBox::tr("Video is private")); |
|
131 |
layout->addWidget(cbPrivate, row++, 0, 1, 2); |
|
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
132 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
133 |
hr = new QFrame(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
134 |
hr->setFrameStyle(QFrame::HLine); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
135 |
hr->setLineWidth(3); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
136 |
hr->setFixedHeight(10); |
7507 | 137 |
layout->addWidget(hr, row++, 0, 1, 2); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
138 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
139 |
lbLabel = new QLabel(this); |
7507 | 140 |
lbLabel->setWordWrap(true); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
141 |
lbLabel->setText(GoogleNotice); |
7507 | 142 |
layout->addWidget(lbLabel, row++, 0, 1, 2); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
143 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
144 |
QDialogButtonBox* dbbButtons = new QDialogButtonBox(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
145 |
btnUpload = dbbButtons->addButton(tr("Upload"), QDialogButtonBox::ActionRole); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
146 |
QPushButton * pbCancel = dbbButtons->addButton(QDialogButtonBox::Cancel); |
7507 | 147 |
layout->addWidget(dbbButtons, row++, 0, 1, 2); |
148 |
||
149 |
/* hr = new QFrame(this); |
|
150 |
hr->setFrameStyle(QFrame::HLine); |
|
151 |
hr->setLineWidth(3); |
|
152 |
hr->setFixedHeight(10); |
|
153 |
layout->addWidget(hr, row++, 0, 1, 2);*/ |
|
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
154 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
155 |
connect(btnUpload, SIGNAL(clicked()), this, SLOT(upload())); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
156 |
connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject())); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
157 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
158 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
159 |
void HWUploadVideoDialog::setEditable(bool editable) |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
160 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
161 |
leTitle->setEnabled(editable); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
162 |
leAccount->setEnabled(editable); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
163 |
lePassword->setEnabled(editable); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
164 |
btnUpload->setEnabled(editable); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
165 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
166 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
167 |
void HWUploadVideoDialog::upload() |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
168 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
169 |
setEditable(false); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
170 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
171 |
// Documentation is at https://developers.google.com/youtube/2.0/developers_guide_protocol_clientlogin#ClientLogin_Authentication |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
172 |
QNetworkRequest request; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
173 |
request.setUrl(QUrl("https://www.google.com/accounts/ClientLogin")); |
7528
f8cf277dca36
FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
7507
diff
changeset
|
174 |
request.setRawHeader("User-Agent", USER_AGENT); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
175 |
request.setRawHeader("Content-Type", "application/x-www-form-urlencoded"); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
176 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
177 |
QString account(QUrl::toPercentEncoding(leAccount->text())); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
178 |
QString pass(QUrl::toPercentEncoding(lePassword->text())); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
179 |
QByteArray data = QString("Email=%1&Passwd=%2&service=youtube&source=Hedgewars").arg(account).arg(pass).toAscii(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
180 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
181 |
QNetworkReply *reply = netManager->post(request, data); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
182 |
connect(reply, SIGNAL(finished()), this, SLOT(authFinished())); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
183 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
184 |
|
7507 | 185 |
static QString XmlEscape(const QString& str) |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
186 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
187 |
QString str2 = str; |
7507 | 188 |
// youtube doesn't understand this characters, even when they are properly escaped |
189 |
// (either with CDATA or with < >) |
|
190 |
str2.replace('<', ' ').replace('>', ' '); |
|
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
191 |
return "<![CDATA[" + str2.replace("]]>", "]]]]><![CDATA[>") + "]]>"; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
192 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
193 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
194 |
void HWUploadVideoDialog::authFinished() |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
195 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
196 |
QNetworkReply *reply = (QNetworkReply*)sender(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
197 |
reply->deleteLater(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
198 |
|
7507 | 199 |
int HttpCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); |
200 |
||
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
201 |
QByteArray answer = reply->readAll(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
202 |
QString authToken = ""; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
203 |
QList<QByteArray> lines = answer.split('\n'); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
204 |
foreach (const QByteArray& line, lines) |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
205 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
206 |
QString str(line); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
207 |
if (!str.startsWith("Auth=", Qt::CaseInsensitive)) |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
208 |
continue; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
209 |
str.remove(0, 5); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
210 |
authToken = str; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
211 |
break; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
212 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
213 |
if (authToken.isEmpty()) |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
214 |
{ |
7507 | 215 |
QString errorStr = QMessageBox::tr("Error while authenticating at google.com:\n"); |
216 |
if (HttpCode == 403) |
|
217 |
errorStr += QMessageBox::tr("Login or password is incorrect"); |
|
218 |
else |
|
219 |
errorStr += reply->errorString(); |
|
220 |
QMessageBox::warning(this, QMessageBox::tr("Error"), errorStr); |
|
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
221 |
setEditable(true); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
222 |
return; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
223 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
224 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
225 |
QByteArray auth = ("GoogleLogin auth=" + authToken).toAscii(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
226 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
227 |
// We have authenticated, now we can send metadata and start upload |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
228 |
// Documentation is here: https://developers.google.com/youtube/2.0/developers_guide_protocol_resumable_uploads#Resumable_uploads |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
229 |
QByteArray body = |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
230 |
"<?xml version=\"1.0\"?>" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
231 |
"<entry xmlns=\"http://www.w3.org/2005/Atom\" " |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
232 |
"xmlns:media=\"http://search.yahoo.com/mrss/\" " |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
233 |
"xmlns:yt=\"http://gdata.youtube.com/schemas/2007\">" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
234 |
"<media:group>" |
7507 | 235 |
// "<yt:incomplete/>" |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
236 |
"<media:category " |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
237 |
"scheme=\"http://gdata.youtube.com/schemas/2007/categories.cat\">Games" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
238 |
"</media:category>" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
239 |
"<media:title type=\"plain\">" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
240 |
+ XmlEscape(leTitle->text()).toUtf8() + |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
241 |
"</media:title>" |
7507 | 242 |
"<media:description type=\"plain\">" |
243 |
+ XmlEscape(teDescription->toPlainText()).toUtf8() + |
|
244 |
"</media:description>" |
|
245 |
"<media:keywords type=\"plain\">" |
|
246 |
+ XmlEscape(leTags->text()).toUtf8() + |
|
247 |
"</media:keywords>" |
|
248 |
+ (cbPrivate->isChecked()? "<yt:private/>" : "") + |
|
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
249 |
"</media:group>" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
250 |
"</entry>"; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
251 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
252 |
QNetworkRequest request; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
253 |
request.setUrl(QUrl("http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads")); |
7528
f8cf277dca36
FindFFMPEG.cmake (used only for frontend for now).
Stepan777 <stepik-777@mail.ru>
parents:
7507
diff
changeset
|
254 |
request.setRawHeader("User-Agent", USER_AGENT); |
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
255 |
request.setRawHeader("Authorization", auth); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
256 |
request.setRawHeader("GData-Version", "2"); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
257 |
request.setRawHeader("X-GData-Key", "key=" + devKey); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
258 |
request.setRawHeader("Slug", filename.toUtf8()); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
259 |
request.setRawHeader("Content-Type", "application/atom+xml; charset=UTF-8"); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
260 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
261 |
reply = netManager->post(request, body); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
262 |
connect(reply, SIGNAL(finished()), this, SLOT(startUpload())); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
263 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
264 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
265 |
void HWUploadVideoDialog::startUpload() |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
266 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
267 |
QNetworkReply *reply = (QNetworkReply*)sender(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
268 |
reply->deleteLater(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
269 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
270 |
location = QString::fromAscii(reply->rawHeader("Location")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
271 |
if (location.isEmpty()) |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
272 |
{ |
7507 | 273 |
QString errorStr = QMessageBox::tr("Error while sending metadata to youtube.com:\n"); |
274 |
errorStr += reply->errorString(); |
|
275 |
QMessageBox::warning(this, QMessageBox::tr("Error"), errorStr); |
|
7447
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
276 |
setEditable(true); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
277 |
return; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
278 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
279 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
280 |
accept(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
281 |
} |