GlobalPresence::GlobalPresence(QObject *parent)
    : QObject(parent),
      m_connectionStatus(Tp::ConnectionStatusDisconnected),
      m_changingPresence(false)
{
    Tp::Presence unknown;
    unknown.setStatus(Tp::ConnectionPresenceTypeUnknown, QLatin1String("unknown"), QString());

    m_requestedPresence = KTp::Presence(unknown);
    m_currentPresence = KTp::Presence(unknown);
}
コード例 #2
0
void PresenceSource::onAccountCurrentPresenceChanged(
        const Tp::Presence &presence)
{
    // Update the data of this source
    setData("PresenceType", presenceTypeToString(presence.type()));
    setData("PresenceTypeID", presenceTypeToID(presence.type()));
    setData("PresenceStatus", presence.status());
    setData("PresenceStatusMessage", presence.statusMessage());

    // Required to trigger emission of update signal after changing data
    checkForUpdate();
}
void GlobalPresence::onCurrentPresenceChanged()
{
    /* basic idea of choosing global presence it to make it reflects the presence
     * over all accounts, usually this is used to indicates user the whole system
     * status.
     *
     * If there isn't any account, currentPresence should be offline, since there is nothing
     * online.
     * If there's only one account, then currentPresence should represent the presence
     * of this account.
     * If there're more than one accounts, the situation is more complicated.
     * There can be some accounts is still connecting (thus it's offline), and there can be
     * some accounts doesn't support the presence you're choosing. The user-chosen presence
     * priority will be higher than standard presence order.
     *
     * Example:
     * user choose to be online, 1 account online, 1 account offline, current presence
     * should be online, since online priority is higher than offline.
     * user chooses a presence supported by part of the account, current presence will be
     * the one chosen by user, to indicate there is at least one account supports it.
     * user choose a presence supported by no account, current presence will be chosen
     * from all accounts based on priority, and it also indicates there is no account support
     * the user-chosen presence.
     */
    Tp::Presence highestCurrentPresence = Tp::Presence::offline();
    Q_FOREACH(const Tp::AccountPtr &account, m_enabledAccounts->accounts()) {
        if (account->currentPresence().type() == m_requestedPresence.type()) {
            highestCurrentPresence = account->currentPresence();
            break;
        }

        if (Presence::sortPriority(account->currentPresence().type()) < Presence::sortPriority(highestCurrentPresence.type())) {
            highestCurrentPresence = account->currentPresence();
        }
    }

    qCDebug(KTP_COMMONINTERNALS) << "Current presence changed";

    if (highestCurrentPresence.type() != m_currentPresence.type() ||
            highestCurrentPresence.status() != m_currentPresence.status() ||
            highestCurrentPresence.statusMessage() != m_currentPresence.statusMessage()) {

        m_currentPresence = Presence(highestCurrentPresence);
        Q_EMIT currentPresenceChanged(m_currentPresence);
    }

    onChangingPresence();
}
コード例 #4
0
void AppletAvialabilityWidget::onCurrentPresenceChanged(const Tp::Presence &presence)
{
    currentIconId = presenceToIconId(presence);
    m_iconPresence->setImage(currentIconId);

    if (presence.type() == Tp::ConnectionPresenceTypeOffline)
        nextPresence = Tp::Presence(Tp::ConnectionPresenceTypeAvailable, "", "");
    else
        nextPresence = Tp::Presence(Tp::ConnectionPresenceTypeOffline, "", "");
}
コード例 #5
0
void AccountWrapper::onCurrentPresenceChanged(const Tp::Presence &presence)
{
    currentIconId = presenceToIconId(presence);
    m_iconPresence->setImage(currentIconId);

    if (presence.type() == Tp::ConnectionPresenceTypeOffline)
        nextPresence = Tp::Presence(Tp::ConnectionPresenceTypeAvailable, "", "");
    else
        nextPresence = Tp::Presence(Tp::ConnectionPresenceTypeOffline, "", "");
}
void GlobalPresence::onRequestedPresenceChanged()
{
    Tp::Presence highestRequestedPresence = Tp::Presence::offline();
    Q_FOREACH(const Tp::AccountPtr &account, m_enabledAccounts->accounts()) {
        if (Presence::sortPriority(account->requestedPresence().type()) < Presence::sortPriority(highestRequestedPresence.type())) {
            highestRequestedPresence = account->requestedPresence();
        }
    }

    if (highestRequestedPresence.type() != m_requestedPresence.type() ||
            highestRequestedPresence.status() != m_requestedPresence.status() ||
            highestRequestedPresence.statusMessage() != m_requestedPresence.statusMessage()) {
        m_requestedPresence = Presence(highestRequestedPresence);
        // current presence priority is affected by requested presence
        onCurrentPresenceChanged();
        Q_EMIT requestedPresenceChanged(m_requestedPresence);
    }

    onChangingPresence();
}
コード例 #7
0
QString AppletAvialabilityWidget::presenceToIconId(Tp::Presence presence)
{
    switch (presence.type())
    {
    case Tp::ConnectionPresenceTypeOffline:     return "icon-m-common-presence-offline";
    case Tp::ConnectionPresenceTypeAvailable:   return "icon-m-common-presence-online";
    case Tp::ConnectionPresenceTypeAway:        return "icon-m-common-presence-away";
    case Tp::ConnectionPresenceTypeBusy:        return "icon-m-common-presence-busy";
    case Tp::ConnectionPresenceTypeHidden:      return "icon-m-common-presence-unknown";
    default:                                    return "icon-m-common-presence-away";
    }
}
コード例 #8
0
ファイル: astralityutil.cpp プロジェクト: Akon32/leechcraft
	EntryStatus Status2Azoth (const Tp::Presence& p)
	{
		return EntryStatus (StateTelepathy2Azoth (p.type ()), p.statusMessage ());
	}
コード例 #9
0
void TelepathyClient::onContactPresenceChanged(const Tp::Presence &presence) {
    if (presence.type() == Tp::ConnectionPresenceTypeOffline)
        setState(Disconnected);
}