]> git.zarvox.org Git - imoo.git/commitdiff
ribbon: extract blist into separate class
authorDrew Fisher <drew.m.fisher@gmail.com>
Sat, 26 Apr 2014 06:39:52 +0000 (23:39 -0700)
committerDrew Fisher <drew.m.fisher@gmail.com>
Sat, 26 Apr 2014 06:39:52 +0000 (23:39 -0700)
ribbon/ribbon.pro
ribbon/ribbonblist.cpp [new file with mode: 0644]
ribbon/ribbonblist.h [new file with mode: 0644]
ribbon/ribbonmanager.cpp
ribbon/ribbonmanager.h

index 2e19c40d0f4a8c1efd089c89efa2f359f427f4e9..8f5cd7aa42db92cc267e296c54c3c5af16b9fe0f 100644 (file)
@@ -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 (file)
index 0000000..6f45df1
--- /dev/null
@@ -0,0 +1,27 @@
+#include "ribbonblist.h"
+#include "ribbonmanager.h"
+
+#include <QDebug>
+
+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 (file)
index 0000000..87bcfe0
--- /dev/null
@@ -0,0 +1,25 @@
+#ifndef RIBBONBLIST_H
+#define RIBBONBLIST_H
+
+#include <QObject>
+#include <QString>
+#include <QVariantMap>
+
+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
index 074afd559d7c8c1f334c485f2c9016826ee8dd66..7a56a3b8c37585eec6916924588a8fadda5b1304 100644 (file)
@@ -1,5 +1,6 @@
 #include "ribbonmanager.h"
 #include "ribbonaccounts.h"
+#include "ribbonblist.h"
 #include "ribbonconversations.h"
 
 #include <QDebug>
@@ -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();
 }
 
index 58e460b59214bb477b9864f3dee675fa99882176..171dfefc09b9cdde0e1950441f5a1ed3dbb2518b 100644 (file)
@@ -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)
 };