-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.c
69 lines (56 loc) · 1.68 KB
/
client.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include <gdk/gdk.h>
#include "client.h"
#include "../musiclib-grpc/cgo/build/client.h"
#ifdef DEBUG
#define CLIENT_DEBUG TRUE
#else
#define CLIENT_DEBUG FALSE
#endif
void
client_connect ()
{
MLibGRPC_Connect ("127.0.0.1:8337", FALSE, CLIENT_DEBUG);
}
void
client_disconnect ()
{
MLibGRPC_Disconnect ();
}
GPtrArray *
client_browse_items (const gchar *uri, const gchar *search, const gint browse_type)
{
MLibGRPC_BrowseItems *results = MLibGRPC_Browse ((char*)uri, (char*)search, browse_type + 1);
GPtrArray *items = g_ptr_array_sized_new (results->count);
MLibGRPC_BrowseItem **idx = results->items;
for (int i = 0; i < results->count; idx++, i++) {
MLibGRPC_BrowseItem *result = *idx;
BrowseItem *item = g_malloc (sizeof *item);
item->name = g_strdup (result->name);
item->uri = g_strdup (result->uri);
item->image_uri = g_strdup (result->image_uri);
item->folder = result->folder;
g_ptr_array_add (items, item);
free (result->name);
free (result->uri);
free (result->image_uri);
free (result);
}
free (results->items);
free (results);
return items;
}
GPtrArray *
client_media_items (const gchar *uri, const gchar *search, const gint browse_type)
{
MLibGRPC_MediaItems *results = MLibGRPC_Media ((char*)uri, (char*)search, browse_type + 1);
GPtrArray *items = g_ptr_array_sized_new (results->count);
gchar **idx = results->items;
int i = 0;
for (gchar *result = *idx; i < results->count; result = *++idx, i++) {
g_ptr_array_add (items, g_strdup (result));
free (result);
}
free (results->items);
free (results);
return items;
}