Esempio n. 1
0
static char *_flickr_api_create_photoset(_flickr_api_context_t *ctx, const char *photo_id)
{
    char *photoset;
    const char *title = ctx->album_title;
    const char *summary = ctx->album_summary;

    photoset = flickcurl_photosets_create(ctx->fc, title, summary, photo_id, NULL);
    if(!photoset) fprintf(stderr, "[flickr] Something went wrong when creating gallery %s", title);
    return photoset;
}
Esempio n. 2
0
int upload_photo(const char *photoset, const char *photo, const char *path) {
    flickcurl_upload_status* status;
    flickcurl_upload_params params;
    cached_photoset *cps;
    cached_photo *cp;
    int retval = FAIL;

    pthread_rwlock_wrlock(&cache_lock);

    cps = g_hash_table_lookup(photoset_ht, photoset);

    if(!cps)
        goto fail;

    if(!(cp = g_hash_table_lookup(cps->photo_ht, photo)))
        goto fail;

    memset(&params, '\0', sizeof(flickcurl_upload_params));
    params.safety_level = 1;    /* default safety */
    params.content_type = 1;    /* default photo */
    params.photo_file = path;
    params.description = "Uploaded using FlickrMS";
    params.title = cp->ci.name;

    status = flickcurl_photos_upload_params(fc, &params);

    if(status) {
        if( cps->ci.dirty == DIRTY ) { // if photoset is dirty, create it
            char * photosetid = flickcurl_photosets_create(fc, cps->ci.name, NULL, status->photoid, NULL);

            if( photosetid ) {
                cps->ci.id = photosetid;
                cps->ci.dirty = CLEAN;
            }
        }
        else if( strcmp( cps->ci.id, "" ) ) { // if photoset has an id, add new photo to it
            flickcurl_photosets_addPhoto(fc, cps->ci.id, status->photoid);
        }

        flickcurl_free_upload_status(status);
    }

    cp->ci.dirty = CLEAN;

    cps->set = CACHE_UNSET;

    retval = SUCCESS;

fail: pthread_rwlock_unlock(&cache_lock);
    return retval;
}