LCID-Fire / liblastfm

Library to access lastfm via it's 2.0 api

This URL has Read+Write access

liblastfm / communication.h
19a3e61f » LCID-Fire 2008-07-06 Does compile 1 #ifndef COMMUNICATION_H_
2 #define COMMUNICATION_H_
3
4 #include <glib.h>
2b8415c9 » LCID-Fire 2008-07-06 Further development (some b... 5 #include "callback.h"
19a3e61f » LCID-Fire 2008-07-06 Does compile 6
dc2c374f » LCID-Fire 2008-07-08 Getting some first simple r... 7 void communication_init();
8 void communication_destroy();
9
10 struct lfmerror
11 {
12 const guint code;
13 const gchar* message;
14 };
15
16 typedef struct lfmerror lfmerror;
17
19a3e61f » LCID-Fire 2008-07-06 Does compile 18 struct lfmproxy;
19 typedef struct lfmproxy lfmproxy;
20
21 #define BUILD_PARAMETER_NAMES(array) \
22 gchar** array = NULL;\
23 createv(gchar, array);\
24 addv(gchar, array, artist_parameters[0]);\
25 addv(gchar, array, artist_parameters[1]);\
26 addv(gchar, array, artist_parameters[2]);
27
28 #define BUILD_PARAMTER_VALUES(array, astruct) \
29 gchar** array = NULL;\
30 createv(gchar, array);\
31 addv(gchar, array, G_STRUCT_MEMBER_P(astruct, 0));\
32 addv(gchar, array, G_STRUCT_MEMBER_P(astruct, 1));\
33 addv(gchar, array, G_STRUCT_MEMBER_P(astruct, 2));
34
2b8415c9 » LCID-Fire 2008-07-06 Further development (some b... 35 //
36 //Token functions
37 //
937d982d » LCID-Fire 2008-07-10 Simplified interface 38 void token_request_authorization(const gchar* token);
19a3e61f » LCID-Fire 2008-07-06 Does compile 39
4663885e » LCID-Fire 2008-07-11 Simplified converters 40 typedef gchar* (*type_converter)(gpointer data);
19a3e61f » LCID-Fire 2008-07-06 Does compile 41
42 struct lfmparameter
43 {
dc2c374f » LCID-Fire 2008-07-08 Getting some first simple r... 44 const gchar* name;
19a3e61f » LCID-Fire 2008-07-06 Does compile 45 type_converter converter;
46 };
47
48 typedef struct lfmparameter lfmparameter;
49
270cc092 » LCID-Fire 2008-07-15 Prepare sending post to web... 50 enum method_type
51 {
52 GET_METHOD,
53 POST_METHOD
54 };
55
19a3e61f » LCID-Fire 2008-07-06 Does compile 56 struct lfmmethod
57 {
58 const gchar* name;
270cc092 » LCID-Fire 2008-07-15 Prepare sending post to web... 59 const enum method_type type;
953b92fd » LCID-Fire 2008-07-18 Declare method in every detail 60 const lfmparameter parameters[5];
61 const lfmparameter optional_parameters[5];
dc2c374f » LCID-Fire 2008-07-08 Getting some first simple r... 62 const lfmerror specific_errors[5];
19a3e61f » LCID-Fire 2008-07-06 Does compile 63 };
64
953b92fd » LCID-Fire 2008-07-18 Declare method in every detail 65 typedef struct lfmmethod lfmmethod;
66
2b8415c9 » LCID-Fire 2008-07-06 Further development (some b... 67 enum data_type
68 {
69 DATA_UTF8,
70 DATA_URL,
71 DATA_DATE_TIME,
72 DATA_BOOLEAN,
270cc092 » LCID-Fire 2008-07-15 Prepare sending post to web... 73 DATA_UINT,
2c9dc967 » LCID-Fire 2008-07-19 Simplified callbacks: 74 DATA_VOID,
75 DATA_MULTI_UTF8,
76 DATA_TAGS = DATA_MULTI_UTF8,
77 DATA_ALBUMS = DATA_MULTI_UTF8,
78 DATA_ARTISTS = DATA_MULTI_UTF8,
79 DATA_EVENTS = DATA_MULTI_UTF8,
80 DATA_TRACKS = DATA_MULTI_UTF8,
81 DATA_USERS = DATA_MULTI_UTF8
2b8415c9 » LCID-Fire 2008-07-06 Further development (some b... 82 };
83
953b92fd » LCID-Fire 2008-07-18 Declare method in every detail 84 struct utf8_syncer
85 {
86 gchar* string;
87 GError* error;
88 GCond* signal;
89 };
90
91 void utf8_sync(const gchar* string, gpointer user_data, GError* error);
92
93 #define IMPLEMENT_SYNC_UTF8(function, ...) \
94 struct utf8_syncer _syncer;\
95 _syncer.string = NULL;\
96 _syncer.error = NULL;\
97 _syncer.signal = g_cond_new();\
98 function(__VA_ARGS__, utf8_sync, &_syncer);\
99 GMutex* _mutex = g_mutex_new();\
100 g_cond_wait(_syncer.signal, _mutex);\
101 g_mutex_free(_mutex);\
a840b696 » LCID-Fire 2008-07-19 Added cleanup of signal 102 g_cond_free(_syncer.signal);\
953b92fd » LCID-Fire 2008-07-18 Declare method in every detail 103 if(_syncer.error)\
104 {\
105 *error = _syncer.error;\
106 return NULL;\
107 }\
108 return _syncer.string
19a3e61f » LCID-Fire 2008-07-06 Does compile 109
110 struct lfmget
111 {
112 const lfmmethod* method;
113 const gchar* path[5];
270cc092 » LCID-Fire 2008-07-15 Prepare sending post to web... 114 const enum data_type data_parser;
19a3e61f » LCID-Fire 2008-07-06 Does compile 115 };
116
117 typedef struct lfmget lfmget;
118
4663885e » LCID-Fire 2008-07-11 Simplified converters 119 gchar* utf8_array2csl(gpointer array);
120 gchar* uint2utf8(gpointer array);
19a3e61f » LCID-Fire 2008-07-06 Does compile 121
953b92fd » LCID-Fire 2008-07-18 Declare method in every detail 122 //variable argument have to be ordered as defined in call
270cc092 » LCID-Fire 2008-07-15 Prepare sending post to web... 123 G_GNUC_NULL_TERMINATED void call_method_with_parameters(const lfmget* call, gpointer callback, gpointer user_data, ...);
19a3e61f » LCID-Fire 2008-07-06 Does compile 124
125 #endif /*COMMUNICATION_H_*/