示例#1
0
static void
server_found_cb (GrlDleynaServersManager *serversmgr,
                 GrlDleynaServer         *server,
                 gpointer                *user_data)
{
  GrlPlugin *plugin = GRL_PLUGIN (user_data);
  GrlDleynaMediaDevice *device;
  GrlSource *source;
  GrlRegistry *registry;
  GError *error = NULL;

  GRL_DEBUG (G_STRFUNC);
  device = grl_dleyna_server_get_media_device (server);
  GRL_DEBUG ("%s udn: %s ", G_STRFUNC, grl_dleyna_media_device_get_udn (device));

  registry = grl_registry_get_default ();

  source = GRL_SOURCE (grl_dleyna_source_new (server));
  GRL_DEBUG ("%s id: %s ", G_STRFUNC, grl_source_get_id (source));
  grl_registry_register_source (registry, plugin, GRL_SOURCE (source), &error);

  if (error != NULL) {
    GRL_WARNING ("Failed to register source for DLNA device %s: %s",
                 grl_dleyna_media_device_get_udn (device), error->message);
    g_error_free (error);
  }
}
/* Callback invoked whenever a source goes away */
static void
source_removed_cb (GrlRegistry *registry,
                   GrlSource *source,
                   gpointer user_data)
{
  GList *entry;
  const gchar *source_name;
  gchar *source_id;

  source_name =
    grl_source_get_name (source);
  source_id =
    g_strdup (grl_source_get_id (source));

  if (!dups) {
    entry = g_list_find_custom (providers_names,
                                source_name,
                                (GCompareFunc) g_strcmp0);
    if (entry) {
      g_free (entry->data);
      providers_names = g_list_delete_link (providers_names, entry);
    }
  }

  sanitize (source_id);
  g_hash_table_remove (servers, source_id);
  g_free (source_id);
}
static void
handle_new_source (MexBliptvPlugin *self, GrlSource *source)
{
  const char *id;

  id = grl_source_get_id (source);
  if (g_strcmp0 (id,"grl-bliptv") != 0)
    return;

  add_model (self, source);
}
示例#4
0
void GriloRegistry::grilo_source_added(GrlRegistry *registry, GrlSource *src,
				       gpointer user_data) {

  Q_UNUSED(registry);

  GriloRegistry *reg = static_cast<GriloRegistry *>(user_data);

  const char *id = grl_source_get_id(src);

  if (reg->m_sources.indexOf(id) == -1) {
    reg->m_sources << id;
    emit reg->availableSourcesChanged();
  }
}
示例#5
0
RBSource *
rb_grilo_source_new (GObject *plugin, GrlSource *grilo_source)
{
	GObject *source;
	RBShell *shell;
	GSettings *settings;
	RhythmDBEntryType *entry_type;
	RhythmDB *db;
	char *name;

	name = g_strdup_printf ("grilo:%s", grl_source_get_id (grilo_source));

	g_object_get (plugin, "object", &shell, NULL);
	g_object_get (shell, "db", &db, NULL);
	entry_type = g_object_new (rb_grilo_entry_type_get_type (),
				   "db", db,
				   "name", name,
				   "save-to-disk", FALSE,
				   "category", RHYTHMDB_ENTRY_NORMAL,
				   "type-data-size", sizeof(RBGriloEntryData),
				   NULL);
	rhythmdb_register_entry_type (db, entry_type);
	g_object_unref (db);
	g_free (name);

	settings = g_settings_new ("org.gnome.rhythmbox.plugins.grilo");
	source = g_object_new (RB_TYPE_GRILO_SOURCE,
			       "name", grl_source_get_name (grilo_source),
			       "entry-type", entry_type,
			       "shell", shell,
			       "plugin", plugin,
			       "show-browser", FALSE,
			       "settings", g_settings_get_child (settings, "source"),
			       "grilo-source", grilo_source,
			       NULL);
	g_object_unref (settings);
	rb_display_page_set_icon_name (RB_DISPLAY_PAGE (source), "network-server-symbolic");

	rb_shell_register_entry_type_for_source (shell, RB_SOURCE (source), entry_type);

	g_object_unref (shell);
	return RB_SOURCE (source);
}
static GrlMedia *
unserialize_media (GrlSource *source, const gchar *serial)
{
  GrlMedia *media;
  /* gchar *parent_serial; */

  if (g_strcmp0 (serial, MS2_ROOT) == 0) {
    /* Root container must be built from scratch */
    media = grl_media_container_new ();
    grl_media_set_source (media, grl_source_get_id (source));

    /* Set parent to itself */
    /* parent_serial = grl_media_serialize (media); */
    /* grl_media_set_grilo_ms2_parent (media, parent_serial); */
    /* g_free (parent_serial); */
    grl_media_set_grilo_ms2_parent (media, MS2_ROOT);
  } else {
    media = grl_media_unserialize (serial);
  }

  return media;
}
/* Callback invoked whenever a new source comes up */
static void
source_added_cb (GrlRegistry *registry,
                 GrlSource *source,
                 gpointer user_data)
{
  GrlSupportedOps supported_ops;
  MS2Server *server;
  const gchar *source_name;
  gchar *sanitized_source_id;
  gchar *source_id;

  /* Only sources that implement browse and resolve are of interest */
  supported_ops =
    grl_source_supported_operations (source);
  if (supported_ops & GRL_OP_BROWSE &&
      supported_ops & GRL_OP_RESOLVE) {

    source_id =
      (gchar *) grl_source_get_id (source);

    /* Check if there is already another provider with the same name */
    if (!dups) {
      source_name =
        grl_source_get_name (source);
      if (g_list_find_custom (providers_names,
                              source_name,
                              (GCompareFunc) g_strcmp0)) {
        g_debug ("Skipping %s [%s] source", source_id, source_name);
        return;
      }
    }

    /* Register a new service name */
    sanitized_source_id = g_strdup (source_id);

    g_debug ("Registering %s [%s] source", sanitized_source_id, source_name);

    sanitize (sanitized_source_id);

    server = ms2_server_new (sanitized_source_id, source);

    if (!server) {
      g_warning ("Cannot register %s", sanitized_source_id);
      g_free (sanitized_source_id);
    } else {
      ms2_server_set_get_properties_func (server, get_properties_cb);
      ms2_server_set_list_children_func (server, list_children_cb);
      /* Add search  */
      if (supported_ops & GRL_OP_SEARCH) {
        ms2_server_set_search_objects_func (server, search_objects_cb);
      }
      /* Save reference */
      if (!dups) {
        providers_names = g_list_prepend (providers_names,
                                          g_strdup(source_name));
      }
      g_hash_table_insert (servers, sanitized_source_id, server);
    }
  } else {
    g_debug ("%s source does not support either browse or resolve",
             grl_source_get_id (source));
  }
}