Merge branch 'master' of https://vcs.maemo.org/git/situare
[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::gpsError(const QString &message)
341 {
342     qDebug() << __PRETTY_FUNCTION__;
343
344     showMaemoInformationBox(message);
345 }
346
347 void MainWindow::gpsTimeout()
348 {
349     qDebug() << __PRETTY_FUNCTION__;
350
351     showMaemoInformationBox(tr("GPS timeout"));
352 }
353
354 void MainWindow::grabZoomKeys(bool grab)
355 {
356     qDebug() << __PRETTY_FUNCTION__;
357
358 #ifdef Q_WS_MAEMO_5
359     // Can't grab keys unless we have a window id
360     if (!winId())
361         return;
362
363     unsigned long val = (grab) ? 1 : 0;
364     Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
365     if (!atom)
366         return;
367
368     XChangeProperty (QX11Info::display(),
369                      winId(),
370                      atom,
371                      XA_INTEGER,
372                      32,
373                      PropModeReplace,
374                      reinterpret_cast<unsigned char *>(&val),
375                      1);
376 #else
377     Q_UNUSED(grab);
378 #endif // Q_WS_MAEMO_5
379 }
380
381 void MainWindow::keyPressEvent(QKeyEvent* event)
382 {
383     qDebug() << __PRETTY_FUNCTION__;
384
385     switch (event->key()) {
386     case Qt::Key_F7:
387         event->accept();
388         emit zoomIn();
389         break;
390
391     case Qt::Key_F8:
392         event->accept();
393         emit zoomOut();
394         break;
395     }
396     QWidget::keyPressEvent(event);
397 }
398
399 void MainWindow::loadCookies()
400 {
401     qDebug() << __PRETTY_FUNCTION__;
402
403     QSettings settings(DIRECTORY_NAME, FILE_NAME);
404
405     QStringList list = settings.value(COOKIES, EMPTY).toStringList();
406
407     if(!list.isEmpty()) {
408         QList<QNetworkCookie> cookieList;
409         for(int i=0;i<list.count();i++) {
410             cookieList.append(QNetworkCookie::parseCookies(list.at(i).toAscii()));
411         }
412
413         if(!m_cookieJar)
414                m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
415
416         m_cookieJar->setAllCookies(cookieList);
417         m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
418
419     }
420 }
421
422 void MainWindow::loadDone(bool done)
423 {
424     qDebug() << __PRETTY_FUNCTION__;
425
426     // for the first time the login page is opened, we need to refresh it to get cookies working
427     if(m_refresh) {
428         m_webView->reload();
429         m_refresh = false;
430     }
431
432     if (done)
433     {
434         QWebFrame* frame = m_webView->page()->currentFrame();
435         if (frame!=NULL)
436         {
437             // set email box
438             QWebElementCollection emailCollection = frame->findAllElements("input[name=email]");
439
440             foreach (QWebElement element, emailCollection) {
441                 element.setAttribute("value", m_email.toAscii());
442             }
443             // set password box
444             QWebElementCollection passwordCollection = frame->findAllElements("input[name=pass]");
445             foreach (QWebElement element, passwordCollection) {
446                 element.setAttribute("value", m_password.toAscii());
447             }
448             // find connect button
449             QWebElementCollection buttonCollection = frame->findAllElements("input[name=login]");
450             foreach (QWebElement element, buttonCollection)
451             {
452                 QPoint pos(element.geometry().center());
453
454                 // send a mouse click event to the web page
455                 QMouseEvent event0(QEvent::MouseButtonPress, pos, Qt::LeftButton, Qt::LeftButton,
456                                    Qt::NoModifier);
457                 QApplication::sendEvent(m_webView->page(), &event0);
458                 QMouseEvent event1(QEvent::MouseButtonRelease, pos, Qt::LeftButton, Qt::LeftButton,
459                                    Qt::NoModifier);
460                 QApplication::sendEvent(m_webView->page(), &event1);
461             }
462         }
463     }
464 }
465
466 void MainWindow::loggedIn(bool logged)
467 {
468     qDebug() << __PRETTY_FUNCTION__;
469
470     m_loggedIn = logged;
471
472     if(logged) {
473         m_loginAct->setText(tr("Logout"));
474     }
475     else {
476         clearCookieJar();
477         m_email.clear();
478         m_password.clear();
479
480         m_loginAct->setText(tr("Login"));
481     }
482     updateItemVisibility(m_loggedIn);
483 }
484
485 void MainWindow::loginFailed()
486 {
487     qDebug() << __PRETTY_FUNCTION__;
488
489     clearCookieJar();
490
491     toggleProgressIndicator(false);
492
493     showMaemoInformationBox(tr("Invalid E-mail address or password"), true);
494
495     QStringList urlParts;
496     urlParts.append(FACEBOOK_LOGINBASE);
497     urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
498     urlParts.append(INTERVAL1);
499     urlParts.append(SITUARE_LOGIN_SUCCESS);
500     urlParts.append(INTERVAL2);
501     urlParts.append(SITUARE_LOGIN_FAILURE);
502     urlParts.append(FACEBOOK_LOGIN_ENDING);
503
504     startLoginProcess(urlParts.join(EMPTY));
505 }
506
507 void MainWindow::loginUsingCookies()
508 {
509     qDebug() << __PRETTY_FUNCTION__;
510
511     buildWebView();
512     loadCookies();
513     
514     QStringList urlParts;
515     urlParts.append(FACEBOOK_LOGINBASE);
516     urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
517     urlParts.append(INTERVAL1);
518     urlParts.append(SITUARE_LOGIN_SUCCESS);
519     urlParts.append(INTERVAL2);
520     urlParts.append(SITUARE_LOGIN_FAILURE);
521     urlParts.append(FACEBOOK_LOGIN_ENDING);
522
523     m_webView->load(QUrl(urlParts.join(EMPTY)));
524
525 }
526
527 void MainWindow::openSettingsDialog()
528 {
529     qDebug() << __PRETTY_FUNCTION__;
530
531     m_settingsDialog->enableSituareSettings(m_gpsToggleAct->isChecked() && m_loggedIn);
532     m_settingsDialog->show();
533 }
534
535 void MainWindow::saveCookies()
536 {
537     qDebug() << __PRETTY_FUNCTION__;
538
539     if(!m_cookieJar)
540         m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
541
542     QList<QNetworkCookie> cookieList = m_cookieJar->allCookies();
543     QStringList list;
544
545     for(int i=0;i<cookieList.count();i++) {
546         QNetworkCookie cookie = cookieList.at(i);
547         QByteArray byteArray = cookie.toRawForm(QNetworkCookie::Full);
548         list.append(QString(byteArray));
549     }
550     list.removeDuplicates();
551
552     QSettings settings(DIRECTORY_NAME, FILE_NAME);
553     settings.setValue(COOKIES, list);
554 }
555
556 void MainWindow::setAutoCenteringButtonEnabled(bool enabled)
557 {
558     qDebug() << __PRETTY_FUNCTION__;
559
560     m_autoCenteringAct->setChecked(enabled);
561 }
562
563 void MainWindow::setGPSButtonEnabled(bool enabled)
564 {
565     qDebug() << __PRETTY_FUNCTION__;
566
567     m_gpsToggleAct->setChecked(enabled);
568
569     if(m_loggedIn)
570         setOwnLocationCrosshairVisibility(!enabled);
571
572     m_autoCenteringAct->setVisible(enabled);
573 }
574
575 void MainWindow::setMapViewScene(QGraphicsScene *scene)
576 {
577     qDebug() << __PRETTY_FUNCTION__;
578
579     m_mapView->setScene(scene);
580 }
581
582 void MainWindow::setOwnLocationCrosshairVisibility(bool visibility)
583 {
584     qDebug() << __PRETTY_FUNCTION__;
585
586     if (visibility) {
587         m_ownLocationCrosshair->show();
588         m_drawOwnLocationCrosshair = true;
589         drawOwnLocationCrosshair(m_viewPortWidth, m_viewPortHeight);
590     }
591     else {
592         m_ownLocationCrosshair->hide();
593         m_drawOwnLocationCrosshair = false;
594     }
595 }
596
597 void MainWindow::setUsername(const QString &username)
598 {
599     qDebug() << __PRETTY_FUNCTION__;
600
601     m_email = username;
602 }
603
604 void MainWindow::setViewPortSize(int width, int height)
605 {
606     qDebug() << __PRETTY_FUNCTION__;
607
608     m_viewPortWidth = width;
609     m_viewPortHeight = height;
610 }
611
612 void MainWindow::showMaemoInformationBox(const QString &message, bool modal)
613 {
614     qDebug() << __PRETTY_FUNCTION__;
615
616 #ifdef Q_WS_MAEMO_5
617     if(modal) {
618         QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::NoTimeout);
619     }
620     else {
621         QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::DefaultTimeout);
622     }
623 #else
624     Q_UNUSED(modal);
625     QMessageBox::information(this, tr("Situare"), message, QMessageBox::Ok);
626 #endif
627 }
628
629 void MainWindow::startLoginProcess(const QUrl &url)
630 {
631     qDebug() << __PRETTY_FUNCTION__;
632
633     buildWebView();
634
635     LoginDialog loginDialog;
636
637     emit fetchUsernameFromSettings();
638
639     if(!m_cookieJar)
640         m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
641
642     m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
643
644     loginDialog.clearTextFields();
645
646     if(!m_email.isEmpty())
647         loginDialog.setEmailField(m_email);
648
649     if(loginDialog.exec() != QDialog::Accepted) {
650         // if login dialog was canceled we need to stop processing webview
651         m_webView->stop();
652
653         emit cancelLoginProcess();
654     }
655     else {
656         loginDialog.userInput(m_email, m_password);
657         m_webView->load(url);
658         toggleProgressIndicator(true);
659         m_refresh = true;
660     }
661 }
662
663 void MainWindow::toggleProgressIndicator(bool value)
664 {
665     qDebug() << __PRETTY_FUNCTION__;
666
667 #ifdef Q_WS_MAEMO_5
668     setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
669 #else
670     Q_UNUSED(value);
671 #endif // Q_WS_MAEMO_5
672 }
673
674 void MainWindow::updateItemVisibility(bool show)
675 {
676     qDebug() << __PRETTY_FUNCTION__;
677     
678     if(show) {
679         m_friendsListPanel->show();
680         m_friendsListPanelSidebar->show();
681         m_userPanel->show();
682         m_userPanelSidebar->show();
683
684         if(m_drawOwnLocationCrosshair) {
685             m_ownLocationCrosshair->show();
686             setGPSButtonEnabled(false);
687             emit gpsTriggered(false);
688         }
689     }
690     else {
691         m_friendsListPanel->closePanel();
692         m_friendsListPanel->hide();
693         m_friendsListPanelSidebar->hide();
694         m_userPanel->closePanel();
695         m_userPanel->hide();
696         m_userPanelSidebar->hide();
697         m_ownLocationCrosshair->hide();       
698     }
699 }
700
701 const QString MainWindow::username()
702 {
703     qDebug() << __PRETTY_FUNCTION__;
704     
705     return m_email;
706 }