From: Drew Fisher Date: Tue, 13 May 2014 05:51:52 +0000 (-0700) Subject: Expose buddy icon changes X-Git-Url: http://git.zarvox.org/shortlog/static/%7Bwebsite%7D?a=commitdiff_plain;h=8a3881be268198b26d6d298698b68e479e4a00aa;p=imoo.git Expose buddy icon changes --- diff --git a/ribbon/ribbonblist.cpp b/ribbon/ribbonblist.cpp index f6ca007..7b6ef45 100644 --- a/ribbon/ribbonblist.cpp +++ b/ribbon/ribbonblist.cpp @@ -4,6 +4,7 @@ #include #include +#include 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); } diff --git a/ribbon/ribbonblist.h b/ribbon/ribbonblist.h index 87bcfe0..e57696b 100644 --- a/ribbon/ribbonblist.h +++ b/ribbon/ribbonblist.h @@ -4,6 +4,7 @@ #include #include #include +#include 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);