[telepathy-qt4/master] Tp::Account: implement hasBeenOnline()
Simon McVittie
simon.mcvittie at collabora.co.uk
Wed Apr 22 05:34:16 PDT 2009
---
TelepathyQt4/account.cpp | 30 ++++++++++++++++++++++++++++++
TelepathyQt4/account.h | 3 +++
2 files changed, 33 insertions(+), 0 deletions(-)
diff --git a/TelepathyQt4/account.cpp b/TelepathyQt4/account.cpp
index ea1c9db..4afa1a7 100644
--- a/TelepathyQt4/account.cpp
+++ b/TelepathyQt4/account.cpp
@@ -81,6 +81,7 @@ struct Account::Private
bool valid;
bool enabled;
bool connectsAutomatically;
+ bool hasBeenOnline;
QString cmName;
QString protocol;
QString displayName;
@@ -107,6 +108,7 @@ Account::Private::Private(Account *parent)
valid(false),
enabled(false),
connectsAutomatically(false),
+ hasBeenOnline(false),
protocolInfo(0),
connectionStatus(ConnectionStatusDisconnected),
connectionStatusReason(ConnectionStatusReasonNoneSpecified)
@@ -320,6 +322,21 @@ QString Account::displayName() const
}
/**
+ * Check whether this account has ever been put online successfully.
+ *
+ * This property cannot change from true to false, only from false to true.
+ * When the account successfully goes online for the first time, or when it
+ * is detected that this has already happened, the firstOnline() signal is
+ * emitted.
+ *
+ * \return Whether the account has even been online.
+ */
+bool Account::hasBeenOnline() const
+{
+ return mPriv->hasBeenOnline;
+}
+
+/**
* Set this account display name.
*
* \param value Account display name.
@@ -839,6 +856,19 @@ void Account::Private::updateProperties(const QVariantMap &props)
emit parent->connectsAutomaticallyPropertyChanged(connectsAutomatically);
}
+ if (props.contains("HasBeenOnline") &&
+ !hasBeenOnline &&
+ qdbus_cast<bool>(props["HasBeenOnline"])) {
+ hasBeenOnline = true;
+ debug() << " HasBeenOnline changed to true";
+ // don't emit firstOnline unless we're already ready, that would be
+ // misleading - we'd emit it just before any already-used account
+ // became ready
+ if (parent->isReady()) {
+ emit parent->firstOnline();
+ }
+ }
+
if (props.contains("Parameters") &&
parameters != qdbus_cast<QVariantMap>(props["Parameters"])) {
parameters = qdbus_cast<QVariantMap>(props["Parameters"]);
diff --git a/TelepathyQt4/account.h b/TelepathyQt4/account.h
index 1b7aaf7..4213fd9 100644
--- a/TelepathyQt4/account.h
+++ b/TelepathyQt4/account.h
@@ -106,6 +106,8 @@ public:
bool connectsAutomatically() const;
PendingOperation *setConnectsAutomatically(bool value);
+ bool hasBeenOnline() const;
+
ConnectionStatus connectionStatus() const;
ConnectionStatusReason connectionStatusReason() const;
bool haveConnection() const;
@@ -165,6 +167,7 @@ Q_SIGNALS:
void validityChanged(bool);
void stateChanged(bool);
void connectsAutomaticallyPropertyChanged(bool);
+ void firstOnline();
void parametersChanged(const QVariantMap &);
void automaticPresenceChanged(const Tp::SimplePresence &) const;
void currentPresenceChanged(const Tp::SimplePresence &) const;
--
1.5.6.5
More information about the telepathy-commits
mailing list