Ejemplo n.º 1
0
int mpd_stats_check(MpdObj *mi)
{
	if(!mpd_check_connected(mi))
	{
		debug_printf(DEBUG_WARNING,"not connected\n");
		return MPD_NOT_CONNECTED;
	}
	if(mi->stats == NULL)
	{
		/* try to update */
		if(mpd_stats_update(mi))
		{
			debug_printf(DEBUG_ERROR,"failed to update status\n");
			return MPD_STATUS_FAILED;
		}
	}
	return MPD_OK;
}
Ejemplo n.º 2
0
static void serverstats_update(void)
{
    gchar **handlers = NULL;
    gchar *value = NULL;

    serverstats_clear();
    if (!mpd_check_connected(connection))
        return;
    mpd_stats_update(connection);
    /** Version */
    value = mpd_server_get_version(connection);
    gtk_label_set_text(GTK_LABEL(serverstats_labels[SERVERSTATS_MPD_VERSION]), value);
    free(value);
    /** Uptime  */
    value = format_time_real(mpd_stats_get_uptime(connection), "");
    gtk_label_set_text(GTK_LABEL(serverstats_labels[SERVERSTATS_MPD_UPTIME]), value);
    g_free(value);
    /** Playtime*/
    value = format_time_real(mpd_stats_get_playtime(connection), "");
    gtk_label_set_text(GTK_LABEL(serverstats_labels[SERVERSTATS_MPD_PLAYTIME]), value);
    g_free(value);
    /** DB Playtime*/
    value = format_time_real(mpd_stats_get_db_playtime(connection), "");
    gtk_label_set_text(GTK_LABEL(serverstats_labels[SERVERSTATS_MPD_DB_PLAYTIME]), value);
    g_free(value);
    /** DB ARTIST*/
    value = g_strdup_printf("%i", mpd_stats_get_total_artists(connection));
    gtk_label_set_text(GTK_LABEL(serverstats_labels[SERVERSTATS_MPD_DB_ARTISTS]), value);
    g_free(value);
    /** DB ALBUMS*/
    value = g_strdup_printf("%i", mpd_stats_get_total_albums(connection));
    gtk_label_set_text(GTK_LABEL(serverstats_labels[SERVERSTATS_MPD_DB_ALBUMS]), value);
    g_free(value);
    /** DB SONGS*/
    value = g_strdup_printf("%i", mpd_stats_get_total_songs(connection));
    gtk_label_set_text(GTK_LABEL(serverstats_labels[SERVERSTATS_MPD_DB_SONGS]), value);
    g_free(value);
    /** URL_HANDLERS*/
    handlers = mpd_server_get_url_handlers(connection);
    if (handlers)
    {
        value = g_strjoinv(",", handlers);
        g_strfreev(handlers);
        handlers = NULL;
    } else
        value = g_strdup("N/A");
    gtk_label_set_text(GTK_LABEL(serverstats_labels[SERVERSTATS_MPD_URLHANDLERS]), value);
    g_free(value);

    if (mpd_server_check_version(connection, 0, 13, 0))
        handlers = mpd_server_get_tag_types(connection);
    if (handlers)
    {
        value = g_strjoinv(", ", handlers);
        g_strfreev(handlers);
        handlers = NULL;
    } else
        value = g_strdup("N/A");
    gtk_label_set_text(GTK_LABEL(serverstats_labels[SERVERSTATS_MPD_TAG_TYPES]), value);
    g_free(value);

}