当前位置: 首页>>代码示例>>C++>>正文


C++ purple_url_encode函数代码示例

本文整理汇总了C++中purple_url_encode函数的典型用法代码示例。如果您正苦于以下问题:C++ purple_url_encode函数的具体用法?C++ purple_url_encode怎么用?C++ purple_url_encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了purple_url_encode函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: hangouts_oauth_with_code

void
hangouts_oauth_with_code(HangoutsAccount *ha, const gchar *auth_code)
{
	PurpleHttpRequest *request;
	PurpleConnection *pc;
	GString *postdata;

	pc = ha->pc;

	postdata = g_string_new(NULL);
	g_string_append_printf(postdata, "client_id=%s&", purple_url_encode(GOOGLE_CLIENT_ID));
	g_string_append_printf(postdata, "client_secret=%s&", purple_url_encode(GOOGLE_CLIENT_SECRET));
	g_string_append_printf(postdata, "code=%s&", purple_url_encode(auth_code));
	g_string_append_printf(postdata, "redirect_uri=%s&", purple_url_encode(HANGOUTS_API_OAUTH2_REDIRECT_URI));
	g_string_append(postdata, "grant_type=authorization_code&");

	request = purple_http_request_new(HANGOUTS_API_OAUTH2_TOKEN_URL);
	purple_http_request_set_cookie_jar(request, ha->cookie_jar);
	purple_http_request_set_method(request, "POST");
	purple_http_request_header_set(request, "Content-Type", "application/x-www-form-urlencoded");
	purple_http_request_set_contents(request, postdata->str, postdata->len);

	purple_http_request(pc, request, hangouts_oauth_with_code_cb, ha);
	purple_http_request_unref(request);
	
	g_string_free(postdata, TRUE);
}
开发者ID:doctorlard,项目名称:pidgin-hangouts,代码行数:27,代码来源:hangouts_auth.c

示例2: hangouts_oauth_refresh_token

void
hangouts_oauth_refresh_token(HangoutsAccount *ha)
{
	PurpleHttpRequest *request;
	PurpleConnection *pc;
	GString *postdata;

	pc = ha->pc;

	postdata = g_string_new(NULL);
	g_string_append_printf(postdata, "client_id=%s&", purple_url_encode(GOOGLE_CLIENT_ID));
	g_string_append_printf(postdata, "client_secret=%s&", purple_url_encode(GOOGLE_CLIENT_SECRET));
	g_string_append_printf(postdata, "refresh_token=%s&", purple_url_encode(ha->refresh_token));
	g_string_append(postdata, "grant_type=refresh_token&");
	
	request = purple_http_request_new(HANGOUTS_API_OAUTH2_TOKEN_URL);
	purple_http_request_set_cookie_jar(request, ha->cookie_jar);
	purple_http_request_set_method(request, "POST");
	purple_http_request_header_set(request, "Content-Type", "application/x-www-form-urlencoded");
	purple_http_request_set_contents(request, postdata->str, postdata->len);

	purple_http_request(pc, request, hangouts_oauth_refresh_token_cb, ha);
	purple_http_request_unref(request);
	
	purple_debug_info("hangouts", "Postdata: %s\n", postdata->str);
	
	g_string_free(postdata, TRUE);
}
开发者ID:doctorlard,项目名称:pidgin-hangouts,代码行数:28,代码来源:hangouts_auth.c

示例3: login_open_cb

static void
login_open_cb(PnNode *conn,
              gpointer data)
{
    MsnNexus *nexus = data;
    MsnSession *session;
    const char *username, *password;
    char *req, *head, *tail;
    guint32 ctint;
    GIOStatus status = G_IO_STATUS_NORMAL;

    g_return_if_fail(conn);

    g_signal_handler_disconnect(conn, nexus->open_handler);
    nexus->open_handler = 0;

    session = nexus->session;

    username = msn_session_get_username(session);
    password = msn_session_get_password(session);

    ctint = strtoul((char *) g_hash_table_lookup(nexus->challenge_data, "ct"), NULL, 10) + 200;

    head = g_strdup_printf("GET %s HTTP/1.1\r\n"
                           "Authorization: Passport1.4 OrgVerb=GET,OrgURL=%s,sign-in=%s",
                           nexus->login_path,
                           (char *) g_hash_table_lookup(nexus->challenge_data, "ru"),
                           purple_url_encode(username));

    tail = g_strdup_printf("lc=%s,id=%s,tw=%s,fs=%s,ru=%s,ct=%" G_GUINT32_FORMAT ",kpp=%s,kv=%s,ver=%s,tpf=%s\r\n"
                           "User-Agent: MSMSGS\r\n"
                           "Host: %s\r\n"
                           "Connection: Keep-Alive\r\n"
                           "Cache-Control: no-cache\r\n",
                           get_key(nexus->challenge_data, "lc"),
                           get_key(nexus->challenge_data, "id"),
                           get_key(nexus->challenge_data, "tw"),
                           get_key(nexus->challenge_data, "fs"),
                           get_key(nexus->challenge_data, "ru"),
                           ctint,
                           get_key(nexus->challenge_data, "kpp"),
                           get_key(nexus->challenge_data, "kv"),
                           get_key(nexus->challenge_data, "ver"),
                           get_key(nexus->challenge_data, "tpf"),
                           nexus->login_host);

    req = g_strdup_printf("%s,pwd=%s,%s\r\n", head, purple_url_encode(password), tail);

    g_free(head);
    g_free(tail);

    status = pn_node_write(conn, req, strlen(req), NULL, NULL);

    if (status != G_IO_STATUS_NORMAL) {
        msn_session_set_error(nexus->session, MSN_ERROR_AUTH,
                              _("nexus stream error"));
    }

    g_free(req);
}
开发者ID:felipec,项目名称:msn-pecan,代码行数:60,代码来源:nexus.c

示例4: g_string_append_cookies

static void g_string_append_cookies(GString *str, GHashTable *table) {
    GHashTableIter iter;
    gpointer key, value;
    gboolean first = TRUE;
    g_hash_table_iter_init(&iter, table);
    while(g_hash_table_iter_next(&iter, &key, &value)) {
        if(!first) g_string_append(str, " ");
        g_string_append_printf(str, "%s", purple_url_encode(key));
        g_string_append(str, "=");
        g_string_append_printf(str, "%s;", purple_url_encode(value));
        first = FALSE;
    }
}
开发者ID:rgooler,项目名称:flist-plugin,代码行数:13,代码来源:f-list_http.c

示例5: send_client_login

/**
 * This function sends a request to
 * https://api.screenname.aol.com/auth/clientLogin with the user's
 * username and password and receives the user's session key, which is
 * used to request a connection to the BOSS server.
 */
void send_client_login(OscarData *od, const char *username)
{
    PurpleConnection *gc;
    GString *request, *body;
    const char *tmp;
    char *password;
    int password_len;

    gc = od->gc;

    /*
     * We truncate ICQ passwords to 8 characters.  There is probably a
     * limit for AIM passwords, too, but we really only need to do
     * this for ICQ because older ICQ clients let you enter a password
     * as long as you wanted and then they truncated it silently.
     *
     * And we can truncate based on the number of bytes and not the
     * number of characters because passwords for AIM and ICQ are
     * supposed to be plain ASCII (I don't know if this has always been
     * the case, though).
     */
    tmp = purple_connection_get_password(gc);
    password_len = strlen(tmp);
    password = g_strndup(tmp, od->icq ? MIN(password_len, MAXICQPASSLEN) : password_len);

    /* Construct the body of the HTTP POST request */
    body = g_string_new("");
    g_string_append_printf(body, "devId=%s", get_client_key(od));
    g_string_append_printf(body, "&f=xml");
    g_string_append_printf(body, "&pwd=%s", purple_url_encode(password));
    g_string_append_printf(body, "&s=%s", purple_url_encode(username));
    g_free(password);

    /* Construct an HTTP POST request */
    request = g_string_new("POST /auth/clientLogin HTTP/1.0\r\n"
                           "Connection: close\r\n"
                           "Accept: */*\r\n");

    /* Tack on the body */
    g_string_append_printf(request, "Content-Type: application/x-www-form-urlencoded; charset=UTF-8\r\n");
    g_string_append_printf(request, "Content-Length: %" G_GSIZE_FORMAT "\r\n\r\n", body->len);
    g_string_append_len(request, body->str, body->len);
    g_string_free(body, TRUE);

    /* Send the POST request  */
    od->url_data = purple_util_fetch_url_request_len_with_account(
                       purple_connection_get_account(gc), URL_CLIENT_LOGIN,
                       TRUE, NULL, FALSE, request->str, FALSE, -1,
                       client_login_cb, od);
    g_string_free(request, TRUE);
}
开发者ID:jrcjc,项目名称:chimein,代码行数:57,代码来源:clientlogin.c

示例6: g_utf8_strdown

static gchar *format_icon(ParserVars *vars, const gchar *ts, const gchar *inner) {
    gchar *lower = g_utf8_strdown(inner, -1);
    gchar *ret;
    if(vars->fla && vars->convo) {
        gchar *smiley = g_strdup_printf("[icon]%s[/icon]", purple_url_encode(lower));
        ret = g_strdup_printf("%s<a href=\"http://www.f-list.net/c/%s\">(%s)</a>", smiley, purple_url_encode(lower), inner);
        flist_fetch_emoticon(vars->fla, smiley, lower, vars->convo);
        g_free(smiley);
    } else {
        ret = g_strdup_printf("<a href=\"http://www.f-list.net/c/%s\">%s</a>", purple_url_encode(lower), inner);
    }
    g_free(lower);
    return ret;
}
开发者ID:FurtiveFox,项目名称:flist-pidgin,代码行数:14,代码来源:f-list_bbcode.c

示例7: process_urls

/* Frees 'urls' */
static void
process_urls(PurpleConversation *conv, GList *urls)
{
	GList *iter;
	int c;
	FinchConv *fconv = FINCH_CONV(conv);
	GntTextView *tv = GNT_TEXT_VIEW(fconv->tv);

	for (iter = urls, c = 1; iter; iter = iter->next, c++) {
		int i;
		CbInfo *cbdata;
		gchar *url, *str;
		gchar *original_url;
		const gchar *tiny_url;

		i = gnt_text_view_get_lines_below(tv);

		original_url = purple_unescape_html((char *)iter->data);
		tiny_url = g_hash_table_lookup(tinyurl_cache, original_url);
		if (tiny_url) {
			gchar *str = g_strdup_printf("\n[%d] %s", c, tiny_url);

			g_free(original_url);
			gnt_text_view_append_text_with_flags(tv, str, GNT_TEXT_FLAG_DIM);
			if (i == 0)
				gnt_text_view_scroll(tv, 0);
			g_free(str);
			continue;
		}
		cbdata = g_new(CbInfo, 1);
		cbdata->num = c;
		cbdata->original_url = original_url;
		cbdata->tag = g_strdup_printf("%s%d", "tiny_", tag_num++);
		cbdata->conv = conv;
		if (g_ascii_strncasecmp(original_url, "http://", 7) && g_ascii_strncasecmp(original_url, "https://", 8)) {
			url = g_strdup_printf("%shttp%%3A%%2F%%2F%s", purple_prefs_get_string(PREF_URL), purple_url_encode(original_url));
		} else {
			url = g_strdup_printf("%s%s", purple_prefs_get_string(PREF_URL), purple_url_encode(original_url));
		}
		purple_http_get(NULL, url_fetched, cbdata, url);
		str = g_strdup_printf(_("\nFetching TinyURL..."));
		gnt_text_view_append_text_with_tag((tv), str, GNT_TEXT_FLAG_DIM, cbdata->tag);
		g_free(str);
		if (i == 0)
			gnt_text_view_scroll(tv, 0);
		g_free(iter->data);
		g_free(url);
	}
	g_list_free(urls);
}
开发者ID:N8Fear,项目名称:purple-facebook,代码行数:51,代码来源:gnttinyurl.c

示例8: skypeweb_download_video_message

void
skypeweb_download_video_message(SkypeWebAccount *sa, const gchar *sid, PurpleConversation *conv)
{
	gchar *url, *username_encoded;
	
	username_encoded = g_strdup(purple_url_encode(sa->username));
	url = g_strdup_printf("/users/%s/video_mails/%s", username_encoded, purple_url_encode(sid));
	
	skypeweb_post_or_get(sa, SKYPEWEB_METHOD_GET | SKYPEWEB_METHOD_SSL, SKYPEWEB_VIDEOMAIL_HOST, url, NULL, skypeweb_got_vm_info, conv, TRUE);
	
	g_free(url);
	g_free(username_encoded);
	
}
开发者ID:rtmf,项目名称:skype4pidgin,代码行数:14,代码来源:skypeweb_contacts.c

示例9: g_string_append_cgi

//TODO: you're supposed to change spaces to "+" values??
static void g_string_append_cgi(GString *str, GHashTable *table) {
    GHashTableIter iter;
    gpointer key, value;
    gboolean first = TRUE;
    g_hash_table_iter_init(&iter, table);
    while(g_hash_table_iter_next(&iter, &key, &value)) {
        purple_debug_info("flist", "cgi writing key, value: %s, %s\n", (gchar *)key, (gchar *)value);
        if(!first) g_string_append(str, "&");
        g_string_append_printf(str, "%s", purple_url_encode(key));
        g_string_append(str, "=");
        g_string_append_printf(str, "%s", purple_url_encode(value));
        first = FALSE;
    }
}
开发者ID:rgooler,项目名称:flist-plugin,代码行数:15,代码来源:f-list_http.c

示例10: g_string_new

PurpleUtilFetchUrlData *flist_login_ticket_request(PurpleConnection *pc, const gchar *user_agent, const gchar *username, const gchar *password, PurpleUtilFetchUrlCallback callback) {
    const gchar *url_pattern = "http://www.f-list.net/json/getApiTicket.php";
    PurpleUtilFetchUrlData *ret;
    GString *url_str = g_string_new(NULL);
    gchar *url;
    
    g_string_append(url_str, url_pattern);
    g_string_append_printf(url_str, "?account=%s", purple_url_encode(username));
    g_string_append_printf(url_str, "&password=%s", purple_url_encode(password));
    g_string_append_printf(url_str, "&secure=%s", "no");
    url = g_string_free(url_str, FALSE);
    ret = purple_util_fetch_url_request(url, FALSE, user_agent, TRUE, NULL, FALSE, callback, pc);
    g_free(url);
    return ret;
}
开发者ID:rgooler,项目名称:flist-plugin,代码行数:15,代码来源:f-list_http.c

示例11: append_params_to_body

static gboolean append_params_to_body(gpointer key, gpointer value, gpointer data)
{
	GString *body;

	body = data;

	if (body->len > 0)
		g_string_append_c(body, '&');

	g_string_append(body, purple_url_encode(key));
	g_string_append_c(body, '=');
	g_string_append(body, purple_url_encode(value));

	return FALSE;
}
开发者ID:hellais,项目名称:Adium-old,代码行数:15,代码来源:fbapi.c

示例12: fb_buddy_delete

void fb_buddy_delete(PurpleConnection *pc, PurpleBuddy *buddy,
		PurpleGroup *group)
{
	FacebookAccount *fba = pc->proto_data;
	gchar *buddy_tmp, *postdata;

	//This function removes a buddy from our friends list on facebook
	//and shouldn't really be used
	if (!purple_account_get_bool(fba->account, "facebook_manage_friends", FALSE)) {
		purple_debug_warning("facebook", "attempted to add %s but was blocked\n", buddy->name);
		return;
	}

	buddy_tmp = g_strdup(purple_url_encode(buddy->name));
	postdata = g_strdup_printf(
			"uid=%s&post_form_id=%s&fb_dtsg=%s&"
			"post_form_id_source=AsyncRequest&__a=1",
			buddy_tmp, fba->post_form_id, fba->dtsg);
	g_free(buddy_tmp);

	fb_post_or_get(fba, FB_METHOD_POST, NULL, "/ajax/profile/removefriend.php",
			postdata, NULL, NULL, FALSE);

	g_free(postdata);
}
开发者ID:wosigh,项目名称:messaging-plugins,代码行数:25,代码来源:fb_managefriends.c

示例13: bing_translate

void
bing_translate(const gchar *plain_phrase, const gchar *from_lang, const gchar *to_lang, TranslateCallback callback, gpointer userdata)
{
	gchar *encoded_phrase;
	gchar *url;
	struct _TranslateStore *store;
	PurpleUtilFetchUrlCallback urlcallback;
	
	encoded_phrase = g_strescape(purple_url_encode(plain_phrase), NULL);
	
	store = g_new0(struct _TranslateStore, 1);
	store->original_phrase = g_strdup(plain_phrase);
	store->callback = callback;
	store->userdata = userdata;
	
	if (!from_lang || !(*from_lang) || g_str_equal(from_lang, "auto"))
	{
		url = g_strdup_printf(BING_DETECT_URL, encoded_phrase);
		store->detected_language = g_strdup(to_lang);
		urlcallback = bing_translate_autodetect_cb;
	} else {
		url = g_strdup_printf(BING_TRANSLATE_URL, encoded_phrase, from_lang, to_lang);
		urlcallback = bing_translate_cb;
	}
	
	purple_debug_info("translate", "Fetching %s\n", url);
	
	purple_util_fetch_url_request(url, TRUE, "libpurple", FALSE, NULL, FALSE, urlcallback, store);
	
	g_free(encoded_phrase);
	g_free(url);
}
开发者ID:Javran,项目名称:purple-plugin-pack,代码行数:32,代码来源:translate.c

示例14: bing_translate

void
bing_translate(const gchar *plain_phrase, const gchar *from_lang, const gchar *to_lang, TranslateCallback callback, gpointer userdata)
{
	gchar *encoded_phrase;
	gchar *url;
	struct _TranslateStore *store;
	PurpleUtilFetchUrlCallback urlcallback;
	
	encoded_phrase = g_strescape(purple_url_encode(plain_phrase), NULL);
	
	store = g_new0(struct _TranslateStore, 1);
	store->original_phrase = g_strdup(plain_phrase);
	store->callback = callback;
	store->userdata = userdata;
	
	if (!from_lang || !(*from_lang) || g_str_equal(from_lang, "auto"))
	{
		url = g_strdup_printf("http://api.microsofttranslator.com/V2/Ajax.svc/Detect?appId=" BING_APPID "&text=%%22%s%%22",
						encoded_phrase);
		store->detected_language = g_strdup(to_lang);
		urlcallback = bing_translate_autodetect_cb;
	} else {
		url = g_strdup_printf("http://api.microsofttranslator.com/V2/Ajax.svc/Translate?appId=" BING_APPID "&text=%%22%s%%22&from=%s&to=%s",
						encoded_phrase, from_lang, to_lang);
		urlcallback = bing_translate_cb;
	}
	
	purple_debug_info("translate", "Fetching %s\n", url);
	
	purple_util_fetch_url_request(url, TRUE, "libpurple", FALSE, NULL, FALSE, urlcallback, store);
	
	g_free(encoded_phrase);
	g_free(url);
}
开发者ID:andrey01,项目名称:purple-translate,代码行数:34,代码来源:purple-translate.c

示例15: om_send_typing

static unsigned int om_send_typing(PurpleConnection *pc, const gchar *name,
		PurpleTypingState state)
{
	gchar *postdata;
	OmegleAccount *oma = pc->proto_data;
	gchar *url;

	g_return_val_if_fail(oma != NULL, 0);

	if (state == PURPLE_TYPING)
	{
		url = "/typing";	
	} else if (state == PURPLE_TYPED)
	{
		url = "/stoppedtyping";
	} else {
		return 0;
	}
	
	postdata = g_strdup_printf("id=%s", purple_url_encode(name));
	
	om_post_or_get(oma, OM_METHOD_POST, NULL, url, postdata, NULL, NULL, FALSE);
	
	g_free(postdata);
	
	return 10;
}
开发者ID:Javran,项目名称:purple-plugin-pack,代码行数:27,代码来源:omegle.c


注:本文中的purple_url_encode函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。