QTfrontend/ui/dialog/upload_video.cpp
author Wuzzy <almikes@aol.com>
Sun, 01 May 2016 01:04:45 +0200
changeset 11918 9da78300c5d0
parent 11046 47a8c19ecb60
child 12268 2eedf9e0cd6d
permissions -rw-r--r--
Fix sniper rifle making timer gray all the time
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
7631
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     1
/*
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     2
 * Hedgewars, a free turn based strategy game
11046
47a8c19ecb60 more copyright fixes
sheepluva
parents: 10108
diff changeset
     3
 * Copyright (c) 2004-2015 Andrey Korotaev <unC0Rr@gmail.com>
7631
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     4
 *
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     6
 * it under the terms of the GNU General Public License as published by
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     7
 * the Free Software Foundation; version 2 of the License
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     8
 *
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    12
 * GNU General Public License for more details.
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    13
 *
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    14
 * You should have received a copy of the GNU General Public License
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    15
 * along with this program; if not, write to the Free Software
10108
c68cf030eded update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents: 9998
diff changeset
    16
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
7631
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    17
 */
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    18
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    19
#include <QLineEdit>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    20
#include <QDialogButtonBox>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    21
#include <QPushButton>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    22
#include <QGridLayout>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    23
#include <QCheckBox>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    24
#include <QLabel>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    25
#include <QFrame>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    26
#include <QPlainTextEdit>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    27
#include <QSslError>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    28
#include <QUrl>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    29
#include <QNetworkAccessManager>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    30
#include <QNetworkRequest>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    31
#include <QNetworkReply>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    32
#include <QMessageBox>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    33
#include <QRegExp>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    34
#include <QRegExpValidator>
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    35
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    36
#include "upload_video.h"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    37
#include "hwconsts.h"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    38
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    39
// User-agent string used in http requests.
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    40
// Don't make it a global varibale - crash on linux because of cVersionString
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    41
#define USER_AGENT ("Hedgewars-QtFrontend/" + *cVersionString).toAscii()
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    42
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    43
// This is developer key obtained from http://code.google.com/apis/youtube/dashboard/
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    44
// If you are reusing this code outside Hedgewars, don't use this developer key,
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    45
// obtain you own at http://code.google.com/apis/youtube/dashboard/
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    46
static const QByteArray devKey = "AI39si5pKjxR0XgNIlmrEFF-LyYD31rps4g2O5dZTxLgD0fvJ2rHxrMrNFY8FYTZrzeI3VlaFVQLKfFnSBugvdZmy8vFzRDefQ";
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    47
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    48
HWUploadVideoDialog::HWUploadVideoDialog(QWidget* parent, const QString &filename, QNetworkAccessManager* netManager) : QDialog(parent)
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    49
{
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    50
    this->filename = filename;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    51
    this->netManager = netManager;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    52
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    53
    setWindowTitle(tr("Upload video"));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    54
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    55
    // Google requires us to display this, see https://developers.google.com/youtube/terms
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    56
    QString GoogleNotice =
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    57
        "<p>By clicking 'upload,' you certify that you own all rights to the content or that "
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    58
        "you are authorized by the owner to make the content publicly available on YouTube, "
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    59
        "and that it otherwise complies with the YouTube Terms of Service located at "
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    60
        "<a href=\"http://www.youtube.com/t/terms\" style=\"color: white;\">http://www.youtube.com/t/terms</a>.</p>";
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    61
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    62
    // youtube doesn't understand this characters, even when they are properly escaped
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    63
    // (either with CDATA or with &lt or &gt)
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    64
    QRegExp rx("[^<>]*");
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    65
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    66
    int row = 0;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    67
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    68
    QGridLayout * layout = new QGridLayout(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    69
    layout->setColumnStretch(0, 1);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    70
    layout->setColumnStretch(1, 2);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    71
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    72
    QLabel * lbLabel = new QLabel(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    73
    lbLabel->setWordWrap(true);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    74
    lbLabel->setText(QLabel::tr(
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    75
                         "Please provide either the YouTube account name "
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    76
                         "or the email address associated with the Google Account."));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    77
    layout->addWidget(lbLabel, row++, 0, 1, 2);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    78
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    79
    lbLabel = new QLabel(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    80
    lbLabel->setText(QLabel::tr("Account name (or email): "));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    81
    layout->addWidget(lbLabel, row, 0);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    82
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    83
    leAccount = new QLineEdit(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    84
    layout->addWidget(leAccount, row++, 1);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    85
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    86
    lbLabel = new QLabel(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    87
    lbLabel->setText(QLabel::tr("Password: "));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    88
    layout->addWidget(lbLabel, row, 0);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    89
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    90
    lePassword = new QLineEdit(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    91
    lePassword->setEchoMode(QLineEdit::Password);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    92
    layout->addWidget(lePassword, row++, 1);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    93
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    94
    cbSave = new QCheckBox(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    95
    cbSave->setText(QCheckBox::tr("Save account name and password"));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    96
    layout->addWidget(cbSave, row++, 0, 1, 2);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    97
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    98
    QFrame * hr = new QFrame(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
    99
    hr->setFrameStyle(QFrame::HLine);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   100
    hr->setLineWidth(3);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   101
    hr->setFixedHeight(10);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   102
    layout->addWidget(hr, row++, 0, 1, 2);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   103
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   104
    lbLabel = new QLabel(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   105
    lbLabel->setText(QLabel::tr("Video title: "));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   106
    layout->addWidget(lbLabel, row, 0);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   107
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   108
    leTitle = new QLineEdit(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   109
    leTitle->setText(filename);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   110
    leTitle->setValidator(new QRegExpValidator(rx, leTitle));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   111
    layout->addWidget(leTitle, row++, 1);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   112
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   113
    lbLabel = new QLabel(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   114
    lbLabel->setText(QLabel::tr("Video description: "));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   115
    layout->addWidget(lbLabel, row++, 0, 1, 2);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   116
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   117
    teDescription = new QPlainTextEdit(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   118
    layout->addWidget(teDescription, row++, 0, 1, 2);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   119
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   120
    lbLabel = new QLabel(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   121
    lbLabel->setText(QLabel::tr("Tags (comma separated): "));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   122
    layout->addWidget(lbLabel, row, 0);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   123
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   124
    leTags = new QLineEdit(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   125
    leTags->setText("hedgewars");
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   126
    leTags->setMaxLength(500);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   127
    leTags->setValidator(new QRegExpValidator(rx, leTags));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   128
    layout->addWidget(leTags, row++, 1);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   129
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   130
    cbPrivate = new QCheckBox(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   131
    cbPrivate->setText(QCheckBox::tr("Video is private"));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   132
    layout->addWidget(cbPrivate, row++, 0, 1, 2);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   133
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   134
    hr = new QFrame(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   135
        hr->setFrameStyle(QFrame::HLine);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   136
        hr->setLineWidth(3);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   137
        hr->setFixedHeight(10);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   138
        layout->addWidget(hr, row++, 0, 1, 2);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   139
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   140
    lbLabel = new QLabel(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   141
    lbLabel->setWordWrap(true);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   142
    lbLabel->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   143
    lbLabel->setTextFormat(Qt::RichText);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   144
    lbLabel->setOpenExternalLinks(true);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   145
    lbLabel->setText(GoogleNotice);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   146
    layout->addWidget(lbLabel, row++, 0, 1, 2);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   147
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   148
    QDialogButtonBox* dbbButtons = new QDialogButtonBox(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   149
    btnUpload = dbbButtons->addButton(tr("Upload"), QDialogButtonBox::ActionRole);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   150
    QPushButton * pbCancel = dbbButtons->addButton(QDialogButtonBox::Cancel);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   151
    layout->addWidget(dbbButtons, row++, 0, 1, 2);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   152
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   153
   /* hr = new QFrame(this);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   154
        hr->setFrameStyle(QFrame::HLine);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   155
        hr->setLineWidth(3);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   156
        hr->setFixedHeight(10);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   157
        layout->addWidget(hr, row++, 0, 1, 2);*/
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   158
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   159
    connect(btnUpload, SIGNAL(clicked()), this, SLOT(upload()));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   160
    connect(pbCancel, SIGNAL(clicked()), this, SLOT(reject()));
7795
ba32d3f9e567 set window modality also for custom dialogs, small text changes
koda
parents: 7794
diff changeset
   161
ba32d3f9e567 set window modality also for custom dialogs, small text changes
koda
parents: 7794
diff changeset
   162
    this->setWindowModality(Qt::WindowModal);
7631
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   163
}
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   164
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   165
void HWUploadVideoDialog::showEvent(QShowEvent * event)
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   166
{
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   167
    QDialog::showEvent(event);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   168
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   169
    // set width to the same value as height (otherwise dialog has too small width)
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   170
    QSize s = size();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   171
    QPoint p = pos();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   172
    resize(s.height(), s.height());
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   173
    move(p.x() - (s.height() - s.width())/2, p.y());
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   174
}
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   175
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   176
void HWUploadVideoDialog::setEditable(bool editable)
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   177
{
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   178
    leTitle->setEnabled(editable);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   179
    leAccount->setEnabled(editable);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   180
    lePassword->setEnabled(editable);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   181
    btnUpload->setEnabled(editable);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   182
}
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   183
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   184
void HWUploadVideoDialog::upload()
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   185
{
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   186
    setEditable(false);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   187
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   188
    // Documentation is at https://developers.google.com/youtube/2.0/developers_guide_protocol_clientlogin#ClientLogin_Authentication
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   189
    QNetworkRequest request;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   190
    request.setUrl(QUrl("https://www.google.com/accounts/ClientLogin"));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   191
    request.setRawHeader("User-Agent", USER_AGENT);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   192
    request.setRawHeader("Content-Type", "application/x-www-form-urlencoded");
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   193
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   194
    QString account(QUrl::toPercentEncoding(leAccount->text()));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   195
    QString pass(QUrl::toPercentEncoding(lePassword->text()));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   196
    QByteArray data = QString("Email=%1&Passwd=%2&service=youtube&source=Hedgewars").arg(account).arg(pass).toAscii();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   197
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   198
    QNetworkReply *reply = netManager->post(request, data);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   199
    connect(reply, SIGNAL(finished()), this, SLOT(authFinished()));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   200
}
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   201
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   202
static QString XmlEscape(const QString& str)
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   203
{
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   204
    QString str2 = str;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   205
    // youtube doesn't understand this characters, even when they are properly escaped
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   206
    // (either with CDATA or with &lt; &gt;)
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   207
    str2.replace('<', ' ').replace('>', ' ');
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   208
    return "<![CDATA[" + str2.replace("]]>", "]]]]><![CDATA[>") + "]]>";
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   209
}
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   210
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   211
void HWUploadVideoDialog::authFinished()
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   212
{
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   213
    QNetworkReply *reply = (QNetworkReply*)sender();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   214
    reply->deleteLater();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   215
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   216
    int HttpCode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   217
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   218
    QByteArray answer = reply->readAll();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   219
    QString authToken = "";
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   220
    QList<QByteArray> lines = answer.split('\n');
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   221
    foreach (const QByteArray& line, lines)
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   222
    {
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   223
        QString str(line);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   224
        if (!str.startsWith("Auth=", Qt::CaseInsensitive))
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   225
            continue;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   226
        str.remove(0, 5);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   227
        authToken = str;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   228
        break;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   229
    }
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   230
    if (authToken.isEmpty())
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   231
    {
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   232
        QString errorStr = QMessageBox::tr("Error while authenticating at google.com:\n");
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   233
        if (HttpCode == 403)
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   234
            errorStr += QMessageBox::tr("Login or password is incorrect");
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   235
        else
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   236
            errorStr += reply->errorString();
7794
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   237
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   238
        QMessageBox deniedMsg(this);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   239
        deniedMsg.setIcon(QMessageBox::Warning);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   240
        deniedMsg.setWindowTitle(QMessageBox::tr("Video upload - Error"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   241
        deniedMsg.setText(errorStr);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   242
        deniedMsg.setWindowModality(Qt::WindowModal);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   243
        deniedMsg.exec();
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   244
7631
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   245
        setEditable(true);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   246
        return;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   247
    }
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   248
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   249
    QByteArray auth = ("GoogleLogin auth=" + authToken).toAscii();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   250
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   251
    // We have authenticated, now we can send metadata and start upload
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   252
    // Documentation is here: https://developers.google.com/youtube/2.0/developers_guide_protocol_resumable_uploads#Resumable_uploads
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   253
    QByteArray body =
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   254
            "<?xml version=\"1.0\"?>"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   255
            "<entry xmlns=\"http://www.w3.org/2005/Atom\" "
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   256
                "xmlns:media=\"http://search.yahoo.com/mrss/\" "
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   257
                "xmlns:yt=\"http://gdata.youtube.com/schemas/2007\">"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   258
                "<media:group>"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   259
                  //  "<yt:incomplete/>"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   260
                    "<media:category "
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   261
                        "scheme=\"http://gdata.youtube.com/schemas/2007/categories.cat\">Games"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   262
                    "</media:category>"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   263
                    "<media:title type=\"plain\">"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   264
                        + XmlEscape(leTitle->text()).toUtf8() +
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   265
                    "</media:title>"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   266
                    "<media:description type=\"plain\">"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   267
                        + XmlEscape(teDescription->toPlainText()).toUtf8() +
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   268
                    "</media:description>"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   269
                    "<media:keywords type=\"plain\">"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   270
                        + XmlEscape(leTags->text()).toUtf8() +
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   271
                    "</media:keywords>"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   272
                    + (cbPrivate->isChecked()? "<yt:private/>" : "") +
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   273
                "</media:group>"
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   274
            "</entry>";
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   275
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   276
    QNetworkRequest request;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   277
    request.setUrl(QUrl("http://uploads.gdata.youtube.com/resumable/feeds/api/users/default/uploads"));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   278
    request.setRawHeader("User-Agent", USER_AGENT);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   279
    request.setRawHeader("Authorization", auth);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   280
    request.setRawHeader("GData-Version", "2");
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   281
    request.setRawHeader("X-GData-Key", "key=" + devKey);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   282
    request.setRawHeader("Slug", filename.toUtf8());
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   283
    request.setRawHeader("Content-Type", "application/atom+xml; charset=UTF-8");
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   284
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   285
    reply = netManager->post(request, body);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   286
    connect(reply, SIGNAL(finished()), this, SLOT(startUpload()));
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   287
}
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   288
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   289
void HWUploadVideoDialog::startUpload()
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   290
{
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   291
    QNetworkReply *reply = (QNetworkReply*)sender();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   292
    reply->deleteLater();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   293
9357
a501f5ec7b34 fromAscii is deprecated in qt5
koda
parents: 9080
diff changeset
   294
    location = QString::fromLatin1(reply->rawHeader("Location"));
7631
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   295
    if (location.isEmpty())
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   296
    {
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   297
        QString errorStr = QMessageBox::tr("Error while sending metadata to youtube.com:\n");
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   298
        errorStr += reply->errorString();
7794
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   299
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   300
        QMessageBox deniedMsg(this);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   301
        deniedMsg.setIcon(QMessageBox::Warning);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   302
        deniedMsg.setWindowTitle(QMessageBox::tr("Video upload - Error"));
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   303
        deniedMsg.setText(errorStr);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   304
        deniedMsg.setWindowModality(Qt::WindowModal);
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   305
        deniedMsg.exec();
ab7b94c03bc9 QMessageBox overhaul: unify buttons, style and appearance of info dialogs, fixing a few typos and return values along the way
koda
parents: 7631
diff changeset
   306
7631
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   307
        setEditable(true);
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   308
        return;
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   309
    }
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   310
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   311
    accept();
01b599d6f72d dos2unix newline fixes on 7 (video recording-)merged files
sheepluva
parents: 7531
diff changeset
   312
}