示例#1
0
void
FlickrInitializer::test_login() throw()
{
    std::ifstream fin(tokenFilePath_.c_str());
    const std::string token((std::istreambuf_iterator<char>(fin)),
                            std::istreambuf_iterator<char>());
    fin.close();

    flickcurl * const fc = flickrContext_->get_flickr_session();

    flickcurl_set_auth_token(fc, token.c_str());
    char * user_name = flickcurl_test_login(fc);

    if (true == (loginStatus_ = (0 != user_name)))
    {
        flickrContext_->set_user_name(user_name);
        free(user_name);
        user_name = 0;
    }
    else
    {
        flickcurl_set_auth_token(fc, "");
    }

    testLoginEnd_.emit();
}
示例#2
0
文件: cache.c 项目: Xirg/FlickrMS
/*
 * Initialize the flickcurl connection
*/
static int flickr_init() {
    char *conf_path;
    char *login;

    flickcurl_init();
    fc = flickcurl_new();

    conf_path = get_conf_path();
    if(!conf_path)
        return FAIL;

    if(check_conf_file(conf_path, fc))
        return FAIL;

    /* Read from the config file, ~/.flickcurl.conf */
    if(flickcurl_config_read_ini(fc, conf_path, "flickr", fc, flickcurl_config_var_handler))
        return FAIL;

    login = flickcurl_test_login(fc);
    if(!login)
        return FAIL;

    free(login);
    free(conf_path);
    return SUCCESS;
}