Commit description: facebook and situare services now in engine class
[situare] / src / engine / engine.cpp
1  /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Kaj Wallin - kaj.wallin@ixonos.com
6
7     Situare is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     version 2 as published by the Free Software Foundation.
10
11     Situare is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with Situare; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19     USA.
20  */
21
22 #include "engine.h"
23
24 SituareEngine::SituareEngine(QMainWindow *parent)
25     : QObject(parent)
26 {
27     m_loggedIn = false;
28     m_facebookAuthenticator = new FacebookAuthentication();
29
30     m_networkManager = new QNetworkAccessManager;
31     m_situareService = new SituareService(this,m_networkManager);
32     connect(m_facebookAuthenticator, SIGNAL(credentialsReady()), this, SLOT(loginOk()));
33     connect(m_facebookAuthenticator, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
34 }
35
36 SituareEngine::~SituareEngine()
37 {
38     qDebug() << __PRETTY_FUNCTION__;
39 }
40
41 void SituareEngine::start()
42 {
43     m_facebookAuthenticator->start();
44 }
45
46
47 void SituareEngine::loginOk()
48 {
49     qDebug() << __PRETTY_FUNCTION__;
50     m_loggedIn = true;
51     m_facebookAuthenticator->close();
52 }
53 void SituareEngine::loginScreenClosed()
54 {
55     qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
56     if (m_loggedIn) {
57         emit engine_showMainWindow();
58         return;
59     }
60     else {
61         emit engine_closeMainWindow();
62     }
63 }