static RBSource * create_source_cb (RBRemovableMediaManager *rmm, GMount *mount, RBIpodPlugin *plugin) { RBSource *src; if (!rb_ipod_helpers_is_ipod (mount)) { return NULL; } if (rb_ipod_helpers_needs_init (mount)) { gboolean inited; gchar *glade_file; glade_file = rb_plugin_find_file (RB_PLUGIN (plugin), "ipod-init.glade"); inited = rb_ipod_helpers_show_first_time_dialog (mount, glade_file); g_free (glade_file); if (!inited) { return NULL; } } src = RB_SOURCE (rb_ipod_source_new (RB_PLUGIN (plugin), plugin->shell, mount)); plugin->ipod_sources = g_list_prepend (plugin->ipod_sources, src); g_signal_connect_object (G_OBJECT (src), "deleted", G_CALLBACK (rb_ipod_plugin_source_deleted), plugin, 0); return src; }
static RBSource * create_source_cb (RBRemovableMediaManager *rmm, GMount *mount, MPIDDevice *device_info, RBAudioCdPlugin *plugin) { RBSource *source = NULL; GVolume *volume = NULL; if (rb_audiocd_is_mount_audiocd (mount)) { volume = g_mount_get_volume (mount); if (volume != NULL) { source = RB_SOURCE (rb_audiocd_source_new (RB_PLUGIN (plugin), plugin->shell, volume)); g_object_unref (volume); } } if (source != NULL) { g_hash_table_insert (plugin->sources, g_object_ref (volume), g_object_ref (source)); g_signal_connect_object (G_OBJECT (source), "deleted", G_CALLBACK (rb_audiocd_plugin_source_deleted), plugin, 0); } return source; }
static RBSource * create_source_cb (RBRemovableMediaManager *rmm, GMount *mount, MPIDDevice *device_info, RBGenericPlayerPlugin *plugin) { RBSource *source = NULL; if (rb_psp_is_mount_player (mount, device_info)) source = RB_SOURCE (rb_psp_source_new (RB_PLUGIN (plugin), plugin->shell, mount, device_info)); if (source == NULL && rb_nokia770_is_mount_player (mount, device_info)) source = RB_SOURCE (rb_nokia770_source_new (RB_PLUGIN (plugin), plugin->shell, mount, device_info)); if (source == NULL && rb_generic_player_is_mount_player (mount, device_info)) source = RB_SOURCE (rb_generic_player_source_new (RB_PLUGIN (plugin), plugin->shell, mount, device_info)); if (plugin->actions == NULL) { plugin->actions = gtk_action_group_new ("GenericPlayerActions"); gtk_action_group_set_translation_domain (plugin->actions, GETTEXT_PACKAGE); _rb_action_group_add_source_actions (plugin->actions, G_OBJECT (plugin->shell), rb_generic_player_plugin_actions, G_N_ELEMENTS (rb_generic_player_plugin_actions)); } if (source) { if (plugin->ui_merge_id == 0) { GtkUIManager *uimanager = NULL; char *file = NULL; g_object_get (G_OBJECT (plugin->shell), "ui-manager", &uimanager, NULL); gtk_ui_manager_insert_action_group (uimanager, plugin->actions, 0); file = rb_plugin_find_file (RB_PLUGIN (plugin), "generic-player-ui.xml"); plugin->ui_merge_id = gtk_ui_manager_add_ui_from_file (uimanager, file, NULL); g_free (file); g_object_unref (G_OBJECT (uimanager)); } plugin->player_sources = g_list_prepend (plugin->player_sources, source); g_signal_connect_object (G_OBJECT (source), "deleted", G_CALLBACK (rb_generic_player_plugin_source_deleted), plugin, 0); } return source; }
static void source_burn (RBCdRecorderPlugin *pi, RBSource *source) { GtkWidget *recorder; GtkWidget *parent; char *name; RBShell *shell; gboolean res; GError *error; GtkTreeModel *model; g_object_get (G_OBJECT (source), "query-model", &model, NULL); /* don't burn if the source is empty */ if (gtk_tree_model_iter_n_children (model, NULL) == 0) { g_object_unref (model); return; } rb_debug ("burning source"); g_object_get (source, "name", &name, "shell", &shell, NULL); parent = gtk_widget_get_toplevel (GTK_WIDGET (source)); recorder = rb_playlist_source_recorder_new (parent, shell, RB_PLUGIN (pi), name); g_object_unref (shell); g_free (name); error = NULL; res = rb_playlist_source_recorder_add_from_model (RB_PLAYLIST_SOURCE_RECORDER (recorder), model, burn_source_iter_func, &error); g_object_unref (model); if (! res) { rb_error_dialog (GTK_WINDOW (parent), _("Unable to create audio CD"), "%s", error->message); g_error_free (error); gtk_widget_destroy (recorder); return; } g_signal_connect (recorder, "response", G_CALLBACK (gtk_widget_destroy), NULL); gtk_widget_show (recorder); }
static RBSource * create_source_cb (RBRemovableMediaManager *rmm, GMount *mount, MPIDDevice *device_info, RBIpodPlugin *plugin) { RBSource *src; if (!rb_ipod_helpers_is_ipod (mount, device_info)) { return NULL; } if (rb_ipod_helpers_needs_init (mount)) { gboolean inited; gchar *builder_file; builder_file = rb_plugin_find_file (RB_PLUGIN (plugin), "ipod-init.ui"); inited = rb_ipod_helpers_show_first_time_dialog (mount, builder_file); g_free (builder_file); if (!inited) { return NULL; } } GtkAction *sync_action = gtk_action_group_get_action (plugin->action_group, "iPodSourceSync"); src = RB_SOURCE (rb_ipod_source_new (RB_PLUGIN (plugin), plugin->shell, mount, device_info, &plugin->key_file, sync_action)); plugin->ipod_sources = g_list_prepend (plugin->ipod_sources, src); g_signal_connect_object (G_OBJECT (src), "deleted", G_CALLBACK (rb_ipod_plugin_source_deleted), plugin, 0); return src; }
static gboolean load_plugin_module (RBPluginInfo *info) { gchar *path; gchar *dirname; g_return_val_if_fail (info != NULL, FALSE); g_return_val_if_fail (info->file != NULL, FALSE); g_return_val_if_fail (info->location != NULL, FALSE); g_return_val_if_fail (info->plugin == NULL, FALSE); switch (info->lang) { case RB_PLUGIN_LOADER_C: dirname = g_path_get_dirname (info->file); g_return_val_if_fail (dirname != NULL, FALSE); path = g_module_build_path (dirname, info->location); #ifdef USE_UNINSTALLED_DIRS if (!g_file_test (path, G_FILE_TEST_EXISTS)) { char *temp; g_free (path); temp = g_build_filename (dirname, ".libs", NULL); path = g_module_build_path (temp, info->location); g_free (temp); } #endif g_free (dirname); g_return_val_if_fail (path != NULL, FALSE); info->module = G_TYPE_MODULE (rb_module_new (path, info->location)); g_free (path); break; case RB_PLUGIN_LOADER_PY: #ifdef ENABLE_PYTHON info->module = G_TYPE_MODULE (rb_python_module_new (info->file, info->location)); #else rb_debug ("cannot load plugin %s, python plugin support is disabled", info->location); #endif break; } if (g_type_module_use (info->module) == FALSE) { g_warning ("Could not load plugin %s\n", info->location); g_object_unref (G_OBJECT (info->module)); info->module = NULL; return FALSE; } switch (info->lang) { case RB_PLUGIN_LOADER_C: info->plugin = RB_PLUGIN (rb_module_new_object (RB_MODULE (info->module))); break; case RB_PLUGIN_LOADER_PY: #ifdef ENABLE_PYTHON info->plugin = RB_PLUGIN (rb_python_module_new_object (RB_PYTHON_MODULE (info->module))); #endif break; } return TRUE; }
static void impl_activate (RBPlugin *plugin, RBShell *shell) { // rb_error_dialog (NULL, _("Spotify Plugin"), "Spotify plugin activated, with shell %p", shell); RBSpotifySource *source; RhythmDBEntryType type; RhythmDB *db; char *entry_type_name, *username, *password; int err; RBSpotifyPluginPrivate *pprivate = RB_SPOTIFY_PLUGIN_GET_PRIVATE(plugin); pthread_mutex_init(&g_notify_mutex, NULL); pthread_cond_init(&g_notify_cond, NULL); audio_fifo_init(&g_audio_fifo); spconfig.application_key_size = g_appkey_size; err = sp_session_init(&spconfig, &pprivate->sess); if (err != SP_ERROR_OK) { rb_error_dialog (NULL, _("Spotify Plugin"), "Error initialising spotify session"); pprivate->sess = NULL; return; } fprintf(stderr, "err: %x", err); err = pthread_create(&pprivate->notify_thread, 0, notification_routine, pprivate->sess); fprintf(stderr, "Thread created"); if (err != 0) { fprintf(stderr, "Error creating notification thread %x\n", err); return; } username = eel_gconf_get_string (CONF_SPOTIFY_USERNAME); password = eel_gconf_get_string (CONF_SPOTIFY_PASSWORD); if (username == NULL || password == NULL) { rb_error_dialog (NULL, _("Spotify Plugin"), "Username and password not set."); return; } err = sp_session_login(pprivate->sess, username, password); fprintf(stderr, "err: %x", err); rbspotifysrc_set_plugin(plugin); g_object_get (shell, "db", &db, NULL); entry_type_name = g_strdup_printf ("spotify"); type = rhythmdb_entry_register_type (db, entry_type_name); g_free (entry_type_name); type->save_to_disk = FALSE; type->category = RHYTHMDB_ENTRY_NORMAL; // type->get_playback_uri = (RhythmDBEntryStringFunc) rb_daap_source_get_playback_uri; g_object_unref (db); // icon = rb_daap_plugin_get_icon (RB_DAAP_PLUGIN (plugin), password_protected, FALSE); source = (RBSpotifySource*)RB_SOURCE (g_object_new (RBSPOTIFYSOURCE_TYPE, "name", "spotify", "entry-type", type, "shell", shell, "visibility", TRUE, // "sorting-key", CONF_STATE_SORTING, "source-group", RB_SOURCE_GROUP_SHARED, "plugin", RB_PLUGIN (plugin), NULL)); source->priv->sess = pprivate->sess; source->priv->db = db; source->priv->type = type; rb_shell_register_entry_type_for_source (shell, (RBSource*)source, type); rb_shell_append_source (shell, (RBSource*)source, NULL); // return source; }