From: <mar...@us...> - 2014-03-12 10:39:04
|
Revision: 4276 http://sourceforge.net/p/synce/code/4276 Author: mark_ellis Date: 2014-03-12 10:38:58 +0000 (Wed, 12 Mar 2014) Log Message: ----------- When a device disconnects, remove it from dbus before doing anything else Modified Paths: -------------- trunk/core/dccm/synce-device-internal.h trunk/core/dccm/synce-device-legacy.c trunk/core/dccm/synce-device.c Modified: trunk/core/dccm/synce-device-internal.h =================================================================== --- trunk/core/dccm/synce-device-internal.h 2014-03-11 13:07:51 UTC (rev 4275) +++ trunk/core/dccm/synce-device-internal.h 2014-03-12 10:38:58 UTC (rev 4276) @@ -94,6 +94,7 @@ void synce_device_change_password_flags (SynceDevice *self, SynceDevicePasswordFlags new_flag); void synce_device_conn_broker_done_cb (SynceConnectionBroker *broker, gpointer user_data); void synce_device_dbus_init(SynceDevice *self); +void synce_device_dbus_uninit(SynceDevice *self); void synce_device_conn_event_cb(GObject *istream, GAsyncResult *res, gpointer user_data); G_END_DECLS Modified: trunk/core/dccm/synce-device-legacy.c =================================================================== --- trunk/core/dccm/synce-device-legacy.c 2014-03-11 13:07:51 UTC (rev 4275) +++ trunk/core/dccm/synce-device-legacy.c 2014-03-12 10:38:58 UTC (rev 4276) @@ -80,6 +80,7 @@ g_object_get(self, "name", &name, NULL); g_warning("%s: Device %s not responded to %d pings, assume disconnected", G_STRFUNC, name, DCCM_MAX_PING_COUNT); + synce_device_dbus_uninit(SYNCE_DEVICE(self)); g_signal_emit (self, SYNCE_DEVICE_GET_CLASS(SYNCE_DEVICE(self))->signals[SYNCE_DEVICE_SIGNAL_DISCONNECTED], 0); g_free(name); return FALSE; Modified: trunk/core/dccm/synce-device.c =================================================================== --- trunk/core/dccm/synce-device.c 2014-03-11 13:07:51 UTC (rev 4275) +++ trunk/core/dccm/synce-device.c 2014-03-12 10:38:58 UTC (rev 4276) @@ -239,6 +239,7 @@ g_debug("%s: received uevent remove for our device", G_STRFUNC); + synce_device_dbus_uninit(self); g_signal_emit(self, SYNCE_DEVICE_GET_CLASS(SYNCE_DEVICE(self))->signals[SYNCE_DEVICE_SIGNAL_DISCONNECTED], 0); return; @@ -648,6 +649,41 @@ } void +synce_device_dbus_uninit(SynceDevice *self) +{ + SynceDevicePrivate *priv = SYNCE_DEVICE_GET_PRIVATE (self); + g_return_if_fail(priv->inited && !(priv->dispose_has_run)); + + GError *error = NULL; +#if !USE_GDBUS + DBusGConnection *system_bus = NULL; +#endif + + g_message ("%s: unregistering object path '%s'", G_STRFUNC, priv->obj_path); + +#if USE_GDBUS + g_dbus_interface_skeleton_unexport(G_DBUS_INTERFACE_SKELETON(priv->interface)); + g_object_unref(priv->interface); + priv->interface = NULL; + +#else + system_bus = dbus_g_bus_get (DBUS_BUS_SYSTEM, &error); + if (system_bus == NULL) { + g_critical("Failed to connect to system bus: %s", error->message); + g_error_free(error); + g_free(obj_path); + return; + } + + dbus_g_connection_unregister_g_object(system_bus, G_OBJECT(self)); + + dbus_g_connection_unref(system_bus); +#endif + + return; +} + +void synce_device_change_password_flags (SynceDevice *self, SynceDevicePasswordFlags new_flag) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |