summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/commands.c b/commands.c
index 2cf7909..e8f552a 100644
--- a/commands.c
+++ b/commands.c
@@ -5,6 +5,10 @@
#include <string.h>
+GQuark commands_quark() {
+ return g_quark_from_static_string("commands");
+}
+
static void commands_list(GSocketConnection *connection, const gchar *cmd, GError **error) {
gchar **data = g_strsplit(cmd, " ", 2);
for(gint i = 0; data[i]; i++) {
@@ -23,11 +27,7 @@ static void commands_list(GSocketConnection *connection, const gchar *cmd, GErro
struct directory *directory = music_find_dir(dirname);
if(directory == NULL) {
- g_warning("couldn't find directory %s", dirname);
- gchar *buf = g_strdup_printf("error: couldn't find directory %s\n", dirname);
- GSocket *socket = g_socket_connection_get_socket(connection);
- g_socket_send(socket, buf, strlen(buf), NULL, NULL);
- g_free(buf);
+ *error = g_error_new(commands_quark(), 0, "error: couldn't find directory %s\n", dirname);
return;
}
@@ -58,9 +58,7 @@ static void commands_find(GSocketConnection *connection, const gchar *cmd, GErro
gchar **data = g_strsplit(cmd, " ", 3);
if(g_strv_length(data) != 3) {
- const gchar *buf = "syntax: find (artist) search\n";
- GSocket *socket = g_socket_connection_get_socket(connection);
- g_socket_send(socket, buf, strlen(buf), NULL, NULL);
+ *error = g_error_new(commands_quark(), 0, "syntax: find artist|title|album search");
return;
}
@@ -74,7 +72,8 @@ static void commands_find(GSocketConnection *connection, const gchar *cmd, GErro
} else if(g_ascii_strcasecmp(data[1], "album") == 0) {
list = music_find_album(data[2]);
} else {
- g_debug("unknown search");
+ *error = g_error_new(commands_quark(), 0, "unknown search method %s", data[1]);
+ return;
}
GString *string = g_string_new(NULL);
@@ -136,6 +135,6 @@ void commands_handle(GSocketConnection *connection, const gchar *cmd, GError **e
commands_exit(connection, cmd, error);
} else {
g_debug("unknown command");
- *error = g_error_new(0, 0, "unknown command %s", cmd);
+ *error = g_error_new(commands_quark(), 0, "unknown command %s", cmd);
}
}