Changeset 16475

Show
Ignore:
Timestamp:
05/26/08 15:38:52 (5 months ago)
Author:
piotras
Message:

Send serialized object as message when general method is invoked

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midgard/core/midgard/src/midgard_core_object.h

    r16465 r16475  
    177177gboolean _midgard_object_violates_sitegroup(MgdObject *object); 
    178178 
     179/* D-Bus */ 
     180void _midgard_core_dbus_send_serialized_object(MgdObject *object, const gchar *path); 
    179181 
    180182/* ID lists */ 
  • trunk/midgard/core/midgard/src/midgard_dbus.c

    r16468 r16475  
    1919#include "midgard_dbus.h" 
    2020#include "midgard_core_object.h" 
     21#include "midgard_replicator.h" 
    2122 
    2223#define MIDGARD_DBUS_SERVICE    "org.midgardproject" 
     
    134135} 
    135136 
    136 void midgard_dbus_send(MidgardConnection *mgd, const gchar *path, const gchar *message
     137DBusGProxy *__get_bus_proxy(MidgardConnection *mgd, const gchar *path
    137138{ 
    138139        DBusGProxy *remote_object; 
    139         DBusGProxy *remote_introspection; 
    140140        GError *error = NULL; 
    141141 
     
    145145 
    146146        if(!new_path) 
    147                 return
     147                return NULL
    148148 
    149149        DBusGConnection *system_bus =  
     
    156156        } 
    157157         
    158         /* I have no idea (for a while), how to check if given path is correct */ 
    159         /* 
    160         GObject *registered =  
    161                 dbus_g_connection_lookup_g_object(system_bus, path); 
    162  
    163         if(registered == NULL) { 
    164                 g_warning("'%s' object is not registered", path); 
    165                 return; 
    166         } 
    167         */ 
    168  
    169158        remote_object = dbus_g_proxy_new_for_name_owner(system_bus, 
    170159                        MIDGARD_DBUS_SERVICE, 
     
    172161                        MIDGARD_DBUS_IFACE, &error); 
    173162 
    174         /* Return silently */ 
     163        g_free(new_path); 
     164 
    175165        if(error) { 
    176                  
    177                 g_free(new_path); 
     166 
    178167                g_error_free(error); 
     168                return NULL; 
     169        } 
     170 
     171        return remote_object; 
     172} 
     173 
     174void midgard_dbus_send(MidgardConnection *mgd, const gchar *path, const gchar *message) 
     175{ 
     176        DBusGProxy *remote_object = __get_bus_proxy(mgd, path); 
     177 
     178        if(!remote_object)  
    179179                return; 
    180         } 
    181  
    182         if(!remote_object) { 
    183                  
    184                 g_free(new_path); 
    185                 return; 
    186         } 
    187  
    188         /* Check if we can do itrospection */ 
    189         remote_introspection = dbus_g_proxy_new_for_name(system_bus, 
    190                         MIDGARD_DBUS_SERVICE, 
    191                         new_path, 
    192                         "org.freedesktop.DBus.Introspectable"); 
    193  
    194         g_free(new_path); 
    195  
    196         gchar *introspect_data; 
    197  
    198         if (!dbus_g_proxy_call(remote_introspection, "Introspect", &error, 
    199                                 G_TYPE_INVALID, 
    200                                 G_TYPE_STRING, &introspect_data, G_TYPE_INVALID)) { 
    201  
    202                 g_error_free(error); 
    203                 return; 
    204         } 
    205          
    206         g_debug("Introspect %s", introspect_data); 
    207         g_free(introspect_data); 
    208  
     180         
    209181        g_debug("%s, %s, %s",  
    210182                        dbus_g_proxy_get_bus_name(remote_object), 
     
    215187                        G_TYPE_STRING, message, G_TYPE_INVALID); 
    216188         
     189        return; 
     190} 
     191 
     192void _midgard_core_dbus_send_serialized_object(MgdObject *object, const gchar *path) 
     193{ 
     194        g_assert(object != NULL); 
     195        g_assert(path != NULL); 
     196 
     197        DBusGProxy *remote_object = __get_bus_proxy(object->dbpriv->mgd, path); 
     198 
     199        if(!remote_object) 
     200                return; 
     201 
     202        gchar *xml = midgard_replicator_serialize(NULL, object); 
     203 
     204        dbus_g_proxy_call_no_reply(remote_object, "notify", 
     205                        G_TYPE_STRING, xml, G_TYPE_INVALID); 
     206 
     207        g_free(xml); 
     208 
    217209        return; 
    218210} 
  • trunk/midgard/core/midgard/src/midgard_object.c

    r16472 r16475  
    6969#define __dbus_send(_obj, _action) \ 
    7070        gchar *_dbus_path = g_strconcat("/mgdschema/", \ 
    71         G_OBJECT_TYPE_NAME(G_OBJECT(_obj)), \ 
    72                        "/", _action, NULL); \ 
    73         midgard_dbus_send(_obj->dbpriv->mgd, _dbus_path, _obj->dbpriv->guid); \ 
     71               G_OBJECT_TYPE_NAME(G_OBJECT(_obj)), \ 
     72                "/", _action, NULL); \ 
     73        _midgard_core_dbus_send_serialized_object(_obj, _dbus_path); \ 
    7474        g_free(_dbus_path); 
    7575