[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: playground/pim/akonaditelepathy
From: Rafael Roquetto <rafael () kdab ! com>
Date: 2010-09-22 15:36:38
Message-ID: 20100922153638.11EC0AC888 () svn ! kde ! org
[Download RAW message or body]
SVN commit 1178270 by rafaelroquetto:
Handling of presence status, type and message
M +3 -0 akonadi/CMakeLists.txt
M +20 -3 akonadi/akonaditelepathyresource.cpp
A akonadi/presencemessageattribute.cpp [License: LGPL]
A akonadi/presencemessageattribute.h [License: LGPL]
A akonadi/presencestatusattribute.cpp [License: LGPL]
A akonadi/presencestatusattribute.h [License: LGPL]
A akonadi/presencetypeattribute.cpp [License: LGPL]
A akonadi/presencetypeattribute.h [License: LGPL]
M +4 -0 akonadi/subscriptionattribute.cpp
M +2 -1 akonadi/subscriptionattribute.h
M +15 -12 telepathy/telepathyaccount.cpp
M +2 -2 telepathy/telepathyaccount.h
M +51 -3 telepathy/telepathycontact.cpp
M +19 -3 telepathy/telepathycontact.h
--- trunk/playground/pim/akonaditelepathy/akonadi/CMakeLists.txt #1178269:1178270
@@ -1,5 +1,8 @@
set( akonaditelepathyresource_SRCS
akonaditelepathyresource.cpp
+ presencemessageattribute.cpp
+ presencestatusattribute.cpp
+ presencetypeattribute.cpp
subscriptionattribute.cpp
telepathyaccountfetchjob.cpp
telepathycontactfetchjob.cpp
--- trunk/playground/pim/akonaditelepathy/akonadi/akonaditelepathyresource.cpp \
#1178269:1178270 @@ -22,6 +22,9 @@
#include "akonaditelepathyresource.h"
+#include "presencetypeattribute.h"
+#include "presencemessageattribute.h"
+#include "presencestatusattribute.h"
#include "subscriptionattribute.h"
#include "settings.h"
@@ -59,6 +62,9 @@
setName( "Akonadi + Telepathy" );
AttributeFactory::registerAttribute<SubscriptionAttribute>();
+ AttributeFactory::registerAttribute<PresenceTypeAttribute>();
+ AttributeFactory::registerAttribute<PresenceStatusAttribute>();
+ AttributeFactory::registerAttribute<PresenceMessageAttribute>();
}
AkonadiTelepathyResource::~AkonadiTelepathyResource()
@@ -399,12 +405,23 @@
/* attributes */
- SubscriptionAttribute *attr = item.attribute<SubscriptionAttribute>( \
Item::AddIfMissing ); + SubscriptionAttribute *sattr = \
item.attribute<SubscriptionAttribute>( Item::AddIfMissing );
if ( contact->subscription() == TelepathyContact::Subscribed )
- attr->setSubscription( SubscriptionAttribute::Subscribed );
+ sattr->setSubscription( SubscriptionAttribute::Subscribed );
else if ( contact->subscription() == TelepathyContact::Unsubscribed )
- attr->setSubscription( SubscriptionAttribute::Unsubscribed );
+ sattr->setSubscription( SubscriptionAttribute::Unsubscribed );
+ else if ( contact->subscription() == TelepathyContact::Ask )
+ sattr->setSubscription( SubscriptionAttribute::Ask );
+
+ PresenceTypeAttribute *tattr = item.attribute<PresenceTypeAttribute>( \
Item::AddIfMissing ); + tattr->setTypeVal( contact->presenceType() );
+
+ PresenceMessageAttribute *mattr = item.attribute<PresenceMessageAttribute>( \
Item::AddIfMissing ); + mattr->setMessage( contact->presenceMessage() );
+
+ PresenceStatusAttribute *stattr = item.attribute<PresenceStatusAttribute>( \
Item::AddIfMissing ); + stattr->setStatus( contact->presenceStatus() );
}
TelepathyAccount * AkonadiTelepathyResource::accountForCollection( const \
Akonadi::Collection &collection )
--- trunk/playground/pim/akonaditelepathy/akonadi/subscriptionattribute.cpp \
#1178269:1178270 @@ -50,6 +50,8 @@
return "subscribed";
else if ( mSubscription == Unsubscribed )
return "unsubscribed";
+ else if ( mSubscription == Ask )
+ return "ask";
return "unsubscribed";
}
@@ -60,6 +62,8 @@
mSubscription = Subscribed;
else if ( data == "unsubscribed" )
mSubscription = Unsubscribed;
+ else if ( data == "ask" )
+ mSubscription = Ask;
}
Akonadi::Attribute * SubscriptionAttribute::clone() const
--- trunk/playground/pim/akonaditelepathy/akonadi/subscriptionattribute.h \
#1178269:1178270 @@ -30,7 +30,8 @@
public:
enum Subscription {
Subscribed,
- Unsubscribed
+ Unsubscribed,
+ Ask
};
SubscriptionAttribute( Subscription subscription = Unsubscribed );
--- trunk/playground/pim/akonaditelepathy/telepathy/telepathyaccount.cpp \
#1178269:1178270 @@ -414,19 +414,22 @@
}
}
-void TelepathyAccount::onContactSubscribed(TelepathyContact *contact)
+void TelepathyAccount::onContactSubscriptionChanged(TelepathyContact *contact)
{
- qDebug() << "Contact" << contact->id() << "subscribed";
+ qDebug() << "Contact" << contact->id() << "subscription changed to"
+ << contact->subscription();
+ emit contactChanged(contact);
}
-void TelepathyAccount::onContactUnsubscribed(TelepathyContact *contact)
+void TelepathyAccount::onContactInfoUpdated(TelepathyContact *contact)
{
- qDebug() << "Contact" << contact->id() << "unsubscribed";
+ qDebug() << "Contact info updated for contact" << contact->id();
+ emit contactChanged(contact);
}
-void TelepathyAccount::onContactInfoUpdated(TelepathyContact *contact)
+void TelepathyAccount::onContactPresenceChanged(TelepathyContact *contact)
{
- qDebug() << "Contact info updated for contact" << contact->id();
+ qDebug() << "Presence changed for contact" << contact->id();
emit contactChanged(contact);
}
@@ -442,17 +445,17 @@
telepathyContact->setAccountId(id());
connect(telepathyContact,
- SIGNAL(subscribed(TelepathyContact*)),
- SLOT(onContactSubscribed(TelepathyContact*)));
+ SIGNAL(subscriptionChanged(TelepathyContact*)),
+ SLOT(onContactSubscriptionChanged(TelepathyContact*)));
connect(telepathyContact,
- SIGNAL(unsubscribed(TelepathyContact*)),
- SLOT(onContactUnsubscribed(TelepathyContact*)));
-
- connect(telepathyContact,
SIGNAL(infoUpdated(TelepathyContact*)),
SLOT(onContactInfoUpdated(TelepathyContact*)));
+ connect(telepathyContact,
+ SIGNAL(presenceChanged(TelepathyContact*)),
+ SLOT(onContactPresenceChanged(TelepathyContact*)));
+
qDebug() << "Added new contact to cache " << telepathyContact->id();
mContactList << telepathyContact;
--- trunk/playground/pim/akonaditelepathy/telepathy/telepathyaccount.h \
#1178269:1178270 @@ -71,9 +71,9 @@
void onAllKnownContactsChanged(const Tp::Contacts &added, const Tp::Contacts \
&removed);
void onGroupMembersChanged(const QString &group, const Tp::Contacts &added, \
const Tp::Contacts &removed); void onContactDestroyed(const Tp::ContactPtr \
&contact);
- void onContactSubscribed(TelepathyContact *contact);
- void onContactUnsubscribed(TelepathyContact *contact);
+ void onContactSubscriptionChanged(TelepathyContact *contact);
void onContactInfoUpdated(TelepathyContact *contact);
+ void onContactPresenceChanged(TelepathyContact *contact);
void contactInfoStub(uint contact, const Tp::ContactInfoFieldList \
&contactInfo);
--- trunk/playground/pim/akonaditelepathy/telepathy/telepathycontact.cpp \
#1178269:1178270 @@ -57,6 +57,10 @@
connect(mContact.data(),
SIGNAL(aliasChanged(const QString&)),
SLOT(onAliasChanged(const QString&)));
+
+ connect(mContact.data(),
+ SIGNAL(simplePresenceChanged(const QString&, uint, const QString &)),
+ SLOT(onPresenceChanged(const QString&, uint, const QString&)));
}
TelepathyContact::~TelepathyContact()
@@ -109,6 +113,8 @@
setSubscription( Subscribed );
else if ( mContact->subscriptionState() == Tp::Contact::PresenceStateNo )
setSubscription( Unsubscribed );
+ else if ( mContact->subscriptionState() == Tp::Contact::PresenceStateAsk )
+ setSubscription( Ask );
emit infoUpdated(this);
}
@@ -133,15 +139,27 @@
emit infoUpdated(this);
}
+void TelepathyContact::onPresenceChanged(const QString &status, uint type,
+ const QString &message)
+{
+ setPresenceStatus(status);
+ setPresenceType(type);
+ setPresenceMessage(message);
+
+ emit presenceChanged(this);
+}
+
void TelepathyContact::onSubscriptionStateChanged(Tp::Contact::PresenceState state)
{
if (state == Tp::Contact::PresenceStateYes) {
setSubscription( Subscribed );
- emit subscribed(this);
- updateInfo();
+ emit subscriptionChanged(this);
} else if (state == Tp::Contact::PresenceStateNo) {
setSubscription( Unsubscribed );
- emit unsubscribed(this);
+ emit subscriptionChanged(this);
+ } else if (state == Tp::Contact::PresenceStateAsk) {
+ setSubscription( Ask );
+ emit subscriptionChanged(this);
}
}
@@ -247,6 +265,21 @@
mSubscription = subscription;
}
+void TelepathyContact::setPresenceStatus(const QString &status)
+{
+ mPresenceStatus = status;
+}
+
+void TelepathyContact::setPresenceMessage(const QString &message)
+{
+ mPresenceMessage = message;
+}
+
+void TelepathyContact::setPresenceType(uint type)
+{
+ mPresenceType = type;
+}
+
QString TelepathyContact::id() const
{
return mId;
@@ -322,6 +355,21 @@
return mCountry;
}
+QString TelepathyContact::presenceStatus() const
+{
+ return mPresenceStatus;
+}
+
+QString TelepathyContact::presenceMessage() const
+{
+ return mPresenceMessage;
+}
+
+uint TelepathyContact::presenceType() const
+{
+ return mPresenceType;
+}
+
bool TelepathyContact::isReady() const
{
return mReady;
--- trunk/playground/pim/akonaditelepathy/telepathy/telepathycontact.h \
#1178269:1178270 @@ -36,7 +36,8 @@
public:
enum Subscription {
Unsubscribed,
- Subscribed
+ Subscribed,
+ Ask
};
TelepathyContact(Tp::ContactPtr contact,
@@ -59,6 +60,11 @@
QString zip() const;
QString country() const;
+ QString presenceStatus() const;
+ QString presenceMessage() const;
+
+ uint presenceType() const;
+
Subscription subscription() const;
bool isReady() const;
@@ -75,15 +81,17 @@
Q_SIGNALS:
void gotReady(const TelepathyContact *);
- void subscribed(TelepathyContact *);
- void unsubscribed(TelepathyContact *);
+ void subscriptionChanged(TelepathyContact *);
void infoUpdated(TelepathyContact *);
+ void presenceChanged(TelepathyContact *);
private Q_SLOTS:
void handleInfoChanged(const Tp::ContactInfoFieldList &);
void onRefreshInfo(Tp::PendingOperation *op);
void onSubscriptionStateChanged(Tp::Contact::PresenceState state);
void onAliasChanged(const QString &alias);
+ void onPresenceChanged(const QString &status, uint type,
+ const QString &message);
private:
void setId(const QString &id);
@@ -104,6 +112,9 @@
void setReady(bool ready);
void setAddressInfo(const QStringList &addr);
void setSubscription( Subscription subscription );
+ void setPresenceStatus(const QString &status);
+ void setPresenceMessage(const QString &message);
+ void setPresenceType(uint type);
Tp::ContactPtr mContact;
Tp::ContactInfoFieldList mInfo;
@@ -127,6 +138,11 @@
QString mAvatarToken;
QString mAccountId;
+ QString mPresenceStatus;
+ QString mPresenceMessage;
+
+ uint mPresenceType;
+
QImage mAvatar;
Subscription mSubscription;
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic