guint daap_command_update (gchar *host, gint port, guint session_id, guint request_id) { xmms_daap_conn_t *conn = NULL; gchar *request; cc_data_t *cc_data; guint revision_id = 0; conn = daap_conn_new (host, port); if (!conn) { return 0; } request = g_strdup_printf ("/update?session-id=%d", session_id); cc_data = daap_request_data (conn->chan, request, host, request_id); if (cc_data) { revision_id = cc_data->revision_id; cc_data_free (cc_data); } g_free (request); daap_conn_free (conn); return revision_id; }
GSList * daap_command_db_list (gchar *host, gint port, guint session_id, guint revision_id, guint request_id) { xmms_daap_conn_t *conn = NULL; gchar *request; cc_data_t *cc_data; GSList *db_id_list = NULL; conn = daap_conn_new (host, port); if (!conn) { return NULL; } request = g_strdup_printf ("/databases?session-id=%d&revision-id=%d", session_id, revision_id); cc_data = daap_request_data (conn->chan, request, host, request_id); g_free (request); if (cc_data) { db_id_list = cc_record_list_deep_copy (cc_data->record_list); cc_data_free (cc_data); } daap_conn_free (conn); return db_id_list; }
guint daap_command_login (gchar *host, gint port, guint request_id, xmms_error_t *err) { xmms_daap_conn_t *conn; cc_data_t *cc_data; guint session_id = 0; conn = daap_conn_new (host, port); if (!conn) { xmms_error_set (err, XMMS_ERROR_GENERIC, "Connection to server failed! " "Please make sure the url is of the form:\n" "daap://ip[:port]/[song]"); return 0; } cc_data = daap_request_data (conn->chan, "/login", host, request_id); if (cc_data) { session_id = cc_data->session_id; cc_data_free (cc_data); } daap_conn_free (conn); return session_id; }
guint daap_command_update (gchar *host, gint port, guint session_id, guint request_id) { GIOChannel *chan; gchar *request; cc_data_t *cc_data; guint revision_id = 0; chan = daap_open_connection (host, port); if (!chan) { return 0; } request = g_strdup_printf ("/update?session-id=%d", session_id); cc_data = daap_request_data (chan, request, host, request_id); if (cc_data) { revision_id = cc_data->revision_id; cc_data_free (cc_data); } g_free (request); g_io_channel_shutdown (chan, TRUE, NULL); g_io_channel_unref (chan); return revision_id; }
guint daap_command_login (gchar *host, gint port, guint request_id, xmms_error_t *err) { GIOChannel *chan; cc_data_t *cc_data; guint session_id = 0; chan = daap_open_connection (host, port); if (!chan) { xmms_error_set (err, XMMS_ERROR_GENERIC, "Connection to server failed! " "Please make sure the url is of the form:\n" "daap://ip[:port]/[song]"); return 0; } cc_data = daap_request_data (chan, "/login", host, request_id); if (cc_data) { session_id = cc_data->session_id; cc_data_free (cc_data); } g_io_channel_shutdown (chan, TRUE, NULL); g_io_channel_unref (chan); return session_id; }
GSList * daap_command_db_list (gchar *host, gint port, guint session_id, guint revision_id, guint request_id) { GIOChannel *chan; gchar *request; cc_data_t *cc_data; GSList *db_id_list = NULL; chan = daap_open_connection (host, port); if (!chan) { return NULL; } request = g_strdup_printf ("/databases?session-id=%d&revision-id=%d", session_id, revision_id); cc_data = daap_request_data (chan, request, host, request_id); g_free (request); if (cc_data) { db_id_list = cc_record_list_deep_copy (cc_data->record_list); cc_data_free (cc_data); } g_io_channel_shutdown (chan, TRUE, NULL); g_io_channel_unref (chan); return db_id_list; }
GSList * daap_command_song_list (gchar *host, gint port, guint session_id, guint revision_id, guint request_id, gint db_id) { GIOChannel *chan; gchar *request; cc_data_t *cc_data; GSList * song_list; GSList * meta_items = NULL; chan = daap_open_connection (host, port); if (!chan) { return NULL; } meta_items = g_slist_prepend (meta_items, g_strdup ("dmap.itemid")); meta_items = g_slist_prepend (meta_items, g_strdup ("dmap.itemname")); meta_items = g_slist_prepend (meta_items, g_strdup ("daap.songartist")); meta_items = g_slist_prepend (meta_items, g_strdup ("daap.songformat")); meta_items = g_slist_prepend (meta_items, g_strdup ("daap.songtracknumber")); meta_items = g_slist_prepend (meta_items, g_strdup ("daap.songalbum")); request = g_strdup_printf ("/databases/%d/items?" "session-id=%d&revision-id=%d", db_id, session_id, revision_id); if (meta_items) { request = daap_url_append_meta (request, meta_items); } cc_data = daap_request_data (chan, request, host, request_id); song_list = cc_record_list_deep_copy (cc_data->record_list); g_free (request); cc_data_free (cc_data); g_io_channel_shutdown (chan, TRUE, NULL); g_io_channel_unref (chan); g_slist_foreach (meta_items, (GFunc) g_free, NULL); g_slist_free (meta_items); return song_list; }
gboolean daap_command_logout (gchar *host, gint port, guint session_id, guint request_id) { xmms_daap_conn_t *conn = NULL; gchar *request; conn = daap_conn_new (host, port); if (!conn) { return FALSE; } request = g_strdup_printf ("/logout?session-id=%d", session_id); /* there is no cc_data generated, so we don't need to store it anywhere */ daap_request_data (conn->chan, request, host, request_id); g_free (request); daap_conn_free (conn); return TRUE; }
gboolean daap_command_logout (gchar *host, gint port, guint session_id, guint request_id) { GIOChannel *chan; gchar *request; chan = daap_open_connection (host, port); if (!chan) { return FALSE; } request = g_strdup_printf ("/logout?session-id=%d", session_id); /* there is no cc_data generated, so we don't need to store it anywhere */ daap_request_data (chan, request, host, request_id); g_free (request); g_io_channel_shutdown (chan, TRUE, NULL); g_io_channel_unref (chan); return TRUE; }