summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaroline Chao <caroline.chao@digia.com>2014-09-23 09:19:09 +0200
committerCaroline Chao <caroline.chao@digia.com>2014-09-23 11:06:01 +0200
commit0db918a6e8a93ad73fcfbe1a97b7239b7e40f27c (patch)
tree975c72e4244296e127e759419e1549a1cbf5b5dd
parent2ccb54a7724b2f4c64f5a10664cb3c22a5817909 (diff)
Fetch conference data only once
Fetching the conference data each time we authenticate may create too much traffic as it causes other objects to be fetched too. Thus fetch the conference only once after a successful authentication. If no conference were fetched though, allow another conference query. Also, enable authentication only on devices. It may not always be necessary but this allows the application to resume properly after a potential undeterminated state (device went to sleep for example) Change-Id: I14f1b298be95dfb16a62daa480d6b0a995eced7f Reviewed-by: Niels Weber <niels.weber@digia.com>
-rw-r--r--src/applicationclient.cpp17
-rw-r--r--src/applicationclient.h1
2 files changed, 14 insertions, 4 deletions
diff --git a/src/applicationclient.cpp b/src/applicationclient.cpp
index 0887b23..4d5989a 100644
--- a/src/applicationclient.cpp
+++ b/src/applicationclient.cpp
@@ -56,6 +56,7 @@
#define BACKEND_ID QUOTE(TALK_SCHEDULE_BACKEND_ID)
ApplicationClient::ApplicationClient()
+ : init(true)
{
m_settings = new FileIO(this, "settings.txt");
@@ -145,10 +146,13 @@ void ApplicationClient::authenticationSuccess(EnginioReply *reply)
int timeout = (reply->data().value("expires_in").toInt() - 20*60)*1000;
timer->setSingleShot(true);
timer->start(timeout);
- QJsonObject query;
- query["objectType"] = QString::fromUtf8("objects.Conference");
- const EnginioReply *replyConf = m_client->query(query);
- connect(replyConf, SIGNAL(finished(EnginioReply*)), this, SLOT(queryConferenceReply(EnginioReply*)));
+ if (init) { // Query the conference only once
+ QJsonObject query;
+ query["objectType"] = QString::fromUtf8("objects.Conference");
+ const EnginioReply *replyConf = m_client->query(query);
+ connect(replyConf, SIGNAL(finished(EnginioReply*)), this, SLOT(queryConferenceReply(EnginioReply*)));
+ init = false;
+ }
}
void ApplicationClient::setCurrentConferenceId(const QString &newConfId)
@@ -167,6 +171,9 @@ void ApplicationClient::setCurrentConferenceId(const QString &newConfId)
void ApplicationClient::queryConferenceReply(EnginioReply *reply)
{
m_conferenceModel->onFinished(reply);
+ // If no conference were retrieved, allow conference query on next authentication
+ if (m_conferenceModel->rowCount() == 0)
+ init = true;
setCurrentConferenceId(m_settings->read());
emit conferencesModelChanged();
}
@@ -184,11 +191,13 @@ void ApplicationClient::setCurrentConferenceIndex(const int index)
bool ApplicationClient::eventFilter(QObject *object, QEvent *event)
{
+#if defined(Q_OS_ANDROID) || defined(Q_OS_IOS) || defined(Q_OS_WINPHONE)
if (event->type() == QEvent::ApplicationStateChange) {
if (QApplication::applicationState() == Qt::ApplicationActive) {
authenticate();
return true;
}
}
+#endif
return QObject::eventFilter(object, event);
}
diff --git a/src/applicationclient.h b/src/applicationclient.h
index 538d3fb..6492f3f 100644
--- a/src/applicationclient.h
+++ b/src/applicationclient.h
@@ -103,6 +103,7 @@ private:
QString m_currentConferenceId;
QQmlPropertyMap *m_details;
QTimer *timer;
+ bool init;
};
#endif // APPLICATIONCLIENT_H