|
1 /** |
|
2 * Copyright (c) 2010 Sasken Communication Technologies Ltd. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "{License}" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "{LicenseUrl}". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Narasimhulu Kavadapu, Sasken Communication Technologies Ltd - Initial contribution |
|
11 * |
|
12 * Contributors: |
|
13 * Siddhartha Chandra, Sasken Communication Technologies Ltd |
|
14 * Description: |
|
15 * UI Class of Authentication Application |
|
16 */ |
|
17 |
|
18 #include "AuthApp.h" |
|
19 #include <QDebug> |
|
20 #include <QMessageBox> |
|
21 #include <keys.h> |
|
22 |
|
23 AuthApp::AuthApp(QWidget *parent) |
|
24 : QMainWindow(parent), |
|
25 ui(new Ui::AuthAppClass) |
|
26 { |
|
27 ui->setupUi(this); |
|
28 iFBSession = FBSession::sessionForApplication(kApiKey, kApiSecret, QString());//LastFm Web based |
|
29 connect (iFBSession, SIGNAL(sessionDidLogout()), this, SLOT(sessionDidLogout())); |
|
30 connect (iFBSession,SIGNAL(sessionDidLogin(QString)), this, SLOT(sessionDidLogin(QString))); |
|
31 } |
|
32 |
|
33 AuthApp::~AuthApp() |
|
34 { |
|
35 delete iFBSession; |
|
36 delete ui; |
|
37 } |
|
38 |
|
39 void AuthApp::changeEvent(QEvent *e) |
|
40 { |
|
41 QMainWindow::changeEvent(e); |
|
42 switch (e->type()) { |
|
43 case QEvent::LanguageChange: |
|
44 ui->retranslateUi(this); |
|
45 break; |
|
46 default: |
|
47 break; |
|
48 } |
|
49 } |
|
50 void AuthApp::CheckforLogin() |
|
51 { |
|
52 iLoginDialog = NULL; |
|
53 if ( !( iFBSession->resume() ) ){ |
|
54 ui->buttonForget->setDisabled(true); |
|
55 ui->pushButton->setEnabled(true); |
|
56 } |
|
57 } |
|
58 void AuthApp::on_pushButton_clicked() |
|
59 { |
|
60 qDebug()<<"Inside AuthApp::on_pushButton_clicked"; |
|
61 iLoginDialog = new FBLoginDialog(); |
|
62 iLoginDialog->connecttoGetFrob(); |
|
63 |
|
64 } |
|
65 void AuthApp::sessionDidLogin(QString Token) |
|
66 { |
|
67 Q_UNUSED(Token) |
|
68 if (iLoginDialog ) |
|
69 { |
|
70 QMessageBox msgbox; |
|
71 QString msg ("Authorization completes!!"); |
|
72 msgbox.setText(msg); |
|
73 msgbox.exec(); |
|
74 |
|
75 iLoginDialog->deleteLater(); |
|
76 iLoginDialog = NULL; |
|
77 }else{ |
|
78 QMessageBox msgbox; |
|
79 QString msg ("your already authorized,Please logout and Login again for new authorization!!"); |
|
80 msgbox.setText(msg); |
|
81 msgbox.exec(); |
|
82 } |
|
83 |
|
84 ui->pushButton->setDisabled(true); |
|
85 ui->buttonForget->setEnabled(true); |
|
86 } |
|
87 |
|
88 void AuthApp::sessionDidLogout() |
|
89 { |
|
90 QMessageBox msgbox; |
|
91 msgbox.setText("logged out successfully!!"); |
|
92 msgbox.exec(); |
|
93 |
|
94 ui->pushButton->setEnabled(true); |
|
95 ui->buttonForget->setDisabled(true); |
|
96 |
|
97 } |
|
98 void AuthApp::requestFailedWithFacebookError ( const FBError& aError ) |
|
99 { |
|
100 qDebug() << "facebook error is " << aError.code() << " - " << aError.description(); |
|
101 } |
|
102 |
|
103 void AuthApp::on_buttonForget_clicked() |
|
104 { |
|
105 iFBSession->logout(); |
|
106 } |