Code Refactoring 31/37231/1 accepted/tizen/tv/20150323.091439 submit/tizen_tv/20150323.080316
authorKim Youngjin <yj21c.kim@samsung.com>
Mon, 23 Mar 2015 05:22:03 +0000 (14:22 +0900)
committerKim Youngjin <yj21c.kim@samsung.com>
Mon, 23 Mar 2015 05:22:03 +0000 (14:22 +0900)
Change-Id: I3de03fd6f1637cca01318196eb0e91db03d5efd9
Signed-off-by: Kim Youngjin <yj21c.kim@samsung.com>
include/bus.h
include/engine.h
packaging/org.tizen.homescreen-tv-ref.spec
src/bus.cpp
src/engine.cpp

index e59a8c1..c135902 100644 (file)
 #include <cp_config.h>
 
 
-class CBus {
+class CBaseBus {
+private:
+       struct SBaseBus* m;
+
+private:
+       /**
+       * Invoked function to register callbacks in interface table if bus is acquired.
+       *
+       * @param connection The GDBusConnection to a message bus
+       * @param name The name tha is requested to be owned
+       * @param data The bus object
+       */
+       static void sm_CbHandlerBusAcquired(GDBusConnection *conn, const gchar *name,
+               gpointer data);
+       /**
+       * Invoked when bus name is acquired and calls bus ready callback function
+       * to emit the SIGNAL_REFRESH signal to daemons.
+       *
+       * @param connection The GDBusConnection on which to acquired the name
+       * @param name The name being owned
+       * @param data The bus object
+       */
+       static void sm_CbHandlerNameAcquired(GDBusConnection *conn, const char *name,
+               gpointer data);
+       /**
+       * Invoked when bus name lost and calls bus end callback function.
+       *
+       * @param conn The GDBusConnection on which to acquire the name or NULL
+       *        if the connection was disconected
+       * @param name The name being owned
+       * @param data The bus object
+       */
+       static void sm_CbHandlerNameLost(GDBusConnection *conn, const char *name,
+               gpointer data);
+
+       /**
+       * Registers method and handler callback function.
+       *
+       * @param conn The GDBusConnection
+       * @param sender The unique bus name
+       * @param obj_path The object path that the method was invoked on
+       * @param if_name The D-Bus interface name the method was invoked on
+       * @param method The name of the method that was invoked
+       * @param param The message the remote caller would send
+       * @param iv The GDBusMethodInvocation object that can be used to return a value
+       * @param data The bus object
+       */
+       static void sm_CbMethodCall(GDBusConnection *conn,
+               const gchar *sender, const gchar *obj_path,
+               const gchar *if_name, const gchar *method,
+               GVariant *param, GDBusMethodInvocation *iv,
+               gpointer data);
+
+protected:
+       void t_OnBusAcquired(GDBusConnection *conn, const gchar *name);
+       void t_OnNameAcquired(GDBusConnection *conn, const char *name);
+       void t_OnNameLost(GDBusConnection *conn, const char *name);
+
+       virtual void t_OnReady(void);
+       virtual void t_OnEnd(void);
+
+public:
+       struct SCallback {
+               void *cookie;
+               void(*cbReady)(CBaseBus *bus, void *cookie);
+               void(*cbEnd)(CBaseBus *bus, void *cookie);
+       };
+
+protected:
+       virtual bool t_OnEvent(const char *method, GVariant *param) { return false; }
+
+private:
+       /**
+       * Initialize bus for sending the dynamic bar contents.
+       *
+       * Parses BUS_INTROSPECTION_XML data and creates bus.
+       *
+       * @param bus The bus object
+       * @return This function returns zero on success, or negative value
+       */
+       bool m_Create(void);
+       void m_Destroy(void);
+
+public:
+       CBaseBus() : m(0) {}
+       virtual ~CBaseBus() {}
+       bool FlagCreate(void) { return !!m; }
+
+       bool Create(const SCallback *callback);
+       virtual void Destroy(void);
+
+       bool SendSignal(const char *sig);
+};
+
+
+class CBus : public CBaseBus {
 public:
        enum EActionOp {
                ACTION_OP_LAUNCH_NONE,
@@ -89,77 +184,20 @@ public:
                const char *args;
        };
 
-       struct SCallback {
-               void (*ready)(CBus *bus, void *data);
-
+       struct SCallback : public CBaseBus::SCallback {
                bool (*cbAddLabel)(SLabel *opdata, void *data);
                bool (*cbAddAlbum)(SAlbum *opdata, SAction *act, void *data);
                bool (*cbAddContent)(SContent *opdata, SAction *act, void *data);
                bool (*cbAddPin)(SPin *opdata, SAction *act, void *data);
                bool (*cbDelContent)(const char *svcid, int ctnt_id, void *data);
                bool (*cbDelAll)(const char *svcid, bool reload, void *data);
-
-               void (*end)(CBus *bus, void *data);
        };
 
 private:
        struct SBus *m;
 
-private:
-       /**
-        * Invoked function to register callbacks in interface table if bus is acquired.
-        *
-        * @param connection The GDBusConnection to a message bus
-        * @param name The name tha is requested to be owned
-        * @param data The bus object
-        */
-       static void sm_CbHandlerBusAcquired(GDBusConnection *conn, const gchar *name,
-               gpointer data);
-       /**
-        * Invoked when bus name is acquired and calls bus ready callback function
-        * to emit the SIGNAL_REFRESH signal to daemons.
-        *
-        * @param connection The GDBusConnection on which to acquired the name
-        * @param name The name being owned
-        * @param data The bus object
-        */
-       static void sm_CbHandlerNameAcquired(GDBusConnection *conn, const char *name,
-                       gpointer data);
-       /**
-        * Invoked when bus name lost and calls bus end callback function.
-        *
-        * @param conn The GDBusConnection on which to acquire the name or NULL
-        *        if the connection was disconected
-        * @param name The name being owned
-        * @param data The bus object
-        */
-       static void sm_CbHandlerNameLost(GDBusConnection *conn, const char *name,
-                       gpointer data);
-
-       /**
-        * Registers method and handler callback function.
-        *
-        * @param conn The GDBusConnection
-        * @param sender The unique bus name
-        * @param obj_path The object path that the method was invoked on
-        * @param if_name The D-Bus interface name the method was invoked on
-        * @param method The name of the method that was invoked
-        * @param param The message the remote caller would send
-        * @param iv The GDBusMethodInvocation object that can be used to return a value
-        * @param data The bus object
-        */
-public:
-       static void sm_CbMethodCall(GDBusConnection *conn,
-               const gchar *sender, const gchar *obj_path,
-               const gchar *if_name, const gchar *method,
-               GVariant *param, GDBusMethodInvocation *iv,
-               gpointer data);
-
 protected:
-       void t_OnBusAcquired(GDBusConnection *conn, const gchar *name);
-       void t_OnNameAcquired(GDBusConnection *conn, const char *name);
-       void t_OnNameLost(GDBusConnection *conn, const char *name);
-
+       virtual bool t_OnEvent(const char *method, GVariant *param);
 
        bool t_EventAddLabel(GVariant *param);
        bool t_EventAddAlbum(GVariant *param);
@@ -168,8 +206,6 @@ protected:
        bool t_EventDelContent(GVariant *param);
        bool t_EventDelAllContent(GVariant *param);
 
-private:
-       bool _init_bus(void);
 public:
        //! Constructor
        CBus() : m(0) {}
@@ -179,12 +215,9 @@ public:
        bool FlagCreate(void) { return !!m; }
 
        //! Initializes bus.
-       bool Create(const SCallback *callback, void *data);
+       bool Create(const SCallback *callback);
        //! Finalizes bus.
        virtual void Destroy(void);
-
-       //! Invoked for sending the signal to bus.
-       bool SendSignal(const char *sig);
 };
 
 
index 9e74fe0..cedea03 100644 (file)
@@ -46,6 +46,7 @@ enum engine_dbar_content_type {
        ENGINE_DBAR_CONTENT_TYPE_MAX
 };
 
+
 struct engine *engine_init(void);
 void engine_fini(struct engine *eng);
 int engine_get_user_info(struct engine *eng, const char **name,
index 25e1195..b9ff47d 100644 (file)
@@ -9,6 +9,7 @@ Source1:   %{name}.service
 Source2:   %{name}.manifest
 
 BuildRequires: cmake
+BuildRequires: pkgconfig(application-common)
 BuildRequires: pkgconfig(capi-appfw-application)
 BuildRequires: pkgconfig(elementary)
 BuildRequires: pkgconfig(json-glib-1.0)
index c9f844c..c0f17ab 100644 (file)
 #include "dbg.h"
 
 
-#define ASSERT(exp)   if (!(exp))   { int *a = 0; *a = 5; }
+
+#define  ASSERT(exp)   if (!(exp)) { _DBG(#exp); int* a = 0; *a = 5; }
+
+#define _CREATE_BEGIN           int ___fail = 0;
+#define _CHECK(exp)             do {  if (!(exp)) { ___fail = 1; _DBG("_CHECK FAIL"); break; }
+#define _CHECK_FAIL             } while (0); if (___fail != 0) ___fail++; if (___fail > 2)
+#define _CREATE_END_AND_CATCH   if (___fail != 0)
+#define _WHEN_SUCCESS           if (___fail == 0)
+#define _COMMAND                if (___fail == 0)
+
+
 
 #define RESEND_TIMEOUT 5
 #define ADDRESS_BUF_MAX 128
 #define TLM_SEAT_ID "seat0"
 #define TLM_DBUS_ROOT_SOCKET_PATH "/var/run/tlm/dbus-sock"
 
-struct SBus {
-       guint owner_id;
-       GDBusNodeInfo *node;
+
+// CBaseBus Implement Code
+
+
+struct SBaseBus {
+       CBaseBus::SCallback cb;
+
+       guint            owner_id;
+       GDBusNodeInfo   *node;
        GDBusConnection *conn;
-       CBus::SCallback cbs;
-       void *cb_data;
 };
 
-void CBus::sm_CbHandlerBusAcquired(GDBusConnection *conn, const gchar *name,
-               gpointer data)
+
+void CBaseBus::sm_CbHandlerBusAcquired(GDBusConnection *conn, const gchar *name,
+       gpointer data)
 {
-       CBus *root = (CBus*)data;
+       CBaseBus *root = (CBaseBus*)data;
 
        if (root)
                root->t_OnBusAcquired(conn, name);
 }
 
 
-void CBus::sm_CbHandlerNameAcquired(GDBusConnection *conn, const char *name,
-               gpointer data)
+void CBaseBus::sm_CbHandlerNameAcquired(GDBusConnection *conn, const char *name,
+       gpointer data)
 {
-       CBus *root = (CBus*)data;
+       CBaseBus *root = (CBaseBus*)data;
 
        if (root)
                root->t_OnNameAcquired(conn, name);
 }
 
-void CBus::sm_CbHandlerNameLost(GDBusConnection *conn, const char *name,
-               gpointer data)
+void CBaseBus::sm_CbHandlerNameLost(GDBusConnection *conn, const char *name,
+       gpointer data)
 {
-       CBus *root = (CBus*)data;
+       CBaseBus *root = (CBaseBus*)data;
 
        if (root)
                root->t_OnNameLost(conn, name);
 }
 
-static const GDBusInterfaceVTable _bus_ifaces = {
-       CBus::sm_CbMethodCall,
-       NULL,
-       NULL
-};
 
-void CBus::t_OnBusAcquired(GDBusConnection *conn, const gchar *name)
+void CBaseBus::sm_CbMethodCall(GDBusConnection *conn,
+       const gchar *sender, const gchar *obj_path,
+       const gchar *if_name, const gchar *method,
+       GVariant *param, GDBusMethodInvocation *iv,
+       gpointer data)
+{
+       CBaseBus *bus = (CBaseBus*)data;
+       int r;
+
+       if (!data || !param || !iv) {
+               _ERR("Invalid arguments");
+               return;
+       }
+
+       r = bus->t_OnEvent(method, param);
+
+       g_dbus_method_invocation_return_value(iv, g_variant_new("(i)", r));
+}
+
+
+void CBaseBus::t_OnBusAcquired(GDBusConnection *conn, const gchar *name)
 {
        GError *err;
        guint regid;
+       static const GDBusInterfaceVTable _bus_ifaces = {
+               CBaseBus::sm_CbMethodCall,
+               NULL,
+               NULL
+       };
 
        if (!conn) {
                _ERR("Invalid argument");
@@ -83,23 +118,22 @@ void CBus::t_OnBusAcquired(GDBusConnection *conn, const gchar *name)
 
        err = NULL;
        regid = g_dbus_connection_register_object(conn,
-                       BUS_OBJECT_PATH,
-                       m->node->interfaces[0],
-                       &_bus_ifaces,
-                       this, NULL, &err);
+               BUS_OBJECT_PATH,
+               m->node->interfaces[0],
+               &_bus_ifaces,
+               this, NULL, &err);
        if (!regid) {
                _ERR("register object failed: %s", err ? err->message : "");
                g_error_free(err);
-               if (!m->cbs.end)
-                       return;
-               m->cbs.end(this, m->cb_data);
+
+               t_OnEnd();
                return;
        }
 
        m->conn = conn;
 }
 
-void CBus::t_OnNameAcquired(GDBusConnection *conn, const char *name)
+void CBaseBus::t_OnNameAcquired(GDBusConnection *conn, const char *name)
 {
        if (!conn) {
                _ERR("Invalid argument");
@@ -107,13 +141,12 @@ void CBus::t_OnNameAcquired(GDBusConnection *conn, const char *name)
        }
 
        _DBG("Name acquired: %s", name);
-       
-       if (!m->cbs.ready)
-               return;
-       m->cbs.ready(this, m->cb_data);
+
+       t_OnReady();
 }
 
-void CBus::t_OnNameLost(GDBusConnection *conn, const char *name)
+
+void CBaseBus::t_OnNameLost(GDBusConnection *conn, const char *name)
 {
        if (!conn) {
                _ERR("Invalid argument");
@@ -121,24 +154,122 @@ void CBus::t_OnNameLost(GDBusConnection *conn, const char *name)
        }
 
        _DBG("Name lost: %s", name);
-       if (!m->cbs.end)
-               return;
+       t_OnEnd();
+}
+
 
-       m->cbs.end(this, m->cb_data);
+void CBaseBus::t_OnReady(void)
+{
+       if (m->cb.cbReady)
+               m->cb.cbReady(this, m->cb.cookie);
 }
 
 
+void CBaseBus::t_OnEnd(void)
+{
+       if (m->cb.cbEnd) {
+               m->cb.cbEnd(this, m->cb.cookie);
+       }
+}
 
 
+bool CBaseBus::m_Create(void)
+{
+       guint owner_id;
+       GDBusNodeInfo *node;
+       GError *err;
 
+       err = NULL;
+       node = g_dbus_node_info_new_for_xml(BUS_INTROSPECTION_XML, &err);
+       if (!node) {
+               _ERR("get node failed: %s", err->message);
+               g_error_free(err);
+               return false;
+       }
+
+       _CREATE_BEGIN{
+               _CHECK(node = g_dbus_node_info_new_for_xml(BUS_INTROSPECTION_XML, &err))
+               _CHECK(node->interfaces)
+               _CHECK(owner_id = g_bus_own_name(BUS_TYPE, BUS_NAME,
+               G_BUS_NAME_OWNER_FLAGS_NONE,
+               sm_CbHandlerBusAcquired,
+               sm_CbHandlerNameAcquired,
+               sm_CbHandlerNameLost, this, NULL))
+
+               _CHECK_FAIL{ /* */ }
+               _CHECK_FAIL{ /* */ }
+               _CHECK_FAIL{ g_object_unref(node); }
+       } _CREATE_END_AND_CATCH{ return false; }
+
+       m->node = node;
+       m->owner_id = owner_id;
+
+       return true;
+}
+
+
+void CBaseBus::m_Destroy(void)
+{
+       g_dbus_node_info_unref(m->node);
+       g_bus_unown_name(m->owner_id);
+}
+
+
+bool CBaseBus::Create(const SCallback *callback)
+{
+       ASSERT(!m);
+
+       m = new SBaseBus;
+       if (!m)
+               return false;
 
+       if (!m_Create()) {
+               delete m;
+               m = NULL;
+               return false;
+       }
+       m->cb = *callback;
 
+       return true;
+}
 
 
+void CBaseBus::Destroy(void)
+{
+       ASSERT(m);
 
+       m_Destroy();
+       delete m;
+       m = NULL;
+}
 
 
+bool CBaseBus::SendSignal(const char *sig)
+{
+       ASSERT(m);
+       ASSERT(sig);
 
+       GError *err = NULL;
+       gboolean r;
+
+       r = g_dbus_connection_emit_signal(m->conn, NULL,
+               BUS_OBJECT_PATH, BUS_INTERFACE, sig, NULL, &err);
+       if (r == FALSE) {
+               _ERR("emit %s signal failed: %s\n",
+                       sig, err ? err->message : NULL);
+               g_error_free(err);
+               return false;
+       }
+
+       return true;
+}
+
+
+// CBus Implement Code
+
+struct SBus {
+       CBus::SCallback cb;
+};
 
 
 /**
@@ -353,91 +484,34 @@ static inline void _free_content_array(struct CBus::SContent contents[],
 }
 
 
-
-void CBus::sm_CbMethodCall(GDBusConnection *conn,
-               const gchar *sender, const gchar *obj_path,
-               const gchar *if_name, const gchar *method,
-               GVariant *param, GDBusMethodInvocation *iv,
-               gpointer data)
+bool CBus::t_OnEvent(const char *method, GVariant *param)
 {
-       CBus *bus = (CBus*)data;
-       int r;
-
-       if (!data || !param || !iv) {
+       if (!param) {
                _ERR("Invalid arguments");
-               return;
+               return false;
        }
        
-       r = -1;
 
        if (strcmp(BUS_METHOD_ADD_ALBUM, method) == 0) {
-               r = bus->t_EventAddAlbum(param);
+               t_EventAddAlbum(param);
        }
        else if (strcmp(BUS_METHOD_ADD_LABEL, method) == 0) {
-               r = bus->t_EventAddLabel(param);
+               t_EventAddLabel(param);
        }
        else if (strcmp(BUS_METHOD_ADD_CONTENT, method) == 0) {
-               r = bus->t_EventAddContent(param);
+               t_EventAddContent(param);
        }
        else if (strcmp(BUS_METHOD_ADD_PIN, method) == 0) {
-               r = bus->t_EventAddPin(param);
+               t_EventAddPin(param);
        }
        else if (strcmp(BUS_METHOD_DEL_CONTENT, method) == 0) {
-               r = bus->t_EventDelAllContent(param);
+               t_EventDelAllContent(param);
        }
        else if (strcmp(BUS_METHOD_DEL_ALL, method) == 0) {
-               r = bus->t_EventDelAllContent(param);
+               t_EventDelAllContent(param);
        }
        
-       g_dbus_method_invocation_return_value(iv, g_variant_new("(i)", r));
-}
-
-/**
- * Initialize bus for sending the dynamic bar contents.
- *
- * Parses BUS_INTROSPECTION_XML data and creates bus.
- *
- * @param bus The bus object
- * @return This function returns zero on success, or negative value
- */
-bool CBus::_init_bus(void)
-{
-       guint owner_id;
-       GDBusNodeInfo *node;
-       GError *err;
-       
-       err = NULL;
-       node = g_dbus_node_info_new_for_xml(BUS_INTROSPECTION_XML, &err);
-       if (!node) {
-               _ERR("get node failed: %s", err->message);
-               g_error_free(err);
-               return false;
-       }
-
-       if (!node->interfaces) {
-               _ERR("no interface received");
-               goto unref_node;
-       }
-
-       owner_id = g_bus_own_name(BUS_TYPE, BUS_NAME,
-                       G_BUS_NAME_OWNER_FLAGS_NONE,
-                       sm_CbHandlerBusAcquired, 
-                       sm_CbHandlerNameAcquired,
-                       sm_CbHandlerNameLost, this, NULL);
-       if (!owner_id) {
-               _ERR("bus own name failed");
-               goto unref_node;
-       }
-
-       m->node = node;
-       m->owner_id = owner_id;
-
        return true;
-
-unref_node:
-       g_object_unref(node);
-
-       return false;
 }
 
 
@@ -446,7 +520,7 @@ bool CBus::t_EventAddLabel(GVariant *param)
        SLabel data;
        GVariantIter iter;
 
-       if (!m->cbs.cbAddLabel) {
+       if (!m->cb.cbAddLabel) {
                _ERR("Invalid argument");
                return false;
        }
@@ -466,7 +540,7 @@ bool CBus::t_EventAddLabel(GVariant *param)
                return false;
        }
 
-       return m->cbs.cbAddLabel(&data, m->cb_data);
+       return m->cb.cbAddLabel(&data, m->cb.cookie);
 }
 
 
@@ -477,7 +551,7 @@ bool CBus::t_EventAddAlbum(GVariant *param)
        GVariantIter iter;
        int r;
 
-       if (!m->cbs.cbAddAlbum || !param) {
+       if (!m->cb.cbAddAlbum || !param) {
                _ERR("Invalid argument");
                return false;
        }
@@ -508,7 +582,7 @@ bool CBus::t_EventAddAlbum(GVariant *param)
        act.actor = _get_iter_string(&iter);
        act.args = _get_iter_string(&iter);
 
-       r = m->cbs.cbAddAlbum(&data, &act, m->cb_data);
+       r = m->cb.cbAddAlbum(&data, &act, m->cb.cookie);
        _free_content_array(data.contents, BUS_DATA_ALBUM_CONTENT_MAX);
 
        return r;
@@ -521,7 +595,7 @@ bool CBus::t_EventAddContent(GVariant *param)
        struct SAction act;
        GVariantIter iter;
 
-       if (!m->cbs.cbAddContent || !param) {
+       if (!m->cb.cbAddContent || !param) {
                _ERR("Invalid argument");
                return false;
        }
@@ -551,7 +625,7 @@ bool CBus::t_EventAddContent(GVariant *param)
        act.actor = _get_iter_string(&iter);
        act.args = _get_iter_string(&iter);
 
-       return m->cbs.cbAddContent(&data, &act, m->cb_data);
+       return m->cb.cbAddContent(&data, &act, m->cb.cookie);
 }
 
 
@@ -561,7 +635,7 @@ bool CBus::t_EventAddPin(GVariant *param)
        struct SAction act;
        GVariantIter iter;
 
-       if (!m->cbs.cbAddPin || !param) {
+       if (!m->cb.cbAddPin || !param) {
                _ERR("Invalid argument");
                return false;
        }
@@ -587,7 +661,7 @@ bool CBus::t_EventAddPin(GVariant *param)
        act.actor = _get_iter_string(&iter);
        act.args = _get_iter_string(&iter);
 
-       return m->cbs.cbAddPin(&data, &act, m->cb_data);
+       return m->cb.cbAddPin(&data, &act, m->cb.cookie);
 }
 
 
@@ -597,7 +671,7 @@ bool CBus::t_EventDelContent(GVariant *param)
        const gchar *svcid;
        int ctnt_id;
 
-       if (!m->cbs.cbDelContent || !param) {
+       if (!m->cb.cbDelContent || !param) {
                _ERR("Invalid argument");
                return false;
        }
@@ -615,7 +689,7 @@ bool CBus::t_EventDelContent(GVariant *param)
                return false;
        }
 
-       return m->cbs.cbDelContent(svcid, ctnt_id, m->cb_data);
+       return m->cb.cbDelContent(svcid, ctnt_id, m->cb.cookie);
 }
 
 
@@ -625,7 +699,7 @@ bool CBus::t_EventDelAllContent(GVariant *param)
        const gchar *svcid;
        bool reload;
 
-       if (!m->cbs.cbDelAll || !param) {
+       if (!m->cb.cbDelAll || !param) {
                _ERR("Invalid argument");
                return false;
        }
@@ -639,11 +713,11 @@ bool CBus::t_EventDelAllContent(GVariant *param)
 
        reload = _get_iter_boolean(&iter);
 
-       return m->cbs.cbDelAll(svcid, reload, m->cb_data);
+       return m->cb.cbDelAll(svcid, reload, m->cb.cookie);
 }
 
 
-bool CBus::Create(const SCallback *cbs, void *data)
+bool CBus::Create(const SCallback *cb)
 {
        ASSERT(!FlagCreate());
 
@@ -653,83 +727,29 @@ bool CBus::Create(const SCallback *cbs, void *data)
                return false;
        }
 
-       if (!_init_bus()) {
+       if (!CBaseBus::Create(cb)) {
                delete m;
                m = NULL;
                return false;
        }
 
-       m->cbs     = *cbs;
-       m->cb_data = data;
+       m->cb = *cb;
 
        return true;
 }
 
+
 void CBus::Destroy(void)
 {
        ASSERT(FlagCreate());
 
-       g_dbus_node_info_unref(m->node);
-       g_bus_unown_name(m->owner_id);
+       CBaseBus::Destroy();
        delete m;
        m = NULL;
 }
 
-bool CBus::SendSignal(const char *sig)
-{
-       ASSERT(FlagCreate());
-
-       GError *err;
-       gboolean r;
-
-       if (!sig) {
-               _ERR("Invalid argument\n");
-               return false;
-       }
-
-       err = NULL;
-       r = g_dbus_connection_emit_signal(m->conn, NULL,
-                       BUS_OBJECT_PATH, BUS_INTERFACE, sig, NULL, &err);
-       if (r == FALSE) {
-               _ERR("emit %s signal failed: %s\n",
-                               sig, err ? err->message : NULL);
-               g_error_free(err);
-               return false;
-       }
-
-       return true;
-}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-
-
-
-
-
-
-
 
+// CClientBus Implemente Code
 
 
 struct SClientBus {
index 929bac4..c3a847e 100644 (file)
@@ -717,12 +717,12 @@ static void _unload_config(struct engine *eng)
        _unload_ubar_items(eng);
 }
 
-static void _bus_ready(CBus *bus, void *data)
+static void _bus_ready(CBaseBus *bus, void *data)
 {
        bus->SendSignal(BUS_SIGNAL_REFRESH);
 }
 
-static void _bus_end(CBus *bus, void *data)
+static void _bus_end(CBaseBus *bus, void *data)
 {
 }
 
@@ -1274,24 +1274,25 @@ struct engine *engine_init(void)
        struct engine *eng;
        CBus *bus;
        int r;
-       CBus::SCallback cb;
 
-       cb.ready        = _bus_ready;
+       CBus::SCallback cb;
+       cb.cbReady      = _bus_ready;
+       cb.cbEnd        = _bus_end;
 
        cb.cbAddLabel   = _bus_add_label;
        cb.cbAddAlbum   = _bus_add_album;
        cb.cbAddContent = _bus_add_content;
-       cb.cbAddPin     = &_bus_add_pin;
+       cb.cbAddPin     = _bus_add_pin;
 
        cb.cbDelContent = _bus_del_ctnt;
        cb.cbDelAll     = _bus_del_ctnt_all;
-       cb.end          = _bus_end;
 
        eng = (struct engine *)calloc(1, sizeof(*eng));
        if (!eng) {
                _ERR("calloc failed");
                return NULL;
        }
+       cb.cookie = eng;
 
        r = _load_user(eng);
        if (r != 0) {
@@ -1311,7 +1312,7 @@ struct engine *engine_init(void)
                free(eng);
                return NULL;
        }
-       bus->Create(&cb, eng);
+       bus->Create(&cb);
        if (!bus) {
                delete bus;
                _unload_config(eng);