Skip to content
Snippets Groups Projects
Commit ed960fce authored by aviau's avatar aviau Committed by Alexandre Viau
Browse files

presence: load tracked buddies

Load track buddies when creating an account. We do this so that the
state of contactmethods is as up to date as possible.

Otherwise, restarting the client would show the contacts as offline
because we wait for callbacks of the daemon to set the presence status.

This loads the status of all currently tracked buddies.

Tuleap: #1379
Change-Id: I047900bcbec9196f66d0d425e573f64090e3eba7
parent 0f6898c9
No related branches found
No related tags found
No related merge requests found
......@@ -35,6 +35,7 @@
#include "dbus/configurationmanager.h"
#include "dbus/callmanager.h"
#include "dbus/videomanager.h"
#include "dbus/presencemanager.h"
#include "globalinstances.h"
#include "interfaces/accountlistcolorizeri.h"
#include "certificate.h"
......@@ -162,6 +163,15 @@ Account* Account::buildExistingAccountFromId(const QByteArray& _accountId)
}
}
//Load the tracked buddies
const VectorMapStringString subscriptions = PresenceManager::instance().getSubscriptions(a->id());
foreach(auto subscription, subscriptions){
ContactMethod* tracked_buddy = PhoneDirectoryModel::instance().getNumber(subscription["Buddy"], a);
bool tracked_buddy_present = subscription["Status"].compare("Online") == 0;
tracked_buddy->setTracked(true);
tracked_buddy->setPresent(tracked_buddy_present);
}
return a;
} //buildExistingAccountFromId
......
......@@ -31,6 +31,7 @@
#include "itemdataroles.h"
#include "uri.h"
class Account;
class AccountPrivate;
class Person;
class Call;
class ContactMethodPrivate;
......@@ -54,6 +55,7 @@ public:
friend class PhoneDirectoryModelPrivate;
friend class LocalTextRecordingCollection;
friend class CallPrivate;
friend class AccountPrivate;
enum class Role {
Uri = static_cast<int>(Ring::Role::UserRole) + 1000,
......@@ -149,6 +151,7 @@ public:
void setUid (const QString& uri );
bool setType (ContactMethod::Type t );
void setLastUsed (time_t t );
void setPresent (bool present );
//Mutator
Q_INVOKABLE void addCall(Call* call);
......@@ -172,7 +175,6 @@ protected:
virtual ~ContactMethod();
//Private setters
void setPresent(bool present);
void setPresenceMessage(const QString& message);
//PhoneDirectoryModel mutator
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment