author | Stepan777 <stepik-777@mail.ru> |
Thu, 26 Jul 2012 21:58:25 +0400 | |
changeset 7447 | 01111960a48d |
child 7507 | 3032a5739fe1 |
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> |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
32 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
33 |
#include "upload_video.h" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
34 |
#include "hwconsts.h" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
35 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
36 |
// User-agent string used in http requests. |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
37 |
static const QByteArray UserAgent = ("Hedgewars-QtFrontend/" + *cVersionString).toAscii(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
38 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
39 |
// 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
|
40 |
// 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
|
41 |
// 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
|
42 |
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
|
43 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
44 |
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
|
45 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
46 |
this->filename = filename; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
47 |
this->netManager = netManager; |
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 |
setWindowTitle(tr("Upload video")); |
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 |
// 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
|
52 |
QString GoogleNotice = |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
53 |
"By clicking 'upload,' you certify that you own all rights to the content or that\n" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
54 |
"you are authorized by the owner to make the content publicly available on YouTube,\n" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
55 |
"and that it otherwise complies with the YouTube Terms of Service located at\n" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
56 |
"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
|
57 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
58 |
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
|
59 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
60 |
QLabel * lbLabel = new QLabel(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
61 |
lbLabel->setText(QLabel::tr( |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
62 |
"Please provide either the YouTube account name\n" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
63 |
"or the email address associated with the Google Account.")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
64 |
layout->addWidget(lbLabel, 0, 0, 1, 2); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
65 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
66 |
lbLabel = new QLabel(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
67 |
lbLabel->setText(QLabel::tr("Account name (or email): ")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
68 |
layout->addWidget(lbLabel, 1, 0); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
69 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
70 |
leAccount = new QLineEdit(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
71 |
layout->addWidget(leAccount, 1, 1); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
72 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
73 |
lbLabel = new QLabel(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
74 |
lbLabel->setText(QLabel::tr("Password: ")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
75 |
layout->addWidget(lbLabel, 2, 0); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
76 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
77 |
lePassword = new QLineEdit(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
78 |
lePassword->setEchoMode(QLineEdit::Password); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
79 |
layout->addWidget(lePassword, 2, 1); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
80 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
81 |
cbSave = new QCheckBox(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
82 |
cbSave->setText(QCheckBox::tr("Save account name and password")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
83 |
layout->addWidget(cbSave, 3, 0, 1, 2); |
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 |
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
|
86 |
hr->setFrameStyle(QFrame::HLine); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
87 |
hr->setLineWidth(3); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
88 |
hr->setFixedHeight(10); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
89 |
layout->addWidget(hr, 4, 0, 1, 2); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
90 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
91 |
lbLabel = new QLabel(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
92 |
lbLabel->setText(QLabel::tr("Video title: ")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
93 |
layout->addWidget(lbLabel, 5, 0); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
94 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
95 |
leTitle = new QLineEdit(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
96 |
leTitle->setText(filename); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
97 |
layout->addWidget(leTitle, 5, 1); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
98 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
99 |
lbLabel = new QLabel(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
100 |
lbLabel->setText(QLabel::tr("Video description: ")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
101 |
layout->addWidget(lbLabel, 6, 0, 1, 2); |
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 |
teDescription = new QPlainTextEdit(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
104 |
layout->addWidget(teDescription, 7, 0, 1, 2); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
105 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
106 |
hr = new QFrame(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
107 |
hr->setFrameStyle(QFrame::HLine); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
108 |
hr->setLineWidth(3); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
109 |
hr->setFixedHeight(10); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
110 |
layout->addWidget(hr, 8, 0, 1, 2); |
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(GoogleNotice); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
114 |
layout->addWidget(lbLabel, 9, 0, 1, 2); |
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 |
labelLog = new QLabel(this); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
117 |
layout->addWidget(labelLog, 10, 0, 1, 2); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
118 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
119 |
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
|
120 |
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
|
121 |
QPushButton * pbCancel = dbbButtons->addButton(QDialogButtonBox::Cancel); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
122 |
layout->addWidget(dbbButtons, 11, 0, 1, 2); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
123 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
124 |
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
|
125 |
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
|
126 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
127 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
128 |
void HWUploadVideoDialog::log(const QString& text) |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
129 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
130 |
labelLog->setText(labelLog->text() + text); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
131 |
} |
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 |
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
|
134 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
135 |
leTitle->setEnabled(editable); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
136 |
leAccount->setEnabled(editable); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
137 |
lePassword->setEnabled(editable); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
138 |
btnUpload->setEnabled(editable); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
139 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
140 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
141 |
void HWUploadVideoDialog::upload() |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
142 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
143 |
setEditable(false); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
144 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
145 |
labelLog->clear(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
146 |
log(tr("Authenticating at www.google.com... ")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
147 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
148 |
// 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
|
149 |
QNetworkRequest request; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
150 |
request.setUrl(QUrl("https://www.google.com/accounts/ClientLogin")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
151 |
request.setRawHeader("User-Agent", UserAgent); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
152 |
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
|
153 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
154 |
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
|
155 |
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
|
156 |
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
|
157 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
158 |
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
|
159 |
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
|
160 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
161 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
162 |
QString XmlEscape(const QString& str) |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
163 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
164 |
QString str2 = str; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
165 |
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
|
166 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
167 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
168 |
void HWUploadVideoDialog::authFinished() |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
169 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
170 |
QNetworkReply *reply = (QNetworkReply*)sender(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
171 |
reply->deleteLater(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
172 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
173 |
QByteArray answer = reply->readAll(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
174 |
QString authToken = ""; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
175 |
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
|
176 |
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
|
177 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
178 |
QString str(line); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
179 |
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
|
180 |
continue; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
181 |
str.remove(0, 5); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
182 |
authToken = str; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
183 |
break; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
184 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
185 |
if (authToken.isEmpty()) |
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 |
log(tr("failed\n")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
188 |
log(reply->errorString() + "\n"); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
189 |
setEditable(true); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
190 |
return; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
191 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
192 |
log(tr("Ok\n")); |
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 |
log(tr("Sending metadata... ")); |
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 |
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
|
197 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
198 |
// 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
|
199 |
// 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
|
200 |
QByteArray body = |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
201 |
"<?xml version=\"1.0\"?>" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
202 |
"<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
|
203 |
"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
|
204 |
"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
|
205 |
"<media:group>" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
206 |
"<yt:incomplete/>" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
207 |
"<media:category " |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
208 |
"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
|
209 |
"</media:category>" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
210 |
"<media:title type=\"plain\">" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
211 |
+ XmlEscape(leTitle->text()).toUtf8() + |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
212 |
"</media:title>" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
213 |
"</media:group>" |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
214 |
"</entry>"; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
215 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
216 |
QNetworkRequest request; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
217 |
request.setUrl(QUrl("http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
218 |
request.setRawHeader("User-Agent", UserAgent); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
219 |
request.setRawHeader("Authorization", auth); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
220 |
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
|
221 |
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
|
222 |
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
|
223 |
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
|
224 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
225 |
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
|
226 |
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
|
227 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
228 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
229 |
void HWUploadVideoDialog::startUpload() |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
230 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
231 |
QNetworkReply *reply = (QNetworkReply*)sender(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
232 |
reply->deleteLater(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
233 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
234 |
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
|
235 |
if (location.isEmpty()) |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
236 |
{ |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
237 |
log(tr("failed\n")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
238 |
log(reply->errorString() + "\n"); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
239 |
setEditable(true); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
240 |
return; |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
241 |
} |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
242 |
|
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
243 |
log(tr("Ok\n")); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
244 |
accept(); |
01111960a48d
uploading to youtube, it works, but user interface is still incomplete
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
245 |
} |