~ubuntu-branches/ubuntu/quantal/libdmapsharing/quantal

« back to all changes in this revision

Viewing changes to libdmapsharing/dmap-share.h

  • Committer: Bazaar Package Importer
  • Author(s): Josselin Mouette
  • Date: 2011-03-29 19:52:57 UTC
  • mfrom: (0.1.2 experimental) (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20110329195257-0zas0lq4c03gwo46
Tags: 2.9.7-1
Initial release. (Closes: #620060)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Header for DMAP (e.g., iTunes Music or iPhoto Picture) sharing
 
1
/* Header for DMAP (e.g., iTunes Music or iPhoto Picture) sharing
3
2
 *
4
3
 * Copyright (C) 2005 Charles Schmidt <cschmidt2@emich.edu>
5
4
 *
37
36
#include <libdmapsharing/dmap-container-record.h>
38
37
 
39
38
G_BEGIN_DECLS
40
 
 
41
39
/**
42
 
 * TYPE_DMAP_SHARE:
 
40
 * DMAP_TYPE_SHARE:
43
41
 *
44
42
 * The type for #DMAPShare.
45
43
 */
46
 
#define TYPE_DMAP_SHARE         (dmap_share_get_type ())
 
44
#define DMAP_TYPE_SHARE         (dmap_share_get_type ())
47
45
/**
48
46
 * DMAP_SHARE:
49
47
 * @o: Object which is subject to casting.
53
51
 * certain runtime checks to identify invalid casts.
54
52
 */
55
53
#define DMAP_SHARE(o)           (G_TYPE_CHECK_INSTANCE_CAST ((o), \
56
 
                                 TYPE_DMAP_SHARE, DMAPShare))
 
54
                                 DMAP_TYPE_SHARE, DMAPShare))
57
55
/**
58
56
 * DMAP_SHARE_CLASS:
59
57
 * @k: a valid #DMAPShareClass
61
59
 * Casts a derived #DMAPShareClass structure into a #DMAPShareClass structure.
62
60
 */
63
61
#define DMAP_SHARE_CLASS(k)     (G_TYPE_CHECK_CLASS_CAST((k), \
64
 
                                 TYPE_DMAP_SHARE, DMAPShareClass))
 
62
                                 DMAP_TYPE_SHARE, DMAPShareClass))
65
63
/**
66
64
 * IS_DMAP_SHARE:
67
 
 * @o: Instance to check for being a %TYPE_DMAP_SHARE.
 
65
 * @o: Instance to check for being a %DMAP_TYPE_SHARE.
68
66
 *
69
 
 * Checks whether a valid #GTypeInstance pointer is of type %TYPE_DMAP_SHARE.
 
67
 * Checks whether a valid #GTypeInstance pointer is of type %DMAP_TYPE_SHARE.
70
68
 */
71
 
 
72
69
#define IS_DMAP_SHARE(o)        (G_TYPE_CHECK_INSTANCE_TYPE ((o), \
73
 
                                 TYPE_DMAP_SHARE))
 
70
                                 DMAP_TYPE_SHARE))
74
71
/**
75
72
 * IS_DMAP_SHARE_CLASS:
76
73
 * @k: a #DMAPShareClass
79
76
 * %DMAP_SHARE or derived.
80
77
 */
81
78
#define IS_DMAP_SHARE_CLASS(k)  (G_TYPE_CHECK_CLASS_TYPE ((k), \
82
 
                                 TYPE_DMAP_SHARE))
 
79
                                 DMAP_TYPE_SHARE))
83
80
/**
84
81
 * DMAP_SHARE_GET_CLASS:
85
82
 * @o: a #DMAPShare instance.
89
86
 * Returns: pointer to object class structure.
90
87
 */
91
88
#define DMAP_SHARE_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), \
92
 
                                 TYPE_DMAP_SHARE, DMAPShareClass))
93
 
 
94
 
#define DMAP_SHARE_CHUNK_SIZE 16384
 
89
                                 DMAP_TYPE_SHARE, DMAPShareClass))
95
90
#define DMAP_STATUS_OK 200
96
 
 
97
91
typedef struct DMAPSharePrivate DMAPSharePrivate;
98
92
 
99
 
typedef struct {
 
93
typedef struct
 
94
{
100
95
        GObject parent;
101
96
        DMAPSharePrivate *priv;
102
97
} DMAPShare;
103
98
 
104
99
typedef struct _DMAPMetaDataMap DMAPMetaDataMap;
105
100
 
106
 
typedef struct {
 
101
typedef struct
 
102
{
107
103
        GObjectClass parent;
108
104
 
109
105
        /* Pure virtual methods: */
110
 
        guint             (*get_desired_port)             (DMAPShare *share);
111
 
        const char *      (*get_type_of_service)          (DMAPShare *share);
112
 
        void              (*message_add_standard_headers) (DMAPShare *share,
113
 
                                                           SoupMessage *msg);
114
 
        struct DMAPMetaDataMap * (*get_meta_data_map)     (DMAPShare *share);
115
 
        void              (*add_entry_to_mlcl)            (gpointer id,
116
 
                                                           DMAPRecord *record,
117
 
                                                           gpointer mb);
118
 
        void              (*databases_browse_xxx)         (DMAPShare *share,
119
 
                                                           SoupServer *server,
120
 
                                                           SoupMessage *msg,
121
 
                                                           const char *path,
122
 
                                                           GHashTable *query,
123
 
                                                           SoupClientContext *context);
124
 
        void              (*databases_items_xxx)          (DMAPShare *share,
125
 
                                                           SoupServer *server,
126
 
                                                           SoupMessage *msg,
127
 
                                                           const char *path,
128
 
                                                           GHashTable *query,
129
 
                                                           SoupClientContext *context);
 
106
          guint (*get_desired_port) (DMAPShare * share);
 
107
        const char *(*get_type_of_service) (DMAPShare * share);
 
108
        void (*message_add_standard_headers) (DMAPShare * share,
 
109
                                              SoupMessage * msg);
 
110
        struct DMAPMetaDataMap *(*get_meta_data_map) (DMAPShare * share);
 
111
        void (*add_entry_to_mlcl) (gpointer id,
 
112
                                   DMAPRecord * record, gpointer mb);
 
113
        void (*databases_browse_xxx) (DMAPShare * share,
 
114
                                      SoupServer * server,
 
115
                                      SoupMessage * msg,
 
116
                                      const char *path,
 
117
                                      GHashTable * query,
 
118
                                      SoupClientContext * context);
 
119
        void (*databases_items_xxx) (DMAPShare * share,
 
120
                                     SoupServer * server,
 
121
                                     SoupMessage * msg,
 
122
                                     const char *path,
 
123
                                     GHashTable * query,
 
124
                                     SoupClientContext * context);
130
125
 
131
126
        /* Pure virtual methods: libsoup callbacks */
132
 
        void      (*server_info)   (DMAPShare *share, SoupServer *server,
133
 
                                    SoupMessage *message, const char *path,
134
 
                                    GHashTable *query, SoupClientContext *ctx);
135
 
 
136
 
        void      (*content_codes) (DMAPShare *share, SoupServer *server,
137
 
                                    SoupMessage *message, const char *path,
138
 
                                    GHashTable *query, SoupClientContext *ctx);
139
 
 
140
 
        void      (*login)         (DMAPShare *share, SoupServer *server,
141
 
                                    SoupMessage *message, const char *path,
142
 
                                    GHashTable *query, SoupClientContext *ctx);
143
 
 
144
 
        void      (*logout)        (DMAPShare *share, SoupServer *server,
145
 
                                    SoupMessage *message, const char *path,
146
 
                                    GHashTable *query, SoupClientContext *ctx);
147
 
 
148
 
        void      (*update)        (DMAPShare *share, SoupServer *server,
149
 
                                    SoupMessage *message, const char *path,
150
 
                                    GHashTable *query, SoupClientContext *ctx);
151
 
                                    
152
 
        void      (*ctrl_int)        (DMAPShare *share, SoupServer *server,
153
 
                                    SoupMessage *message, const char *path,
154
 
                                    GHashTable *query, SoupClientContext *ctx);
 
127
        void (*server_info) (DMAPShare * share, SoupServer * server,
 
128
                             SoupMessage * message, const char *path,
 
129
                             GHashTable * query, SoupClientContext * ctx);
 
130
 
 
131
        void (*content_codes) (DMAPShare * share, SoupServer * server,
 
132
                               SoupMessage * message, const char *path,
 
133
                               GHashTable * query, SoupClientContext * ctx);
 
134
 
 
135
        void (*login) (DMAPShare * share, SoupServer * server,
 
136
                       SoupMessage * message, const char *path,
 
137
                       GHashTable * query, SoupClientContext * ctx);
 
138
 
 
139
        void (*logout) (DMAPShare * share, SoupServer * server,
 
140
                        SoupMessage * message, const char *path,
 
141
                        GHashTable * query, SoupClientContext * ctx);
 
142
 
 
143
        void (*update) (DMAPShare * share, SoupServer * server,
 
144
                        SoupMessage * message, const char *path,
 
145
                        GHashTable * query, SoupClientContext * ctx);
 
146
 
 
147
        void (*ctrl_int) (DMAPShare * share, SoupServer * server,
 
148
                          SoupMessage * message, const char *path,
 
149
                          GHashTable * query, SoupClientContext * ctx);
155
150
 
156
151
        /* Virtual methods: MDNS callbacks */
157
 
        void      (*published)     (DMAPShare         *share,
158
 
                                    DmapMdnsPublisher *publisher,
159
 
                                    const char        *name);
 
152
        void (*published) (DMAPShare * share,
 
153
                           DMAPMdnsPublisher * publisher, const char *name);
160
154
 
161
 
        void      (*name_collision)(DMAPShare         *share,
162
 
                                    DmapMdnsPublisher *publisher,
163
 
                                    const char        *name);
 
155
        void (*name_collision) (DMAPShare * share,
 
156
                                DMAPMdnsPublisher * publisher,
 
157
                                const char *name);
164
158
 
165
159
        /* Virtual methods: */
166
 
        void      (*databases)     (DMAPShare         *share,
167
 
                                    SoupServer        *server,
168
 
                                    SoupMessage       *message,
169
 
                                    const char        *path,
170
 
                                    GHashTable        *query,
171
 
                                    SoupClientContext *context);
 
160
        void (*databases) (DMAPShare * share,
 
161
                           SoupServer * server,
 
162
                           SoupMessage * message,
 
163
                           const char *path,
 
164
                           GHashTable * query, SoupClientContext * context);
172
165
} DMAPShareClass;
173
166
 
174
 
struct DMAPMetaDataMap {
175
 
        gchar *tag;
 
167
struct DMAPMetaDataMap
 
168
{
 
169
        gchar *tag;
176
170
        guint md;
177
171
};
178
172
 
179
 
GType    dmap_share_get_type (void);
 
173
/* FIXME: this is passed as user_data to various functions; 
 
174
 * need to rename. Also, get rid of initializations elsewhere: { NULL, 0, NULL };
 
175
 * instead define a function to do this.
 
176
 */
 
177
struct MLCL_Bits
 
178
{
 
179
        GNode *mlcl;
 
180
        bitwise bits;
 
181
        DMAPShare *share;
 
182
};
 
183
 
 
184
GType dmap_share_get_type (void);
180
185
 
181
186
/* Non-virtual methods */
182
 
guint    _dmap_share_get_auth_method (DMAPShare *share);
183
 
 
184
 
guint    _dmap_share_get_revision_number (DMAPShare *share);
185
 
 
186
 
gboolean _dmap_share_get_revision_number_from_query (GHashTable *query,
187
 
                                                    guint *number);
188
 
 
189
 
gboolean _dmap_share_session_id_validate (DMAPShare *share,
190
 
                                         SoupClientContext *context, 
191
 
                                         SoupMessage *msg, GHashTable *query,
192
 
                                         guint32 *id);
193
 
 
194
 
guint32  _dmap_share_session_id_create (DMAPShare *share,
195
 
                                       SoupClientContext *ctx);
196
 
 
197
 
void     _dmap_share_session_id_remove (DMAPShare *share,
198
 
                                       SoupClientContext *ctx,
199
 
                                       guint32 id);
 
187
guint _dmap_share_get_auth_method (DMAPShare * share);
 
188
 
 
189
guint _dmap_share_get_revision_number (DMAPShare * share);
 
190
 
 
191
gboolean _dmap_share_get_revision_number_from_query (GHashTable * query,
 
192
                                                     guint * number);
 
193
 
 
194
gboolean _dmap_share_session_id_validate (DMAPShare * share,
 
195
                                          SoupClientContext * context,
 
196
                                          SoupMessage * msg,
 
197
                                          GHashTable * query, guint32 * id);
 
198
 
 
199
guint32 _dmap_share_session_id_create (DMAPShare * share,
 
200
                                       SoupClientContext * ctx);
 
201
 
 
202
void _dmap_share_session_id_remove (DMAPShare * share,
 
203
                                    SoupClientContext * ctx, guint32 id);
200
204
 
201
205
gboolean _dmap_share_client_requested (bitwise bits, gint field);
202
206
 
203
207
gboolean _dmap_share_uri_is_local (const char *text_uri);
204
208
 
205
 
gboolean _dmap_share_soup_auth_filter (SoupAuthDomain *auth_domain,
206
 
                                      SoupMessage *msg, gpointer user_data);
207
 
 
208
 
gboolean _dmap_share_server_start  (DMAPShare *share);
209
 
 
210
 
gboolean _dmap_share_publish_start (DMAPShare *share);
211
 
 
212
 
void     _dmap_share_message_set_from_dmap_structure (DMAPShare *share,
213
 
                                                     SoupMessage *message,
214
 
                                                     GNode *structure);
215
 
 
216
 
bitwise  _dmap_share_parse_meta (GHashTable *query,
 
209
gboolean _dmap_share_soup_auth_filter (SoupAuthDomain * auth_domain,
 
210
                                       SoupMessage * msg, gpointer user_data);
 
211
 
 
212
gboolean _dmap_share_server_start (DMAPShare * share);
 
213
 
 
214
gboolean _dmap_share_publish_start (DMAPShare * share);
 
215
 
 
216
void _dmap_share_message_set_from_dmap_structure (DMAPShare * share,
 
217
                                                  SoupMessage * message,
 
218
                                                  GNode * structure);
 
219
 
 
220
bitwise _dmap_share_parse_meta (GHashTable * query,
217
221
                                struct DMAPMetaDataMap *mdm);
218
222
 
219
 
bitwise  _dmap_share_parse_meta_str (const char *attrs,
 
223
bitwise _dmap_share_parse_meta_str (const char *attrs,
220
224
                                    struct DMAPMetaDataMap *mdm);
221
225
 
222
226
void _dmap_share_add_playlist_to_mlcl (gpointer id,
223
 
                                       DMAPContainerRecord *record,
 
227
                                       DMAPContainerRecord * record,
224
228
                                       gpointer mb);
225
229
 
226
 
GSList * _dmap_share_build_filter (gchar *filterstr);
 
230
GSList *_dmap_share_build_filter (gchar * filterstr);
227
231
 
228
 
void dmap_share_free_filter (GSList *filter);
 
232
void dmap_share_free_filter (GSList * filter);
229
233
 
230
234
/* Virtual methods (libsoup callbacks with default implementation): */
231
 
void _dmap_share_content_codes (DMAPShare *share,
232
 
                  SoupServer        *server,
233
 
                  SoupMessage       *message,
234
 
                  const char        *path,
235
 
                  GHashTable        *query,
236
 
                  SoupClientContext *context);
237
 
 
238
 
void _dmap_share_login (DMAPShare *share,
239
 
                  SoupServer        *server,
240
 
                  SoupMessage       *message,
241
 
                  const char        *path,
242
 
                  GHashTable        *query,
243
 
                  SoupClientContext *context);
244
 
 
245
 
void _dmap_share_logout (DMAPShare *share,
246
 
                  SoupServer        *server,
247
 
                  SoupMessage       *message,
248
 
                  const char        *path,
249
 
                  GHashTable        *query,
250
 
                  SoupClientContext *context);
251
 
 
252
 
void _dmap_share_update (DMAPShare *share,
253
 
                  SoupServer        *server,
254
 
                  SoupMessage       *message,
255
 
                  const char        *path,
256
 
                  GHashTable        *query,
257
 
                  SoupClientContext *context);
 
235
void _dmap_share_content_codes (DMAPShare * share,
 
236
                                SoupServer * server,
 
237
                                SoupMessage * message,
 
238
                                const char *path,
 
239
                                GHashTable * query,
 
240
                                SoupClientContext * context);
 
241
 
 
242
void _dmap_share_login (DMAPShare * share,
 
243
                        SoupServer * server,
 
244
                        SoupMessage * message,
 
245
                        const char *path,
 
246
                        GHashTable * query, SoupClientContext * context);
 
247
 
 
248
void _dmap_share_logout (DMAPShare * share,
 
249
                         SoupServer * server,
 
250
                         SoupMessage * message,
 
251
                         const char *path,
 
252
                         GHashTable * query, SoupClientContext * context);
 
253
 
 
254
void _dmap_share_update (DMAPShare * share,
 
255
                         SoupServer * server,
 
256
                         SoupMessage * message,
 
257
                         const char *path,
 
258
                         GHashTable * query, SoupClientContext * context);
258
259
 
259
260
void
260
 
_dmap_share_databases (DMAPShare *share,
261
 
                       SoupServer        *server,
262
 
                       SoupMessage       *message,
263
 
                       const char        *path,
264
 
                       GHashTable        *query,
265
 
                       SoupClientContext *context);
 
261
_dmap_share_databases (DMAPShare * share,
 
262
                       SoupServer * server,
 
263
                       SoupMessage * message,
 
264
                       const char *path,
 
265
                       GHashTable * query, SoupClientContext * context);
266
266
 
267
 
void _dmap_share_ctrl_int (DMAPShare         *share,
268
 
                           SoupServer        *server,
269
 
                           SoupMessage       *message,
270
 
                           const char        *path,
271
 
                           GHashTable        *query,
272
 
                           SoupClientContext *context);
 
267
void _dmap_share_ctrl_int (DMAPShare * share,
 
268
                           SoupServer * server,
 
269
                           SoupMessage * message,
 
270
                           const char *path,
 
271
                           GHashTable * query, SoupClientContext * context);
273
272
 
274
273
/* Virtual methods: MDNS callbacks */
275
 
void _dmap_share_published     (DMAPShare         *share,
276
 
                               DmapMdnsPublisher *publisher,
277
 
                               const char        *name);
278
 
 
279
 
void _dmap_share_name_collision(DMAPShare         *share,
280
 
                               DmapMdnsPublisher *publisher,
281
 
                               const char        *name);
282
 
 
 
274
void _dmap_share_published (DMAPShare * share,
 
275
                            DMAPMdnsPublisher * publisher, const char *name);
 
276
 
 
277
void _dmap_share_name_collision (DMAPShare * share,
 
278
                                 DMAPMdnsPublisher * publisher,
 
279
                                 const char *name);
283
280
 
284
281
#endif /* __DMAP_SHARE_H */
285
282