]> git.zarvox.org Git - imoo.git/commitdiff
Expose buddy icon changes
authorDrew Fisher <drew.m.fisher@gmail.com>
Tue, 13 May 2014 05:51:52 +0000 (22:51 -0700)
committerDrew Fisher <drew.m.fisher@gmail.com>
Tue, 13 May 2014 05:51:52 +0000 (22:51 -0700)
ribbon/ribbonblist.cpp
ribbon/ribbonblist.h

index f6ca007f1b6abcb0963fe3314d5bce3a3a1d98d4..7b6ef4510b9a064c745bb6aee750fc6ad786cad3 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <QDebug>
 #include <QDateTime>
+#include <QDir>
 
 RibbonBlist::RibbonBlist(RibbonManager* parent) : QObject((QObject*)parent)
 {
@@ -81,6 +82,29 @@ static void buddy_signed_off(PurpleBuddy* buddy, void* data)
                     m);
 }
 
+void RibbonBlist::on_buddy_icon_change(PurpleBuddy* buddy)
+{
+       qDebug() << purple_buddy_get_contact_alias(buddy) << "buddy icon changed";
+       QVariantMap m = RibbonAccounts::context(buddy);
+       PurpleBuddyIcon* bicon = purple_buddy_icons_find(
+               purple_buddy_get_account(buddy),
+               purple_buddy_get_name(buddy)
+               );
+       QString icon_abspath = QString::fromUtf8(purple_buddy_icon_get_full_path(bicon));
+       QDir state_dir(_manager->get_state_dir());
+       QString relative_path = state_dir.relativeFilePath(icon_abspath);
+       m["url"] = relative_path;
+       emit event(QString::fromUtf8("blist"),
+                  QString::fromUtf8("buddy_icon_changed"),
+                  m);
+}
+
+static void buddy_icon_changed(PurpleBuddy* buddy, void* data)
+{
+       RibbonBlist* blist = (RibbonBlist*)data;
+       blist->on_buddy_icon_change(buddy);
+}
+
 void RibbonBlist::init()
 {
        /* Create and load the buddylist */
@@ -96,4 +120,6 @@ void RibbonBlist::init()
                        PURPLE_CALLBACK(buddy_signed_off), this);
        purple_signal_connect(blist_handle, "buddy-status-changed", &handle,
                        PURPLE_CALLBACK(buddy_status_changed), this);
+       purple_signal_connect(blist_handle, "buddy-icon-changed", &handle,
+                       PURPLE_CALLBACK(buddy_icon_changed), this);
 }
index 87bcfe0fe64075f3ec3168411048f7d70b566434..e57696b3f567a86b77f75e2cf9e9493f7176dd69 100644 (file)
@@ -4,6 +4,7 @@
 #include <QObject>
 #include <QString>
 #include <QVariantMap>
+#include <purple.h>
 
 class RibbonManager;
 
@@ -14,6 +15,7 @@ public:
        ~RibbonBlist();
 
        void init();
+       void on_buddy_icon_change(PurpleBuddy* buddy);
 signals:
        void event(QString source, QString signal, QVariantMap context);