Skip to content

Commit

Permalink
Added sendRegister() and setAccountActive() Functions along with chan…
Browse files Browse the repository at this point in the history
…ges to connect and disconnect functions.
  • Loading branch information
alok4nand committed Aug 19, 2016
1 parent 7f8e15a commit 1a625fb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 17 deletions.
49 changes: 32 additions & 17 deletions connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,6 @@ setConnectCallback(Tp::memFun(this, &Connection::doConnect));
setInspectHandlesCallback(Tp::memFun(this, &Connection::inspectHandles));
setRequestHandlesCallback(Tp::memFun(this, &Connection::requestHandles));
connect(this, SIGNAL(disconnected()), SLOT(doDisconnect()));

mConfigurationManagerInterface.connection().connect(
"cx.ring.Ring","/cx/ring/Ring/ConfigurationManager","cx.ring.Ring.ConfigurationManager",
"registrationStateChanged",this,SLOT(onRegistrationStateChanged(QString, QString)));
}

Connection::~Connection()
Expand All @@ -100,12 +96,31 @@ Connection::~Connection()

}

void Connection::sendRegister(bool enable)
{
qDebug() << Q_FUNC_INFO << enable ;
mConfigurationManagerInterface.call("sendRegister",mAccountID,enable);
}

void Connection::setAccountActive(bool enable)
{
qDebug() << Q_FUNC_INFO << enable ;
mConfigurationManagerInterface.call("setAccountActive",mAccountID,enable);
}

void Connection::doConnect(Tp::DBusError *error)
{
qDebug() << Q_FUNC_INFO << mAccountID;
setStatus(Tp::ConnectionStatusConnecting, Tp::ConnectionStatusReasonRequested);
mConfigurationManagerInterface.call("sendAccountActive",mAccountID,true);
mContactListInterface->setContactListState(Tp::ContactListStateWaiting);
sendRegister(true);
mContactListInterface->setContactListState(Tp::ContactListStateWaiting);

mConfigurationManagerInterface.connection().connect(
"cx.ring.Ring","/cx/ring/Ring/ConfigurationManager","cx.ring.Ring.ConfigurationManager",
"registrationStateChanged",this,SLOT(onRegistrationStateChanged(QString, QString)));
mConfigurationManagerInterface.connection().connect(
"cx.ring.Ring","/cx/ring/Ring/ConfigurationManager","cx.ring.Ring.ConfigurationManager",
"volatileAccountDetailsChanged",this,SLOT(onVolatileAccountDetailsChanged(QString, MapStringString)));
}

void Connection::onRegistrationStateChanged(QString accountID, QString state)
Expand All @@ -130,17 +145,17 @@ void Connection::onConnected()
setStatus(Tp::ConnectionStatusConnected, Tp::ConnectionStatusReasonRequested);
mSelfPresence.type = Tp::ConnectionPresenceTypeAvailable;
mSelfPresence.status = QLatin1String("available");
Tp::SimpleContactPresences presences;
presences[selfHandle()] = mSelfPresence;
mSimplePresenceInterface->setPresences(presences);
}
void Connection::doDisconnect()
{
qDebug() << Q_FUNC_INFO << mAccountID;
mConfigurationManagerInterface.call("setAccountActive",mAccountID,false);
mConfigurationManagerInterface.call("sendRegister",mAccountID,false);
setStatus(Tp::ConnectionStatusDisconnected, Tp::ConnectionStatusReasonRequested);
}
// Tp::SimpleContactPresences presences;
// presences[selfHandle()] = mSelfPresence;
// mSimplePresenceInterface->setPresences(presences);
}

void Connection::doDisconnect()
{
qDebug() << Q_FUNC_INFO << mAccountID;
sendRegister(false);
setStatus(Tp::ConnectionStatusDisconnected, Tp::ConnectionStatusReasonRequested);
}

uint Connection::setPresence(const QString &status, const QString &message, Tp::DBusError *error)
{
Expand Down
3 changes: 3 additions & 0 deletions connection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Tp::UIntList requestHandles(uint handleType, const QStringList &identifiers, Tp:
Tp::ContactAttributesMap getContactAttributes(const Tp::UIntList &handles, const QStringList &ifaces, Tp::DBusError *error);
uint ensureHandle(const QString& identifier);

void sendRegister(bool enable);
void setAccountActive(bool enable);

private slots:
void doConnect(Tp::DBusError *error);
void onRegistrationStateChanged(QString accountID, QString state);
Expand Down

0 comments on commit 1a625fb

Please sign in to comment.