2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Kaj Wallin - kaj.wallin@ixonos.com
6 Henri Lampela - henri.lampela@ixonos.com
7 Jussi Laitinen jussi.laitinen@ixonos.com
9 Situare is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 version 2 as published by the Free Software Foundation.
13 Situare is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Situare; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
25 #include "ui/mainwindow.h"
27 SituareEngine::SituareEngine(QMainWindow *parent)
30 qDebug() << __PRETTY_FUNCTION__;
31 m_ui = new MainWindow;
33 m_situareService = new SituareService(this);
35 m_facebookAuthenticator = new FacebookAuthentication();
37 connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
38 m_situareService, SLOT(credentialsReady(FacebookCredentials)));
39 connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
40 this, SLOT(loginOk()));
42 connect(m_ui, SIGNAL(requestReverseGeo()), this, SLOT(requestAddress()));
43 connect(m_situareService, SIGNAL(reverseGeoReady(QString)), m_ui, SIGNAL(reverseGeoReady(QString)));
44 connect(m_ui, SIGNAL(statusUpdate(QString,bool)), this, SLOT(requestUpdateLocation(QString,bool)));
45 connect(m_situareService, SIGNAL(userDataChanged(User*,QList<User*>&)),
46 this, SLOT(userDataChanged(User*,QList<User*>&)));
47 connect(this, SIGNAL(userLocationReady(User*)), m_ui, SIGNAL(userLocationReady(User*)));
48 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)), m_ui, SIGNAL(friendsLocationsReady(QList<User*>&)));
49 connect(m_situareService, SIGNAL(error(QString)), this, SLOT(error(QString)));
50 connect(m_situareService, SIGNAL(updateWasSuccessful()), this, SLOT(updateWasSuccessful()));
52 connect(m_ui, SIGNAL(refreshUserData()), this, SLOT(refreshUserData()));
54 m_facebookAuthenticator->start();
57 SituareEngine::~SituareEngine()
59 qDebug() << __PRETTY_FUNCTION__;
61 delete m_facebookAuthenticator;
64 void SituareEngine::error(const QString &error)
66 qDebug() << __PRETTY_FUNCTION__;
71 void SituareEngine::loginOk()
73 qDebug() << __PRETTY_FUNCTION__;
74 m_facebookAuthenticator->hide();
76 m_situareService->fetchLocations(); // request user locations
79 void SituareEngine::requestAddress()
81 qDebug() << __PRETTY_FUNCTION__;
83 QPointF coordinates(65.0109, 25.5092); // this will be get from somewhere, map etc...
84 m_situareService->reverseGeo(coordinates);
87 void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
89 qDebug() << __PRETTY_FUNCTION__;
91 m_ui->toggleProgressIndicator(true);
93 QPointF coordinates(65.0109, 25.5092); // this will be get from somewhere, map etc...
94 m_situareService->updateLocation(coordinates, status, publish);
97 void SituareEngine::updateWasSuccessful()
99 qDebug() << __PRETTY_FUNCTION__;
101 m_situareService->fetchLocations();
104 void SituareEngine::refreshUserData()
106 qDebug() << __PRETTY_FUNCTION__;
108 m_ui->toggleProgressIndicator(true);
110 m_situareService->fetchLocations();
113 void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
115 qDebug() << __PRETTY_FUNCTION__;
117 m_ui->toggleProgressIndicator(false);
119 emit userLocationReady(user);
120 emit friendsLocationsReady(friendsList);