From: Drew Fisher Date: Sat, 26 Apr 2014 06:39:52 +0000 (-0700) Subject: ribbon: extract blist into separate class X-Git-Url: http://git.zarvox.org/static/%7B%7B%20url_for%28%27main.logout_page%27%29%20%7D%7D?a=commitdiff_plain;h=8e8e4771387b6c3b58470670409c880d46129702;p=imoo.git ribbon: extract blist into separate class --- diff --git a/ribbon/ribbon.pro b/ribbon/ribbon.pro index 2e19c40..8f5cd7a 100644 --- a/ribbon/ribbon.pro +++ b/ribbon/ribbon.pro @@ -19,6 +19,7 @@ QMAKE_CXXFLAGS += -Werror -W HEADERS += ribbonmanager.h \ ribbonaccount.h \ ribbonaccounts.h \ + ribbonblist.h \ ribbonconversations.h \ ribbonserver.h \ ribbonsocket.h @@ -26,6 +27,7 @@ HEADERS += ribbonmanager.h \ SOURCES += ribbonmanager.cpp \ ribbonaccount.cpp \ ribbonaccounts.cpp \ + ribbonblist.cpp \ ribbonconversations.cpp \ ribbonserver.cpp \ ribbonsocket.cpp \ diff --git a/ribbon/ribbonblist.cpp b/ribbon/ribbonblist.cpp new file mode 100644 index 0000000..6f45df1 --- /dev/null +++ b/ribbon/ribbonblist.cpp @@ -0,0 +1,27 @@ +#include "ribbonblist.h" +#include "ribbonmanager.h" + +#include + +RibbonBlist::RibbonBlist(RibbonManager* parent) : QObject((QObject*)parent) +{ + _manager = parent; +} + +RibbonBlist::~RibbonBlist() +{ +} + +static void buddy_signed_on(PurpleBuddy* buddy, void* data) +{ + Q_UNUSED(data); + qDebug() << purple_buddy_get_contact_alias(buddy) << "signed on"; +} + +void RibbonBlist::init() +{ + static int handle; + void *blist_handle = purple_blist_get_handle(); + purple_signal_connect(blist_handle, "buddy-signed-on", &handle, + PURPLE_CALLBACK(buddy_signed_on), NULL); +} diff --git a/ribbon/ribbonblist.h b/ribbon/ribbonblist.h new file mode 100644 index 0000000..87bcfe0 --- /dev/null +++ b/ribbon/ribbonblist.h @@ -0,0 +1,25 @@ +#ifndef RIBBONBLIST_H +#define RIBBONBLIST_H + +#include +#include +#include + +class RibbonManager; + +class RibbonBlist : public QObject { + Q_OBJECT +public: + RibbonBlist(RibbonManager* parent = 0); + ~RibbonBlist(); + + void init(); +signals: + void event(QString source, QString signal, QVariantMap context); + +private: + RibbonManager* _manager; + +}; + +#endif // RIBBONBLIST_H diff --git a/ribbon/ribbonmanager.cpp b/ribbon/ribbonmanager.cpp index 074afd5..7a56a3b 100644 --- a/ribbon/ribbonmanager.cpp +++ b/ribbon/ribbonmanager.cpp @@ -1,5 +1,6 @@ #include "ribbonmanager.h" #include "ribbonaccounts.h" +#include "ribbonblist.h" #include "ribbonconversations.h" #include @@ -210,28 +211,22 @@ static void signed_on(PurpleConnection *gc, void* data) printf("Account connected: \"%s\" (%s)\n", purple_account_get_username(account), purple_account_get_protocol_id(account)); } -static void buddy_signed_on(PurpleBuddy* buddy, void* data) -{ - Q_UNUSED(data); - qDebug() << purple_buddy_get_contact_alias(buddy) << "signed on"; -} - static void connect_to_signals(void) { static int handle; - void *blist_handle = purple_blist_get_handle(); void *connections_handle = purple_connections_get_handle(); purple_signal_connect(connections_handle, "signed-on", &handle, PURPLE_CALLBACK(signed_on), NULL); - purple_signal_connect(blist_handle, "buddy-signed-on", &handle, - PURPLE_CALLBACK(buddy_signed_on), NULL); } RibbonManager::RibbonManager(QObject* parent) : QObject(parent) { _accounts = new RibbonAccounts(this); + _blist = new RibbonBlist(this); _conversations = new RibbonConversations(this); + QObject::connect(_blist, SIGNAL(event(QString,QString,QVariantMap)), + this, SIGNAL(event(QString,QString,QVariantMap))); QObject::connect(_conversations, SIGNAL(event(QString,QString,QVariantMap)), this, SIGNAL(event(QString,QString,QVariantMap))); } @@ -270,6 +265,7 @@ void RibbonManager::init(void) connect_to_signals(); // TODO: add more children init() calls when refactoring + _blist->init(); _conversations->init(); } diff --git a/ribbon/ribbonmanager.h b/ribbon/ribbonmanager.h index 58e460b..171dfef 100644 --- a/ribbon/ribbonmanager.h +++ b/ribbon/ribbonmanager.h @@ -7,6 +7,7 @@ // Forward declarations class RibbonAccounts; +class RibbonBlist; class RibbonConversations; #define UI_ID "ribbon" @@ -20,6 +21,7 @@ public: // Called to configure libpurple and connect to purple signals void init(void); RibbonAccounts* accounts() { return _accounts; } + RibbonBlist* blist() { return _blist; } RibbonConversations* conversations() { return _conversations; } // Exposes purple_get_version() @@ -33,6 +35,7 @@ signals: private: RibbonAccounts* _accounts; + RibbonBlist* _blist; RibbonConversations* _conversations; Q_DISABLE_COPY(RibbonManager) };