void flist_get_profile(PurpleConnection *pc, const char *who) { FListAccount *fla; FListProfiles *flp; GString *link_str; gchar *link; FListCharacter *character; g_return_if_fail((fla = pc->proto_data)); flp = _flist_profiles(fla); if(flp->character) g_free(flp->character); flp->character = NULL; if(flp->profile_info) purple_notify_user_info_destroy(flp->profile_info); flp->profile_info = NULL; if(flp->table) g_hash_table_destroy(flp->table); flp->table = NULL; if(flp->profile_request) { flist_web_request_cancel(flp->profile_request); flp->profile_request = NULL; } flp->character = g_strdup(who); flp->profile_info = purple_notify_user_info_new(); link_str = g_string_new(NULL); g_string_append_printf(link_str, "http://www.f-list.net/c/%s", purple_url_encode(who)); link = g_string_free(link_str, FALSE); character = flist_get_character(fla, who); if(!character) { purple_notify_user_info_add_pair(flp->profile_info, "Status", "Offline"); } else { gchar *clean_message = flist_html_unescape_utf8(character->status_message); gchar *parsed_message = flist_bbcode_to_html(fla, NULL, clean_message); purple_notify_user_info_add_pair(flp->profile_info, "Status", flist_format_status(character->status)); purple_notify_user_info_add_pair(flp->profile_info, "Gender", flist_format_gender(character->gender)); purple_notify_user_info_add_pair(flp->profile_info, "Message", parsed_message); g_free(parsed_message); g_free(clean_message); } purple_notify_user_info_add_pair(flp->profile_info, "Link", link); purple_notify_userinfo(pc, flp->character, flp->profile_info, NULL, NULL); if(!character) { //The character is offline. There's nothing more we should do. g_free(flp->character); flp->character = NULL; purple_notify_user_info_destroy(flp->profile_info); flp->profile_info = NULL; } else if(flp->category_table) { /* Try to get the profile through the website API first. */ GHashTable *args = flist_web_request_args(fla); g_hash_table_insert(args, "name", g_strdup(flp->character)); flp->profile_request = flist_web_request(JSON_CHARACTER_INFO, args, NULL, TRUE, fla->secure, flist_get_profile_cb, fla); g_hash_table_destroy(args); } else { /* Try to get the profile through F-Chat. */ JsonObject *json = json_object_new(); json_object_set_string_member(json, "character", flp->character); flist_request(pc, "PRO", json); json_object_unref(json); } g_free(link); }
static void on_userpic_loaded (struct tgl_state *TLS, void *extra, int success, char *filename) { if (!success) { struct download_desc *dld = extra; struct tgl_user *U = dld->data; warning ("Can not load userpic for user %s %s\n", U->first_name, U->last_name); } telegram_conn *conn = TLS->ev_base; gchar *data = NULL; size_t len; GError *err = NULL; g_file_get_contents (filename, &data, &len, &err); int imgStoreId = purple_imgstore_add_with_id (g_memdup(data, (guint)len), len, NULL); struct download_desc *dld = extra; struct tgl_user *U = dld->data; if (imgStoreId <= 0) { warning ("Can not load userpic for user %s %s\n", U->first_name, U->last_name); } char *who = g_strdup_printf ("%d", tgl_get_peer_id (U->id)); if (dld->type == 1) { PurpleNotifyUserInfo *info = create_user_notify_info(U); char *profile_image = profile_image = format_img_full(imgStoreId); purple_notify_user_info_add_pair (info, "Profile image", profile_image); purple_notify_userinfo (conn->gc, who, info, NULL, NULL); g_free (profile_image); } purple_buddy_icons_set_for_user(conn->pa, who, g_memdup(data, (guint)len), len, NULL); g_free(who); }
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); }
static void plainprpl_get_info(PurpleConnection *gc, const char *buddy_name) { PurpleBuddy *buddy; plain_buddy_state *bstate; PurpleNotifyUserInfo *info; const char *addr_str; buddy = purple_find_buddy(gc->account, buddy_name); bstate = purple_buddy_get_protocol_data(buddy); info = purple_notify_user_info_new(); if (bstate) { PurplePresence *presence = purple_buddy_get_presence(buddy); PurpleStatus *status = purple_presence_get_active_status(presence); const char *status_name = purple_status_get_name(status); purple_notify_user_info_add_pair(info, "Status", status_name); addr_str = purple_blist_node_get_string(PURPLE_BLIST_NODE(buddy), "addr_str"); purple_notify_user_info_add_pair(info, "Address", addr_str); if (bstate->state == BUDDY_STATE_RESOLVE) { /* The IP address has not been resolved yet */ purple_notify_user_info_add_pair(info, "Resolved", "Unknown"); } else { purple_notify_user_info_add_pair(info, "Resolved", str_addr(&bstate->addr)); } purple_notify_user_info_add_pair(info, "Last Seen", str_time(bstate->time_recv)); } else { purple_notify_user_info_add_pair(info, "Info", "Missing Data"); } /* Show a buddy's user info in a nice dialog box */ purple_notify_userinfo(gc, buddy_name, info, NULL, NULL); }
static void tgp_info_load_channel_done (struct tgl_state *TLS, void *extra, int success, struct tgl_channel *C) { g_return_if_fail(success); PurpleNotifyUserInfo *info = purple_notify_user_info_new (); if (str_not_empty (C->about)) { purple_notify_user_info_add_pair (info, _("Description"), C->about); } if (str_not_empty (C->username)) { char *link = g_strdup_printf ("https://telegram.me/%s", C->username); purple_notify_user_info_add_pair (info, _("Link"), link); g_free (link); } if (str_not_empty (C->print_title)) { purple_notify_user_info_add_pair (info, _("Print Title"), C->print_title); } char *admins = g_strdup_printf ("%d", C->admins_count); purple_notify_user_info_add_pair (info, _("Administrators"), admins); g_free (admins); char *participants = g_strdup_printf ("%d", C->participants_count); purple_notify_user_info_add_pair (info, _("Participants"), participants); g_free (participants); char *kicked = g_strdup_printf ("%d", C->kicked_count); purple_notify_user_info_add_pair (info, _("Kicked"), kicked); g_free (kicked); purple_notify_userinfo (tls_get_conn (TLS), tgp_blist_lookup_purple_name (TLS, C->id), info, NULL, NULL); }
static void purplemot_get_info(PurpleConnection *gc, const char *username) { const char *body; PurpleNotifyUserInfo *info = purple_notify_user_info_new(); PurpleAccount *acct; purple_debug_info("purplemot", "Fetching %s's user info for %s\n", username, gc->account->username); if (!get_purplemot_gc(username)) { char *msg = g_strdup_printf(_("%s is not logged in."), username); purple_notify_error(gc, _("User Info"), _("User info not available. "), msg); g_free(msg); } acct = purple_accounts_find(username, PURPLEMOT_ID); if (acct) body = purple_account_get_user_info(acct); else body = _("No user info."); purple_notify_user_info_add_pair(info, "Info", body); /* show a buddy's user info in a nice dialog box */ purple_notify_userinfo(gc, /* connection the buddy info came through */ username, /* buddy's username */ info, /* body */ NULL, /* callback called when dialog closed */ NULL); /* userdata for callback */ }
static void nullprpl_get_info(PurpleConnection *gc, const char *username) { const char *body; PurpleNotifyUserInfo *info = purple_notify_user_info_new(); PurpleAccount *acct; purple_debug_info("nullprpl", "Fetching %s's user info for %s\n", username, purple_account_get_username(purple_connection_get_account(gc))); acct = purple_accounts_find(username, NULLPRPL_ID); if (!get_nullprpl_gc(username)) { char *msg = g_strdup_printf(_("%s is not logged in."), username); purple_notify_error(gc, _("User Info"), _("User info not available. "), msg, purple_request_cpar_from_account(acct)); g_free(msg); } if (acct) body = purple_account_get_user_info(acct); else body = _("No user info."); /* TODO: Check whether it's correct to call add_pair_html, or if we should be using add_pair_plaintext */ purple_notify_user_info_add_pair_html(info, "Info", body); /* show a buddy's user info in a nice dialog box */ purple_notify_userinfo(gc, /* connection the buddy info came through */ username, /* buddy's username */ info, /* body */ NULL, /* callback called when dialog closed */ NULL); /* userdata for callback */ }
void *p2tgl_notify_userinfo(struct tgl_state *TLS, tgl_peer_id_t user, PurpleNotifyUserInfo *user_info, PurpleNotifyCloseCallback cb, gpointer user_data) { char *name = peer_strdup_id(user); void *handle = 0; handle = purple_notify_userinfo(tg_get_conn(TLS), name, user_info, cb, user_data); g_free(name); return handle; }
void flist_profile_process_flood(FListAccount *fla, const gchar *message) { FListProfiles *flp = _flist_profiles(fla); if(flp->profile_info && flp->character) { purple_notify_user_info_add_pair(flp->profile_info, "Error", message); purple_notify_userinfo(fla->pc, flp->character, flp->profile_info, NULL, NULL); g_free(flp->character); flp->character = NULL; purple_notify_user_info_destroy(flp->profile_info); flp->profile_info = NULL; } }
static void netsoul_get_info(PurpleConnection *gc, const char *who) { PurpleBuddy *gb; NetsoulBuddy *nb; char *primary; char *text; char *title; char **tab; int i; GList *tmp; NetsoulConn *nc; purple_debug_info("netsoul", "netsoul_get_info %s\n", who); if (!(gb = get_good_stored_buddy(gc, (char *) who))) { PurpleNotifyUserInfo *user_info; user_info = purple_notify_user_info_new(); purple_notify_user_info_add_pair(user_info,"Error", "No Info about this user!"); purple_notify_userinfo(gc, who, user_info, NULL, NULL); purple_notify_user_info_destroy(user_info); return; } nb = gb->proto_data; tab = g_new0(char *, nb->nblocations + 1); for (i = 0, tmp = nb->locationlist; tmp; tmp = tmp->next, i++) { nc = tmp->data; tab[i] = netsoul_conn_text_html(nc); } text = g_strjoinv("<br>", tab); g_strfreev(tab); primary = g_strdup_printf("<b>Status:</b> %s<br><b>Groupe:</b> %s<hr>%s", ns_state_to_text(nb->state), nb->group, text); title = g_strdup_printf("Info for %s", who); PurpleNotifyUserInfo *user_info; user_info = purple_notify_user_info_new(); purple_notify_user_info_add_pair(user_info, title, primary); purple_notify_userinfo(gc, gb->name, user_info, NULL, NULL); purple_notify_user_info_destroy(user_info); g_free(primary); g_free(text); }
void BuddyListNode::retrieveUserInfoForName(PurpleConnection *gc, const char *name) const { PurpleNotifyUserInfo *info = purple_notify_user_info_new(); purple_notify_user_info_add_pair(info, _("Information"), _("Retrieving...")); purple_notify_userinfo(gc, name, info, NULL, NULL); purple_notify_user_info_destroy(info); serv_get_info(gc, name); }
/*------------------------------------------------------------------------ * Display the profile information. * * @param session The MXit session object * @param username The username who's profile information this is * @param profile The profile */ void mxit_show_profile( struct MXitSession* session, const char* username, struct MXitProfile* profile ) { PurpleNotifyUserInfo* info = purple_notify_user_info_new(); struct contact* contact = NULL; PurpleBuddy* buddy; buddy = purple_find_buddy( session->acc, username ); if ( buddy ) { purple_notify_user_info_add_pair( info, _( "Alias" ), purple_buddy_get_alias( buddy ) ); purple_notify_user_info_add_section_break( info ); contact = purple_buddy_get_protocol_data(buddy); } purple_notify_user_info_add_pair( info, _( "Nick Name" ), profile->nickname ); purple_notify_user_info_add_pair( info, _( "Birthday" ), profile->birthday ); purple_notify_user_info_add_pair( info, _( "Gender" ), profile->male ? _( "Male" ) : _( "Female" ) ); // purple_notify_user_info_add_pair( info, _( "Hidden Number" ), profile->hidden ? _( "Yes" ) : _( "No" ) ); /* optional information */ // purple_notify_user_info_add_pair( info, _( "Title" ), profile->title ); purple_notify_user_info_add_pair( info, _( "First Name" ), profile->firstname ); purple_notify_user_info_add_pair( info, _( "Last Name" ), profile->lastname ); // purple_notify_user_info_add_pair( info, _( "Email" ), profile->email ); purple_notify_user_info_add_pair( info, _( "Country" ), profile->regcountry ); purple_notify_user_info_add_section_break( info ); if ( contact ) { /* presence */ purple_notify_user_info_add_pair( info, _( "Status" ), mxit_convert_presence_to_name( contact->presence ) ); /* mood */ if ( contact->mood != MXIT_MOOD_NONE ) purple_notify_user_info_add_pair( info, _( "Mood" ), mxit_convert_mood_to_name( contact->mood ) ); else purple_notify_user_info_add_pair( info, _( "Mood" ), _( "None" ) ); /* status message */ if ( contact->statusMsg ) purple_notify_user_info_add_pair( info, _( "Status Message" ), contact->statusMsg ); /* subscription type */ purple_notify_user_info_add_pair( info, _( "Subscription" ), mxit_convert_subtype_to_name( contact->subtype ) ); /* hidden number */ purple_notify_user_info_add_pair( info, _( "Hidden Number" ), ( contact->flags & MXIT_CFLAG_HIDDEN ) ? _( "Yes" ) : _( "No" ) ); } purple_notify_userinfo( session->con, username, info, NULL, NULL ); purple_notify_user_info_destroy( info ); }
static void info_display_only(PurpleConnection *gc, gchar **segments) { PurpleNotifyUserInfo *user_info; gchar *utf8_value; int index; int choice_num; user_info = purple_notify_user_info_new(); for (index = 1; segments[index] != NULL && index < QQ_INFO_LAST; index++) { if (field_infos[index].iclass == QQ_FIELD_UNUSED) { continue; } switch (field_infos[index].type) { case QQ_FIELD_BOOL: purple_notify_user_info_add_pair(user_info, field_infos[index].text, strtol(segments[index], NULL, 10) ? _("True") : _("False")); break; case QQ_FIELD_CHOICE: choice_num = strtol(segments[index], NULL, 10); if (choice_num < 0 || choice_num >= field_infos[index].choice_size) { choice_num = 0; } purple_notify_user_info_add_pair(user_info, field_infos[index].text, field_infos[index].choice[choice_num]); break; case QQ_FIELD_LABEL: case QQ_FIELD_STRING: case QQ_FIELD_MULTI: default: if (strlen(segments[index]) != 0) { utf8_value = qq_to_utf8(segments[index], QQ_CHARSET_DEFAULT); purple_notify_user_info_add_pair(user_info, field_infos[index].text, utf8_value); g_free(utf8_value); } break; } } purple_notify_userinfo(gc, segments[0], user_info, NULL, NULL); purple_notify_user_info_destroy(user_info); g_strfreev(segments); }
void GetBuddyInfo_cb(struct fetion_account_data *sip, struct sipmsg *msg, struct transaction *tc) { xmlnode *root, *son, *item; const gchar *uri, *name; const gchar *nickname, *gender; const gchar *impresa, *birthday; PurpleNotifyUserInfo *user_info; purple_debug_info("fetion:", "GetBuddyInfo_cb[%s]", msg->body); root = xmlnode_from_str(msg->body, msg->bodylen); item = xmlnode_get_child(root, "contacts/contact"); g_return_if_fail(item != NULL); uri = xmlnode_get_attrib(item, "uri"); item = xmlnode_get_child(item, "personal"); g_return_if_fail(item != NULL); nickname = xmlnode_get_attrib(item, "nickname"); impresa = xmlnode_get_attrib(item, "impresa"); gender = xmlnode_get_attrib(item, "gender"); purple_debug(PURPLE_DEBUG_MISC, "fetion", "get info \n"); user_info = purple_notify_user_info_new(); purple_notify_user_info_add_pair(user_info, "昵称", nickname); //purple_notify_user_info_add_pair(user_info,"手机号码",mobileno); //purple_notify_user_info_add_pair(user_info,"飞信号码",uri); //purple_notify_user_info_add_section_header(user_info, _("General")); if ((gender != NULL) && (gender[0] == '1')) purple_notify_user_info_add_pair(user_info, "性别", "男"); else purple_notify_user_info_add_pair(user_info, "性别", "女"); purple_notify_user_info_add_pair(user_info, "心情短语", impresa); purple_notify_userinfo(sip->gc, uri, user_info, NULL, NULL); purple_notify_user_info_destroy(user_info); xmlnode_free(root); }
static void room_info_display(PurpleConnection *gc, qq_room_data *rmd) { PurpleNotifyUserInfo *room_info; gchar *utf8_value; g_return_if_fail(rmd != NULL && rmd->id > 0); room_info = purple_notify_user_info_new(); /* XXX: Should this be "Topic"? */ purple_notify_user_info_add_pair(room_info, _("Room Title"), rmd->name); purple_notify_user_info_add_pair(room_info, _("Notice"), rmd->bulletin); purple_notify_user_info_add_pair(room_info, _("Detail"), rmd->intro); purple_notify_user_info_add_section_break(room_info); utf8_value = g_strdup_printf(("%u"), rmd->creator_uid); purple_notify_user_info_add_pair(room_info, _("Creator"), utf8_value); g_free(utf8_value); utf8_value = get_role_desc(rmd->my_role); purple_notify_user_info_add_pair(room_info, _("About me"), utf8_value); g_free(utf8_value); utf8_value = g_strdup_printf(("%d"), rmd->category); purple_notify_user_info_add_pair(room_info, _("Category"), utf8_value); g_free(utf8_value); utf8_value = g_strdup_printf(("%d"), rmd->auth_type); purple_notify_user_info_add_pair(room_info, _("Authorize"), utf8_value); g_free(utf8_value); utf8_value = g_strdup_printf(("%u"), rmd->qun_id); purple_notify_userinfo(gc, utf8_value, room_info, NULL, NULL); g_free(utf8_value); purple_notify_user_info_destroy(room_info); }
static void ga_gabuddy_parse_info_cb(HttpHandler* handler, gchar* response, gsize len, gpointer userdata) { htmlDocPtr doc; xmlXPathContextPtr xpathCtx; xmlXPathObjectPtr xpathObj; GayAttitudeAccount *gaa = handler->data; GayAttitudeBuddyInfoRequest *request = userdata; purple_debug(PURPLE_DEBUG_INFO, "gayattitude", "ga_buddy: Fetching info for '%s'.\n", request->gabuddy->buddy->name); doc = htmlReadMemory(response, len, "gayattitude.xml", NULL, 0); if (doc == NULL) { purple_debug(PURPLE_DEBUG_ERROR, "gayattitude", "ga_buddy: Unable to parse response (XML Parsing).\n"); return; } /* Create xpath evaluation context */ xpathCtx = xmlXPathNewContext(doc); if(xpathCtx == NULL) { purple_debug(PURPLE_DEBUG_ERROR, "gayattitude", "ga_buddy: Unable to parse response (XPath context init).\n"); xmlFreeDoc(doc); return; } xmlNode *info_node; /* Search internal Ref ID */ if (!request->gabuddy->ref_id) { purple_debug(PURPLE_DEBUG_INFO, "gayattitude", "ga_buddy: Fetching missing ref_id for '%s'.\n", request->gabuddy->buddy->name); xpathObj = xmlXPathEvalExpression((xmlChar*) "//input[@type='hidden' and @name='ref_id']", xpathCtx); if(xpathObj == NULL) { purple_debug(PURPLE_DEBUG_ERROR, "gayattitude", "ga_buddy: Unable to parse response (XPath evaluation).\n"); xmlXPathFreeContext(xpathCtx); xmlFreeDoc(doc); return; } if (!xmlXPathNodeSetIsEmpty(xpathObj->nodesetval)) { gchar *ref_id; info_node = xpathObj->nodesetval->nodeTab[0]; ref_id = (gchar*) xmlGetProp(info_node, (xmlChar*) "value"); if (request->gabuddy->real_gabuddy) request->gabuddy->real_gabuddy->ref_id = ref_id; else request->gabuddy->ref_id = ref_id; purple_debug(PURPLE_DEBUG_INFO, "gayattitude", "ga_buddy: Found ref_id for '%s': %s.\n", request->gabuddy->buddy->name, request->gabuddy->ref_id); } xmlXPathFreeObject(xpathObj); } if (request->advertise) { PurpleNotifyUserInfo *user_info = purple_notify_user_info_new(); int i; GString *str = NULL; /* Search short description */ xpathCtx->node = doc->parent; xpathObj = xmlXPathEvalExpression((xmlChar*) "//div[@id='PORTRAITHEADER2']/p/text()", xpathCtx); if(xpathObj == NULL) { purple_debug(PURPLE_DEBUG_ERROR, "gayattitude", "ga_buddy: Unable to parse response (XPath evaluation).\n"); xmlXPathFreeContext(xpathCtx); xmlFreeDoc(doc); return; } if (!xmlXPathNodeSetIsEmpty(xpathObj->nodesetval)) { info_node = xpathObj->nodesetval->nodeTab[0]; purple_notify_user_info_add_pair(user_info, "Short Description", (gchar*) info_node->content); } xmlXPathFreeObject(xpathObj); /* Search user research */ xpathCtx->node = doc->parent; xpathObj = xmlXPathEvalExpression((xmlChar*) "//div[@id='bloc_recherche']/p/text()", xpathCtx); if(xpathObj == NULL) { purple_debug(PURPLE_DEBUG_ERROR, "gayattitude", "ga_buddy: Unable to parse response (XPath evaluation).\n"); xmlXPathFreeContext(xpathCtx); xmlFreeDoc(doc); return; } if (!xmlXPathNodeSetIsEmpty(xpathObj->nodesetval)) { for(i = 0; i < xpathObj->nodesetval->nodeNr; i++) { info_node = xpathObj->nodesetval->nodeTab[i]; if (i == 0) str = g_string_new((gchar*) info_node->content); else g_string_append_printf(str, " -- %s", info_node->content); } purple_notify_user_info_add_pair(user_info, "Research", str->str); g_string_free(str, TRUE); } xmlXPathFreeObject(xpathObj); purple_notify_userinfo(gaa->pc, request->gabuddy->buddy->name, user_info, NULL, NULL); purple_notify_user_info_destroy(user_info); } /* Cleanup */ xmlXPathFreeContext(xpathCtx); xmlFreeDoc(doc); /* Chained Callback */ if (request->callback) { purple_debug(PURPLE_DEBUG_INFO, "gayattitude", "ga_buddy: Calling callback after info for '%s' was retrieved\n", request->gabuddy->buddy->name); request->callback(gaa, request->callback_data); } }
static void tgp_info_load_user_done (struct tgl_state *TLS, void *extra, int success, struct tgl_user *U) { g_return_if_fail(success); // user info PurpleNotifyUserInfo *info = purple_notify_user_info_new (); if (str_not_empty (U->first_name) && str_not_empty (U->last_name)) { purple_notify_user_info_add_pair (info, _("First name"), U->first_name); purple_notify_user_info_add_pair (info, _("Last name"), U->last_name); } else { purple_notify_user_info_add_pair (info, _("Name"), U->print_name); } if (str_not_empty (U->username)) { char *username = g_strdup_printf ("@%s", U->username); purple_notify_user_info_add_pair (info, _("Username"), username); g_free (username); } char *status = tgp_format_user_status (&U->status); purple_notify_user_info_add_pair (info, _("Last seen"), status); g_free (status); if (str_not_empty (U->phone)) { char *phone = g_strdup_printf ("+%s", U->phone); purple_notify_user_info_add_pair (info, _("Phone"), phone); g_free (phone); } // secret chat info tgl_peer_t *O = extra; if (O && tgl_get_peer_type (O->id) == TGL_PEER_ENCR_CHAT) { struct tgl_secret_chat *secret = &O->encr_chat; if (secret->state == sc_waiting) { purple_notify_user_info_add_pair (info, "", _("Waiting for the user to get online...")); } else { const char *ttl_key = _("Self destruction timer"); if (secret->ttl) { char *ttl = g_strdup_printf ("%d", secret->ttl); purple_notify_user_info_add_pair (info, ttl_key, ttl); g_free (ttl); } else { purple_notify_user_info_add_pair (info, ttl_key, _("Timer is not enabled.")); } if (secret->first_key_sha[0]) { int sha1key = tgp_visualize_key (TLS, secret->first_key_sha); if (sha1key != -1) { char *ident_icon = tgp_format_img (sha1key); purple_notify_user_info_add_pair (info, _("Secret key"), ident_icon); g_free(ident_icon); } } } } const char *who = NULL; if (tgl_get_peer_type (O->id) == TGL_PEER_ENCR_CHAT) { who = tgp_blist_lookup_purple_name (TLS, O->id); } else { who = tgp_blist_lookup_purple_name (TLS, U->id); } purple_notify_userinfo (tls_get_conn (TLS), who, info, NULL, NULL); }
static void nap_callback(gpointer data, gint source, PurpleInputCondition condition) { PurpleConnection *gc = data; struct nap_data *ndata = gc->proto_data; PurpleAccount *account = NULL; PurpleConversation *c = NULL; PurpleNotifyUserInfo *pnui = NULL; gchar *buf = NULL, *buf2 = NULL, *buf3 = NULL, **res = NULL; unsigned short header[2] = { 0 , 0 }; int len = 0; int command = 0; int i; account = purple_connection_get_account(gc); if (read(source, (void*)header, 4) != 4) { purple_connection_error(gc, _("Unable to read header from server")); return; } len = header[0]; command = header[1]; buf = (gchar *)g_malloc((len + 1) * sizeof(gchar)); buf[len] = '\0'; i = 0; do { int tmp = read(source, buf + i, len - i); if (tmp <= 0) { g_free(buf); buf = g_strdup_printf(_("Unable to read message from server: %s. Command is %hd, length is %hd."), strerror(errno), len, command); purple_connection_error(gc, buf); g_free(buf); return; } i += tmp; } while (i != len); purple_debug(PURPLE_DEBUG_MISC, "napster", "R %3hd: %s\n", command, buf); switch (command) { case 000: /* MSG_SERVER_ERROR */ purple_notify_error(gc, NULL, buf, NULL); purple_input_remove(gc->inpa); gc->inpa = 0; close(source); purple_connection_error(gc, _("Unknown server error.")); break; case 003: /* MSG_SERVER_EMAIL */ purple_debug(PURPLE_DEBUG_MISC, "napster", "Registered with e-mail address: %s\n", buf); ndata->email = g_strdup(buf); /* Our signon is complete */ purple_connection_set_state(gc, PURPLE_CONNECTED); /* Send the server our buddy list */ nap_send_buddylist(gc); break; case 201: /* MSG_SERVER_SEARCH_RESULT */ res = g_strsplit(buf, " ", 0); purple_prpl_got_user_status(account, res[0], "available", NULL); g_strfreev(res); break; case 202: /* MSG_SERVER_SEARCH_END */ purple_prpl_got_user_status(account, buf, "offline", NULL); break; case 205: /* MSG_CLIENT_PRIVMSG */ res = g_strsplit(buf, " ", 2); buf2 = g_markup_escape_text(res[1], -1); serv_got_im(gc, res[0], buf2, 0, time(NULL)); g_free(buf2); g_strfreev(res); break; case 209: /* MSG_SERVER_USER_SIGNON */ /* USERNAME SPEED */ res = g_strsplit(buf, " ", 2); purple_prpl_got_user_status(account, res[0], "available", NULL); g_strfreev(res); break; case 210: /* MSG_SERVER_USER_SIGNOFF */ /* USERNAME SPEED */ res = g_strsplit(buf, " ", 2); purple_prpl_got_user_status(account, res[0], "offline", NULL); g_strfreev(res); break; case 214: /* MSG_SERVER_STATS */ res = g_strsplit(buf, " ", 3); buf2 = g_strdup_printf(_("users: %s, files: %s, size: %sGB"), res[0], res[1], res[2]); serv_got_im(gc, "server", buf2, 0, time(NULL)); g_free(buf2); g_strfreev(res); break; case 301: /* MSG_SERVER_HOTLIST_ACK */ /* Our buddy was added successfully */ break; case 302: /* MSG_SERVER_HOTLIST_ERROR */ buf2 = g_strdup_printf(_("Unable to add \"%s\" to your Napster hotlist"), buf); purple_notify_error(gc, NULL, buf2, NULL); g_free(buf2); break; case 316: /* MSG_SERVER_DISCONNECTING */ /* we have been kicked off =^( */ purple_connection_error(gc, _("You were disconnected from the server.")); break; case 401: /* MSG_CLIENT_PART */ c = nap_find_chat(gc, buf); if (c) serv_got_chat_left(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(c))); break; case 403: /* MSG_SERVER_PUBLIC */ res = g_strsplit(buf, " ", 3); c = nap_find_chat(gc, res[0]); if (c) serv_got_chat_in(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(c)), res[1], 0, res[2], time((time_t)NULL)); g_strfreev(res); break; case 404: /* MSG_SERVER_NOSUCH */ /* abused by opennap servers to broadcast stuff */ buf2 = g_markup_escape_text(buf, -1); serv_got_im(gc, "server", buf2, 0, time(NULL)); g_free(buf2); break; case 405: /* MSG_SERVER_JOIN_ACK */ c = nap_find_chat(gc, buf); if (!c) serv_got_joined_chat(gc, purple_conv_chat_get_id(PURPLE_CONV_CHAT(c)), buf); break; case 407: /* MSG_SERVER_PART */ res = g_strsplit(buf, " ", 0); c = nap_find_chat(gc, res[0]); purple_conv_chat_remove_user(PURPLE_CONV_CHAT(c), res[1], NULL); g_strfreev(res); break; case 406: /* MSG_SERVER_JOIN */ case 408: /* MSG_SERVER_CHANNEL_USER_LIST */ res = g_strsplit(buf, " ", 4); c = nap_find_chat(gc, res[0]); purple_conv_chat_add_user(PURPLE_CONV_CHAT(c), res[1], NULL, PURPLE_CBFLAGS_NONE, TRUE); g_strfreev(res); break; case 409: /* MSG_SERVER_CHANNEL_USER_LIST_END */ break; case 410: /* MSG_SERVER_TOPIC */ /* display the topic in the channel */ res = g_strsplit(buf, " ", 2); c = nap_find_chat(gc, res[0]); purple_conv_chat_set_topic(PURPLE_CONV_CHAT(c), res[0], res[1]); g_strfreev(res); break; case 603: /* MSG_CLIENT_WHOIS */ buf2 = g_strdup_printf(_("%s requested your information"), buf); serv_got_im(gc, "server", buf2, 0, time(NULL)); g_free(buf2); break; case 604: /* MSG_SERVER_WHOIS_RESPONSE */ /* XXX - Format is: "Elite" 37 " " "Active" 0 0 0 0 "purple 0.63cvs" 0 0 192.168.1.41 32798 0 unknown flounder */ res = g_strsplit(buf, " ", 2); /* res[0] == username */ pnui = purple_notify_user_info_new(); purple_notify_user_info_add_pair(pnui, _("Napster User Info:"), res[1]); purple_notify_userinfo(gc, res[0], pnui, NULL, NULL); g_strfreev(res); break; case 621: case 622: /* MSG_CLIENT_MOTD */ /* also replaces MSG_SERVER_MOTD, so we should display it */ buf2 = g_markup_escape_text(buf, -1); serv_got_im(gc, "motd", buf2, 0, time(NULL)); g_free(buf2); break; case 627: /* MSG_CLIENT_WALLOP */ /* abused by opennap server maintainers to broadcast stuff */ buf2 = g_markup_escape_text(buf, -1); serv_got_im(gc, "wallop", buf2, 0, time(NULL)); g_free(buf2); break; case 628: /* MSG_CLIENT_ANNOUNCE */ buf2 = g_markup_escape_text(buf, -1); serv_got_im(gc, "announce", buf2, 0, time(NULL)); g_free(buf); break; case 748: /* MSG_SERVER_GHOST */ /* Looks like someone logged in as us! =-O */ purple_connection_error(gc, _("You have signed on from another location.")); break; case 751: /* MSG_CLIENT_PING */ buf2 = g_strdup_printf(_("%s requested a PING"), buf); serv_got_im(gc, "server", buf2, 0, time(NULL)); g_free(buf2); /* send back a pong */ /* MSG_CLIENT_PONG */ nap_write_packet(gc, 752, "%s", buf); break; case 752: /* MSG_CLIENT_PONG */ buf2 = g_strdup_printf("Received pong from %s", buf); purple_notify_info(gc, NULL, buf2, NULL); g_free(buf2); break; case 824: /* MSG_CLIENT_EMOTE */ res = g_strsplit(buf, " ", 3); buf2 = g_strndup(res[2]+1, strlen(res[2]) - 2); /* chomp off the surround quotes */ buf3 = g_strdup_printf("/me %s", buf2); g_free(buf2); if ((c = nap_find_chat(gc, res[0]))) { purple_conv_chat_write(PURPLE_CONV_CHAT(c), res[1], buf3, PURPLE_MESSAGE_NICK, time(NULL)); } g_free(buf3); g_strfreev(res); break; default: purple_debug(PURPLE_DEBUG_MISC, "napster", "Unknown packet %hd: %s\n", command, buf); break; } g_free(buf); }
static void flist_show_profile(PurpleConnection *pc, const gchar *character, GHashTable *profile, gboolean by_id, PurpleNotifyUserInfo *info) { FListAccount *fla = pc->proto_data; FListProfiles *flp = _flist_profiles(fla); GSList *priority = flp->priority_profile_fields; GSList *category_list = flp->category_list; GList *remaining; //Add a section break after the main info. purple_notify_user_info_add_section_break(info); while(priority) { FListProfileField *field = priority->data; const gchar *key = !by_id ? field->name : field->fieldid; const gchar *value = g_hash_table_lookup(profile, key); if(value) { purple_notify_user_info_add_pair(info, field->name, value); g_hash_table_remove(profile, key); } else { purple_notify_user_info_add_pair(info, field->name, FLIST_PROFILE_DEFAULT_VALUE); } priority = g_slist_next(priority); } //Now, add by category. while(category_list) { FListProfileFieldCategory *category = category_list->data; GSList *field_list = category->fields; gboolean first = TRUE; while(field_list) { FListProfileField *field = field_list->data; const gchar *key = !by_id ? field->name : field->fieldid; const gchar *value = g_hash_table_lookup(profile, key); if(value) { if(first) { purple_notify_user_info_add_section_break(info); //purple_notify_user_info_add_section_header(info, category->name); } purple_notify_user_info_add_pair(info, field->name, value); first = FALSE; g_hash_table_remove(profile, key); } field_list = g_slist_next(field_list); } category_list = g_slist_next(category_list); } //Now, add everything that we missed. //(Ideally, we should do nothing.) remaining = g_hash_table_get_keys(profile); if(remaining) { GList *cur; remaining = g_list_sort(remaining, (GCompareFunc) purple_utf8_strcasecmp); cur = remaining; purple_notify_user_info_add_section_break(info); //purple_notify_user_info_add_section_header(info, FLIST_PROFILE_DEFAULT_CATEGORY); while(cur) { const gchar *field = cur->data; const gchar *value = g_hash_table_lookup(profile, field); purple_notify_user_info_add_pair(info, field, value); g_hash_table_remove(profile, field); cur = g_list_next(cur); } g_list_free(remaining); } purple_notify_userinfo(pc, character, info, NULL, NULL); }
void irc_msg_endwhois(struct irc_conn *irc, const char *name, const char *from, char **args) { PurpleConnection *gc; char *tmp, *tmp2; PurpleNotifyUserInfo *user_info; if (!irc->whois.nick) { purple_debug(PURPLE_DEBUG_WARNING, "irc", "Unexpected End of %s for %s\n", !strcmp(name, "369") ? "WHOWAS" : "WHOIS" , args[1]); return; } if (purple_utf8_strcasecmp(irc->whois.nick, args[1])) { purple_debug(PURPLE_DEBUG_WARNING, "irc", "Received end of %s for %s, expecting %s\n", !strcmp(name, "369") ? "WHOWAS" : "WHOIS" , args[1], irc->whois.nick); return; } user_info = purple_notify_user_info_new(); tmp2 = g_markup_escape_text(args[1], -1); tmp = g_strdup_printf("%s%s%s", tmp2, (irc->whois.ircop ? _(" <i>(ircop)</i>") : ""), (irc->whois.identified ? _(" <i>(identified)</i>") : "")); purple_notify_user_info_add_pair(user_info, _("Nick"), tmp); g_free(tmp2); g_free(tmp); if (irc->whois.away) { tmp = g_markup_escape_text(irc->whois.away, strlen(irc->whois.away)); g_free(irc->whois.away); purple_notify_user_info_add_pair(user_info, _("Away"), tmp); g_free(tmp); } if (irc->whois.userhost) { tmp = g_markup_escape_text(irc->whois.name, strlen(irc->whois.name)); g_free(irc->whois.name); purple_notify_user_info_add_pair(user_info, _("Username"), irc->whois.userhost); purple_notify_user_info_add_pair(user_info, _("Real name"), tmp); g_free(irc->whois.userhost); g_free(tmp); } if (irc->whois.server) { tmp = g_strdup_printf("%s (%s)", irc->whois.server, irc->whois.serverinfo); purple_notify_user_info_add_pair(user_info, _("Server"), tmp); g_free(tmp); g_free(irc->whois.server); g_free(irc->whois.serverinfo); } if (irc->whois.channels) { purple_notify_user_info_add_pair(user_info, _("Currently on"), irc->whois.channels->str); g_string_free(irc->whois.channels, TRUE); } if (irc->whois.idle) { gchar *timex = purple_str_seconds_to_string(irc->whois.idle); purple_notify_user_info_add_pair(user_info, _("Idle for"), timex); g_free(timex); purple_notify_user_info_add_pair(user_info, _("Online since"), purple_date_format_full(localtime(&irc->whois.signon))); } if (!strcmp(irc->whois.nick, "Paco-Paco")) { purple_notify_user_info_add_pair(user_info, _("<b>Defining adjective:</b>"), _("Glorious")); } gc = purple_account_get_connection(irc->account); purple_notify_userinfo(gc, irc->whois.nick, user_info, NULL, NULL); purple_notify_user_info_destroy(user_info); g_free(irc->whois.nick); memset(&irc->whois, 0, sizeof(irc->whois)); }
static void ggp_pubdir_get_info_protocol_got(PurpleConnection *gc, int records_count, const ggp_pubdir_record *records, int next_offset, void *_uin_p) { uin_t uin = *((uin_t*)_uin_p); PurpleNotifyUserInfo *info = purple_notify_user_info_new(); const ggp_pubdir_record *record = &records[0]; PurpleBuddy *buddy; g_free(_uin_p); if (records_count < 1) { purple_debug_error("gg", "ggp_pubdir_get_info_protocol_got: " "couldn't get info for %u\n", uin); purple_notify_user_info_add_pair_plaintext(info, NULL, _("Cannot get user information")); purple_notify_userinfo(gc, ggp_uin_to_str(uin), info, NULL, NULL); purple_notify_user_info_destroy(info); return; } purple_debug_info("gg", "ggp_pubdir_get_info_protocol_got: %u\n", uin); g_assert(uin == record->uin); g_assert(records_count == 1); buddy = purple_blist_find_buddy(purple_connection_get_account(gc), ggp_uin_to_str(uin)); if (buddy) { const char *alias; PurpleStatus *status; gchar *status_message; alias = purple_buddy_get_alias_only(buddy); if (alias) purple_notify_user_info_add_pair_plaintext(info, _("Alias"), alias); status = purple_presence_get_active_status( purple_buddy_get_presence(buddy)); ggp_status_from_purplestatus(status, &status_message); purple_notify_user_info_add_pair_plaintext(info, _("Status"), purple_status_get_name(status)); if (status_message) { purple_notify_user_info_add_pair_plaintext(info, _("Message"), status_message); } } if (record->nickname) { purple_notify_user_info_add_pair_plaintext(info, _("Nickname"), record->nickname); } if (record->first_name) { purple_notify_user_info_add_pair_plaintext(info, _("First name"), record->first_name); } if (record->last_name) { purple_notify_user_info_add_pair_plaintext(info, _("Last name"), record->last_name); } if (record->gender != GGP_PUBDIR_GENDER_UNSPECIFIED) { purple_notify_user_info_add_pair_plaintext(info, _("Gender"), record->gender == GGP_PUBDIR_GENDER_FEMALE ? _("Female") : _("Male")); } if (record->city) { purple_notify_user_info_add_pair_plaintext(info, _("City"), record->city); } if (record->birth) { purple_notify_user_info_add_pair_plaintext(info, _("Birthday"), ggp_date_strftime("%Y-%m-%d", record->birth)); } else if (record->age) { gchar *age_s = g_strdup_printf("%d", record->age); purple_notify_user_info_add_pair_plaintext(info, _("Age"), age_s); g_free(age_s); } purple_notify_userinfo(gc, ggp_uin_to_str(uin), info, NULL, NULL); purple_notify_user_info_destroy(info); }
static void skypeweb_got_info(SkypeWebAccount *sa, JsonNode *node, gpointer user_data) { gchar *username = user_data; PurpleNotifyUserInfo *user_info; JsonObject *userobj; PurpleBuddy *buddy; SkypeWebBuddy *sbuddy; const gchar *new_avatar; if (node == NULL || json_node_get_node_type(node) != JSON_NODE_OBJECT) return; userobj = json_node_get_object(node); user_info = purple_notify_user_info_new(); #define _SKYPE_USER_INFO(prop, key) if (prop && json_object_has_member(userobj, (prop)) && !json_object_get_null_member(userobj, (prop))) \ purple_notify_user_info_add_pair_html(user_info, _(key), json_object_get_string_member(userobj, (prop))); _SKYPE_USER_INFO("firstname", "First Name"); _SKYPE_USER_INFO("lastname", "Last Name"); _SKYPE_USER_INFO("birthday", "Birthday"); //_SKYPE_USER_INFO("gender", "Gender"); if (json_object_has_member(userobj, "gender") && !json_object_get_null_member(userobj, "gender")) { const gchar *gender = json_object_get_string_member(userobj, "gender"); const gchar *gender_output; if (*gender == '1') { gender_output = _("Male"); } else if (*gender == '2') { gender_output = _("Female"); } else { gender_output = _("Unknown"); } purple_notify_user_info_add_pair_html(user_info, _("Gender"), gender_output); } _SKYPE_USER_INFO("language", "Language"); _SKYPE_USER_INFO("country", "Country"); _SKYPE_USER_INFO("province", "Province"); _SKYPE_USER_INFO("city", "City"); _SKYPE_USER_INFO("homepage", "Homepage"); _SKYPE_USER_INFO("about", "About"); _SKYPE_USER_INFO("jobtitle", "Job Title"); _SKYPE_USER_INFO("phoneMobile", "Phone - Mobile"); _SKYPE_USER_INFO("phoneHome", "Phone - Home"); _SKYPE_USER_INFO("phoneOffice", "Phone - Office"); //_SKYPE_USER_INFO("mood", "Mood"); //_SKYPE_USER_INFO("richMood", "Mood"); //_SKYPE_USER_INFO("avatarUrl", "Avatar"); buddy = purple_find_buddy(sa->account, username); if (buddy) { sbuddy = purple_buddy_get_protocol_data(buddy); if (sbuddy == NULL) { sbuddy = g_new0(SkypeWebBuddy, 1); purple_buddy_set_protocol_data(buddy, sbuddy); sbuddy->skypename = g_strdup(username); sbuddy->sa = sa; } new_avatar = json_object_get_string_member(userobj, "avatarUrl"); if (new_avatar && (!sbuddy->avatar_url || !g_str_equal(sbuddy->avatar_url, new_avatar))) { g_free(sbuddy->avatar_url); sbuddy->avatar_url = g_strdup(new_avatar); skypeweb_get_icon(buddy); } g_free(sbuddy->mood); sbuddy->mood = g_strdup(json_object_get_string_member(userobj, "mood")); } purple_notify_userinfo(sa->pc, username, user_info, NULL, NULL); g_free(username); }