void purple_prefs_set_bool(const char *name, gboolean value) { struct purple_pref *pref = find_pref(name); if(pref) { if(pref->type != PURPLE_PREF_BOOLEAN) { purple_debug_error("prefs", "purple_prefs_set_bool: %s not a boolean pref\n", name); return; } if(pref->value.boolean != value) { pref->value.boolean = value; do_callbacks(name, pref); } } else { purple_prefs_add_bool(name, value); } }
static void jingle_handle_session_initiate(JingleSession *session, xmlnode *jingle) { xmlnode *content = xmlnode_get_child(jingle, "content"); for (; content; content = xmlnode_get_next_twin(content)) { JingleContent *parsed_content = jingle_content_parse(content); if (parsed_content == NULL) { purple_debug_error("jingle", "Error parsing content\n"); jabber_iq_send(jingle_session_terminate_packet(session, "unsupported-applications")); } else { jingle_session_add_content(session, parsed_content); jingle_content_handle_action(parsed_content, content, JINGLE_SESSION_INITIATE); } } jabber_iq_send(jingle_session_create_ack(session, jingle)); }
static void group_join_cb(qq_room_req *opt_req, const gchar *reason_utf8) { qq_room_data *rmd; g_return_if_fail(opt_req != NULL); if (opt_req->gc == NULL || opt_req->id == 0) { g_free(opt_req); return; } rmd = qq_room_data_find(opt_req->gc, opt_req->id); if (rmd == NULL) { purple_debug_error("QQ", "Can not find room data of %u\n", opt_req->id); g_free(opt_req); return; } qq_send_cmd_group_auth(opt_req->gc, rmd, QQ_ROOM_AUTH_REQUEST_APPLY, 0, reason_utf8); g_free(opt_req); }
void purple_prefs_set_int(const char *name, int value) { struct purple_pref *pref = find_pref(name); if(pref) { if(pref->type != PURPLE_PREF_INT) { purple_debug_error("prefs", "purple_prefs_set_int: %s not an integer pref\n", name); return; } if(pref->value.integer != value) { pref->value.integer = value; do_callbacks(name, pref); } } else { purple_prefs_add_int(name, value); } }
PurplePluginPrefFrame * purple_perl_get_plugin_frame(PurplePlugin *plugin) { /* Sets up the Perl Stack for our call back into the script to run the * plugin_pref... sub */ int count; PurplePerlScript *gps; PurplePluginPrefFrame *ret_frame; dSP; gps = (PurplePerlScript *)plugin->info->extra_info; ENTER; SAVETMPS; /* Some perl magic to run perl_plugin_pref_frame_SV perl sub and * return the frame */ PUSHMARK(SP); PUTBACK; count = call_pv(gps->prefs_sub, G_EVAL | G_SCALAR | G_NOARGS); SPAGAIN; if (SvTRUE(ERRSV)) { purple_debug_error("perl", "Perl plugin prefs frame init exited abnormally: %s\n", SvPVutf8_nolen(ERRSV)); } if (count != 1) croak("call_pv: Did not return the correct number of values.\n"); /* the frame was created in a perl sub and is returned */ ret_frame = (PurplePluginPrefFrame *)purple_perl_ref_object(POPs); /* Tidy up the Perl stack */ PUTBACK; FREETMPS; LEAVE; return ret_frame; }
static void do_port_mapping_cb(gboolean has_control_mapping, gpointer data) { UPnPMappingAddRemove *ar = data; if (has_control_mapping) { gchar action_name[25]; gchar *action_params; if(ar->add) { const gchar *internal_ip; /* get the internal IP */ if(!(internal_ip = purple_upnp_get_internal_ip())) { purple_debug_error("upnp", "purple_upnp_set_port_mapping(): couldn't get local ip\n"); ar->success = FALSE; ar->tima = purple_timeout_add(0, fire_ar_cb_async_and_free, ar); return; } strncpy(action_name, "AddPortMapping", sizeof(action_name)); action_params = g_strdup_printf( ADD_PORT_MAPPING_PARAMS, ar->portmap, ar->protocol, ar->portmap, internal_ip); } else { strncpy(action_name, "DeletePortMapping", sizeof(action_name)); action_params = g_strdup_printf( DELETE_PORT_MAPPING_PARAMS, ar->portmap, ar->protocol); } ar->gfud = purple_upnp_generate_action_message_and_send(action_name, action_params, done_port_mapping_cb, ar); g_free(action_params); return; } ar->success = FALSE; ar->tima = purple_timeout_add(0, fire_ar_cb_async_and_free, ar); }
/* ------------------ * called on received presence * ------------------ */ static gboolean jabber_presence_received(PurpleConnection *pc, const char *type, const char *from, xmlnode *presence) { const xmlnode* parent_node = presence; xmlnode* x_node = NULL; // check if presence has special "x" childnode x_node = xmlnode_get_child_with_namespace(parent_node,"x",NS_SIGNED); if (x_node != NULL) { // user supports openpgp encryption purple_debug_info(PLUGIN_ID, "user %s supports openpgp encryption!\n",from); char* x_node_data = xmlnode_get_data(x_node); if (x_node_data != NULL) { // try to verify char* fpr = verify(x_node_data); if (fpr != NULL) { char* bare_jid = get_bare_jid(from); purple_debug_info(PLUGIN_ID, "user %s has fingerprint %s\n",bare_jid,fpr); // add key to list struct list_item *item = malloc(sizeof(struct list_item)); item->fpr = fpr; g_hash_table_replace(list_fingerprints,bare_jid,item); }else { purple_debug_error(PLUGIN_ID, "could not verify presence of user %s\n",from); } }else { purple_debug_info(PLUGIN_ID, "user %s sent empty signed presence\n",from); } } /* We don't want the plugin to stop processing */ return FALSE; }
GtkWidget * purple_perl_gtk_get_plugin_frame(PurplePlugin *plugin) { SV * sv; int count; MAGIC *mg; GtkWidget *ret; PurplePerlScript *gps; dSP; gps = plugin->info->extra_info; ENTER; SAVETMPS; count = call_pv(gps->gtk_prefs_sub, G_EVAL | G_SCALAR | G_NOARGS); if (count != 1) croak("call_pv: Did not return the correct number of values.\n"); /* the frame was created in a perl sub and is returned */ SPAGAIN; if (SvTRUE(ERRSV)) { purple_debug_error("perl", "Perl gtk plugin frame init exited abnormally: %s\n", SvPVutf8_nolen(ERRSV)); } /* We have a Gtk2::Frame on top of the stack */ sv = POPs; /* The magic field hides the pointer to the actual GtkWidget */ mg = mg_find(SvRV(sv), PERL_MAGIC_ext); ret = (GtkWidget *)mg->mg_ptr; PUTBACK; FREETMPS; LEAVE; return ret; }
static void jingle_handle_transport_info(JingleSession *session, xmlnode *jingle) { xmlnode *content = xmlnode_get_child(jingle, "content"); jabber_iq_send(jingle_session_create_ack(session, jingle)); for (; content; content = xmlnode_get_next_twin(content)) { const gchar *name = xmlnode_get_attrib(content, "name"); const gchar *creator = xmlnode_get_attrib(content, "creator"); JingleContent *parsed_content = jingle_session_find_content(session, name, creator); if (parsed_content == NULL) { purple_debug_error("jingle", "Error parsing content\n"); /* XXX: send error */ } else { jingle_content_handle_action(parsed_content, content, JINGLE_TRANSPORT_INFO); } } }
static void purple_smiley_data_unstore(const char *filename) { const char *dirname; char *path; g_return_if_fail(filename != NULL); dirname = purple_smileys_get_storing_dir(); path = g_build_filename(dirname, filename, NULL); if (g_file_test(path, G_FILE_TEST_EXISTS)) { if (g_unlink(path)) purple_debug_error(SMILEYS_LOG_ID, "Failed to delete %s: %s\n", path, g_strerror(errno)); else purple_debug_info(SMILEYS_LOG_ID, "Deleted cache file: %s\n", path); } g_free(path); }
/*------------------------------------------------------------------------ * Write the request to the HTTP server. * * @param fd The file descriptor * @param pktdata The packet data * @param pktlen The length of the packet data * @return Return -1 on error, otherwise 0 */ static int mxit_http_raw_write( int fd, const char* pktdata, int pktlen ) { int written; int res; written = 0; while ( written < pktlen ) { res = write( fd, &pktdata[written], pktlen - written ); if ( res <= 0 ) { /* error on socket */ if ( errno == EAGAIN ) continue; purple_debug_error( MXIT_PLUGIN_ID, "Error while writing packet to HTTP server (%i)\n", res ); return -1; } written += res; } return 0; }
/*------------------------------------------------------------------------ * User has rejected an invite to join a MultiMX room. * * @param gc The connection object * @param components The list of chat configuration values */ void mxit_chat_reject(PurpleConnection *gc, GHashTable* components) { struct MXitSession* session = (struct MXitSession*) gc->proto_data; const char* roomname = NULL; struct multimx* multimx = NULL; purple_debug_info(MXIT_PLUGIN_ID, "mxit_chat_reject\n"); roomname = g_hash_table_lookup(components, "room"); multimx = find_room_by_alias(session, roomname); if (multimx == NULL) { purple_debug_error(MXIT_PLUGIN_ID, "Groupchat '%s' not found\n", roomname); return; } /* Send Subscription Reject to MXit */ mxit_send_deny_sub(session, multimx->roomid); /* Remove from our list of rooms */ room_remove(session, multimx); }
/* send packet to get who's detailed information */ static void qq_show_buddy_info(PurpleConnection *gc, const gchar *who) { guint32 uid; qq_data *qd; qd = gc->proto_data; uid = purple_name_to_uid(who); if (uid <= 0) { purple_debug_error("QQ", "Not valid QQid: %s\n", who); purple_notify_error(gc, NULL, _("Invalid name"), NULL); return; } if (qd->client_version >= 2007) { qq_request_get_level_2007(gc, uid); } else { qq_request_get_level(gc, uid); } qq_request_buddy_info(gc, uid, 0, QQ_BUDDY_INFO_DISPLAY); }
void ggp_roster_reply(PurpleConnection *gc, struct gg_event_userlist100_reply *reply) { if (GG_USERLIST100_FORMAT_TYPE_GG100 != reply->format_type) { purple_debug_warning("gg", "ggp_roster_reply: " "unsupported format type (%x)\n", reply->format_type); return; } if (reply->type == GG_USERLIST100_REPLY_LIST) ggp_roster_reply_list(gc, reply->version, reply->reply); else if (reply->type == 0x01) /* list up to date (TODO: push to libgadu) */ purple_debug_info("gg", "ggp_roster_reply: list up to date\n"); else if (reply->type == GG_USERLIST100_REPLY_ACK) ggp_roster_reply_ack(gc, reply->version); else if (reply->type == GG_USERLIST100_REPLY_REJECT) ggp_roster_reply_reject(gc, reply->version); else purple_debug_error("gg", "ggp_roster_reply: " "unsupported reply (%x)\n", reply->type); }
void purple_prefs_set_path(const char *name, const char *value) { struct purple_pref *pref = find_pref(name); if(pref) { if(pref->type != PURPLE_PREF_PATH) { purple_debug_error("prefs", "purple_prefs_set_path: %s not a path pref\n", name); return; } if (!purple_strequal(pref->value.string, value)) { g_free(pref->value.string); pref->value.string = g_strdup(value); do_callbacks(name, pref); } } else { purple_prefs_add_path(name, value); } }
static void jingle_handle_content_add(JingleSession *session, xmlnode *jingle) { xmlnode *content = xmlnode_get_child(jingle, "content"); jabber_iq_send(jingle_session_create_ack(session, jingle)); for (; content; content = xmlnode_get_next_twin(content)) { JingleContent *pending_content = jingle_content_parse(content); if (pending_content == NULL) { purple_debug_error("jingle", "Error parsing \"content-add\" content.\n"); /* XXX: send error here */ } else { jingle_session_add_pending_content(session, pending_content); } } /* XXX: signal here */ }
static void xmlnode_parser_structural_error_libxml(void *user_data, xmlErrorPtr error) { struct _xmlnode_parser_data *xpd = user_data; if (error && (error->level == XML_ERR_ERROR || error->level == XML_ERR_FATAL)) { xpd->error = TRUE; purple_debug_error("xmlnode", "XML parser error for xmlnode %p: " "Domain %i, code %i, level %i: %s", user_data, error->domain, error->code, error->level, error->message ? error->message : "(null)\n"); } else if (error) purple_debug_warning("xmlnode", "XML parser error for xmlnode %p: " "Domain %i, code %i, level %i: %s", user_data, error->domain, error->code, error->level, error->message ? error->message : "(null)\n"); else purple_debug_warning("xmlnode", "XML parser error for xmlnode %p\n", user_data); }
/* Warning: do not return NULL */ static gchar *do_convert(const gchar *str, gssize len, const gchar *to_charset, const gchar *from_charset) { GError *error = NULL; gchar *ret; gsize byte_read, byte_write; g_return_val_if_fail(str != NULL && to_charset != NULL && from_charset != NULL, g_strdup(QQ_NULL_MSG)); ret = g_convert(str, len, to_charset, from_charset, &byte_read, &byte_write, &error); if (error == NULL) { return ret; /* convert is OK */ } /* convert error */ purple_debug_error("QQ_CONVERT", "%s\n", error->message); qq_show_packet("Dump failed text", (guint8 *) str, (len == -1) ? strlen(str) : len); g_error_free(error); return g_strdup(QQ_NULL_MSG); }
void purple_prefs_rename(const char *oldname, const char *newname) { struct purple_pref *oldpref, *newpref; oldpref = find_pref(oldname); /* it's already been renamed, call off the dogs */ if(!oldpref) return; newpref = find_pref(newname); if (newpref == NULL) { purple_debug_error("prefs", "Unable to rename %s to %s: new pref not created\n", oldname, newname); return; } purple_prefs_rename_node(oldpref, newpref); }
void fill_auth(struct fetion_account_data *sip, const gchar *hdr, struct sip_auth *auth) { gchar *tmp; if(!hdr) { purple_debug_error("fetion", "fill_auth: hdr==NULL\n"); return; } auth->type = 1; auth->cnonce = gencnonce(); auth->domain = g_strdup("fetion.com.cn"); if((tmp = parse_attribute("nonce=\"", hdr))) auth->nonce = g_ascii_strup(tmp,32); purple_debug(PURPLE_DEBUG_MISC, "fetion", "nonce: %s domain: %s\n", auth->nonce ? auth->nonce : "(null)", auth->domain ? auth->domain : "(null)"); if(auth->domain) auth->digest_session_key = fetion_cipher_digest_calculate_response( sip->username, auth->domain, sip->password, auth->nonce, auth->cnonce); }
static void upnp_parse_description_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *httpResponse, gsize len, const gchar *error_message) { UPnPDiscoveryData *dd = user_data; gchar *control_url = NULL; if (len > 0) control_url = purple_upnp_parse_description_response( httpResponse, len, dd->full_url, dd->service_type); g_free(dd->full_url); if(control_url == NULL) { purple_debug_error("upnp", "purple_upnp_parse_description(): control URL is NULL\n"); } control_info.status = control_url ? PURPLE_UPNP_STATUS_DISCOVERED : PURPLE_UPNP_STATUS_UNABLE_TO_DISCOVER; control_info.lookup_time = time(NULL); control_info.control_url = control_url; strncpy(control_info.service_type, dd->service_type, sizeof(control_info.service_type)); fire_discovery_callbacks(control_url != NULL); /* Look up the public and internal IPs */ if(control_url != NULL) { lookup_public_ip(); lookup_internal_ip(); } if (dd->inpa > 0) purple_input_remove(dd->inpa); if (dd->tima > 0) purple_timeout_remove(dd->tima); g_free(dd); }
static GHashTable *get_environ(const gchar *p_proc_path) { // Get process environment gchar *proc_environ = g_strdup_printf("%s/environ", p_proc_path); #ifdef DEBUG_VERBOSE purple_debug_misc("gfire", "get_environ: Reading environment from \"%s\"\n", proc_environ); #endif // DEBUG_VERBOSE FILE *fenviron = fopen(proc_environ, "r"); g_free(proc_environ); if(!fenviron) { #ifdef DEBUG purple_debug_error("gfire", "get_environ: fopen() failed\n"); #endif // DEBUG return NULL; } GHashTable *ret = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free); gchar *line = NULL; size_t line_len = 0; while(getdelim(&line, &line_len, 0, fenviron) != -1) { const gchar *equal = strchr(line, '='); if(!equal) continue; g_hash_table_insert(ret, g_strndup(line, equal - line), g_strdup(equal + 1)); } fclose(fenviron); g_free(line); #ifdef DEBUG_VERBOSE purple_debug_misc("gfire", "get_environ: saved %u values\n", g_hash_table_size(ret)); #endif // DEBUG_VERBOSE return ret; }
/* * EXPORTED FUNCTIONS */ static gboolean plugin_load(PurplePlugin *plugin) { MySetLayeredWindowAttributes = (void*) wpurple_find_and_loadproc( "user32.dll", "SetLayeredWindowAttributes"); if (!MySetLayeredWindowAttributes) { purple_debug_error(WINTRANS_PLUGIN_ID, "SetLayeredWindowAttributes API not found (Required W2K+)\n"); return FALSE; } purple_signal_connect(purple_conversations_get_handle(), "conversation-created", plugin, PURPLE_CALLBACK(new_conversation_cb), NULL); /* Set callback to remove window from the list, if the window is destroyed */ purple_signal_connect(purple_conversations_get_handle(), "deleting-conversation", plugin, PURPLE_CALLBACK(conversation_delete_cb), NULL); purple_signal_connect(pidgin_conversations_get_handle(), "conversation-dragging", plugin, PURPLE_CALLBACK(set_conv_window_trans), NULL); purple_signal_connect(purple_conversations_get_handle(), "conversation-updated", plugin, PURPLE_CALLBACK(conv_updated_cb), NULL); update_existing_convs(); if (blist) blist_created_cb(NULL, NULL); else purple_signal_connect(pidgin_blist_get_handle(), "gtkblist-created", plugin, PURPLE_CALLBACK(blist_created_cb), NULL); return TRUE; }
static void pb_get_phone_threads(PushBulletAccount *pba, const gchar *device) { const gchar *phonebook_url = "https://api.pushbullet.com/v3/get-permanent"; gchar *device_copy; gchar *postdata; if (device == NULL) { device = pba->main_sms_device; } if (device == NULL) { purple_debug_error("pushbullet", "No SMS device to download threads from\n"); return; } device_copy = g_strdup(device); postdata = g_strdup_printf("{\"key\":\"%s_threads\"}", device_copy); pb_fetch_url(pba, phonebook_url, postdata, pb_got_phone_threads, device_copy); g_free(postdata); }
static void done_port_mapping_cb(PurpleUtilFetchUrlData *url_data, gpointer user_data, const gchar *httpResponse, gsize len, const gchar *error_message) { UPnPMappingAddRemove *ar = user_data; gboolean success = TRUE; /* determine if port mapping was a success */ if ((error_message != NULL) || (httpResponse == NULL) || (g_strstr_len(httpResponse, len, HTTP_OK) == NULL)) { purple_debug_error("upnp", "purple_upnp_set_port_mapping(): Failed HTTP_OK\n%s\n", httpResponse ? httpResponse : "(null)"); success = FALSE; } else purple_debug_info("upnp", "Successfully completed port mapping operation\n"); ar->success = success; ar->tima = purple_timeout_add(0, fire_ar_cb_async_and_free, ar); }
static gboolean res_main_thread_cb(gpointer data) { PurpleSrvResponse *srvres = NULL; int size = 0; PurpleSrvQueryData *query_data = data; if(query_data->error_message != NULL) purple_debug_error("dnssrv", query_data->error_message); else { PurpleSrvResponse *srvres_tmp = NULL; GSList *lst = query_data->results; size = g_slist_length(lst); if(query_data->cb && size > 0) srvres_tmp = srvres = g_new0(PurpleSrvResponse, size); while (lst) { if(query_data->cb) memcpy(srvres_tmp++, lst->data, sizeof(PurpleSrvResponse)); g_free(lst->data); lst = g_slist_remove(lst, lst->data); } query_data->results = NULL; purple_debug_info("dnssrv", "found %d SRV entries\n", size); } if(query_data->cb) query_data->cb(srvres, size, query_data->extradata); query_data->resolver = NULL; query_data->handle = 0; purple_srv_cancel(query_data); return FALSE; }
static size_t ssl_openssl_read(PurpleSslConnection *gsc, void *data, size_t len) { PurpleSslOpensslData *openssl_data = PURPLE_SSL_OPENSSL_DATA(gsc); ssize_t s; int ret; s = SSL_read(openssl_data->ssl, data, len); if (s <= 0) { ret = SSL_get_error(openssl_data->ssl, s); if (ret == SSL_ERROR_WANT_READ || ret == SSL_ERROR_WANT_WRITE) { errno = EAGAIN; return (-1); } purple_debug_error("openssl", "receive failed: %d\n", s); s = 0; } return (s); }
void jabber_ibb_session_close(JabberIBBSession *sess) { JabberIBBSessionState state = jabber_ibb_session_get_state(sess); if (state != JABBER_IBB_SESSION_OPENED && state != JABBER_IBB_SESSION_ERROR) { purple_debug_error("jabber", "jabber_ibb_session_close called on a session that has not been" "opened\n"); } else { JabberIq *set = jabber_iq_new(jabber_ibb_session_get_js(sess), JABBER_IQ_SET); PurpleXmlNode *close = purple_xmlnode_new("close"); purple_xmlnode_set_attrib(set->node, "to", jabber_ibb_session_get_who(sess)); purple_xmlnode_set_namespace(close, NS_IBB); purple_xmlnode_set_attrib(close, "sid", jabber_ibb_session_get_sid(sess)); purple_xmlnode_insert_child(set->node, close); jabber_iq_send(set); sess->state = JABBER_IBB_SESSION_CLOSED; } }
void ggp_image_request(PurpleConnection *gc, uin_t uin, uint64_t id, ggp_image_request_cb cb, gpointer user_data) { GGPInfo *accdata = purple_connection_get_protocol_data(gc); ggp_image_session_data *sdata = ggp_image_get_sdata(gc); ggp_image_requested *req; ggp_image_requested_listener *listener; uint32_t crc = id >> 32; uint32_t size = id; if (size > GGP_IMAGE_SIZE_MAX && crc <= GGP_IMAGE_SIZE_MAX) { uint32_t tmp; purple_debug_warning("gg", "ggp_image_request: " "crc and size are swapped!\n"); tmp = crc; crc = size; size = tmp; } req = g_hash_table_lookup(sdata->incoming_images, &id); if (!req) { req = g_new0(ggp_image_requested, 1); g_hash_table_insert(sdata->incoming_images, ggp_uint64dup(id), req); purple_debug_info("gg", "ggp_image_request: " "requesting image " GGP_IMAGE_ID_FORMAT "\n", id); if (gg_image_request(accdata->session, uin, size, crc) != 0) purple_debug_error("gg", "ggp_image_request: failed\n"); } else { purple_debug_info("gg", "ggp_image_request: " "image " GGP_IMAGE_ID_FORMAT " already requested\n", id); } listener = g_new0(ggp_image_requested_listener, 1); listener->cb = cb; listener->user_data = user_data; req->listeners = g_list_append(req->listeners, listener); }
/* * ssl_openssl_handshake_cb */ static void ssl_openssl_handshake_cb(gpointer data, gint source, PurpleInputCondition cond) { PurpleSslConnection *gsc = (PurpleSslConnection *)data; PurpleSslOpensslData *openssl_data = PURPLE_SSL_OPENSSL_DATA(gsc); int ret, ret2; purple_debug_info("openssl", "Connecting to %s\n", gsc->host); /* * do the negotiation that sets up the SSL connection between * here and there. */ ret = SSL_connect(openssl_data->ssl); if (ret <= 0) { ret2 = SSL_get_error(openssl_data->ssl, ret); if (ret2 == SSL_ERROR_WANT_READ || ret2 == SSL_ERROR_WANT_WRITE) return; purple_debug_error("openssl", "SSL_connect failed: %d\n", ret2); if (gsc->error_cb != NULL) gsc->error_cb(gsc, PURPLE_SSL_HANDSHAKE_FAILED, gsc->connect_cb_data); purple_ssl_close(gsc); return; } purple_input_remove(openssl_data->handshake_handler); openssl_data->handshake_handler = 0; purple_debug_info("openssl", "Connected to %s\n", gsc->host); /* SSL connected now */ gsc->connect_cb(gsc->connect_cb_data, gsc, cond); }