~ubuntu-branches/debian/sid/flickcurl/sid

« back to all changes in this revision

Viewing changes to src/contacts-api.c

  • Committer: Package Import Robot
  • Author(s): Kumar Appaiah
  • Date: 2014-01-12 08:20:42 UTC
  • mfrom: (1.4.2)
  • Revision ID: package-import@ubuntu.com-20140112082042-7p31zl22mw4ohbcd
Tags: 1.25-1
* New upstream release
* Standards version is now 3.9.5 (no changes needed)
* Multiarch conversion
  + Switch to dh based rules file
  + Add ${misc:Pre-Depends} and Multi-Arch: same for libflickcurl0
  + Alter install files to accommodate the multiarch path

Show diffs side-by-side

added added

removed removed

Lines of Context:
68
68
  char page_str[10];
69
69
  char per_page_str[10];
70
70
 
71
 
  flickcurl_init_params(fc);
 
71
  flickcurl_init_params(fc, 1);
72
72
 
73
73
  if(filter) {
74
74
    flickcurl_add_param(fc, "filter", filter);
87
87
  if(flickcurl_prepare(fc, "flickr.contacts.getList"))
88
88
    goto tidy;
89
89
 
90
 
  flickcurl_set_write(fc, 1);
91
 
  flickcurl_set_data(fc, (void*)"", 0);
92
 
 
93
90
  doc = flickcurl_invoke(fc);
94
91
  if(!doc)
95
92
    goto tidy;
145
142
  int contacts_count = 0;
146
143
  char date_lastupload_str[20];
147
144
  
148
 
  flickcurl_init_params(fc);
 
145
  flickcurl_init_params(fc, 0);
149
146
 
150
147
  if(date_lastupload >= 0) {
151
148
    sprintf(date_lastupload_str, "%d", date_lastupload);
198
195
 *
199
196
 * Implements flickr.contacts.getPublicList (0.11)
200
197
 * 
201
 
 * Return value: non-0 on failure
 
198
 * Return value: list of contacts or NULL on failure
202
199
 **/
203
200
flickcurl_contact**
204
201
flickcurl_contacts_getPublicList(flickcurl* fc, const char* user_id,
211
208
  char page_str[10];
212
209
  char per_page_str[10];
213
210
 
214
 
  flickcurl_init_params(fc);
 
211
  flickcurl_init_params(fc, 1);
215
212
 
216
213
  if (!user_id)
217
214
    return NULL;
232
229
  if(flickcurl_prepare(fc, "flickr.contacts.getPublicList"))
233
230
    goto tidy;
234
231
 
235
 
  flickcurl_set_write(fc, 1);
236
 
  flickcurl_set_data(fc, (void*)"", 0);
237
 
 
238
 
  doc = flickcurl_invoke(fc);
239
 
  if(!doc)
240
 
    goto tidy;
241
 
 
242
 
  xpathCtx = xmlXPathNewContext(doc);
243
 
  if(!xpathCtx) {
244
 
    flickcurl_error(fc, "Failed to create XPath context for document");
245
 
    fc->failed = 1;
246
 
    goto tidy;
247
 
  }
248
 
 
249
 
  contacts = flickcurl_build_contacts(fc, xpathCtx, 
250
 
                                    (xmlChar*)"/rsp/contacts/contact", 
251
 
                                    &contacts_count);
252
 
 
 
232
  doc = flickcurl_invoke(fc);
 
233
  if(!doc)
 
234
    goto tidy;
 
235
 
 
236
  xpathCtx = xmlXPathNewContext(doc);
 
237
  if(!xpathCtx) {
 
238
    flickcurl_error(fc, "Failed to create XPath context for document");
 
239
    fc->failed = 1;
 
240
    goto tidy;
 
241
  }
 
242
 
 
243
  contacts = flickcurl_build_contacts(fc, xpathCtx, 
 
244
                                    (xmlChar*)"/rsp/contacts/contact", 
 
245
                                    &contacts_count);
 
246
 
 
247
 
 
248
  tidy:
 
249
  if(xpathCtx)
 
250
    xmlXPathFreeContext(xpathCtx);
 
251
 
 
252
  if(fc->failed)
 
253
    contacts = NULL;
 
254
 
 
255
  return contacts;
 
256
}
 
257
 
 
258
 
 
259
/**
 
260
 * flickcurl_contacts_getTaggingSuggestions:
 
261
 * @fc: flickcurl context
 
262
 * @include_self: Return calling user in the list of suggestions. Default: true. (or NULL)
 
263
 * @include_address_book: Include suggestions from the user's address book. Default: false (or NULL)
 
264
 * @page: The page of results to return. If this argument is omitted, it defaults to 1. (or < 0)
 
265
 * @per_page: Number of contacts to return per page. If this argument is omitted, all contacts will be returned. (or < 0)
 
266
 * 
 
267
 * Get suggestions for tagging people in photos based on the calling user's contacts.
 
268
 *
 
269
 * Implements flickr.contacts.getTaggingSuggestions (1.25)
 
270
 *
 
271
 * NOTE: Parameter order is @page, @per_page like all other
 
272
 * flickr.contacts.* calls, NOT @per_page, @page like in the API
 
273
 * docs.
 
274
 * 
 
275
 * Return value: list of contacts or NULL on failure
 
276
 **/
 
277
flickcurl_contact**
 
278
flickcurl_contacts_getTaggingSuggestions(flickcurl* fc,
 
279
                                         const char* include_self,
 
280
                                         const char* include_address_book,
 
281
                                         int page, int per_page)
 
282
{
 
283
  xmlDocPtr doc = NULL;
 
284
  xmlXPathContextPtr xpathCtx = NULL; 
 
285
  flickcurl_contact** contacts = NULL;
 
286
  int contacts_count = 0;
 
287
  char page_str[10];
 
288
  char per_page_str[10];
 
289
 
 
290
  flickcurl_init_params(fc, 0);
 
291
 
 
292
  if(include_self)
 
293
    flickcurl_add_param(fc, "include_self", include_self);
 
294
  if(include_address_book)
 
295
    flickcurl_add_param(fc, "include_address_book", include_address_book);
 
296
  if(page >= 0) {
 
297
    sprintf(page_str, "%d", page);
 
298
    flickcurl_add_param(fc, "page", page_str);
 
299
  }
 
300
  if(per_page >= 0) {
 
301
    sprintf(per_page_str, "%d", per_page);
 
302
    flickcurl_add_param(fc, "per_page", per_page_str);
 
303
  }
 
304
 
 
305
  flickcurl_end_params(fc);
 
306
 
 
307
  if(flickcurl_prepare(fc, "flickr.contacts.getTaggingSuggestions"))
 
308
    goto tidy;
 
309
 
 
310
  doc = flickcurl_invoke(fc);
 
311
  if(!doc)
 
312
    goto tidy;
 
313
 
 
314
  xpathCtx = xmlXPathNewContext(doc);
 
315
  if(!xpathCtx) {
 
316
    flickcurl_error(fc, "Failed to create XPath context for document");
 
317
    fc->failed = 1;
 
318
    goto tidy;
 
319
  }
 
320
 
 
321
  contacts = flickcurl_build_contacts(fc, xpathCtx, 
 
322
                                    (xmlChar*)"/rsp/contacts/contact", 
 
323
                                    &contacts_count);
253
324
 
254
325
  tidy:
255
326
  if(xpathCtx)