Added error messages and error handling for UI
[situare] / src / ui / mainwindow.cpp
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5       Henri Lampela - henri.lampela@ixonos.com
6       Kaj Wallin - kaj.wallin@ixonos.com
7       Jussi Laitinen jussi.laitinen@ixonos.com
8       Sami Rämö - sami.ramo@ixonos.com
9       Ville Tiensuu - ville.tiensuu@ixonos.com
10
11    Situare is free software; you can redistribute it and/or
12    modify it under the terms of the GNU General Public License
13    version 2 as published by the Free Software Foundation.
14
15    Situare is distributed in the hope that it will be useful,
16    but WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18    GNU General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with Situare; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
23    USA.
24 */
25
26 #include <QtGui>
27 #include <QtWebKit>
28
29 #include "common.h"
30 #include "facebookservice/facebookauthentication.h"
31 #include "friendlistpanel.h"
32 #include "logindialog.h"
33 #include "map/mapview.h"
34 #include "settingsdialog.h"
35 #include "userinfopanel.h"
36 #include "zoombuttonpanel.h"
37
38 #include "mainwindow.h"
39
40 // These MUST BE HERE, compiling for Maemo fails if moved
41 #ifdef Q_WS_MAEMO_5
42 #include <QtMaemo5/QMaemo5InformationBox>
43 #include <QtGui/QX11Info>
44 #include <X11/Xatom.h>
45 #include <X11/Xlib.h>
46 #endif // Q_WS_MAEMO_5
47
48 // values for setting screen size in desktop matching N900 screen size
49 const int N900_APP_WIDTH = 800;
50 const int N900_APP_HEIGHT = 449;
51
52 MainWindow::MainWindow(QWidget *parent)
53     : QMainWindow(parent),
54     m_drawOwnLocationCrosshair(false),
55     m_loggedIn(false),
56     m_refresh(false),
57     m_email(),    
58     m_password(),
59     m_webView(0),
60     m_cookieJar(0)
61 {
62     qDebug() << __PRETTY_FUNCTION__;
63
64     buildMap();
65
66     // build main layout
67     QHBoxLayout *layout = new QHBoxLayout;
68     layout->addWidget(m_mapView);
69     layout->setMargin(0);
70     setCentralWidget(new QWidget());
71     centralWidget()->setLayout(layout);
72
73     buildFriendListPanel();
74     buildUserInfoPanel();
75
76     m_settingsDialog = new SettingsDialog(this);
77     m_settingsDialog->hide();
78     connect(m_settingsDialog, SIGNAL(enableAutomaticLocationUpdate(bool,int)),
79             this, SIGNAL(enableAutomaticLocationUpdate(bool,int)));
80
81     createMenus();
82     setWindowTitle(tr("Situare"));
83
84     // set stacking order of widgets
85     m_zoomButtonPanel->stackUnder(m_userPanel);
86     m_osmLicense->stackUnder(m_zoomButtonPanel);
87     m_ownLocationCrosshair->stackUnder(m_osmLicense);
88     m_mapView->stackUnder(m_ownLocationCrosshair);
89
90     this->toggleProgressIndicator(true);
91
92     grabZoomKeys(true);
93
94     // set screen size in desktop matching N900 screen size
95     resize(N900_APP_WIDTH, N900_APP_HEIGHT);
96 }
97
98 MainWindow::~MainWindow()
99 {
100     qDebug() << __PRETTY_FUNCTION__;
101
102     grabZoomKeys(false);
103
104     if(m_webView)
105         delete m_webView;
106 }
107
108 void MainWindow::buildFriendListPanel()
109 {
110     qDebug() << __PRETTY_FUNCTION__;
111
112     m_friendsListPanel = new FriendListPanel(this);
113     m_friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
114
115     m_friendsListPanel->stackUnder(m_friendsListPanelSidebar);
116
117     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
118             m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
119
120     connect(m_friendsListPanel, SIGNAL(findFriend(QPointF)),
121             this, SIGNAL(findFriend(QPointF)));
122
123     connect(m_mapView, SIGNAL(viewResized(QSize)),
124             m_friendsListPanel, SLOT(screenResized(QSize)));
125
126     connect(this, SIGNAL(locationItemClicked(QList<QString>)),
127             m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
128
129     connect(m_mapView, SIGNAL(viewResizedNewSize(int, int)),
130             m_friendsListPanelSidebar, SLOT(reDrawSidebar(int, int)));
131 }
132
133 void MainWindow::buildManualLocationCrosshair()
134 {
135     qDebug() << __PRETTY_FUNCTION__;
136
137     m_ownLocationCrosshair = new QLabel(this);
138     QPixmap crosshairImage(":/res/images/sight.png");
139     m_ownLocationCrosshair->setPixmap(crosshairImage);
140     m_ownLocationCrosshair->setFixedSize(crosshairImage.size());
141     m_ownLocationCrosshair->hide();
142     m_ownLocationCrosshair->setAttribute(Qt::WA_TransparentForMouseEvents, true);
143
144     connect(m_mapView, SIGNAL(viewResizedNewSize(int, int)),
145             this, SLOT(drawOwnLocationCrosshair(int, int)));
146 }
147
148 void MainWindow::buildMap()
149 {
150     qDebug() << __PRETTY_FUNCTION__;
151
152     m_mapView = new MapView(this);
153
154     buildZoomButtonPanel();
155
156     m_ownLocationCrosshair = 0;
157     buildOsmLicense();
158     buildManualLocationCrosshair();
159
160     connect(m_mapView, SIGNAL(viewScrolled(QPoint)),
161             this, SIGNAL(mapViewScrolled(QPoint)));
162
163     connect(this, SIGNAL(centerToSceneCoordinates(QPoint)),
164             m_mapView, SLOT(centerToSceneCoordinates(QPoint)));
165
166     connect(m_mapView, SIGNAL(viewResized(QSize)),
167             this, SIGNAL(mapViewResized(QSize)));
168
169     connect(m_mapView, SIGNAL(viewResizedNewSize(int, int)),
170              this, SLOT(setViewPortSize(int, int)));
171
172     connect(this, SIGNAL(zoomLevelChanged(int)),
173             m_mapView, SLOT(setZoomLevel(int)));
174
175     connect(m_mapView, SIGNAL(viewZoomFinished()),
176             this, SIGNAL(viewZoomFinished()));
177 }
178
179 void MainWindow::buildOsmLicense()
180 {
181     qDebug() << __PRETTY_FUNCTION__;
182
183     m_osmLicense = new QLabel(this);
184     m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
185     m_osmLicense->setAttribute(Qt::WA_TransparentForMouseEvents, true);
186     m_osmLicense->setText("<font color='black'>" + OSM_LICENSE + "</font>");
187     m_osmLicense->setFont(QFont("Nokia Sans", 9));
188     m_osmLicense->resize(m_osmLicense->fontMetrics().width(OSM_LICENSE),
189                          m_osmLicense->fontMetrics().height());
190
191     connect(m_mapView, SIGNAL(viewResized(QSize)),
192             this, SLOT(drawOsmLicense(QSize)));
193 }
194
195 void MainWindow::buildUserInfoPanel()
196 {
197     qDebug() << __PRETTY_FUNCTION__;
198
199     m_userPanel = new UserInfoPanel(this);
200     m_userPanelSidebar = new PanelSideBar(this, LEFT);
201
202     m_userPanelSidebar->stackUnder(m_friendsListPanel);
203     m_userPanel->stackUnder(m_userPanelSidebar);
204
205     connect(m_userPanel, SIGNAL(findUser(QPointF)),
206             this, SIGNAL(findUser(QPointF)));
207
208     connect(this, SIGNAL(userLocationReady(User*)),
209             m_userPanel, SLOT(userDataReceived(User*)));
210
211     connect(m_userPanel, SIGNAL(requestReverseGeo()),
212             this, SIGNAL(requestReverseGeo()));
213
214     connect(this, SIGNAL(reverseGeoReady(QString)),
215             m_userPanel, SIGNAL(reverseGeoReady(QString)));
216
217     connect(m_userPanel, SIGNAL(statusUpdate(QString,bool)),
218             this, SIGNAL(statusUpdate(QString,bool)));
219
220     connect(m_userPanel, SIGNAL(refreshUserData()),
221             this, SIGNAL(refreshUserData()));
222
223     connect(m_mapView, SIGNAL(viewResized(QSize)),
224             m_userPanel, SLOT(screenResized(QSize)));
225 }
226
227 void MainWindow::buildWebView()
228 {
229     qDebug() << __PRETTY_FUNCTION__;
230
231     if(!m_webView) {
232         m_webView = new QWebView;
233
234         connect(m_webView, SIGNAL(urlChanged(const QUrl &)),
235                 this, SIGNAL(updateCredentials(QUrl)));
236         connect(m_webView, SIGNAL(loadFinished(bool)),
237                 this, SLOT(loadDone(bool)));
238
239         m_webView->hide();
240     }
241 }
242
243 void MainWindow::buildZoomButtonPanel()
244 {
245     qDebug() << __PRETTY_FUNCTION__;
246
247     m_zoomButtonPanel = new ZoomButtonPanel(this);
248
249     connect(m_zoomButtonPanel->zoomInButton(), SIGNAL(clicked()),
250             this, SIGNAL(zoomIn()));
251
252     connect(m_zoomButtonPanel->zoomOutButton(), SIGNAL(clicked()),
253             this, SIGNAL(zoomOut()));
254
255     connect(this, SIGNAL(zoomLevelChanged(int)),
256             m_zoomButtonPanel, SLOT(resetButtons()));
257
258     connect(this, SIGNAL(maxZoomLevelReached()),
259             m_zoomButtonPanel, SLOT(disableZoomInButton()));
260
261     connect(this, SIGNAL(minZoomLevelReached()),
262             m_zoomButtonPanel, SLOT(disableZoomOutButton()));
263
264     connect(m_mapView, SIGNAL(viewResized(QSize)),
265             m_zoomButtonPanel, SLOT(screenResized(QSize)));
266 }
267
268 void MainWindow::clearCookieJar()
269 {
270     qDebug() << __PRETTY_FUNCTION__;
271
272     buildWebView();
273
274     if(!m_cookieJar) {
275         m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
276     }
277     QList<QNetworkCookie> emptyList;
278     emptyList.clear();
279
280     m_cookieJar->setAllCookies(emptyList);
281     m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
282 }
283
284 void MainWindow::createMenus()
285 {
286     qDebug() << __PRETTY_FUNCTION__;
287
288     // login/logout
289     m_loginAct = new QAction(tr("Login"), this);
290     connect(m_loginAct, SIGNAL(triggered()),
291             this, SIGNAL(loginActionPressed()));
292
293     // settings
294     m_toSettingsAct = new QAction(tr("Settings"), this);
295     connect(m_toSettingsAct, SIGNAL(triggered()),
296         this, SLOT(openSettingsDialog()));
297
298     // GPS
299     m_gpsToggleAct = new QAction(tr("GPS"), this);
300     m_gpsToggleAct->setCheckable(true);
301
302     connect(m_gpsToggleAct, SIGNAL(triggered(bool)),
303             this, SIGNAL(gpsTriggered(bool)));
304
305     // automatic centering
306     m_autoCenteringAct = new QAction(tr("Auto centering"), this);
307     m_autoCenteringAct->setCheckable(true);
308     connect(m_autoCenteringAct, SIGNAL(triggered(bool)),
309         this, SIGNAL(autoCenteringTriggered(bool)));
310
311     // build the actual menu
312     m_viewMenu = menuBar()->addMenu(tr("Main"));
313     m_viewMenu->addAction(m_loginAct);
314     m_viewMenu->addAction(m_toSettingsAct);
315     m_viewMenu->addAction(m_gpsToggleAct);
316     m_viewMenu->addAction(m_autoCenteringAct);
317     m_viewMenu->setObjectName(tr("Menu"));
318 }
319
320 void MainWindow::drawOsmLicense(const QSize &size)
321 {
322     qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
323
324     m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
325                        - PANEL_PEEK_AMOUNT,
326                        size.height() - m_osmLicense->fontMetrics().height());
327
328 }
329
330 void MainWindow::drawOwnLocationCrosshair(int width, int height)
331 {
332     qDebug() << __PRETTY_FUNCTION__;
333
334     if (m_drawOwnLocationCrosshair && m_ownLocationCrosshair != 0) {
335         m_ownLocationCrosshair->move(width/2 - m_ownLocationCrosshair->pixmap()->width()/2,
336                             height/2 - m_ownLocationCrosshair->pixmap()->height()/2);
337     }
338 }
339
340 void MainWindow::gpsTimeout()
341 {
342     qDebug() << __PRETTY_FUNCTION__;
343
344     showMaemoInformationBox(tr("GPS timeout"));
345 }
346
347 void MainWindow::grabZoomKeys(bool grab)
348 {
349     qDebug() << __PRETTY_FUNCTION__;
350
351 #ifdef Q_WS_MAEMO_5
352     // Can't grab keys unless we have a window id
353     if (!winId())
354         return;
355
356     unsigned long val = (grab) ? 1 : 0;
357     Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
358     if (!atom)
359         return;
360
361     XChangeProperty (QX11Info::display(),
362                      winId(),
363                      atom,
364                      XA_INTEGER,
365                      32,
366                      PropModeReplace,
367                      reinterpret_cast<unsigned char *>(&val),
368                      1);
369 #else
370     Q_UNUSED(grab);
371 #endif // Q_WS_MAEMO_5
372 }
373
374 void MainWindow::keyPressEvent(QKeyEvent* event)
375 {
376     qDebug() << __PRETTY_FUNCTION__;
377
378     switch (event->key()) {
379     case Qt::Key_F7:
380         event->accept();
381         emit zoomIn();
382         break;
383
384     case Qt::Key_F8:
385         event->accept();
386         emit zoomOut();
387         break;
388     }
389     QWidget::keyPressEvent(event);
390 }
391
392 void MainWindow::loadCookies()
393 {
394     qDebug() << __PRETTY_FUNCTION__;
395
396     QSettings settings(DIRECTORY_NAME, FILE_NAME);
397
398     QStringList list = settings.value(COOKIES, EMPTY).toStringList();
399
400     if(!list.isEmpty()) {
401         QList<QNetworkCookie> cookieList;
402         for(int i=0;i<list.count();i++) {
403             cookieList.append(QNetworkCookie::parseCookies(list.at(i).toAscii()));
404         }
405
406         if(!m_cookieJar)
407                m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
408
409         m_cookieJar->setAllCookies(cookieList);
410         m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
411
412     }
413 }
414
415 void MainWindow::loadDone(bool done)
416 {
417     qDebug() << __PRETTY_FUNCTION__;
418
419     // for the first time the login page is opened, we need to refresh it to get cookies working
420     if(m_refresh) {
421         m_webView->reload();
422         m_refresh = false;
423     }
424
425     if (done)
426     {
427         QWebFrame* frame = m_webView->page()->currentFrame();
428         if (frame!=NULL)
429         {
430             // set email box
431             QWebElementCollection emailCollection = frame->findAllElements("input[name=email]");
432
433             foreach (QWebElement element, emailCollection) {
434                 element.setAttribute("value", m_email.toAscii());
435             }
436             // set password box
437             QWebElementCollection passwordCollection = frame->findAllElements("input[name=pass]");
438             foreach (QWebElement element, passwordCollection) {
439                 element.setAttribute("value", m_password.toAscii());
440             }
441             // find connect button
442             QWebElementCollection buttonCollection = frame->findAllElements("input[name=login]");
443             foreach (QWebElement element, buttonCollection)
444             {
445                 QPoint pos(element.geometry().center());
446
447                 // send a mouse click event to the web page
448                 QMouseEvent event0(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton,
449                                    Qt::NoModifier);
450                 QApplication::sendEvent(m_webView->page(), &event0);
451                 QMouseEvent event1(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton,
452                                    Qt::NoModifier);
453                 QApplication::sendEvent(m_webView->page(), &event1);
454             }
455         }
456     }
457 }
458
459 void MainWindow::loggedIn(bool logged)
460 {
461     qDebug() << __PRETTY_FUNCTION__;
462
463     m_loggedIn = logged;
464
465     if(logged) {
466         m_loginAct->setText(tr("Logout"));
467     }
468     else {
469         clearCookieJar();
470         m_email.clear();
471         m_password.clear();
472
473         m_loginAct->setText(tr("Login"));
474     }
475     updateItemVisibility(m_loggedIn);
476 }
477
478 void MainWindow::loginFailed()
479 {
480     qDebug() << __PRETTY_FUNCTION__;
481
482     clearCookieJar();
483
484     toggleProgressIndicator(false);
485
486     QStringList urlParts;
487     urlParts.append(FACEBOOK_LOGINBASE);
488     urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
489     urlParts.append(INTERVAL1);
490     urlParts.append(SITUARE_LOGIN_SUCCESS);
491     urlParts.append(INTERVAL2);
492     urlParts.append(SITUARE_LOGIN_FAILURE);
493     urlParts.append(FACEBOOK_LOGIN_ENDING);
494
495     startLoginProcess(urlParts.join(EMPTY));
496 }
497
498 void MainWindow::loginUsingCookies()
499 {
500     qDebug() << __PRETTY_FUNCTION__;
501
502     buildWebView();
503     loadCookies();
504     
505     QStringList urlParts;
506     urlParts.append(FACEBOOK_LOGINBASE);
507     urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
508     urlParts.append(INTERVAL1);
509     urlParts.append(SITUARE_LOGIN_SUCCESS);
510     urlParts.append(INTERVAL2);
511     urlParts.append(SITUARE_LOGIN_FAILURE);
512     urlParts.append(FACEBOOK_LOGIN_ENDING);
513
514     m_webView->load(QUrl(urlParts.join(EMPTY)));
515
516 }
517
518 void MainWindow::openSettingsDialog()
519 {
520     qDebug() << __PRETTY_FUNCTION__;
521
522     m_settingsDialog->enableSituareSettings(m_gpsToggleAct->isChecked() && m_loggedIn);
523     m_settingsDialog->show();
524 }
525
526 void MainWindow::saveCookies()
527 {
528     qDebug() << __PRETTY_FUNCTION__;
529
530     if(!m_cookieJar)
531         m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
532
533     QList<QNetworkCookie> cookieList = m_cookieJar->allCookies();
534     QStringList list;
535
536     for(int i=0;i<cookieList.count();i++) {
537         QNetworkCookie cookie = cookieList.at(i);
538         QByteArray byteArray = cookie.toRawForm(QNetworkCookie::Full);
539         list.append(QString(byteArray));
540     }
541     list.removeDuplicates();
542
543     QSettings settings(DIRECTORY_NAME, FILE_NAME);
544     settings.setValue(COOKIES, list);
545 }
546
547 void MainWindow::setAutoCenteringButtonEnabled(bool enabled)
548 {
549     qDebug() << __PRETTY_FUNCTION__;
550
551     m_autoCenteringAct->setChecked(enabled);
552 }
553
554 void MainWindow::setGPSButtonEnabled(bool enabled)
555 {
556     qDebug() << __PRETTY_FUNCTION__;
557
558     m_gpsToggleAct->setChecked(enabled);
559
560     if(m_loggedIn)
561         setOwnLocationCrosshairVisibility(!enabled);
562
563     m_autoCenteringAct->setVisible(enabled);
564 }
565
566 void MainWindow::setMapViewScene(QGraphicsScene *scene)
567 {
568     qDebug() << __PRETTY_FUNCTION__;
569
570     m_mapView->setScene(scene);
571 }
572
573 void MainWindow::setOwnLocationCrosshairVisibility(bool visibility)
574 {
575     qDebug() << __PRETTY_FUNCTION__;
576
577     if (visibility) {
578         m_ownLocationCrosshair->show();
579         m_drawOwnLocationCrosshair = true;
580         drawOwnLocationCrosshair(m_viewPortWidth, m_viewPortHeight);
581     }
582     else {
583         m_ownLocationCrosshair->hide();
584         m_drawOwnLocationCrosshair = false;
585     }
586 }
587
588 void MainWindow::setUsername(const QString &username)
589 {
590     qDebug() << __PRETTY_FUNCTION__;
591
592     m_email = username;
593 }
594
595 void MainWindow::setViewPortSize(int width, int height)
596 {
597     qDebug() << __PRETTY_FUNCTION__;
598
599     m_viewPortWidth = width;
600     m_viewPortHeight = height;
601 }
602
603 void MainWindow::showMaemoInformationBox(const QString &message, bool modal)
604 {
605     qDebug() << __PRETTY_FUNCTION__;
606
607 #ifdef Q_WS_MAEMO_5
608     if(modal) {
609         QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::NoTimeout);
610     }
611     else {
612         QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::DefaultTimeout);
613     }
614 #else
615     Q_UNUSED(modal);
616     QMessageBox::information(this, tr("Situare"), message, QMessageBox::Ok);
617 #endif
618 }
619
620 void MainWindow::startLoginProcess(const QUrl &url)
621 {
622     qDebug() << __PRETTY_FUNCTION__;
623
624     buildWebView();
625
626     LoginDialog loginDialog;
627
628     emit fetchUsernameFromSettings();
629
630     if(!m_cookieJar)
631         m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
632
633     m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
634
635     loginDialog.clearTextFields();
636
637     if(!m_email.isEmpty())
638         loginDialog.setEmailField(m_email);
639
640     if(loginDialog.exec() != QDialog::Accepted) {
641         // if login dialog was canceled we need to stop processing webview
642         m_webView->stop();
643
644         emit cancelLoginProcess();
645     }
646     else {
647         loginDialog.userInput(m_email, m_password);
648         emit saveUsername(m_email);
649         m_webView->load(url);
650         toggleProgressIndicator(true);
651         m_refresh = true;
652     }
653 }
654
655 void MainWindow::toggleProgressIndicator(bool value)
656 {
657     qDebug() << __PRETTY_FUNCTION__;
658
659 #ifdef Q_WS_MAEMO_5
660     setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
661 #else
662     Q_UNUSED(value);
663 #endif // Q_WS_MAEMO_5
664 }
665
666 void MainWindow::updateItemVisibility(bool show)
667 {
668     qDebug() << __PRETTY_FUNCTION__;
669     
670     if(show) {
671         m_friendsListPanel->show();
672         m_friendsListPanelSidebar->show();
673         m_userPanel->show();
674         m_userPanelSidebar->show();
675
676         if(m_drawOwnLocationCrosshair) {
677             m_ownLocationCrosshair->show();
678             setGPSButtonEnabled(false);
679             emit gpsTriggered(false);
680         }
681     }
682     else {
683         m_friendsListPanel->closePanel();
684         m_friendsListPanel->hide();
685         m_friendsListPanelSidebar->hide();
686         m_userPanel->closePanel();
687         m_userPanel->hide();
688         m_userPanelSidebar->hide();
689         m_ownLocationCrosshair->hide();       
690     }
691 }
692
693 const QString MainWindow::username()
694 {
695     qDebug() << __PRETTY_FUNCTION__;
696     
697     return m_email;
698 }