m_mapEngine->init();
m_ui->show();
- initializeGpsAndAutocentering();
-
m_facebookAuthenticator->start();
+ initializeGpsAndAutocentering();
+
m_automaticUpdateIntervalTimer = new QTimer(this);
connect(m_automaticUpdateIntervalTimer, SIGNAL(timeout()),
this, SLOT(automaticUpdateIntervalTimerTimeout()));
qDebug() << __PRETTY_FUNCTION__;
changeAutoCenteringSetting(false);
- m_ui->queueInformationBox(tr("Auto centering disabled"));
+ m_ui->buildInformationBox(tr("Auto centering disabled"));
}
void SituareEngine::enableAutoCentering(bool enabled)
{
qDebug() << __PRETTY_FUNCTION__;
- m_ui->queueInformationBox(error, true);
+ m_ui->buildInformationBox(error, true);
if(error.compare(SESSION_EXPIRED) == 0) {
m_facebookAuthenticator->clearAccountInformation(true); // keep username = true
changeAutoCenteringSetting(true);
enableGPS(true);
- m_ui->queueInformationBox(tr("GPS enabled"));
- m_ui->queueInformationBox(tr("Auto centering enabled"));
+ m_ui->buildInformationBox(tr("GPS enabled"));
+ m_ui->buildInformationBox(tr("Auto centering enabled"));
} else { // Normal start
changeAutoCenteringSetting(autoCenteringEnabled.toBool());
enableGPS(gpsEnabled.toBool());
if (gpsEnabled.toBool())
- m_ui->queueInformationBox(tr("GPS enabled"));
+ m_ui->buildInformationBox(tr("GPS enabled"));
if (gpsEnabled.toBool() && autoCenteringEnabled.toBool())
- m_ui->queueInformationBox(tr("Auto centering enabled"));
+ m_ui->buildInformationBox(tr("Auto centering enabled"));
}
}
connect(m_facebookAuthenticator, SIGNAL(credentialsReady(FacebookCredentials)),
this, SLOT(loginOk()));
- connect(m_facebookAuthenticator, SIGNAL(newLoginRequest(QUrl)),
- m_ui, SLOT(startLoginProcess(QUrl)));
+ connect(m_facebookAuthenticator, SIGNAL(newLoginRequest()),
+ m_ui, SLOT(startLoginProcess()));
connect(m_facebookAuthenticator, SIGNAL(loginFailure()),
m_ui, SLOT(loginFailed()));
}
else {
m_freshLogin = true;
-
- QStringList list;
- list.append(FACEBOOK_LOGINBASE);
- list.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
- list.append(INTERVAL1);
- list.append(SITUARE_LOGIN_SUCCESS);
- list.append(INTERVAL2);
- list.append(SITUARE_LOGIN_FAILURE);
- list.append(FACEBOOK_LOGIN_ENDING);
-
- emit newLoginRequest(list.join(EMPTY));
+ emit newLoginRequest();
}
}
/**
* @brief Signals when credentials are invalid new login is needed
*
- * @param url Login page url
*/
- void newLoginRequest(const QUrl &url);
+ void newLoginRequest();
/**
* @brief This signal is emitted when new cookies need to be saved.
+++ /dev/null
-/*
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
-
- Henri Lampela - henri.lampela@ixonos.com
-
- Situare is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- Situare is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Situare; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA.
-*/
-
-#include <QDebug>
-#include "notedata.h"
-
-NoteData::NoteData(const QString &message, bool modal)
- : m_message(message),
- m_modal(modal)
-{
- qDebug() << __PRETTY_FUNCTION__;
-}
-
-QString NoteData::message() const
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- return m_message;
-}
-
-bool NoteData::modal() const
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- return m_modal;
-}
+++ /dev/null
-/*
- Situare - A location system for Facebook
- Copyright (C) 2010 Ixonos Plc. Authors:
-
- Henri Lampela - henri.lampela@ixonos.com
-
- Situare is free software; you can redistribute it and/or
- modify it under the terms of the GNU General Public License
- version 2 as published by the Free Software Foundation.
-
- Situare is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with Situare; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
- USA.
-*/
-
-#ifndef NOTEDATA_H
-#define NOTEDATA_H
-
-#include <QString>
-
-class NoteData
-{
-public:
- NoteData(const QString &message, bool modal);
-
- QString message() const;
-
- bool modal() const;
-
-private:
-
- QString m_message;
- bool m_modal;
-
-};
-
-#endif // NOTEDATA_H
network/networkaccessmanager.cpp \
network/networkhandler.cpp \
network/networkcookiejar.cpp \
- network/networkreply.cpp \
- notedata.cpp
+ network/networkreply.cpp
HEADERS += ui/mainwindow.h \
map/mapengine.h \
map/mapview.h \
network/networkaccessmanager.h \
network/networkhandler.h \
network/networkcookiejar.h \
- network/networkreply.h \
- notedata.h
+ network/networkreply.h
QT += network \
webkit
#DEFINES += QT_NO_DEBUG_OUTPUT
m_friendsListPanelSidebar, SLOT(reDrawSidebar(int, int)));
}
+void MainWindow::buildInformationBox(const QString &message, bool modal)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+#ifdef Q_WS_MAEMO_5
+ QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(this);
+ QLabel *label = new QLabel(msgBox);
+ label->setAlignment(Qt::AlignCenter);
+ label->setText(message);
+ msgBox->setWidget(label);
+
+ if(modal) {
+ msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
+ } else {
+ msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
+ }
+#else
+ QMessageBox *msgBox = new QMessageBox(this);
+ msgBox->button(QMessageBox::Ok);
+ msgBox->setText(message);
+ msgBox->setModal(modal);
+#endif
+
+ queueDialog(msgBox);
+}
+
void MainWindow::buildManualLocationCrosshair()
{
qDebug() << __PRETTY_FUNCTION__;
m_viewMenu->setObjectName(tr("Menu"));
}
+void MainWindow::dialogFinished(int status)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ qDebug() << status;
+ QDialog *dialog = m_queue.takeFirst();
+ if(!dialog->objectName().isEmpty()) {
+ buildWebView();
+ if(status != 0) {
+ static_cast<LoginDialog *>(dialog)->userInput(m_email, m_password);
+
+ if(!m_cookieJar)
+ m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
+
+ m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
+
+ QStringList urlParts;
+ urlParts.append(FACEBOOK_LOGINBASE);
+ urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
+ urlParts.append(INTERVAL1);
+ urlParts.append(SITUARE_LOGIN_SUCCESS);
+ urlParts.append(INTERVAL2);
+ urlParts.append(SITUARE_LOGIN_FAILURE);
+ urlParts.append(FACEBOOK_LOGIN_ENDING);
+
+ emit saveUsername(m_email);
+ m_webView->load(QUrl(urlParts.join(EMPTY)));
+ toggleProgressIndicator(true);
+ m_refresh = true;
+ } else {
+ m_webView->stop();
+ emit cancelLoginProcess();
+ }
+ }
+
+ dialog->deleteLater();
+
+ if(!m_queue.isEmpty())
+ showInformationBox();
+}
+
void MainWindow::drawFullScreenButton(const QSize &size)
{
qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
{
qDebug() << __PRETTY_FUNCTION__;
- queueInformationBox(tr("GPS timeout"));
+ buildInformationBox(tr("GPS timeout"));
}
void MainWindow::grabZoomKeys(bool grab)
toggleProgressIndicator(false);
- QStringList urlParts;
- urlParts.append(FACEBOOK_LOGINBASE);
- urlParts.append(SITUARE_PUBLIC_FACEBOOKAPI_KEY);
- urlParts.append(INTERVAL1);
- urlParts.append(SITUARE_LOGIN_SUCCESS);
- urlParts.append(INTERVAL2);
- urlParts.append(SITUARE_LOGIN_FAILURE);
- urlParts.append(FACEBOOK_LOGIN_ENDING);
-
- startLoginProcess(urlParts.join(EMPTY));
-}
-
-void MainWindow::noteFinished()
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- NoteData *data = m_queue.takeFirst();
- delete data;
-
- if(!m_queue.isEmpty())
- showInformationBox();
+ startLoginProcess();
}
void MainWindow::loginUsingCookies()
m_settingsDialog->show();
}
-void MainWindow::queueInformationBox(const QString &message, bool modal)
+void MainWindow::queueDialog(QDialog *dialog)
{
qDebug() << __PRETTY_FUNCTION__;
- NoteData *data = new NoteData(message, modal);
-
- m_queue.append(data);
+ if(dialog->isModal()) {
+ m_queue.insert(0, dialog);
+ } else {
+ m_queue.append(dialog);
+ }
if(m_queue.count() == 1)
- showInformationBox();
+ this->showInformationBox();
}
void MainWindow::saveCookies()
{
qDebug() << __PRETTY_FUNCTION__;
- NoteData *data = m_queue.takeFirst();
-
-#ifdef Q_WS_MAEMO_5
- QMaemo5InformationBox *msgBox = new QMaemo5InformationBox(this);
- QLabel *label = new QLabel(msgBox);
- label->setAlignment(Qt::AlignCenter);
- label->setText(data->message());
-
- if(data->modal()) {
- msgBox->setTimeout(QMaemo5InformationBox::NoTimeout);
- } else {
- msgBox->setTimeout(QMaemo5InformationBox::DefaultTimeout);
- }
-#else
- QMessageBox *msgBox = new QMessageBox(this);
- msgBox->button(QMessageBox::Ok);
- msgBox->setText(data->message());
- msgBox->setModal(data->modal());
-#endif
-
- connect(msgBox, SIGNAL(finished(int)),
- this, SLOT(noteFinished()));
-
- msgBox->show();
-
- m_queue.insert(0, data);
-
+ QDialog *dialog = m_queue.takeFirst();
+ connect(dialog, SIGNAL(finished(int)),
+ this, SLOT(dialogFinished(int)));
+ dialog->show();
+ m_queue.insert(0, dialog);
}
-void MainWindow::startLoginProcess(const QUrl &url)
+void MainWindow::startLoginProcess()
{
qDebug() << __PRETTY_FUNCTION__;
- buildWebView();
+ LoginDialog *loginDialog = new LoginDialog();
- LoginDialog loginDialog;
+ loginDialog->setObjectName(QString("loginDialog"));
emit fetchUsernameFromSettings();
- if(!m_cookieJar)
- m_cookieJar = new NetworkCookieJar(new QNetworkCookieJar(this));
-
- m_webView->page()->networkAccessManager()->setCookieJar(m_cookieJar);
-
- loginDialog.clearTextFields();
+ loginDialog->clearTextFields();
if(!m_email.isEmpty())
- loginDialog.setEmailField(m_email);
-
- if(loginDialog.exec() != QDialog::Accepted) {
- // if login dialog was canceled we need to stop processing webview
- m_webView->stop();
+ loginDialog->setEmailField(m_email);
- emit cancelLoginProcess();
- } else {
- loginDialog.userInput(m_email, m_password);
- emit saveUsername(m_email);
- m_webView->load(url);
- toggleProgressIndicator(true);
- m_refresh = true;
- }
+ queueDialog(loginDialog);
}
void MainWindow::toggleProgressIndicator(bool value)
#include "network/networkcookiejar.h"
#include "panelsidebar.h"
-#include "notedata.h"
class QGraphicsScene;
class QLabel;
******************************************************************************/
public:
/**
+ * @brief Builds information box with message.
+ *
+ * @param message Information message
+ * @param modal Modal = true, non-modal false
+ */
+ void buildInformationBox(const QString &message, bool modal=false);
+
+ /**
* @brief Clears cookie jar
*
*/
void loggedIn(bool logged);
/**
- * @brief Queues information box with message.
- *
- * @param message Information message
- * @param modal Modal = true, non-modal false
- */
- void queueInformationBox(const QString &message, bool modal=false);
-
- /**
* @brief Enable / disable auto centering button.
*
* @param enabled true if shoud be enabled, false otherwise
* @brief Public slot to intercept signal when old cerdentials are invalid or credentials
* doesn't exist yet
*
- * @param url Login page url
*/
- void startLoginProcess(const QUrl &url);
+ void startLoginProcess();
/**
* @brief Toggle progress indicator.
void grabZoomKeys(bool grab);
/**
+ * @brief Queues dialog/information box
+ *
+ * @param dialog Dialog to be added into queue
+ */
+ void queueDialog(QDialog *dialog);
+
+ /**
* @brief Set own location crosshair visibility
*
* @param visible
private slots:
/**
+ * @brief Slot to intercept signal when dialog/information note is processed
+ *
+ * @param status Status of the dialog
+ */
+ void dialogFinished(int status);
+
+ /**
* @brief Slot for drawing the fullscreen toggle button
*
* @param size Size of the screen
void loadDone(bool done);
/**
- * @brief Slot to intercept signal when information note is processed
- *
- */
- void noteFinished();
-
- /**
* @brief Slot to save cookies to settings
*
*/
SettingsDialog *m_settingsDialog; ///< Settings dialog
- QList<NoteData *> m_queue; ///< List type queue for information boxes
+ QList<QDialog *> m_queue;
};
#endif // MAINWINDOW_H