本文整理汇总了C++中purple_connection_get_protocol_data函数的典型用法代码示例。如果您正苦于以下问题:C++ purple_connection_get_protocol_data函数的具体用法?C++ purple_connection_get_protocol_data怎么用?C++ purple_connection_get_protocol_data使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了purple_connection_get_protocol_data函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bonjour_dns_sd_set_jid
void
bonjour_dns_sd_set_jid(PurpleAccount *account, const char *hostname)
{
PurpleConnection *conn = purple_account_get_connection(account);
BonjourData *bd = purple_connection_get_protocol_data(conn);
const char *tmp, *account_name = purple_account_get_username(account);
/* Previously we allowed the hostname part of the jid to be set
* explicitly when it should always be the current hostname.
* That is what this is intended to deal with.
*/
if ((tmp = strchr(account_name, '@'))
&& strstr(tmp, hostname) == (tmp + 1)
&& *((tmp + 1) + strlen(hostname)) == '\0')
bd->jid = g_strdup(account_name);
else {
const char *tmp2;
GString *str = g_string_new("");
/* Escape an '@' in the account name */
tmp = account_name;
while ((tmp2 = strchr(tmp, '@')) != NULL) {
g_string_append_len(str, tmp, tmp2 - tmp);
g_string_append(str, "\\40");
tmp = tmp2 + 1;
}
g_string_append(str, tmp);
g_string_append_c(str, '@');
g_string_append(str, hostname);
bd->jid = g_string_free(str, FALSE);
}
}
示例2: qq_send_file
void qq_send_file(PurpleConnection* gc,const char* who,const char* filename)
{
qq_account* ac = purple_connection_get_protocol_data(gc);
if(!ac->debug_file_send) {
//purple_notify_warning(gc,NULL,"难题尚未攻破,曙光遥遥无期","请先用离线文件传输");
PurpleXfer* xfer = purple_xfer_new(ac->account,PURPLE_XFER_SEND,who);
purple_xfer_set_init_fnc(xfer,upload_offline_file_init);
purple_xfer_set_request_denied_fnc(xfer,recv_file_request_denied);
purple_xfer_set_cancel_send_fnc(xfer,recv_file_cancel);
if(filename)
purple_xfer_request_accepted(xfer, filename);
else
purple_xfer_request(xfer);
return;
}
PurpleAccount* account = ac->account;
PurpleXfer* xfer = purple_xfer_new(account,PURPLE_XFER_SEND,who);
purple_xfer_set_init_fnc(xfer,upload_file_init);
//purple_xfer_set_init_fnc(xfer,upload_offline_file_init);
//purple_xfer_set_request_denied_fnc(xfer,file_trans_request_denied);
//purple_xfer_set_cancel_send_fnc(xfer,file_trans_cancel);
void** data = s_malloc(sizeof(void*)*3);
data[0] = ac;
xfer->data = data;
purple_xfer_request(xfer);
}
示例3: ggp_ggdrive_auth
static void ggp_ggdrive_auth(PurpleConnection *gc, ggp_ggdrive_auth_cb cb,
gpointer user_data)
{
GGPInfo *accdata = purple_connection_get_protocol_data(gc);
ggp_edisc_session_data *sdata = ggp_edisc_get_sdata(gc);
ggp_edisc_auth_data *auth;
const gchar *imtoken;
gchar *metadata;
PurpleHttpRequest *req;
g_return_if_fail(sdata != NULL);
imtoken = ggp_get_imtoken(gc);
if (!imtoken) {
cb(gc, FALSE, user_data);
return;
}
if (sdata->auth_done) {
cb(gc, sdata->security_token != NULL, user_data);
return;
}
auth = g_new0(ggp_edisc_auth_data, 1);
auth->cb = cb;
auth->user_data = user_data;
sdata->auth_pending = g_list_prepend(sdata->auth_pending, auth);
if (sdata->auth_request)
return;
purple_debug_info("gg", "ggp_ggdrive_auth(gc=%p)\n", gc);
req = purple_http_request_new("https://drive.mpa.gg.pl/signin");
purple_http_request_set_method(req, "PUT");
ggp_edisc_set_defaults(req);
purple_http_request_set_cookie_jar(req, sdata->cookies);
metadata = g_strdup_printf("{"
"\"id\": \"%032x\", "
"\"name\": \"%s\", "
"\"os_version\": \"" GGP_EDISC_OS "\", "
"\"client_version\": \"%s\", "
"\"type\": \"" GGP_EDISC_TYPE "\"}",
g_random_int_range(1, 1 << 16),
purple_get_host_name(),
ggp_libgaduw_version(gc));
purple_http_request_header_set_printf(req, "Authorization",
"IMToken %s", imtoken);
purple_http_request_header_set_printf(req, "X-gged-user",
"gg/pl:%u", accdata->session->uin);
purple_http_request_header_set(req, "X-gged-client-metadata", metadata);
g_free(metadata);
sdata->auth_request = purple_http_request(gc, req,
ggp_ggdrive_auth_done, NULL);
purple_http_request_unref(req);
}
示例4: jabber_set_status
void jabber_set_status(PurpleAccount *account, PurpleStatus *status)
{
PurpleConnection *gc;
JabberStream *js;
if (!purple_account_is_connected(account))
return;
if (purple_status_is_exclusive(status) && !purple_status_is_active(status)) {
/* An exclusive status can't be deactivated. You should just
* activate some other exclusive status. */
return;
}
gc = purple_account_get_connection(account);
js = purple_connection_get_protocol_data(gc);
/* it's a mood update */
if (purple_status_type_get_primitive(purple_status_get_type(status)) == PURPLE_STATUS_MOOD) {
const char *mood =
purple_status_get_attr_string(status, PURPLE_MOOD_NAME);
const char *mood_text =
purple_status_get_attr_string(status, PURPLE_MOOD_COMMENT);
jabber_mood_set(js, mood, mood_text);
return;
}
jabber_presence_send(js, FALSE);
}
示例5: upload_offline_file_init
static void upload_offline_file_init(PurpleXfer* xfer)
{
qq_account* ac = purple_connection_get_protocol_data(purple_account_get_connection(xfer->account));
LwqqClient* lc = ac->qq;
const char* serv_id;
if(ac->qq_use_qqnum) {
const char* qqnum = purple_xfer_get_remote_user(xfer);
LwqqBuddy* b = find_buddy_by_qqnumber(ac->qq, qqnum);
if(b == NULL) return;
serv_id = b->uin;
} else {
serv_id = purple_xfer_get_remote_user(xfer);
}
LwqqMsgOffFile* file = lwqq_msg_fill_upload_offline_file(
xfer->local_filename, lc->myself->uin, serv_id);
xfer->start_time = time(NULL);
xfer->data = file;
int flags = 0;
if(ac->dont_expected_100_continue) flags |= DONT_EXPECTED_100_CONTINUE;
LwqqAsyncEvent* ev = lwqq_msg_upload_offline_file(lc,file,flags);
lwqq_async_add_event_listener(ev,_C_(2p,send_file,ev,xfer));
LwqqHttpRequest* req = lwqq_async_event_get_conn(ev);
lwqq_http_on_progress(req, file_trans_on_progress, xfer);
lwqq_http_set_option(req, LWQQ_HTTP_CANCELABLE,1L);
}
示例6: yahoo_c_send
int yahoo_c_send(PurpleConnection *gc, int id, PurpleMessage *msg)
{
PurpleChatConversation *c;
int ret;
YahooData *yd;
const gchar *what = purple_message_get_contents(msg);
PurpleMessageFlags flags = purple_message_get_flags(msg);
yd = purple_connection_get_protocol_data(gc);
if (!yd)
return -1;
c = purple_conversations_find_chat(gc, id);
if (!c)
return -1;
if (id != YAHOO_CHAT_ID) {
GList *users;
users = purple_chat_conversation_get_users(c);
ret = yahoo_conf_send(gc,
purple_connection_get_display_name(gc),
purple_conversation_get_name(PURPLE_CONVERSATION(c)),
users, what);
g_list_free(users);
} else {
ret = yahoo_chat_send(gc, purple_connection_get_display_name(gc),
purple_conversation_get_name(PURPLE_CONVERSATION(c)), what, flags);
if (!ret)
purple_serv_got_chat_in(gc, purple_chat_conversation_get_id(c),
purple_connection_get_display_name(gc), flags, what, time(NULL));
}
return ret;
}
示例7: waprpl_set_buddy_icon
static void waprpl_set_buddy_icon(PurpleConnection * gc, PurpleStoredImage * img)
{
/* Send the picture the user has selected! */
whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
size_t size = purple_imgstore_get_size(img);
const void *data = purple_imgstore_get_data(img);
if (data) {
// First of all make the picture a square
char * sqbuffer; int sqsize;
imgProfile(data, size, (void**)&sqbuffer, &sqsize, 640);
char * pbuffer; int osize;
imgProfile(data, size, (void**)&pbuffer, &osize, 96);
waAPI_setavatar(wconn->waAPI, sqbuffer, sqsize, pbuffer, osize);
free(sqbuffer); free(pbuffer);
}
else {
waAPI_setavatar(wconn->waAPI, 0,0,0,0);
}
waprpl_check_output(gc);
}
示例8: waprpl_output_cb
static void waprpl_output_cb(gpointer data, gint source, PurpleInputCondition cond)
{
PurpleConnection *gc = data;
whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
char tempbuff[16*1024];
int ret;
do {
int datatosend = waAPI_sendcb(wconn->waAPI, tempbuff, sizeof(tempbuff));
if (datatosend == 0)
break;
ret = sys_write(wconn->fd, tempbuff, datatosend);
if (ret > 0) {
waAPI_senddone(wconn->waAPI, ret);
} else if (ret == 0 || (ret < 0 && errno == EAGAIN)) {
/* Check later */
} else {
gchar *tmp = g_strdup_printf("Lost connection with server (out cb): %s", g_strerror(errno));
purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
g_free(tmp);
break;
}
} while (ret > 0);
/* Check if we need to callback again or not */
waprpl_check_output(gc);
}
示例9: waprpl_input_cb
/* Try to read some data and push it to the WhatsApp API */
static void waprpl_input_cb(gpointer data, gint source, PurpleInputCondition cond)
{
PurpleConnection *gc = data;
whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
char tempbuff[16*1024];
int ret;
do {
ret = sys_read(wconn->fd, tempbuff, sizeof(tempbuff));
if (ret > 0)
waAPI_input(wconn->waAPI, tempbuff, ret);
else if (ret < 0 && errno == EAGAIN)
break;
else if (ret < 0) {
gchar *tmp = g_strdup_printf("Lost connection with server (in cb): %s", g_strerror(errno));
purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, tmp);
g_free(tmp);
break;
} else {
purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, "Server closed the connection");
}
} while (ret > 0);
waprpl_process_incoming_events(gc);
waprpl_check_output(gc); /* The input data may generate responses! */
}
示例10: waprpl_ssl_input_cb
/* Try to read some data and push it to the WhatsApp API */
void waprpl_ssl_input_cb(gpointer data, gint source, PurpleInputCondition cond)
{
PurpleConnection *gc = data;
whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
/* End point closed the connection */
if (!g_list_find(purple_connections_get_all(), gc)) {
waprpl_ssl_cerr_cb(0, 0, gc);
return;
}
char tempbuff[16*1024];
int ret;
do {
ret = purple_ssl_read(wconn->gsc, tempbuff, sizeof(tempbuff));
purple_debug_info(WHATSAPP_ID, "Input data read %d %d\n", ret, errno);
if (ret > 0) {
waAPI_sslinput(wconn->waAPI, tempbuff, ret);
} else if (ret < 0 && errno == EAGAIN)
break;
else if (ret < 0) {
waprpl_ssl_cerr_cb(0, 0, gc);
break;
} else {
waprpl_ssl_cerr_cb(0, 0, gc);
}
} while (ret > 0);
waprpl_check_ssl_output(gc); /* The input data may generate responses! */
waprpl_check_output(gc);
}
示例11: waprpl_show_privacy
/* Show privacy settings */
static void waprpl_show_privacy(PurplePluginAction * action)
{
PurpleConnection *gc = (PurpleConnection *) action->context;
whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
if (!wconn)
return;
char priv[3][30];
waAPI_queryprivacy(wconn->waAPI, priv[0], priv[1], priv[2]);
PurpleRequestField *field;
PurpleRequestFields *fields = purple_request_fields_new();
PurpleRequestFieldGroup *group = purple_request_field_group_new(NULL);
purple_request_fields_add_group(fields, group);
int i,j;
for (j = 0; j < 3; j++) {
field = purple_request_field_list_new(priv_type[j], priv_type_nice[j]);
for (i = 0; i < 3; i++) {
purple_request_field_list_add(field, priv_opt_nice[i], g_strdup(priv_opt[i]));
if (strcmp(priv_opt[i], priv[j]) == 0)
purple_request_field_list_add_selected(field, priv_opt_nice[i]);
}
purple_request_field_group_add_field(group, field);
}
purple_request_fields(gc, "Edit privacy settings", "Edit privacy settings",
NULL, fields,
"Save", G_CALLBACK(waprpl_update_privacy),
"Cancel", NULL,
purple_connection_get_account(gc), NULL, NULL,
gc);
}
示例12: waprpl_ssl_output_cb
void waprpl_ssl_output_cb(gpointer data, gint source, PurpleInputCondition cond)
{
PurpleConnection *gc = data;
whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
char tempbuff[16*1024];
int ret;
do {
int datatosend = waAPI_sslsendcb(wconn->waAPI, tempbuff, sizeof(tempbuff));
purple_debug_info(WHATSAPP_ID, "Output data to send %d\n", datatosend);
if (datatosend == 0)
break;
ret = purple_ssl_write(wconn->gsc, tempbuff, datatosend);
if (ret > 0) {
waAPI_sslsenddone(wconn->waAPI, ret);
} else if (ret == 0 || (ret < 0 && errno == EAGAIN)) {
/* Check later */
} else {
waprpl_ssl_cerr_cb(0, 0, gc);
}
} while (ret > 0);
/* Check if we need to callback again or not */
waprpl_check_ssl_output(gc);
waprpl_check_output(gc);
}
示例13: waprpl_chat_join
static void waprpl_chat_join(PurpleConnection * gc, GHashTable * data)
{
whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
const char *groupname = g_hash_table_lookup(data, "subject");
char *id = g_hash_table_lookup(data, "id");
if (!id) {
gchar *tmp = g_strdup_printf("Joining %s requires an invitation.", groupname);
purple_notify_error(gc, "Invitation only", "Invitation only", tmp);
g_free(tmp);
return;
}
int prplid = chatid_to_convo(id);
purple_debug_info(WHATSAPP_ID, "joining group %s\n", groupname);
if (!purple_find_chat(gc, prplid)) {
char *subject, *owner, *part;
if (!waAPI_getgroupinfo(wconn->waAPI, id, &subject, &owner, &part)) {
subject = g_strdup("Unknown");
owner = g_strdup("000000");
part = g_strdup("");
}
/* Notify chat add */
PurpleConversation *conv = serv_got_joined_chat(gc, prplid, groupname);
/* Add people in the chat */
purple_debug_info(WHATSAPP_ID, "group info ID(%s) SUBJECT(%s) OWNER(%s)\n", id, subject, owner);
conv_add_participants(conv, part, owner);
g_free(subject); g_free(part);
}
}
示例14: waprpl_get_info
static void waprpl_get_info(PurpleConnection * gc, const char *username)
{
PurpleNotifyUserInfo *info = purple_notify_user_info_new();
purple_debug_info(WHATSAPP_ID, "Fetching %s's user info for %s\n", username, gc->account->username);
/* Get user status */
whatsapp_connection *wconn = purple_connection_get_protocol_data(gc);
const char *status_string = waAPI_getuserstatusstring(wconn->waAPI, username);
/* Get user picture (big one) */
char *profile_image = "";
char *icon;
int len;
int res = waAPI_queryavatar(wconn->waAPI, username, &icon, &len);
if (res) {
int iid = purple_imgstore_add_with_id(g_memdup(icon, len), len, NULL);
profile_image = g_strdup_printf("<img id=\"%u\">", iid);
}
purple_notify_user_info_add_pair(info, "Status", status_string);
purple_notify_user_info_add_pair(info, "Profile image", profile_image);
if (res)
g_free(profile_image);
purple_notify_userinfo(gc, username, info, NULL, NULL);
waprpl_check_output(gc);
}
示例15: yahoo_chat_goto
void yahoo_chat_goto(PurpleConnection *gc, const char *name)
{
YahooData *yd;
struct yahoo_packet *pkt;
yd = purple_connection_get_protocol_data(gc);
if (yd->wm) {
g_return_if_fail(yd->ycht != NULL);
ycht_chat_goto_user(yd->ycht, name);
return;
}
if (!yd->chat_online) {
yahoo_chat_online(gc);
g_free(yd->pending_chat_room);
yd->pending_chat_room = NULL;
g_free(yd->pending_chat_id);
yd->pending_chat_id = NULL;
g_free(yd->pending_chat_topic);
yd->pending_chat_topic = NULL;
g_free(yd->pending_chat_goto);
yd->pending_chat_goto = g_strdup(name);
return;
}
pkt = yahoo_packet_new(YAHOO_SERVICE_CHATGOTO, YAHOO_STATUS_AVAILABLE, yd->session_id);
yahoo_packet_hash(pkt, "sss", 109, name, 1, purple_connection_get_display_name(gc), 62, "2");
yahoo_packet_send_and_free(pkt, yd);
}