File indexing completed on 2025-01-19 03:55:37
0001 #include <QApplication> 0002 #include <QStringList> 0003 #include <QTimer> 0004 #include <QDebug> 0005 0006 #include <QUrl> 0007 #include <QDesktopServices> 0008 0009 #include "vimeodemo.h" 0010 0011 const char OPT_OAUTH_CODE[] = "-o"; 0012 0013 class Helper : public QObject { 0014 Q_OBJECT 0015 0016 public: 0017 Helper() : QObject(), demo_(this), waitForMsg_(false), msg_(QString()) {} 0018 0019 public slots: 0020 void run() { 0021 connect(&demo_, SIGNAL(linkingFailed()), this, SLOT(onLinkingFailed())); 0022 connect(&demo_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); 0023 connect(&demo_, SIGNAL(userNameReceived()), this, SLOT(onUserNameReceived())); 0024 connect(&demo_, SIGNAL(userNameFailed()), this, SLOT(onUserNameFailed())); 0025 0026 demo_.doOAuth(O2::GrantFlowAuthorizationCode); 0027 } 0028 0029 void onLinkingFailed() { 0030 qDebug() << "Linking failed!"; 0031 qApp->exit(1); 0032 } 0033 0034 void onLinkingSucceeded() { 0035 qDebug() << "Linking succeeded!"; 0036 demo_.getUserName(); 0037 } 0038 0039 void onUserNameFailed() { 0040 qDebug() << "Error getting user name!"; 0041 qApp->exit(1); 0042 } 0043 0044 void onUserNameReceived() { 0045 qDebug() << "User namereceived!"; 0046 qApp->quit(); 0047 } 0048 0049 private: 0050 VimeoDemo demo_; 0051 bool waitForMsg_; 0052 QString msg_; 0053 }; 0054 0055 int main(int argc, char *argv[]) { 0056 QApplication a(argc, argv); 0057 QCoreApplication::setOrganizationName("O2"); 0058 QCoreApplication::setApplicationName("Vimeo Test"); 0059 Helper helper; 0060 QTimer::singleShot(0, &helper, SLOT(run())); 0061 return a.exec(); 0062 } 0063 0064 #include "main.moc"