Esempio n. 1
0
static void
track_changed(XmrWindow *window,
			SongInfo *new_track,
			XmrMprisPlugin *plugin)
{
	song_info_free(plugin->current_song);
	plugin->current_song = song_info_copy(new_track);
}
Esempio n. 2
0
static void
impl_deactivate(PeasActivatable *activatable)
{
	XmrMprisPlugin *plugin;

	plugin = XMR_MPRIS_PLUGIN(activatable);

	g_signal_handlers_disconnect_by_func(plugin->window,
					track_changed, plugin);

	g_signal_handlers_disconnect_by_func(plugin->player,
				player_tick, plugin);

	g_signal_handlers_disconnect_by_func(plugin->player,
			player_state_changed, plugin);

	if (plugin->root_id != 0)
	{
		g_dbus_connection_unregister_object(plugin->connection, plugin->root_id);
		plugin->root_id = 0;
	}
	if (plugin->player_id != 0)
	{
		g_dbus_connection_unregister_object(plugin->connection, plugin->player_id);
		plugin->player_id = 0;
	}
	if (plugin->name_own_id > 0) {
		g_bus_unown_name(plugin->name_own_id);
		plugin->name_own_id = 0;
	}
	if (plugin->connection != NULL)
	{
		g_object_unref(plugin->connection);
		plugin->connection = NULL;
	}

	if (plugin->current_song)
	{
		song_info_free(plugin->current_song);
		plugin->current_song = NULL;
	}

	g_object_unref(plugin->window);
	g_object_unref(plugin->player);
}
Esempio n. 3
0
static GList *
parse_result_data(const gchar *data)
{
	GList *list = NULL;

	const gchar *current = data;
	const gchar *p;

	/*
	<td class="song_name">
		<a target="_blank" href="http://www.xiami.com/song/1770779526" title="中国人"><b class="key_red">中国人</b></a>
	</td>
	<td class="song_artist">
		<a target="_blank" href="http://www.xiami.com/artist/648" title="刘德华">刘德华</a>
	</td>
	<td class="song_album">
		<a target="_blank" href="http://www.xiami.com/album/491512" title="Unforgettable 2011中国巡回演唱会">《Unforgettable 2011中国巡回演唱会》</a>
	</td>
	*/
	while ((p = strstr(current, SONG_PATTERN)) != NULL)
	{
		gchar *tmp;
		SongInfo *info;
		current = p + strlen(SONG_PATTERN);
		p = strstr(current, "/song/");
		if (p == NULL)
			break;

		current = p + strlen("/song/");
		if (!isdigit(*current))
			continue;
		
		p = current + 1;
		while (p && isdigit(*p))
			p++;

		// song id
		tmp = g_strndup(current, p - current);
		// get song info
		info = get_song_id_info(tmp);
		g_free(tmp);
		if (!info)
			continue ;

		current = p + 1;
		// song name
		tmp = get_title_attr(current, &current);
		if (tmp == NULL)
		{
			song_info_free(info);
			continue;
		}
		info->song_name = tmp;

		// artist name
		p = strstr(current, ARTIST_PATTERN);
		if (p != NULL)
		{
			tmp = get_title_attr(p, &current);
			if (tmp != NULL)
				info->artist_name = tmp;
		}
		
		current = p + 1;
		// album name
		p = strstr(current, ALBUM_PATTERN);
		if (p != NULL)
		{
			tmp = get_title_attr(p, &current);
			if (tmp != NULL)
				info->album_name = tmp;
		}
		
		list = g_list_append(list, info);
	}
		
	return list;
}
Esempio n. 4
0
static void
get_track(xmlNodePtr root, GList **list)
{
	SongInfo *song;
	gchar *url;

	song = song_info_new();
	if (song == NULL)
		return ;

	do
	{
		GList *p = *list;
		gboolean song_exists = FALSE;

		song->song_id		= (gchar *)xml_first_child_content(root, BAD_CAST "song_id");
		if (song->song_id == NULL)
			break;

		for ( ; p != NULL; p = p->next)
		{
			SongInfo *si = (SongInfo *)p->data;
			if (g_strcmp0(si->song_id, song->song_id) == 0)
			{
				song_exists = TRUE;
				break;
			}
		}

		if (song_exists)
			break;

		song->song_name		= (gchar *)xml_first_child_content(root, BAD_CAST "title");
		song->album_id		= (gchar *)xml_first_child_content(root, BAD_CAST "album_id");
		song->album_name	= (gchar *)xml_first_child_content(root, BAD_CAST "album_name");
		song->artist_id		= (gchar *)xml_first_child_content(root, BAD_CAST "artist_id");
		song->artist_name	= (gchar *)xml_first_child_content(root, BAD_CAST "artist");
		song->album_cover	= (gchar *)xml_first_child_content(root, BAD_CAST "pic");
		url					= (gchar *)xml_first_child_content(root, BAD_CAST "location");
		
		if (song->song_name == NULL)
			song->song_name = (gchar *)xml_first_child_content(root, BAD_CAST "song_name");
		if (song->artist_name == NULL)
			song->artist_name = (gchar *)xml_first_child_content(root, BAD_CAST "artist_name");
		if (song->album_cover == NULL)
			song->album_cover = (gchar *)xml_first_child_content(root, BAD_CAST "album_cover");
		
		if (url == NULL)
			break;

		song->location = decode_url(url);
		g_free(url);

		song->grade = (gchar *)xml_first_child_content(root, BAD_CAST "grade");

		*list = g_list_append(*list, song);

		return ;
	}
	while(0);

	song_info_free(song);
}