summaryrefslogtreecommitdiff
path: root/commands.c
diff options
context:
space:
mode:
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/commands.c b/commands.c
index db7e133..9b9e543 100644
--- a/commands.c
+++ b/commands.c
@@ -1,5 +1,7 @@
#include "commands.h"
#include "music.h"
+#include "servers.h"
+#include "server_communication.h"
#include <string.h>
@@ -62,6 +64,8 @@ static void commands_find(GSocketConnection *connection, const gchar *cmd, GErro
return;
}
+ gboolean remote = g_strncasecmp(data[0], "rfind", 5) == 0 ? TRUE : FALSE;
+
GSList *list = NULL;
if(g_ascii_strcasecmp(data[1], "artist") == 0) {
list = music_find_artist(data[2]);
@@ -83,6 +87,25 @@ static void commands_find(GSocketConnection *connection, const gchar *cmd, GErro
}
g_slist_free(list);
+ if(remote == TRUE) {
+ for(GSList *node = servers; node; node = g_slist_next(node)) {
+ struct server *server = node->data;
+ g_debug("fetching data from server %s", server->host);
+ gchar **temp = server_find(server, data[1], data[2]);
+ if(temp == NULL) {
+ continue;
+ }
+ for(gint i = 0; i < g_strv_length(temp); i++) {
+ if(strlen(temp[i]) == 0) {
+ break;
+ }
+ g_string_append_printf(string, "%s:%s\n", server->host, temp[i]);
+ }
+ g_strfreev(temp);
+ }
+ }
+
+
GOutputStream *os = g_io_stream_get_output_stream((GIOStream*)connection);
if(g_output_stream_write_all(os, string->str, string->len, NULL, NULL,
error) == FALSE) {