Beispiel #1
0
/**
 * flickcurl_tags_getClusterPhotos:
 * @fc: flickcurl context
 * @tag: The tag that this cluster belongs to.
 * @cluster_id: The top three tags for the cluster, separated by dashes (just like the url).
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 * 
 * Returns the first 24 photos for a given tag cluster
 *
 * Implements flickr.tags.getClusterPhotos (1.7)
 *
 * Added to API (not announced) some time between 2008-09-04 and 2008-09-19
 * 
 * Return value: non-0 on failure
 **/
flickcurl_photos_list*
flickcurl_tags_getClusterPhotos(flickcurl* fc, const char* tag,
                                const char* cluster_id,
                                flickcurl_photos_list_params* list_params)
{
  flickcurl_photos_list* photos_list = NULL;
  const char* format = NULL;
  
  flickcurl_init_params(fc);

  if(!tag || !cluster_id)
    return NULL;

  flickcurl_add_param(fc, "tag", tag);
  flickcurl_add_param(fc, "cluster_id", cluster_id);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.tags.getClusterPhotos"))
    goto tidy;

  photos_list = flickcurl_invoke_photos_list(fc,
                                             (const xmlChar*)"/rsp/photos",
                                             format);
  tidy:
  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list = NULL;
  }

  return photos_list;
}
Beispiel #2
0
/**
 * flickcurl_interestingness_getList_params:
 * @fc: flickcurl context
 * @date: A specific date, formatted as YYYY-MM-DD, to return interesting photos for. (or NULL)
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 * 
 * Returns the list of interesting photos for the most recent day or a user-specified date.
 *
 * Optional extra type 'media' that will return an extra media = VALUE
 * for VALUE "photo" or "video".  API addition 2008-04-07.
 *
 * Return value: non-0 on failure
 **/
flickcurl_photos_list*
flickcurl_interestingness_getList_params(flickcurl* fc, const char* date,
                                         flickcurl_photos_list_params* list_params)
{
  flickcurl_photos_list* photos_list = NULL;
  const char* format = NULL;

  flickcurl_init_params(fc);

  /* API parameters */
  if(date) {
    flickcurl_add_param(fc, "date", date);
  }

  /* Photos List parameters */
  flickcurl_append_photos_list_params(fc, list_params, &format);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.interestingness.getList"))
    goto tidy;

  photos_list = flickcurl_invoke_photos_list(fc,
                                             (const xmlChar*)"/rsp/photos",
                                             format);

  tidy:
  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list = NULL;
  }

  return photos_list;
}
Beispiel #3
0
/**
 * flickcurl_people_getPhotosOf_params:
 * @fc: flickcurl context
 * @user_id: The NSID of the user who's photo to search. A value of "me" will search against the calling user's photos for authenticated calls.
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 * 
 * Returns a list of photos containing a particular Flickr member.
 *
 * Announced 2010-01-21
 * http://code.flickr.com/blog/2010/01/21/people-in-photos-the-api-methods/
 * 
 * Return value: photos list or NULL on failure
 **/
flickcurl_photos_list*
flickcurl_people_getPhotosOf_params(flickcurl* fc, const char* user_id,
                                    flickcurl_photos_list_params* list_params)
{
  flickcurl_photos_list* photos_list = NULL;
  const char* format = NULL;
  
  flickcurl_init_params(fc, 0);

  if(!user_id)
    return photos_list;

  flickcurl_add_param(fc, "user_id", user_id);

  /* Photos List parameters */
  flickcurl_append_photos_list_params(fc, list_params, &format);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.people.getPhotosOf"))
    goto tidy;

  photos_list = flickcurl_invoke_photos_list(fc,
                                             (const xmlChar*)"/rsp/photos",
                                             format);

  tidy:
  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list = NULL;
  }

  return photos_list;
}
Beispiel #4
0
/**
 * flickcurl_tags_getClusterPhotos:
 * @fc: flickcurl context
 * @tag: The tag that this cluster belongs to.
 * @cluster_id: The top three tags for the cluster, separated by dashes (just like the url).
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 * 
 * Returns the first 24 photos for a given tag cluster
 *
 * Implements flickr.tags.getClusterPhotos (1.7)
 *
 * Added to API (not announced) some time between 2008-09-04 and 2008-09-19
 * 
 * Return value: non-0 on failure
 **/
flickcurl_photos_list*
flickcurl_tags_getClusterPhotos(flickcurl* fc, const char* tag,
                                const char* cluster_id,
                                flickcurl_photos_list_params* list_params)
{
  const char* parameters[10][2];
  int count = 0;
  flickcurl_photos_list* photos_list = NULL;
  const char* format = NULL;
  
  if(!tag || !cluster_id)
    return NULL;

  parameters[count][0]  = "tag";
  parameters[count++][1]= tag;
  parameters[count][0]  = "cluster_id";
  parameters[count++][1]= cluster_id;

  parameters[count][0]  = NULL;

  if(flickcurl_prepare(fc, "flickr.tags.getClusterPhotos", parameters, count))
    goto tidy;

  photos_list = flickcurl_invoke_photos_list(fc,
                                             (const xmlChar*)"/rsp/photos",
                                             format);
  tidy:
  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list = NULL;
  }

  return photos_list;
}
Beispiel #5
0
/**
 * flickcurl_photos_geo_photosForLocation_params:
 * @fc: flickcurl context
 * @location: The location (lat, long, accuracy) of the photos
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 * 
 * Get a list of photos for a user at a specific location (latitude, longitude
 * and accuracy)
 *
 * Return value: list of photos or NULL on failure
 **/
flickcurl_photos_list*
flickcurl_photos_geo_photosForLocation_params(flickcurl* fc,
                                              flickcurl_location* location,
                                              flickcurl_photos_list_params* list_params)
{
  flickcurl_photos_list* photos_list = NULL;
  char latitude_s[50];
  char longitude_s[50];
  char accuracy_s[50];
  const char* format = NULL;

  flickcurl_init_params(fc, 0);

  if(!location)
    return NULL;
  
  if(location->latitude < -90.0)
    location->latitude= -90.0;
  if(location->latitude > 90.0)
    location->latitude= 90.0;
  if(location->longitude < -180.0)
    location->longitude= -180.0;
  if(location->longitude > 180.0)
    location->longitude= 180.0;
  if(location->accuracy < 1 || location->accuracy > 16)
    location->accuracy = 0;
  

  sprintf(latitude_s, "%f", location->latitude);
  flickcurl_add_param(fc, "lat", latitude_s);
  sprintf(longitude_s, "%f", location->longitude);
  flickcurl_add_param(fc, "lon", longitude_s);
  sprintf(accuracy_s, "%d", location->accuracy);
  flickcurl_add_param(fc, "accuracy", accuracy_s);

  /* Photos List parameters */
  flickcurl_append_photos_list_params(fc, list_params, &format);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.photos.geo.photosForLocation"))
    goto tidy;

  photos_list = flickcurl_invoke_photos_list(fc,
                                             (const xmlChar*)"/rsp/photos",
                                             format);

  tidy:
  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list = NULL;
  }

  return photos_list;
}
Beispiel #6
0
/**
 * flickcurl_groups_pools_getPhotos_params:
 * @fc: flickcurl context
 * @group_id: The id of the group who's pool you which to get the photo list for.
 * @tags: A tag to filter the pool with. At the moment only one tag at a time is supported. (or NULL)
 * @user_id: The nsid of a user (or NULL).  If given, retrieves only photos that the user has contributed to the group pool.
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 * 
 * Returns a list of pool photos for a given group.
 *
 * Currently supported extra fields are: license, date_upload,
 * date_taken, owner_name, icon_server, original_format,
 * last_update, geo, tags, machine_tags.
 *
 * Optional extra type 'media' that will return an extra media=VALUE
 * for VALUE "photo" or "video".  API addition 2008-04-07.
 *
 * Return value: non-0 on failure
 **/
flickcurl_photos_list*
flickcurl_groups_pools_getPhotos_params(flickcurl* fc, const char* group_id,
                                        const char* tags, const char* user_id,
                                        flickcurl_photos_list_params* list_params)
{
  const char* parameters[14][2];
  int count=0;
  flickcurl_photos_list* photos_list=NULL;
  const char* format=NULL;
  
  if(!group_id)
    return NULL;

  /* API parameters */
  parameters[count][0]  = "group_id";
  parameters[count++][1]= group_id;
  if(tags) {
    parameters[count][0]  = "tags";
    parameters[count++][1]= tags;
  }
  if(user_id) {
    parameters[count][0]  = "user_id";
    parameters[count++][1]= user_id;
  }

  /* Photos List parameters */
  flickcurl_append_photos_list_params(list_params, parameters, &count, &format);
  
  parameters[count][0]  = NULL;

  if(flickcurl_prepare(fc, "flickr.groups.pools.getPhotos", parameters, count))
    goto tidy;

  photos_list=flickcurl_invoke_photos_list(fc,
                                           (const xmlChar*)"/rsp/photos/photo",
                                           format);

  tidy:
  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list=NULL;
  }

  return photos_list;
}
/**
 * flickcurl_photosets_getPhotos_params:
 * @fc: flickcurl context
 * @photoset_id: The id of the photoset to return the photos for.
 * @privacy_filter: Return photos only matching a certain privacy level 1-5 (or <0)
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 *
 * Get the list of photos in a set.
 *
 * Currently supported extra fields are: license, date_upload,
 * date_taken, owner_name, icon_server, original_format,
 * last_update.
 *
 * Optional extra type 'media' that will return an extra media = VALUE
 * for VALUE "photo" or "video".  API addition 2008-04-07.
 *
 * Return value: list of photos or NULL on failure
 **/
flickcurl_photos_list*
flickcurl_photosets_getPhotos_params(flickcurl* fc, const char* photoset_id,
                                     int privacy_filter,
                                     flickcurl_photos_list_params* list_params)
{
    const char* parameters[13][2];
    int count = 0;
    flickcurl_photos_list* photos_list = NULL;
    char privacy_filter_str[2];
    const char* format = NULL;

    if(!photoset_id)
        return NULL;

    /* API parameters */
    parameters[count][0]  = "photoset_id";
    parameters[count++][1]= photoset_id;
    if(privacy_filter >= 1 && privacy_filter <= 5) {
        parameters[count][0]  = "privacy_filter";
        sprintf(privacy_filter_str, "%d", privacy_filter);
        parameters[count++][1]= privacy_filter_str;
    }

    /* Photos List parameters */
    flickcurl_append_photos_list_params(list_params, parameters, &count, &format);

    parameters[count][0]  = NULL;

    if(flickcurl_prepare(fc, "flickr.photosets.getPhotos", parameters, count))
        goto tidy;

    photos_list = flickcurl_invoke_photos_list(fc,
                  (const xmlChar*)"/rsp/photoset/photo",
                  format);

tidy:
    if(fc->failed) {
        if(photos_list)
            flickcurl_free_photos_list(photos_list);
        photos_list = NULL;
    }

    return photos_list;
}
Beispiel #8
0
/**
 * flickcurl_groups_pools_getPhotos_params:
 * @fc: flickcurl context
 * @group_id: The id of the group who's pool you which to get the photo list for.
 * @tags: A tag to filter the pool with. At the moment only one tag at a time is supported. (or NULL)
 * @user_id: The nsid of a user (or NULL).  If given, retrieves only photos that the user has contributed to the group pool.
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 * 
 * Returns a list of pool photos for a given group.
 *
 * Currently supported extra fields are: license, date_upload,
 * date_taken, owner_name, icon_server, original_format,
 * last_update, geo, tags, machine_tags.
 *
 * Optional extra type 'media' that will return an extra media = VALUE
 * for VALUE "photo" or "video".  API addition 2008-04-07.
 *
 * Return value: non-0 on failure
 **/
flickcurl_photos_list*
flickcurl_groups_pools_getPhotos_params(flickcurl* fc, const char* group_id,
                                        const char* tags, const char* user_id,
                                        flickcurl_photos_list_params* list_params)
{
  flickcurl_photos_list* photos_list = NULL;
  const char* format = NULL;
  
  flickcurl_init_params(fc);

  if(!group_id)
    return NULL;

  /* API parameters */
  flickcurl_add_param(fc, "group_id", group_id);
  if(tags) {
    flickcurl_add_param(fc, "tags", tags);
  }
  if(user_id) {
    flickcurl_add_param(fc, "user_id", user_id);
  }

  /* Photos List parameters */
  flickcurl_append_photos_list_params(fc, list_params, &format);
  
  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.groups.pools.getPhotos"))
    goto tidy;

  photos_list = flickcurl_invoke_photos_list(fc,
                                             (const xmlChar*)"/rsp/photos",
                                             format);

  tidy:
  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list = NULL;
  }

  return photos_list;
}
Beispiel #9
0
/**
 * flickcurl_photosets_getPhotos_params:
 * @fc: flickcurl context
 * @photoset_id: The id of the photoset to return the photos for.
 * @privacy_filter: Return photos only matching a certain privacy level 1-5 (or <0)
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 *
 * Get the list of photos in a set.
 *
 * Currently supported extra fields are: license, date_upload,
 * date_taken, owner_name, icon_server, original_format,
 * last_update.
 *
 * Optional extra type 'media' that will return an extra media = VALUE
 * for VALUE "photo" or "video".  API addition 2008-04-07.
 *
 * Return value: list of photos or NULL on failure
 **/
flickcurl_photos_list*
flickcurl_photosets_getPhotos_params(flickcurl* fc, const char* photoset_id,
                                     int privacy_filter,
                                     flickcurl_photos_list_params* list_params)
{
    flickcurl_photos_list* photos_list = NULL;
    char privacy_filter_str[2];
    const char* format = NULL;

    flickcurl_init_params(fc);

    if(!photoset_id)
        return NULL;

    /* API parameters */
    flickcurl_add_param(fc, "photoset_id", photoset_id);
    if(privacy_filter >= 1 && privacy_filter <= 5) {
        sprintf(privacy_filter_str, "%d", privacy_filter);
        flickcurl_add_param(fc, "privacy_filter", privacy_filter_str);
    }

    /* Photos List parameters */
    flickcurl_append_photos_list_params(fc, list_params, &format);

    flickcurl_end_params(fc);

    if(flickcurl_prepare(fc, "flickr.photosets.getPhotos"))
        goto tidy;

    photos_list = flickcurl_invoke_photos_list(fc,
                  (const xmlChar*)"/rsp/photoset",
                  format);

tidy:
    if(fc->failed) {
        if(photos_list)
            flickcurl_free_photos_list(photos_list);
        photos_list = NULL;
    }

    return photos_list;
}
Beispiel #10
0
	bool Free(ThreadInfo* Thread){
		//checking if everything is already freed
		if(Thread){
			//killing thread
			Thread->Terminate = true;
			SetEvent(Thread->Running);
			WaitForSingleObject((HANDLE)Thread->Thread, INFINITE);

			//killing cache
			ClearCache(Thread);
		
			//killing flickcurl
			if(Thread->Flickcurl){
				flickcurl_free(Thread->Flickcurl);
				//flickcurl_finish();
			}
	
			//killing results list
			if(Thread->ResultList)
				flickcurl_free_photos_list(Thread->ResultList);
			
			//killing mutex
			if(Thread->CacheAvailable)
				CloseHandle(Thread->CacheAvailable);
		
			//killing curl
			if(Thread->Curl)
				curl_easy_cleanup(Thread->Curl);
		
			//killing event
			if(Thread->Running)
				CloseHandle(Thread->Running);
	
			if(Thread->ImageAvailable)
				CloseHandle(Thread->ImageAvailable);
		};

		return true;
	};
Beispiel #11
0
/**
 * flickcurl_people_getPublicPhotos_params:
 * @fc: flickcurl context
 * @user_id: The NSID of the user who's photos to return.
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 * 
 * Get a list of public photos for the given user.
 *
 * Currently supported extras fields are: license, date_upload,
 * date_taken, owner_name, icon_server, original_format,
 * last_update, geo, tags, machine_tags.
 *
 * Optional extra type 'media' that will return an extra media=VALUE
 * for VALUE "photo" or "video".  API addition 2008-04-07.
 *
 * Return value: non-0 on failure
 **/
flickcurl_photos_list*
flickcurl_people_getPublicPhotos_params(flickcurl* fc, const char* user_id, 
                                        flickcurl_photos_list_params* list_params)
{
  const char* parameters[12][2];
  int count=0;
  flickcurl_photos_list* photos_list=NULL;
  const char* format=NULL;
  
  if(!user_id)
    return NULL;

  /* API parameters */
  parameters[count][0]  = "user_id";
  parameters[count++][1]= user_id;

  /* Photos List parameters */
  flickcurl_append_photos_list_params(list_params, parameters, &count, &format);

  parameters[count][0]  = NULL;

  if(flickcurl_prepare(fc, "flickr.people.getPublicPhotos", parameters, count))
    goto tidy;

  photos_list=flickcurl_invoke_photos_list(fc,
                                           (const xmlChar*)"/rsp/photos/photo",
                                           format);

  tidy:
  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list=NULL;
  }

  return photos_list;
}
Beispiel #12
0
/**
 * flickcurl_galleries_getPhotos_params:
 * @fc: flickcurl context
 * @gallery_id: The ID of the gallery of photos to return
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 *
 * Return the list of photos for a gallery
 *
 * Currently supported extras fields are: description, license,
 * date_upload, date_taken, owner_name, icon_server, original_format,
 * last_update, geo, tags, machine_tags, o_dims, views, media,
 * path_alias, url_sq, url_t, url_s, url_m, url_o
 *
 * Return value: list of people public photos or NULL on failure
 **/
flickcurl_photos_list*
flickcurl_galleries_getPhotos_params(flickcurl* fc, const char* gallery_id,
                                     flickcurl_photos_list_params* list_params)
{
    flickcurl_photos_list* photos_list = NULL;
    const char* format = NULL;

    flickcurl_init_params(fc);

    if(!gallery_id)
        return NULL;

    /* API parameters */
    flickcurl_add_param(fc, "gallery_id", gallery_id);

    /* Photos List parameters */
    flickcurl_append_photos_list_params(fc, list_params, &format);

    flickcurl_end_params(fc);

    if(flickcurl_prepare(fc, "flickr.galleries.getPhotos"))
        goto tidy;

    photos_list = flickcurl_invoke_photos_list(fc,
                  (const xmlChar*)"/rsp/gallery",
                  format);

tidy:
    if(fc->failed) {
        if(photos_list)
            flickcurl_free_photos_list(photos_list);
        photos_list = NULL;
    }

    return photos_list;
}
Beispiel #13
0
/*
 * flickcurl_invoke_photos_list:
 * @fc: Flickcurl context
 * @xpathExpr: Xpath to the list of photos e.g. '/rsp/photos' or '/rsp/gallery'.  The /photos suffix is added internally.
 * @format: result format wanted
 *
 * INTERNAL - Build photos list from XML or get format content result from web service response document
 *
 * Return value: new photos list or NULL on failure
 */
flickcurl_photos_list*
flickcurl_invoke_photos_list(flickcurl* fc, const xmlChar* xpathExpr,
                             const char* format)
{
  flickcurl_photos_list* photos_list = NULL;
  xmlXPathContextPtr xpathCtx = NULL;
  xmlXPathObjectPtr xpathObj = NULL;
  xmlXPathContextPtr xpathNodeCtx = NULL;
  const char *nformat;
  size_t format_len;

  photos_list = (flickcurl_photos_list*)calloc(1, sizeof(*photos_list));
  if(!photos_list) {
    fc->failed = 1;
    goto tidy;
  }

  photos_list->page = -1;
  photos_list->per_page = -1;
  photos_list->total_count = -1;
  
  if(format) {
    nformat = format;
    format_len = strlen(format);
  
    photos_list->content = flickcurl_invoke_get_content(fc,
                                                        &photos_list->content_length);
    if(!photos_list->content) {
      fc->failed = 1;
      goto tidy;
    }

  } else {
    xmlDocPtr doc = NULL;
    xmlNodePtr photos_node;
    size_t xpathExprLen = strlen((const char*)xpathExpr);
    char* value;
    xmlChar* photosXpathExpr;
#define SUFFIX "/photo"
#define SUFFIX_LEN 6

    nformat = "xml";
    format_len = 3;
    
    doc = flickcurl_invoke(fc);
    if(!doc)
      goto tidy;

    xpathCtx = xmlXPathNewContext(doc);
    if(!xpathCtx) {
      flickcurl_error(fc, "Failed to create XPath context for document");
      fc->failed = 1;
      goto tidy;
    }

    /* set up a new XPath context for the top level list-of-photos
     * XML element.  It may be <photos> or <gallery> or ... - the
     * code does not care.
     */

    xpathObj = xmlXPathEvalExpression(xpathExpr, xpathCtx);
    if(!xpathObj) {
      flickcurl_error(fc, "Unable to evaluate XPath expression \"%s\"", 
                      xpathExpr);
      fc->failed = 1;
      goto tidy;
    }

    if(!xpathObj->nodesetval || !xpathObj->nodesetval->nodeTab) {
      /* No <photo> elements found in content - not a failure */
      goto tidy;
    }

    photos_node = xpathObj->nodesetval->nodeTab[0];

    xpathNodeCtx = xmlXPathNewContext(xpathCtx->doc);
    if(!xpathNodeCtx) {
      flickcurl_error(fc, "Unable to create XPath context for XPath \"%s\"", 
                      xpathExpr);
      fc->failed = 1;
      goto tidy;
    }
    
    xpathNodeCtx->node = photos_node;

    value = flickcurl_xpath_eval(fc, xpathNodeCtx,
                                 (const xmlChar*)"./@page");
    if(value) {
      photos_list->page = atoi(value);
      free(value);
    }

    value = flickcurl_xpath_eval(fc, xpathNodeCtx,
                                 (const xmlChar*)"./@perpage");
    if(value) {
      photos_list->per_page = atoi(value);
      free(value);
    }

    value = flickcurl_xpath_eval(fc, xpathNodeCtx,
                                 (const xmlChar*)"./@total");
    if(value) {
      photos_list->total_count = atoi(value);
      free(value);
    }

    /* finished with these */
    xmlXPathFreeContext(xpathNodeCtx);
    xpathNodeCtx = NULL;
    xmlXPathFreeObject(xpathObj);
    xpathObj = NULL;


    photosXpathExpr = (xmlChar*)malloc(xpathExprLen + SUFFIX_LEN + 1);
    memcpy(photosXpathExpr, xpathExpr, xpathExprLen);
    memcpy(photosXpathExpr + xpathExprLen, SUFFIX, SUFFIX_LEN + 1);
  
    photos_list->photos = flickcurl_build_photos(fc, xpathCtx, photosXpathExpr,
                                                 &photos_list->photos_count);
    if(!photos_list->photos) {
      fc->failed = 1;
      goto tidy;
    }

  }


  photos_list->format = (char*)malloc(format_len+1);
  if(!photos_list->format) {
    fc->failed = 1;
    goto tidy;
  }
  memcpy(photos_list->format, nformat, format_len+1);

  tidy:
  if(xpathNodeCtx)
    xmlXPathFreeContext(xpathNodeCtx);
  if(xpathObj)
    xmlXPathFreeObject(xpathObj);
  if(xpathCtx)
    xmlXPathFreeContext(xpathCtx);

  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list = NULL;
  }

  return photos_list;
}
Beispiel #14
0
flickcurl_photos_list*
flickcurl_invoke_photos_list(flickcurl* fc, const xmlChar* xpathExpr,
                             const char* format)
{
  flickcurl_photos_list* photos_list=NULL;
  xmlXPathContextPtr xpathCtx=NULL;
  const char *nformat;
  size_t format_len;

  photos_list=(flickcurl_photos_list*)calloc(1, sizeof(flickcurl_photos_list));
  if(!photos_list) {
    fc->failed=1;
    goto tidy;
  }

  if(format) {
    nformat=format;
    format_len=strlen(format);
  
    photos_list->content=flickcurl_invoke_get_content(fc,
                                                      &photos_list->content_length);
    if(!photos_list->content) {
      fc->failed=1;
      goto tidy;
    }

  } else {
    xmlDocPtr doc=NULL;

    nformat="xml";
    format_len=3;
    
    doc=flickcurl_invoke(fc);
    if(!doc)
      goto tidy;

    xpathCtx = xmlXPathNewContext(doc);
    if(!xpathCtx) {
      flickcurl_error(fc, "Failed to create XPath context for document");
      fc->failed=1;
      goto tidy;
    }

    photos_list->photos=flickcurl_build_photos(fc, xpathCtx, xpathExpr,
                                               &photos_list->photos_count);
    if(!photos_list->photos) {
      fc->failed=1;
      goto tidy;
    }

  }


  photos_list->format=(char*)malloc(format_len+1);
  if(!photos_list->format) {
    fc->failed=1;
    goto tidy;
  }
  memcpy(photos_list->format, nformat, format_len+1);

  tidy:
  if(xpathCtx)
    xmlXPathFreeContext(xpathCtx);

  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list=NULL;
  }

  return photos_list;
}
Beispiel #15
0
/**
 * flickcurl_people_getPhotos_params:
 * @fc: flickcurl context
 * @user_id: The NSID of the user who's photos to return. A value of "me" will return the calling user's photos.
 * @safe_search: Safe search setting: 1 for safe, 2 for moderate, 3 for restricted. (Please note: Un-authed calls can only see Safe content.) (or < 0)
 * @min_upload_date: Minimum upload date. Photos with an upload date greater than or equal to this value will be returned. The date should be in the form of a unix timestamp. (or NULL)
 * @max_upload_date: Maximum upload date. Photos with an upload date less than or equal to this value will be returned. The date should be in the form of a unix timestamp. (or NULL)
 * @min_taken_date: Minimum taken date. Photos with an taken date greater than or equal to this value will be returned. The date should be in the form of a mysql datetime. (or NULL)
 * @max_taken_date: Maximum taken date. Photos with an taken date less than or equal to this value will be returned. The date should be in the form of a mysql datetime. (or NULL)
 * @content_type: Content Type setting: 1 for photos only, 2 for screenshots only, 3 for 'other' only, 4 for photos and screenshots, 5 for screenshots and 'other', 6 for photos and 'other', 7 for photos, screenshots, and 'other' (all) (or < 0)
 * @privacy_filter: Return photos only matching a certain privacy level. This only applies when making an authenticated call to view photos you own. Valid values are: 1 public photos, 2 private photos visible to friends, 3 private photos visible to family, 4 private photos visible to friends & family, 5 completely private photos (or < 0)
 * @list_params: #flickcurl_photos_list_params result parameters (or NULL)
 * 
 * Get photos from the given user's photostream.
 *
 * Only photos visible to the calling user will be returned. This
 * method must be authenticated; to return public photos for a user,
 * use flickcurl_people_getPublicPhotos().
 *
 * Return value: non-0 on failure
 **/
flickcurl_photos_list*
flickcurl_people_getPhotos_params(flickcurl* fc, const char* user_id,
                                  int safe_search,
                                  const char* min_upload_date,
                                  const char* max_upload_date,
                                  const char* min_taken_date,
                                  const char* max_taken_date,
                                  int content_type,
                                  int privacy_filter,
                                  flickcurl_photos_list_params* list_params)
{
  flickcurl_photos_list* photos_list = NULL;
  const char* format = NULL;
  char safe_search_s[4];
  char content_type_s[4];
  char privacy_filter_s[4];
  
  flickcurl_init_params(fc, 0);

  if(!user_id)
    return NULL;

  flickcurl_add_param(fc, "user_id", user_id);
  if(safe_search >= 0 && safe_search < 10) {
    sprintf(safe_search_s, "%d", safe_search);
    flickcurl_add_param(fc, "safe_search", safe_search_s);
  }
  if(min_upload_date) {
    flickcurl_add_param(fc, "min_upload_date", min_upload_date);
  }
  if(max_upload_date) {
    flickcurl_add_param(fc, "max_upload_date", max_upload_date);
  }
  if(min_taken_date) {
    flickcurl_add_param(fc, "min_taken_date", min_taken_date);
  }
  if(max_taken_date) {
    flickcurl_add_param(fc, "max_taken_date", max_taken_date);
  }
  if(content_type >= 0 && content_type < 10) {
    sprintf(content_type_s, "%d", content_type);
    flickcurl_add_param(fc, "content_type", content_type_s);
  }
  if(privacy_filter >= 0 && privacy_filter < 10) {
    sprintf(privacy_filter_s, "%d", privacy_filter);
    flickcurl_add_param(fc, "privacy_filter", privacy_filter_s);
  }

  /* Photos List parameters */
  flickcurl_append_photos_list_params(fc, list_params, &format);

  flickcurl_end_params(fc);

  if(flickcurl_prepare(fc, "flickr.people.getPhotos"))
    goto tidy;

  photos_list = flickcurl_invoke_photos_list(fc,
                                             (const xmlChar*)"/rsp/photos",
                                             format);

  tidy:
  if(fc->failed) {
    if(photos_list)
      flickcurl_free_photos_list(photos_list);
    photos_list = NULL;
  }

  return photos_list;
}
Beispiel #16
0
	void ThreadFunc(void* args){
		//checking if we have right args
		if(!args)
			return;
		
		//getting thread info
		ThreadInfo* t = (ThreadInfo*)args;

		uint CurImage = 0;
		t->CurImage = 0;

		//main loop
		do{
			//checking if thread is paused
			WaitForSingleObject(t->Running, INFINITE);

			//checking if thread is not terminated
			if(!t->Terminate){
				//checking if we need list and downloading it
				if(!t->ResultList){
					t->ResultList = flickcurl_photos_search_params(t->Flickcurl, 
						&t->SearchParams, &t->ListParams);

					if(t->ResultList)
						t->TotalImages = t->ResultList->total_count;
					
					CurImage = 0;
					t->ListParams.page++; //updating page
				}

				//checking if anything were found
				if(t->ResultList){
					t->CurImage++;

					//creating new image
					Image* img = new(Image);
					InitImage(img);

					//downloading photo meta if needed
					if(t->WantMeta)
						img->Meta = flickcurl_photos_getInfo(t->Flickcurl, t->ResultList->photos[CurImage]->id);
				
					//downloading photo exif if needed
					if(t->WantEXIF)
						img->EXIF = flickcurl_photos_getExif(t->Flickcurl, t->ResultList->photos[CurImage]->id,
									t->ResultList->photos[CurImage]->fields[PHOTO_FIELD_secret].string);
				
					//downloading photo itself if needed
					if(t->WantImage)
						img->Img = DownloadImage(t, t->ResultList->photos[CurImage]);

					//checking if we've got any data
					if(img->EXIF || img->Img != "" || img->Meta)
						AddCache(t, img); //adding to cache
					else
						FreeImage(img); //or killing intance

					//updating image number
					if(CurImage < t->ResultList->photos_count - 1)
						CurImage++;
					else{
						CurImage = 0;
						flickcurl_free_photos_list(t->ResultList);
						t->ResultList = 0;
					}
				}else
					if(!t->Terminate)
						ResetEvent(t->Running); //pause thread if nothing were found
			}
		}while(!t->Terminate);
	};