Changeset 16476
- Timestamp:
- 05/26/08 15:40:09 (6 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/branch-1-9/midgard/core/midgard/src/midgard_core_object.h
r16460 r16476 151 151 gboolean _midgard_object_violates_sitegroup(MgdObject *object); 152 152 153 /* D-Bus */ 154 void _midgard_core_dbus_send_serialized_object(MgdObject *object, const gchar *path); 155 153 156 #endif /* _MIDGARD_CORE_OBJECT_H */ branches/branch-1-9/midgard/core/midgard/src/midgard_dbus.c
r16462 r16476 18 18 19 19 #include "midgard/midgard_dbus.h" 20 #include "midgard_core_object.h" 20 #include "src/midgard_core_object.h" 21 #include "midgard/midgard_replicator.h" 21 22 22 23 #define MIDGARD_DBUS_SERVICE "org.midgardproject" … … 134 135 } 135 136 136 void midgard_dbus_send(MidgardConnection *mgd, const gchar *path, const gchar *message)137 DBusGProxy *__get_bus_proxy(MidgardConnection *mgd, const gchar *path) 137 138 { 138 139 DBusGProxy *remote_object; 139 DBusGProxy *remote_introspection;140 140 GError *error = NULL; 141 141 … … 145 145 146 146 if(!new_path) 147 return ;147 return NULL; 148 148 149 149 DBusGConnection *system_bus = … … 156 156 } 157 157 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 169 158 remote_object = dbus_g_proxy_new_for_name_owner(system_bus, 170 159 MIDGARD_DBUS_SERVICE, … … 172 161 MIDGARD_DBUS_IFACE, &error); 173 162 174 /* Return silently */ 163 g_free(new_path); 164 175 165 if(error) { 176 177 g_free(new_path); 166 178 167 g_error_free(error); 168 return NULL; 169 } 170 171 return remote_object; 172 } 173 174 void 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) 179 179 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 209 181 g_debug("%s, %s, %s", 210 182 dbus_g_proxy_get_bus_name(remote_object), … … 215 187 G_TYPE_STRING, message, G_TYPE_INVALID); 216 188 189 return; 190 } 191 192 void _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->mgd->_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 217 209 return; 218 210 }
