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
8 Situare is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 version 2 as published by the Free Software Foundation.
12 Situare 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 Situare; if not, write to the Free Software
19 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
24 #include "ui/mainwindow.h"
26 SituareEngine::SituareEngine(QMainWindow *parent)
29 qDebug() << __PRETTY_FUNCTION__;
30 m_ui = new MainWindow;
32 m_situareService = new SituareService(this);
34 m_facebookAuthenticator = new FacebookAuthentication();
36 connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
37 m_situareService, SLOT(credentialsReady(FacebookCredentials)));
38 connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
39 this, SLOT(loginOk()));
41 connect(m_ui, SIGNAL(requestReverseGeo()), this, SLOT(requestAddress()));
42 connect(m_situareService, SIGNAL(reverseGeoReady(QString)), m_ui, SIGNAL(reverseGeoReady(QString)));
43 connect(m_ui, SIGNAL(statusUpdate(QString,bool)), this, SLOT(requestUpdateLocation(QString,bool)));
44 connect(m_situareService, SIGNAL(userDataChanged(User*,QList<User*>&)),
45 this, SLOT(userDataChanged(User*,QList<User*>&)));
46 connect(this, SIGNAL(userLocationReady(User*)), m_ui, SIGNAL(userLocationReady(User*)));
47 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)), m_ui, SIGNAL(friendsLocationsReady(QList<User*>&)));
48 connect(m_situareService, SIGNAL(error(QString)), this, SLOT(error(QString)));
49 connect(m_situareService, SIGNAL(updateWasSuccessful()), this, SLOT(updateWasSuccessful()));
51 m_facebookAuthenticator->start();
54 SituareEngine::~SituareEngine()
56 qDebug() << __PRETTY_FUNCTION__;
58 delete m_facebookAuthenticator;
61 void SituareEngine::error(const QString &error)
63 qDebug() << __PRETTY_FUNCTION__;
68 void SituareEngine::loginOk()
70 qDebug() << __PRETTY_FUNCTION__;
71 m_facebookAuthenticator->hide();
73 m_situareService->fetchLocations(); // request user locations
76 void SituareEngine::requestAddress()
78 qDebug() << __PRETTY_FUNCTION__;
80 QPointF coordinates(65.0109, 25.5092); // this will be get from somewhere, map etc...
81 m_situareService->reverseGeo(coordinates);
84 void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
86 qDebug() << __PRETTY_FUNCTION__;
88 QPointF coordinates(65.0109, 25.5092); // this will be get from somewhere, map etc...
89 m_situareService->updateLocation(coordinates, status, publish);
92 void SituareEngine::updateWasSuccessful()
94 qDebug() << __PRETTY_FUNCTION__;
96 m_situareService->fetchLocations();
99 void SituareEngine::updateFriendsList()
101 qDebug() << __PRETTY_FUNCTION__;
105 void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
107 qDebug() << __PRETTY_FUNCTION__;
109 emit userLocationReady(user);
110 emit friendsLocationsReady(friendsList);