File indexing completed on 2025-01-19 03:55:38

0001 #include <QApplication>
0002 #include <QStringList>
0003 #include <QTimer>
0004 #include <QDebug>
0005 
0006 #include "ytdemo.h"
0007 
0008 const char OPT_OAUTH_CODE[] = "-o";
0009 
0010 class Helper : public QObject {
0011     Q_OBJECT
0012 
0013 public:
0014     Helper() : QObject(), ytdemo_(this), waitForMsg_(false), msg_(QString()) {}
0015 
0016 public slots:
0017     void run() {
0018         connect(&ytdemo_, SIGNAL(linkingFailed()), this, SLOT(onLinkingFailed()));
0019         connect(&ytdemo_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded()));
0020         connect(&ytdemo_, SIGNAL(channelInfoReceived()), this, SLOT(onChannelInfoReceived()));
0021         connect(&ytdemo_, SIGNAL(channelInfoFailed()), this, SLOT(onChannelInfoFailed()));
0022 
0023         ytdemo_.doOAuth(O2::GrantFlowAuthorizationCode);
0024     }
0025 
0026     void onLinkingFailed() {
0027         qDebug() << "Linking failed!";
0028         qApp->exit(1);
0029     }
0030 
0031     void onLinkingSucceeded() {
0032         qDebug() << "Linking succeeded!";
0033         ytdemo_.getUserChannelInfo();
0034     }
0035 
0036     void onChannelInfoFailed() {
0037         qDebug() << "Error getting channel info!";
0038         qApp->exit(1);
0039     }
0040 
0041     void onChannelInfoReceived() {
0042         qDebug() << "Channel info received!";
0043         qApp->quit();
0044     }
0045 
0046 private:
0047     YTDemo ytdemo_;
0048     bool waitForMsg_;
0049     QString msg_;
0050 };
0051 
0052 int main(int argc, char *argv[]) {
0053     QApplication a(argc, argv);
0054     QCoreApplication::setOrganizationName("O2");
0055     QCoreApplication::setApplicationName("YouTube Test");
0056     Helper helper;
0057     QTimer::singleShot(0, &helper, SLOT(run()));
0058     return a.exec();
0059 }
0060 
0061 #include "main.moc"