|
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 * |
|
14 * Description: |
|
15 * UI Class of Authentication Application |
|
16 */ |
|
17 |
|
18 #include "AuthApp.h" |
|
19 #include <QDebug> |
|
20 #include <QMessageBox> |
|
21 |
|
22 |
|
23 AuthApp::AuthApp(QWidget *parent) |
|
24 : QMainWindow(parent), |
|
25 ui(new Ui::AuthAppClass) |
|
26 { |
|
27 ui->setupUi(this); |
|
28 //iFBSession = FBSession::sessionForApplication("df51def3e750a350ddb961a70b5ab5ab", "3b86a756f77967dea4674f080fa5d345", QString()); |
|
29 iFBSession = FBSession::sessionForApplication("ed6d6d36813f0fbae8061776beb68daf", "fb10f1c758fc285b2a6113344ef4c893", QString()); //NArasimha's APP |
|
30 //iFBSession = FBSession::sessionForApplication("077fd6b8881f39c2dc23207323cca439", "cb13436999afde9338ecd8b0bfb82508", QString()); //Nalina's App |
|
31 connect (iFBSession,SIGNAL(sessionDidLogin(QString)), this, SLOT(sessionDidLogin(QString))); |
|
32 connect (iFBSession, SIGNAL(sessionDidLogout()), this, SLOT(sessionDidLogout())); |
|
33 |
|
34 CheckforLogin(); |
|
35 } |
|
36 |
|
37 AuthApp::~AuthApp() |
|
38 { |
|
39 delete iFBSession; |
|
40 delete ui; |
|
41 } |
|
42 |
|
43 void AuthApp::changeEvent(QEvent *e) |
|
44 { |
|
45 QMainWindow::changeEvent(e); |
|
46 switch (e->type()) { |
|
47 case QEvent::LanguageChange: |
|
48 ui->retranslateUi(this); |
|
49 break; |
|
50 default: |
|
51 break; |
|
52 } |
|
53 } |
|
54 void AuthApp::CheckforLogin() |
|
55 { |
|
56 iLoginDialog = NULL; |
|
57 if ( !( iFBSession->resume() ) ){ |
|
58 ui->buttonForget->setDisabled(true); |
|
59 ui->pushButton->setEnabled(true); |
|
60 } |
|
61 } |
|
62 void AuthApp::on_pushButton_clicked() |
|
63 { |
|
64 iLoginDialog = new FBLoginDialog(); |
|
65 iLoginDialog->show(); |
|
66 } |
|
67 void AuthApp::sessionDidLogin(QString sessionkey) |
|
68 { |
|
69 |
|
70 if (iLoginDialog ) |
|
71 { |
|
72 QMessageBox msgbox; |
|
73 QString msg ("Authorization completes!!"); |
|
74 msgbox.setText(msg); |
|
75 msgbox.exec(); |
|
76 |
|
77 iLoginDialog->deleteLater();; |
|
78 iLoginDialog = NULL; |
|
79 }else{ |
|
80 QMessageBox msgbox; |
|
81 QString msg ("your already authorized,Please logout and Login again for new authorization!!"); |
|
82 msgbox.setText(msg); |
|
83 msgbox.exec(); |
|
84 } |
|
85 |
|
86 ui->pushButton->setDisabled(true); |
|
87 ui->buttonForget->setEnabled(true); |
|
88 } |
|
89 |
|
90 void AuthApp::sessionDidLogout() |
|
91 { |
|
92 QMessageBox msgbox; |
|
93 msgbox.setText("logged out successfully!!"); |
|
94 msgbox.exec(); |
|
95 |
|
96 ui->pushButton->setEnabled(true); |
|
97 ui->buttonForget->setDisabled(true); |
|
98 |
|
99 } |
|
100 void AuthApp::requestFailedWithFacebookError ( const FBError& aError ) |
|
101 { |
|
102 qDebug() << "facebook error is " << aError.code() << " - " << aError.description(); |
|
103 } |
|
104 |
|
105 void AuthApp::on_buttonForget_clicked() |
|
106 { |
|
107 iFBSession->logout(); |
|
108 } |