static void hal_device_added_cb (LibHalContext *ctx, const gchar *udi) { OdccmDeviceManager *self = ODCCM_DEVICE_MANAGER ( libhal_ctx_get_user_data (ctx)); OdccmDeviceManagerPrivate *priv = ODCCM_DEVICE_MANAGER_GET_PRIVATE (self); gchar *ifname; if (hal_device_is_pda (ctx, udi, &ifname)) { g_debug ("PDA network interface discovered! udi='%s'", udi); if (priv->udi != NULL) { g_warning ("Only the first device discovered will be auto-" "configured for now"); return; } priv->udi = g_strdup (udi); priv->ifname = g_strdup (ifname); _odccm_configure_interface (ifname, priv->local_ip_address, priv->local_netmask, priv->local_broadcast); g_timeout_add (50, interface_timed_cb, self); } }
void on_libhal_device_added_removed(LibHalContext *ctx, const char *udi) { g_debug("Added / Removed!"); if( !libhal_device_query_capability(ctx, udi, "volume", NULL) && !libhal_device_query_capability(ctx, udi, "storage", NULL) ) return; FormatDialog* dialog = libhal_ctx_get_user_data(ctx); update_dialog(dialog); }
static void rb_mtp_plugin_device_added (LibHalContext *context, const char *udi) { RBMtpPlugin *plugin = (RBMtpPlugin *) libhal_ctx_get_user_data (context); LIBMTP_raw_device_t *mtp_devices; int num_mtp_devices; LIBMTP_Detect_Raw_Devices (&mtp_devices, &num_mtp_devices); if (mtp_devices != NULL) { rb_mtp_plugin_maybe_add_source (plugin, udi, mtp_devices, num_mtp_devices); free (mtp_devices); } }
static void thunar_vfs_volume_manager_hal_device_lost_capability (LibHalContext *context, const gchar *udi, const gchar *capability) { ThunarVfsVolumeManagerHal *manager_hal = libhal_ctx_get_user_data (context); _thunar_vfs_return_if_fail (THUNAR_VFS_IS_VOLUME_MANAGER_HAL (manager_hal)); _thunar_vfs_return_if_fail (manager_hal->context == context); /* update the volume for the device (if any) */ thunar_vfs_volume_manager_hal_update_volume_by_udi (manager_hal, udi); }
void on_libhal_prop_modified (LibHalContext *ctx, const char *udi, const char *key, dbus_bool_t is_removed, dbus_bool_t is_added) { g_debug("Prop Modified!"); if( !libhal_device_query_capability(ctx, udi, "volume", NULL) && !libhal_device_query_capability(ctx, udi, "storage", NULL) ) return; FormatDialog* dialog = libhal_ctx_get_user_data(ctx); update_dialog(dialog); }
static void thunar_vfs_volume_manager_hal_device_property_modified (LibHalContext *context, const gchar *udi, const gchar *key, dbus_bool_t is_removed, dbus_bool_t is_added) { ThunarVfsVolumeManagerHal *manager_hal = libhal_ctx_get_user_data (context); _thunar_vfs_return_if_fail (THUNAR_VFS_IS_VOLUME_MANAGER_HAL (manager_hal)); _thunar_vfs_return_if_fail (manager_hal->context == context); /* update the volume for the device (if any) */ thunar_vfs_volume_manager_hal_update_volume_by_udi (manager_hal, udi); }
static void hal_device_removed_cb (LibHalContext *ctx, const gchar *udi) { OdccmDeviceManager *self = ODCCM_DEVICE_MANAGER ( libhal_ctx_get_user_data (ctx)); OdccmDeviceManagerPrivate *priv = ODCCM_DEVICE_MANAGER_GET_PRIVATE (self); GSList *cur; if (priv->udi == NULL) return; if (strcmp (udi, priv->udi) != 0) return; g_debug ("PDA disconnected! udi='%s', device='%s'", priv->udi, priv->ifname); /* FIXME: Hack. We should have a hashtable mapping UDIs to IP-addresses and * use that instead of this ugly approach... */ for (cur = priv->devices; cur != NULL; cur = cur->next) { OdccmDevice *dev = cur->data; guint32 addr; g_object_get (dev, "ip-address", &addr, NULL); if (addr == inet_addr (priv->device_ip_address)) { gchar *obj_path; g_object_get (dev, "object-path", &obj_path, NULL); g_signal_emit (self, signals[DEVICE_DISCONNECTED], 0, obj_path); g_free (obj_path); priv->devices = g_slist_delete_link (priv->devices, cur); g_object_unref (dev); break; } } g_free (priv->udi); priv->udi = NULL; g_free (priv->ifname); priv->ifname = NULL; }
static void rb_mtp_plugin_device_removed (LibHalContext *context, const char *udi) { RBMtpPlugin *plugin = (RBMtpPlugin *) libhal_ctx_get_user_data (context); GList *list = plugin->mtp_sources; GList *tmp; for (tmp = list; tmp != NULL; tmp = tmp->next) { RBSource *source = (RBSource *)tmp->data; char *source_udi; g_object_get (source, "udi", &source_udi, NULL); if (strcmp (udi, source_udi) == 0) { rb_debug ("removing device %s, %p", udi, source); plugin->mtp_sources = g_list_remove (plugin->mtp_sources, source); rb_display_page_delete_thyself (RB_DISPLAY_PAGE (source)); } g_free (source_udi); } }
static void thunar_vfs_volume_manager_hal_device_removed (LibHalContext *context, const gchar *udi) { ThunarVfsVolumeManagerHal *manager_hal = libhal_ctx_get_user_data (context); ThunarVfsVolumeHal *volume_hal; _thunar_vfs_return_if_fail (THUNAR_VFS_IS_VOLUME_MANAGER_HAL (manager_hal)); _thunar_vfs_return_if_fail (manager_hal->context == context); /* emit the "device-removed" signal (to support thunar-volman) */ g_signal_emit_by_name (G_OBJECT (manager_hal), "device-removed", udi); /* check if we already have a volume object for the UDI */ volume_hal = thunar_vfs_volume_manager_hal_get_volume_by_udi (manager_hal, udi); if (G_LIKELY (volume_hal != NULL)) { /* remove the volume from the volume manager */ thunar_vfs_volume_manager_remove (THUNAR_VFS_VOLUME_MANAGER (manager_hal), THUNAR_VFS_VOLUME (volume_hal)); } }
/* static */ void sbIPDMarshall::HandleLibHalDevicePropertyModified(LibHalContext* aLibHalCtx, const char* aDeviceUDI, const char* aKey, dbus_bool_t aIsRemoved, dbus_bool_t aIsAdded) { // Validate arguments. NS_ENSURE_TRUE(aLibHalCtx, /* void */); NS_ENSURE_TRUE(aDeviceUDI, /* void */); NS_ENSURE_TRUE(aKey, /* void */); // Get the iPod device system object. sbIPDMarshall* marshall = (sbIPDMarshall *) libhal_ctx_get_user_data(aLibHalCtx); // Dispatch processing to the object. nsCAutoString deviceUDI; deviceUDI = aDeviceUDI; marshall->HandleLibHalDevicePropertyModified(deviceUDI, aKey, aIsRemoved, aIsAdded); } void sbIPDMarshall::HandleLibHalDevicePropertyModified(nsACString& aDeviceUDI, const char* aKey, dbus_bool_t aIsRemoved, dbus_bool_t aIsAdded) {
static void thunar_vfs_volume_manager_hal_device_added (LibHalContext *context, const gchar *udi) { ThunarVfsVolumeManagerHal *manager_hal = libhal_ctx_get_user_data (context); ThunarVfsVolumeHal *volume_hal; LibHalVolume *hv; LibHalDrive *hd; const gchar *drive_udi; _thunar_vfs_return_if_fail (THUNAR_VFS_IS_VOLUME_MANAGER_HAL (manager_hal)); _thunar_vfs_return_if_fail (manager_hal->context == context); /* check if we have a volume here */ hv = libhal_volume_from_udi (context, udi); /* HAL might want us to ignore this volume for some reason */ if (G_UNLIKELY (hv != NULL && libhal_volume_should_ignore (hv))) { libhal_volume_free (hv); return; } /* emit the "device-added" signal (to support thunar-volman) */ g_signal_emit_by_name (G_OBJECT (manager_hal), "device-added", udi); if (G_LIKELY (hv != NULL)) { /* check if we have a mountable file system here */ if (libhal_volume_get_fsusage (hv) == LIBHAL_VOLUME_USAGE_MOUNTABLE_FILESYSTEM) { /* determine the UDI of the drive to which this volume belongs */ drive_udi = libhal_volume_get_storage_device_udi (hv); if (G_LIKELY (drive_udi != NULL)) { /* determine the drive for the volume */ hd = libhal_drive_from_udi (context, drive_udi); if (G_LIKELY (hd != NULL)) { /* check if we already have a volume object for the UDI */ volume_hal = thunar_vfs_volume_manager_hal_get_volume_by_udi (manager_hal, udi); if (G_LIKELY (volume_hal == NULL)) { /* otherwise, we allocate a new volume object */ volume_hal = g_object_new (THUNAR_VFS_TYPE_VOLUME_HAL, NULL); volume_hal->udi = g_strdup (udi); } /* update the volume object with the new data from the HAL volume/drive */ thunar_vfs_volume_hal_update (volume_hal, context, hv, hd); /* add the volume object to our list if we allocated a new one */ if (g_list_find (THUNAR_VFS_VOLUME_MANAGER (manager_hal)->volumes, volume_hal) == NULL) { /* add the volume to the volume manager */ thunar_vfs_volume_manager_add (THUNAR_VFS_VOLUME_MANAGER (manager_hal), THUNAR_VFS_VOLUME (volume_hal)); /* release the reference on the volume */ g_object_unref (G_OBJECT (volume_hal)); } /* release the HAL drive */ libhal_drive_free (hd); } } } /* release the HAL volume */ libhal_volume_free (hv); } else { /* but maybe we have a floppy disk drive here */ hd = libhal_drive_from_udi (context, udi); if (G_UNLIKELY (hd == NULL)) return; /* check if we have a floppy disk drive */ if (G_LIKELY (libhal_drive_get_type (hd) == LIBHAL_DRIVE_TYPE_FLOPPY)) { /* check if we already have a volume object for the UDI */ volume_hal = thunar_vfs_volume_manager_hal_get_volume_by_udi (manager_hal, udi); if (G_LIKELY (volume_hal == NULL)) { /* otherwise, we allocate a new volume object */ volume_hal = g_object_new (THUNAR_VFS_TYPE_VOLUME_HAL, NULL); volume_hal->udi = g_strdup (udi); } /* update the volume object with the new data from the HAL volume/drive */ thunar_vfs_volume_hal_update (volume_hal, context, NULL, hd); /* add the volume object to our list if we allocated a new one */ if (g_list_find (THUNAR_VFS_VOLUME_MANAGER (manager_hal)->volumes, volume_hal) == NULL) { /* add the volume to the volume manager */ thunar_vfs_volume_manager_add (THUNAR_VFS_VOLUME_MANAGER (manager_hal), THUNAR_VFS_VOLUME (volume_hal)); /* release the reference on the volume */ g_object_unref (G_OBJECT (volume_hal)); } } /* release the HAL drive */ libhal_drive_free (hd); } }
static void thunar_vfs_volume_manager_hal_device_condition (LibHalContext *context, const gchar *udi, const gchar *name, const gchar *details) { ThunarVfsVolumeManagerHal *manager_hal = libhal_ctx_get_user_data (context); ThunarVfsVolumeHal *volume_hal; DBusError derror; GList *volumes = NULL; GList *lp; gchar **volume_udis; gint n_volume_udis; gint n; _thunar_vfs_return_if_fail (THUNAR_VFS_IS_VOLUME_MANAGER_HAL (manager_hal)); _thunar_vfs_return_if_fail (manager_hal->context == context); /* check if the device should be ejected */ if (G_LIKELY (strcmp (name, "EjectPressed") == 0)) { /* check if we have a volume for the device */ volume_hal = thunar_vfs_volume_manager_hal_get_volume_by_udi (manager_hal, udi); if (G_LIKELY (volume_hal == NULL)) { /* initialize D-Bus error */ dbus_error_init (&derror); /* the UDI most probably identifies the drive of the volume */ volume_udis = libhal_manager_find_device_string_match (context, "info.parent", udi, &n_volume_udis, &derror); if (G_LIKELY (volume_udis != NULL)) { /* determine the volumes for the UDIs */ for (n = 0; n < n_volume_udis; ++n) { /* check if we have a mounted volume for this UDI */ volume_hal = thunar_vfs_volume_manager_hal_get_volume_by_udi (manager_hal, volume_udis[n]); if (volume_hal != NULL && thunar_vfs_volume_is_mounted (THUNAR_VFS_VOLUME (volume_hal))) volumes = g_list_prepend (volumes, g_object_ref (G_OBJECT (volume_hal))); } libhal_free_string_array (volume_udis); } /* free D-Bus error */ dbus_error_free (&derror); } else if (thunar_vfs_volume_is_mounted (THUNAR_VFS_VOLUME (volume_hal))) { volumes = g_list_prepend (volumes, g_object_ref (G_OBJECT (volume_hal))); } /* check there are any mounted volumes on the device */ if (G_LIKELY (volumes != NULL)) { /* tell everybody, that we're about to unmount those volumes */ for (lp = volumes; lp != NULL; lp = lp->next) { thunar_vfs_volume_pre_unmount (lp->data); g_object_unref (G_OBJECT (lp->data)); } g_list_free (volumes); /* emit the "device-eject" signal and let Thunar eject the device */ g_signal_emit_by_name (G_OBJECT (manager_hal), "device-eject", udi); } } }