Beispiel #1
0
static void
impl_activate (PeasActivatable *bplugin)
{
	RBMtpPlugin *plugin = RB_MTP_PLUGIN (bplugin);
	RBRemovableMediaManager *rmm;
	RBShell *shell;
	gboolean rmm_scanned = FALSE;

	g_object_get (plugin, "object", &shell, NULL);
	g_object_get (shell, "removable-media-manager", &rmm, NULL);
	g_object_unref (shell);

	/* device detection */
	plugin->create_device_source_id =
		g_signal_connect_object (rmm,
					 "create-source-device",
					 G_CALLBACK (create_source_device_cb),
					 plugin,
					 0);

	/* only scan if we're being loaded after the initial scan has been done */
	g_object_get (rmm, "scanned", &rmm_scanned, NULL);
	if (rmm_scanned)
		rb_removable_media_manager_scan (rmm);

	g_object_unref (rmm);
}
Beispiel #2
0
static void
impl_deactivate (PeasActivatable *bplugin)
{
	RBMtpPlugin *plugin = RB_MTP_PLUGIN (bplugin);
	GtkUIManager *uimanager = NULL;
	RBRemovableMediaManager *rmm = NULL;
	RBShell *shell;

	g_object_get (plugin, "object", &shell, NULL);
	g_object_get (shell,
		      "ui-manager", &uimanager,
		      "removable-media-manager", &rmm,
		      NULL);

	gtk_ui_manager_remove_ui (uimanager, plugin->ui_merge_id);
	gtk_ui_manager_remove_action_group (uimanager, plugin->action_group);

	g_list_foreach (plugin->mtp_sources, (GFunc)rb_display_page_delete_thyself, NULL);
	g_list_free (plugin->mtp_sources);
	plugin->mtp_sources = NULL;

#if defined(HAVE_GUDEV)
	g_signal_handler_disconnect (rmm, plugin->create_device_source_id);
	plugin->create_device_source_id = 0;
#else
	if (plugin->hal_context != NULL) {
		DBusError error;
		dbus_error_init (&error);
		libhal_ctx_shutdown (plugin->hal_context, &error);
		libhal_ctx_free (plugin->hal_context);
		dbus_error_free (&error);

		plugin->hal_context = NULL;
	}

	if (plugin->dbus_connection != NULL) {
		dbus_connection_unref (plugin->dbus_connection);
		plugin->dbus_connection = NULL;
	}
#endif

	g_object_unref (uimanager);
	g_object_unref (rmm);
	g_object_unref (shell);
}
Beispiel #3
0
static void
impl_deactivate (PeasActivatable *bplugin)
{
	RBMtpPlugin *plugin = RB_MTP_PLUGIN (bplugin);
	RBRemovableMediaManager *rmm = NULL;
	RBShell *shell;

	g_object_get (plugin, "object", &shell, NULL);
	g_object_get (shell,
		      "removable-media-manager", &rmm,
		      NULL);

	g_list_foreach (plugin->mtp_sources, (GFunc)rb_display_page_delete_thyself, NULL);
	g_list_free (plugin->mtp_sources);
	plugin->mtp_sources = NULL;

	g_signal_handler_disconnect (rmm, plugin->create_device_source_id);
	plugin->create_device_source_id = 0;

	g_object_unref (rmm);
	g_object_unref (shell);
}
Beispiel #4
0
static void
impl_activate (PeasActivatable *bplugin)
{
	RBMtpPlugin *plugin = RB_MTP_PLUGIN (bplugin);
	GtkUIManager *uimanager = NULL;
	RBRemovableMediaManager *rmm;
	char *file = NULL;
	RBShell *shell;
#if defined(HAVE_GUDEV)
	gboolean rmm_scanned = FALSE;
#else
	int num_mtp_devices;
	LIBMTP_raw_device_t *mtp_devices;
#endif

	g_object_get (plugin, "object", &shell, NULL);

	g_object_get (shell,
		     "ui-manager", &uimanager,
		     "removable-media-manager", &rmm,
		     NULL);

	/* ui */
	rb_media_player_source_init_actions (shell);
	plugin->action_group = gtk_action_group_new ("MTPActions");
	gtk_action_group_set_translation_domain (plugin->action_group,
						 GETTEXT_PACKAGE);
	_rb_action_group_add_display_page_actions (plugin->action_group,
						   G_OBJECT (shell),
						   rb_mtp_plugin_actions,
						   G_N_ELEMENTS (rb_mtp_plugin_actions));
	gtk_ui_manager_insert_action_group (uimanager, plugin->action_group, 0);
	file = rb_find_plugin_data_file (G_OBJECT (bplugin), "mtp-ui.xml");
	plugin->ui_merge_id = gtk_ui_manager_add_ui_from_file (uimanager, file, NULL);
	g_object_unref (uimanager);
	g_object_unref (shell);

	/* device detection */
#if defined(HAVE_GUDEV)
	plugin->create_device_source_id =
		g_signal_connect_object (rmm,
					 "create-source-device",
					 G_CALLBACK (create_source_device_cb),
					 plugin,
					 0);

	/* only scan if we're being loaded after the initial scan has been done */
	g_object_get (rmm, "scanned", &rmm_scanned, NULL);
	if (rmm_scanned)
		rb_removable_media_manager_scan (rmm);
#else
	if (rb_mtp_plugin_setup_dbus_hal_connection (plugin) == FALSE) {
		rb_debug ("not scanning for MTP devices because we couldn't get a HAL context");
		g_object_unref (rmm);
		return;
	}

	rb_profile_start ("scanning for MTP devices");
	LIBMTP_Detect_Raw_Devices (&mtp_devices, &num_mtp_devices);
	if (num_mtp_devices > 0) {
		int num_hal_devices;
		char **hal_devices;
		int i;

		rb_debug ("%d MTP devices found", num_mtp_devices);

		hal_devices = libhal_get_all_devices (plugin->hal_context, &num_hal_devices, NULL);
		for (i = 0; i < num_hal_devices; i++) {
			/* should narrow this down a bit - usb only, for a start */
			rb_mtp_plugin_maybe_add_source (plugin, hal_devices[i], mtp_devices, num_mtp_devices);
		}
		libhal_free_string_array (hal_devices);
	}
	if (mtp_devices != NULL) {
		free (mtp_devices);
	}
	rb_profile_end ("scanning for MTP devices");
#endif

	g_object_unref (rmm);
}