commit 4967eb1ed87d768578d6665e4ff8d1d2998210aa Author: Robby Zampino Date: Tue Sep 18 23:41:15 2018 -0600 Initial commit. Currently can get POST to and print response from /getMusicDirectory diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..d163863 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +build/ \ No newline at end of file diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..a0b6d9b --- /dev/null +++ b/README.rst @@ -0,0 +1,6 @@ +libremsonic +=========== + +A *sonic client for the Librem 5. + +Built using Vala, LibSoup, and GTK+. \ No newline at end of file diff --git a/meson.build b/meson.build new file mode 100644 index 0000000..08c3805 --- /dev/null +++ b/meson.build @@ -0,0 +1,9 @@ +project('libremsonic', 'vala', 'c') + +glib_dep = dependency('glib-2.0') +gobject_dep = dependency('gobject-2.0') +libsoup_dep = dependency('libsoup-2.4') + +executable('libremsonic', 'src/main.vala', + dependencies : [glib_dep, gobject_dep, + libsoup_dep]) \ No newline at end of file diff --git a/src/main.vala b/src/main.vala new file mode 100644 index 0000000..29ddcbb --- /dev/null +++ b/src/main.vala @@ -0,0 +1,31 @@ +using Soup; + +int main(string[] args) { + + string url = "http://%s:%s/libresonic/rest/getMusicDirectory".printf(args[1], args[2]); + var session = new Soup.Session(); + var message = new Soup.Message("POST", url); + var form = Soup.Form.encode("u", args[3], + "p", args[4], + "c", "curl_zsh", + "f", "json", + "v", "1.14.0", + "id", args[5]); + + stdout.printf("Form: %s\n", form); + + session.ssl_strict = false; + + message.request_headers.set_content_type(Soup.FORM_MIME_TYPE_URLENCODED, null); + message.request_body.append_take(form.data); + + session.send_message(message); + + + stdout.printf("Status Code: %u\n", message.status_code); + stdout.printf("Message length: %lld\n", message.response_body.length); + stdout.printf("Data: \n%s\n", (string) message.response_body.data); + //stdout.printf("%s\n", message.tls_errors.to_string()); + + return 0; +} \ No newline at end of file