2 * This file is part of Maemo 5 Office UI for KOffice
4 * Copyright (C) 2010 Manikandaprasad N C <maninc@gmail.com>.
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
24 #include "loginwindow.h"
25 #include "googledocumentservice.h"
26 #include "googlelistdialog.h"
27 #include "slideshare.h"
28 #include "slidesharelistdialog.h"
34 #include <X11/Xatom.h>
36 LoginWindow::LoginWindow(QWidget *parent)
38 m_authDialog(new Ui_Dialog)
40 m_authDialog->setupUi(this);
42 QStringList onlineServices;
43 onlineServices << "Google Documents";
45 onlineServices << "Slide Share";
46 m_authDialog->comboBox->addItems(onlineServices);
48 connect(m_authDialog->loginButton, SIGNAL(clicked()), this, SLOT(loginService()));
49 connect(m_authDialog->comboBox, SIGNAL(activated(int)), this, SLOT(serviceSelected(int)));
51 m_authDialog->userEdit->setFocus();
55 void LoginWindow::loginService()
58 if (0 == m_authDialog->comboBox->currentIndex()) {
59 gdoc = new GoogleDocumentService();
60 setShowProgressIndicator(true);
61 gdoc->clientLogin(m_authDialog->userEdit->text(), m_authDialog->passwordEdit->text());
62 connect(gdoc, SIGNAL(userAuthenticated(bool)), this, SLOT(authenticated(bool)));
64 if (1 == m_authDialog->comboBox->currentIndex())
66 service = new SlideShare(this);
67 service->setApikey(new QString("KhSMYyiF"));
68 service->setsecretKey(new QString("HDXhAC5g"));
69 service->setUsername(new QString(m_authDialog->userEdit->text()));
70 service->setPassword(new QString(m_authDialog->passwordEdit->text()));
72 connect(service,SIGNAL(loginDone(bool)), this, SLOT(slideShareLoginDoneSlot(bool)));
76 void LoginWindow::serviceSelected(int index)
79 m_authDialog->userEdit->setText("@gmail.com");
80 m_authDialog->passwordEdit->clear();
81 } else if (index == 1) {
82 m_authDialog->userEdit->clear();
83 m_authDialog->passwordEdit->clear();
85 m_authDialog->userEdit->setFocus();
88 void LoginWindow::authenticated(bool success)
91 googleListDialog *ld = new googleListDialog(gdoc, this);
96 QMessageBox::information(this, tr("Login Failed"), tr("Check your username & password"));
101 void LoginWindow::setShowProgressIndicator(bool visible)
103 unsigned long val = visible ? 1 : 0;
104 Atom atom = XInternAtom(QX11Info::display(),
105 "_HILDON_WM_WINDOW_PROGRESS_INDICATOR", False);
106 XChangeProperty(QX11Info::display(), winId(), atom, XA_INTEGER,
108 (unsigned char *) &val, 1);
111 void LoginWindow::slideShareLoginDoneSlot(bool loginStatus)
112 {if(loginStatus == false)
114 QMessageBox::information(this, tr("Login Failed"), tr("Check your username & password"));
119 slideshareListDialog * fi = new slideshareListDialog(service, this);
125 void LoginWindow::enableWidgets()
127 m_authDialog->loginButton->setEnabled(true);
128 m_authDialog->userEdit->setEnabled(true);
129 m_authDialog->passwordEdit->setEnabled(true);
130 m_authDialog->comboBox->setEnabled(true);
133 void LoginWindow::disableWidgets()
135 m_authDialog->loginButton->setEnabled(false);
136 m_authDialog->userEdit->setEnabled(false);
137 m_authDialog->passwordEdit->setEnabled(false);
138 m_authDialog->comboBox->setEnabled(false);