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()));
41 connect(m_facebookAuthenticator, SIGNAL(quitSituare()),
42 this, SLOT(quitApplication()));
44 connect(m_ui, SIGNAL(requestReverseGeo()),
45 this, SLOT(requestAddress()));
46 connect(m_situareService, SIGNAL(reverseGeoReady(QString)),
47 m_ui, SIGNAL(reverseGeoReady(QString)));
48 connect(m_ui, SIGNAL(statusUpdate(QString,bool)),
49 this, SLOT(requestUpdateLocation(QString,bool)));
50 connect(m_situareService, SIGNAL(userDataChanged(User*,QList<User*>&)),
51 this, SLOT(userDataChanged(User*,QList<User*>&)));
52 connect(this, SIGNAL(userLocationReady(User*)),
53 m_ui, SIGNAL(userLocationReady(User*)));
54 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
55 m_ui, SIGNAL(friendsLocationsReady(QList<User*>&)));
56 connect(m_situareService, SIGNAL(error(QString)),
57 this, SLOT(error(QString)));
58 connect(m_situareService, SIGNAL(updateWasSuccessful()),
59 this, SLOT(updateWasSuccessful()));
61 connect(m_ui, SIGNAL(refreshUserData()),
62 this, SLOT(refreshUserData()));
64 m_facebookAuthenticator->start();
67 SituareEngine::~SituareEngine()
69 qDebug() << __PRETTY_FUNCTION__;
73 void SituareEngine::quitApplication()
75 qDebug() << __PRETTY_FUNCTION__;
77 m_facebookAuthenticator->setAttribute(Qt::WA_DeleteOnClose);
78 m_facebookAuthenticator->close();
81 void SituareEngine::error(const QString &error)
83 qDebug() << __PRETTY_FUNCTION__;
88 void SituareEngine::loginOk()
90 qDebug() << __PRETTY_FUNCTION__;
92 m_facebookAuthenticator->setAttribute(Qt::WA_DeleteOnClose);
93 m_facebookAuthenticator->close();
95 m_situareService->fetchLocations(); // request user locations
98 void SituareEngine::requestAddress()
100 qDebug() << __PRETTY_FUNCTION__;
102 QPointF coordinates(65.0109, 25.5092); // this will be get from somewhere, map etc...
103 m_situareService->reverseGeo(coordinates);
106 void SituareEngine::requestUpdateLocation(const QString &status, bool publish)
108 qDebug() << __PRETTY_FUNCTION__;
110 m_ui->toggleProgressIndicator(true);
112 QPointF coordinates(65.0109, 25.5092); // this will be get from somewhere, map etc...
113 m_situareService->updateLocation(coordinates, status, publish);
116 void SituareEngine::updateWasSuccessful()
118 qDebug() << __PRETTY_FUNCTION__;
120 m_situareService->fetchLocations();
123 void SituareEngine::refreshUserData()
125 qDebug() << __PRETTY_FUNCTION__;
127 m_ui->toggleProgressIndicator(true);
129 m_situareService->fetchLocations();
132 void SituareEngine::userDataChanged(User *user, QList<User *> &friendsList)
134 qDebug() << __PRETTY_FUNCTION__;
136 m_ui->toggleProgressIndicator(false);
138 emit userLocationReady(user);
139 emit friendsLocationsReady(friendsList);