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 "msgraphdemo.h" 0010 0011 class Helper : public QObject { 0012 Q_OBJECT 0013 0014 public: 0015 Helper() : QObject(), demo_(this) {} 0016 0017 public slots: 0018 void run() { 0019 connect(&demo_, SIGNAL(linkingFailed()), this, SLOT(onLinkingFailed())); 0020 connect(&demo_, SIGNAL(linkingSucceeded()), this, SLOT(onLinkingSucceeded())); 0021 connect(&demo_, SIGNAL(userPrincipalNameReceived()), this, SLOT(onUserPrincipalNameReceived())); 0022 connect(&demo_, SIGNAL(userPrincipalNameFailed()), this, SLOT(onUserPrincipalNameFailed())); 0023 0024 demo_.doOAuth(O2::GrantFlowAuthorizationCode); 0025 } 0026 0027 void onLinkingFailed() { 0028 qDebug() << "Linking failed!"; 0029 qApp->exit(1); 0030 } 0031 0032 void onLinkingSucceeded() { 0033 qDebug() << "Linking succeeded!"; 0034 demo_.getUserPrincipalName(); 0035 } 0036 0037 void onUserPrincipalNameFailed() { 0038 qDebug() << "Error getting userPrincipalName!"; 0039 qApp->exit(1); 0040 } 0041 0042 void onUserPrincipalNameReceived() { 0043 qDebug() << "UserPrincipalName received!"; 0044 qApp->quit(); 0045 } 0046 0047 private: 0048 MsgraphDemo demo_; 0049 }; 0050 0051 int main(int argc, char *argv[]) { 0052 QApplication a(argc, argv); 0053 QCoreApplication::setOrganizationName("O2"); 0054 QCoreApplication::setApplicationName("Msgraph Example"); 0055 Helper helper; 0056 QTimer::singleShot(0, &helper, SLOT(run())); 0057 return a.exec(); 0058 } 0059 0060 #include "main.moc"