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