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); }
/*------------------------------------------------------------------------ * Return UI tooltip information for a buddy when hovering in buddy list. * * @param buddy The buddy * @param info The tooltip info being returned * @param full Return full or summarized information */ static void mxit_tooltip( PurpleBuddy* buddy, PurpleNotifyUserInfo* info, gboolean full ) { struct contact* contact = purple_buddy_get_protocol_data( buddy ); if ( !contact ) return; /* status (reference: "libpurple/notify.h") */ if ( contact->presence != MXIT_PRESENCE_OFFLINE ) purple_notify_user_info_add_pair( info, _( "Status" ), mxit_convert_presence_to_name( contact->presence ) ); /* status message */ if ( contact->statusMsg ) purple_notify_user_info_add_pair( info, _( "Status Message" ), contact->statusMsg ); /* mood */ if ( contact->mood != MXIT_MOOD_NONE ) purple_notify_user_info_add_pair( info, _( "Mood" ), mxit_convert_mood_to_name( contact->mood ) ); /* subscription type */ if ( contact->subtype != 0 ) purple_notify_user_info_add_pair( info, _( "Subscription" ), mxit_convert_subtype_to_name( contact->subtype ) ); /* rejection message */ if ( ( contact->subtype == MXIT_SUBTYPE_REJECTED ) && ( contact->msg != NULL ) ) purple_notify_user_info_add_pair( info, _( "Rejection Message" ), contact->msg ); }
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 purplemot_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *info, int full) { PurpleConnection *gc = get_purplemot_gc(buddy->name); if (gc) { /* they're logged in */ PurplePresence *presence = purple_buddy_get_presence(buddy); PurpleStatus *status = purple_presence_get_active_status(presence); char *msg = purplemot_status_text(buddy); purple_notify_user_info_add_pair(info, purple_status_get_name(status), msg); g_free(msg); if (full) { const char *user_info = purple_account_get_user_info(gc->account); if (user_info) purple_notify_user_info_add_pair(info, _("User info"), user_info); } } else { /* they're not logged in */ purple_notify_user_info_add_pair(info, _("User info"), _("not logged in")); } purple_debug_info("purplemot", "showing %s tooltip for %s\n", (full) ? "full" : "short", buddy->name); }
PurpleNotifyUserInfo *create_user_notify_info(struct tgl_user *usr) { PurpleNotifyUserInfo *info = purple_notify_user_info_new(); purple_notify_user_info_add_pair(info, "First name", usr->first_name); purple_notify_user_info_add_pair(info, "Last name", usr->last_name); purple_notify_user_info_add_pair(info, "Phone", usr->phone); purple_notify_user_info_add_pair(info, "Status", usr->status.online == 1 ? "Online" : "Offline"); return info; }
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 oscar_user_info_add_pair(PurpleNotifyUserInfo *user_info, const char *name, const char *value) { if (value && value[0]) { purple_notify_user_info_add_pair(user_info, name, value); } }
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); }
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 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 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); }
static void fx_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean UNUSED(full)) { PurpleStatus *status; const gchar *impresa, *alias, *sid, *mobileno; g_return_if_fail(buddy != NULL); status = purple_presence_get_active_status(purple_buddy_get_presence(buddy)); impresa = purple_status_get_attr_string(status, "impresa"); sid = purple_status_get_attr_string(status, "fetionno"); mobileno = purple_status_get_attr_string(status, "mobileno"); alias = purple_buddy_get_alias(buddy); purple_notify_user_info_add_pair(user_info, _("FetionNo"), sid); purple_notify_user_info_add_pair(user_info, _("MobileNo"), mobileno); purple_notify_user_info_add_pair(user_info, _("Alias"), alias); purple_notify_user_info_add_pair(user_info, _("Signature"), impresa); }
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); }
static void oscar_user_info_convert_and_add(PurpleAccount *account, OscarData *od, PurpleNotifyUserInfo *user_info, const char *name, const char *value) { gchar *utf8; if (value && value[0] && (utf8 = oscar_utf8_try_convert(account, od, value))) { purple_notify_user_info_add_pair(user_info, name, utf8); g_free(utf8); } }
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); }
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 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 oscar_user_info_convert_and_add_hyperlink(PurpleAccount *account, OscarData *od, PurpleNotifyUserInfo *user_info, const char *name, const char *value, const char *url_prefix) { gchar *utf8; if (value && value[0] && (utf8 = oscar_utf8_try_convert(account, od, value))) { gchar *tmp = g_strdup_printf("<a href=\"%s%s\">%s</a>", url_prefix, utf8, utf8); purple_notify_user_info_add_pair(user_info, name, tmp); g_free(utf8); g_free(tmp); } }
static void fb_tooltip_text(PurpleBuddy *buddy, PurpleNotifyUserInfo *userinfo, gboolean full) { FacebookBuddy *fbuddy = buddy->proto_data; gchar *status; g_return_if_fail(fbuddy); if (fbuddy->status && *fbuddy->status != '\0') { status = g_strdup_printf("%s %s", fbuddy->name, fbuddy->status); purple_notify_user_info_add_pair(userinfo, _("Status"), status); g_free(status); } }
static void netsoul_tooltip_text(PurpleBuddy *gb, PurpleNotifyUserInfo *user_info, gboolean full) { purple_debug_info("netsoul", "netsoul_tooltip_text"); NetsoulBuddy *nb = gb->proto_data; char *resp, *nctxt; GList *tmp; NetsoulConn *nc; char **tab; int i; PurpleConnection *gc = purple_account_get_connection (purple_buddy_get_account(gb)); NetsoulData *ns = gc->proto_data; PurpleBuddyIcon *icon = purple_buddy_get_icon (gb); if (icon != NULL) purple_debug_info("netsoul", "netsoul_tooltip_text %s icon_type: %s\n", gb->name, purple_buddy_icon_get_extension(icon)); if (nb == NULL) { nb = g_new0(NetsoulBuddy, 1); gb->proto_data = nb; nb->login = g_strdup(gb->name); ns_watch_buddy(gc, gb); // watch_log_user ns_watch_log_user(gc); ns_list_users(gc, ns->watchlist); } if (nb->nblocations == 0) return; purple_debug_info("netsoul", "netsoul_tooltip_text nblocation != 0\n"); 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(nc); } nctxt = g_strjoinv("", tab); g_strfreev(tab); resp = g_strdup_printf("\n<b>Status:</b> %s\n<b>Groupe:</b> %s\n<b>Connections:</b>%s", ns_state_to_text(nb->state), nb->group, nctxt); g_free(nctxt); purple_notify_user_info_add_pair(user_info, "Informations", resp); g_free(resp); }
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); }
/* a floating text when mouse is on the icon, show connection status here */ static void qq_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { qq_buddy_data *bd; gchar *tmp; GString *str; g_return_if_fail(b != NULL); bd = purple_buddy_get_protocol_data(b); if (bd == NULL) return; /* if (PURPLE_BUDDY_IS_ONLINE(b) && bd != NULL) */ if (bd->ip.s_addr != 0) { str = g_string_new(NULL); g_string_printf(str, "%s:%d", inet_ntoa(bd->ip), bd->port); if (bd->comm_flag & QQ_COMM_FLAG_TCP_MODE) { g_string_append(str, " TCP"); } else { g_string_append(str, " UDP"); } g_string_free(str, TRUE); } tmp = g_strdup_printf("%d", bd->age); purple_notify_user_info_add_pair(user_info, _("Age"), tmp); g_free(tmp); switch (bd->gender) { case QQ_BUDDY_GENDER_GG: purple_notify_user_info_add_pair(user_info, _("Gender"), _("Male")); break; case QQ_BUDDY_GENDER_MM: purple_notify_user_info_add_pair(user_info, _("Gender"), _("Female")); break; case QQ_BUDDY_GENDER_UNKNOWN: purple_notify_user_info_add_pair(user_info, _("Gender"), _("Unknown")); break; default: tmp = g_strdup_printf("Error (%d)", bd->gender); purple_notify_user_info_add_pair(user_info, _("Gender"), tmp); g_free(tmp); } if (bd->level) { tmp = g_strdup_printf("%d", bd->level); purple_notify_user_info_add_pair(user_info, _("Level"), tmp); g_free(tmp); } str = g_string_new(NULL); if (bd->comm_flag & QQ_COMM_FLAG_QQ_MEMBER) { g_string_append( str, _("Member") ); } if (bd->comm_flag & QQ_COMM_FLAG_QQ_VIP) { g_string_append( str, _(" VIP") ); } if (bd->comm_flag & QQ_COMM_FLAG_TCP_MODE) { g_string_append( str, _(" TCP") ); } if (bd->comm_flag & QQ_COMM_FLAG_MOBILE) { g_string_append( str, _(" FromMobile") ); } if (bd->comm_flag & QQ_COMM_FLAG_BIND_MOBILE) { g_string_append( str, _(" BindMobile") ); } if (bd->comm_flag & QQ_COMM_FLAG_VIDEO) { g_string_append( str, _(" Video") ); } if (bd->ext_flag & QQ_EXT_FLAG_ZONE) { g_string_append( str, _(" Zone") ); } purple_notify_user_info_add_pair(user_info, _("Flag"), str->str); g_string_free(str, TRUE); #ifdef DEBUG tmp = g_strdup_printf( "%s (%04X)", qq_get_ver_desc(bd->client_tag), bd->client_tag ); purple_notify_user_info_add_pair(user_info, _("Ver"), tmp); g_free(tmp); tmp = g_strdup_printf( "Ext 0x%X, Comm 0x%X", bd->ext_flag, bd->comm_flag ); purple_notify_user_info_add_pair(user_info, _("Flag"), tmp); g_free(tmp); #endif }
/** * @brief Append the status information to a user_info struct * * The returned information is HTML-ready, appropriately escaped, as all information in a user_info struct should be HTML. * * @param gc The PurpleConnection * @param user_info A PurpleNotifyUserInfo object to which status information will be added * @param b The PurpleBuddy whose status is desired. This or the aim_userinfo_t (or both) must be passed to oscar_user_info_append_status(). * @param userinfo The aim_userinfo_t of the buddy whose status is desired. This or the PurpleBuddy (or both) must be passed to oscar_user_info_append_status(). * @param use_html_status If TRUE, prefer HTML-formatted away message over plaintext available message. */ void oscar_user_info_append_status(PurpleConnection *gc, PurpleNotifyUserInfo *user_info, PurpleBuddy *b, aim_userinfo_t *userinfo, gboolean use_html_status) { PurpleAccount *account = purple_connection_get_account(gc); OscarData *od; PurplePresence *presence = NULL; PurpleStatus *status = NULL; gchar *message = NULL, *itmsurl = NULL, *tmp; gboolean escaping_needed = TRUE; od = purple_connection_get_protocol_data(gc); if (b == NULL && userinfo == NULL) return; if (b == NULL) b = purple_find_buddy(purple_connection_get_account(gc), userinfo->bn); else userinfo = aim_locate_finduserinfo(od, purple_buddy_get_name(b)); if (b) { presence = purple_buddy_get_presence(b); status = purple_presence_get_active_status(presence); } /* If we have both b and userinfo we favor userinfo, because if we're viewing someone's profile then we want the HTML away message, and the "message" attribute of the status contains only the plaintext message. */ if (userinfo) { if ((userinfo->flags & AIM_FLAG_AWAY) && use_html_status && userinfo->away_len > 0 && userinfo->away != NULL && userinfo->away_encoding != NULL) { /* Away message */ message = oscar_encoding_to_utf8(userinfo->away_encoding, userinfo->away, userinfo->away_len); escaping_needed = FALSE; } else { /* * Available message or non-HTML away message (because that's * all we have right now. */ if ((userinfo->status != NULL) && userinfo->status[0] != '\0') { message = oscar_encoding_to_utf8(userinfo->status_encoding, userinfo->status, userinfo->status_len); } #if defined (_WIN32) || defined (__APPLE__) if (userinfo->itmsurl && (userinfo->itmsurl[0] != '\0')) { itmsurl = oscar_encoding_to_utf8(userinfo->itmsurl_encoding, userinfo->itmsurl, userinfo->itmsurl_len); } #endif } } else { message = g_strdup(purple_status_get_attr_string(status, "message")); itmsurl = g_strdup(purple_status_get_attr_string(status, "itmsurl")); } if (message) { tmp = oscar_util_format_string(message, purple_account_get_username(account)); g_free(message); message = tmp; if (escaping_needed) { tmp = purple_markup_escape_text(message, -1); g_free(message); message = tmp; } } if (use_html_status && itmsurl) { tmp = g_strdup_printf("<a href=\"%s\">%s</a>", itmsurl, message); g_free(message); message = tmp; } if (b) { if (purple_presence_is_online(presence)) { gboolean is_away = ((status && !purple_status_is_available(status)) || (userinfo && (userinfo->flags & AIM_FLAG_AWAY))); if (oscar_util_valid_name_icq(purple_buddy_get_name(b)) || is_away || !message || !(*message)) { /* Append the status name for online ICQ statuses, away AIM statuses, and for all buddies with no message. * If the status name and the message are the same, only show one. */ const char *status_name = purple_status_get_name(status); if (status_name && message && !strcmp(status_name, message)) status_name = NULL; tmp = g_strdup_printf("%s%s%s", status_name ? status_name : "", ((status_name && message) && *message) ? ": " : "", (message && *message) ? message : ""); g_free(message); message = tmp; } } else if (aim_ssi_waitingforauth(od->ssi.local, aim_ssi_itemlist_findparentname(od->ssi.local, purple_buddy_get_name(b)), purple_buddy_get_name(b))) { /* Note if an offline buddy is not authorized */ tmp = g_strdup_printf("%s%s%s", _("Not Authorized"), (message && *message) ? ": " : "", (message && *message) ? message : ""); g_free(message); message = tmp; } else { g_free(message); message = g_strdup(_("Offline")); } } if (presence) { const char *mood; const char *comment; char *description; status = purple_presence_get_status(presence, "mood"); mood = icq_get_custom_icon_description(purple_status_get_attr_string(status, PURPLE_MOOD_NAME)); if (mood) { comment = purple_status_get_attr_string(status, PURPLE_MOOD_COMMENT); if (comment) { char *escaped_comment = purple_markup_escape_text(comment, -1); description = g_strdup_printf("%s (%s)", _(mood), escaped_comment); g_free(escaped_comment); } else { description = g_strdup(_(mood)); } purple_notify_user_info_add_pair(user_info, _("Mood"), description); g_free(description); } } purple_notify_user_info_add_pair(user_info, _("Status"), message); g_free(message); }
void silcpurple_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { SilcPurple sg = b->account->gc->proto_data; SilcClient client = sg->client; SilcClientConnection conn = sg->conn; SilcClientID *client_id = b->proto_data; SilcClientEntry client_entry; char *moodstr, *statusstr, *contactstr, *langstr, *devicestr, *tzstr, *geostr; char tmp[256]; /* Get the client entry. */ client_entry = silc_client_get_client_by_id(client, conn, client_id); if (!client_entry) return; if (client_entry->nickname) purple_notify_user_info_add_pair(user_info, _("Nickname"), client_entry->nickname); if (client_entry->username && client_entry->hostname) { g_snprintf(tmp, sizeof(tmp), "%s@%s", client_entry->username, client_entry->hostname); purple_notify_user_info_add_pair(user_info, _("Username"), tmp); } if (client_entry->mode) { memset(tmp, 0, sizeof(tmp)); silcpurple_get_umode_string(client_entry->mode, tmp, sizeof(tmp) - strlen(tmp)); purple_notify_user_info_add_pair(user_info, _("User Modes"), tmp); } silcpurple_parse_attrs(client_entry->attrs, &moodstr, &statusstr, &contactstr, &langstr, &devicestr, &tzstr, &geostr); if (statusstr) { purple_notify_user_info_add_pair(user_info, _("Message"), statusstr); g_free(statusstr); } if (full) { if (moodstr) { purple_notify_user_info_add_pair(user_info, _("Mood"), moodstr); g_free(moodstr); } if (contactstr) { purple_notify_user_info_add_pair(user_info, _("Preferred Contact"), contactstr); g_free(contactstr); } if (langstr) { purple_notify_user_info_add_pair(user_info, _("Preferred Language"), langstr); g_free(langstr); } if (devicestr) { purple_notify_user_info_add_pair(user_info, _("Device"), devicestr); g_free(devicestr); } if (tzstr) { purple_notify_user_info_add_pair(user_info, _("Timezone"), tzstr); g_free(tzstr); } if (geostr) { purple_notify_user_info_add_pair(user_info, _("Geolocation"), geostr); g_free(geostr); } } }
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); }
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 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); }
/* a floating text when mouse is on the icon, show connection status here */ static void qq_tooltip_text(PurpleBuddy *b, PurpleNotifyUserInfo *user_info, gboolean full) { qq_buddy_data *bd; gchar *tmp; GString *str; PurplePresence *presence; PurpleStatus *status; gchar *moodtext; g_return_if_fail(b != NULL); presence = purple_buddy_get_presence(b); bd = purple_buddy_get_protocol_data(b); if (bd == NULL) return; if (bd->level == NULL) qq_request_get_level(purple_account_get_connection(purple_buddy_get_account(b)), bd->uid); /* if (PURPLE_BUDDY_IS_ONLINE(b) && bd != NULL) */ if (bd->ip.s_addr != 0) { str = g_string_new(NULL); g_string_printf(str, "%s:%d", inet_ntoa(bd->ip), bd->port); if (bd->comm_flag & QQ_COMM_FLAG_TCP_MODE) { g_string_append(str, " TCP"); } else { g_string_append(str, " UDP"); } g_string_free(str, TRUE); } tmp = g_strdup_printf("%d", bd->age); purple_notify_user_info_add_pair(user_info, _("Age"), tmp); g_free(tmp); switch (bd->gender) { case QQ_BUDDY_GENDER_GG: purple_notify_user_info_add_pair(user_info, _("Gender"), _("Male")); break; case QQ_BUDDY_GENDER_MM: purple_notify_user_info_add_pair(user_info, _("Gender"), _("Female")); break; default: purple_notify_user_info_add_pair(user_info, _("Gender"), _("Unknown")); } if (bd->level) { tmp = g_strdup_printf("%d", bd->level); purple_notify_user_info_add_pair(user_info, _("Level"), tmp); g_free(tmp); } str = g_string_new(NULL); if (bd->comm_flag & QQ_COMM_FLAG_QQ_MEMBER) { g_string_append( str, _("Member") ); } if (bd->comm_flag & QQ_COMM_FLAG_QQ_VIP) { g_string_append( str, _(" VIP") ); } if (bd->comm_flag & QQ_COMM_FLAG_TCP_MODE) { g_string_append( str, _(" TCP") ); } if (bd->comm_flag & QQ_COMM_FLAG_MOBILE) { g_string_append( str, _(" FromMobile") ); } if (bd->comm_flag & QQ_COMM_FLAG_BIND_MOBILE) { g_string_append( str, _(" BindMobile") ); } if (bd->comm_flag & QQ_COMM_FLAG_VIDEO) { g_string_append( str, _(" Video") ); } if (bd->ext_flag & QQ_EXT_FLAG_ZONE) { g_string_append( str, _(" Zone") ); } purple_notify_user_info_add_pair(user_info, _("Flag"), str->str); g_string_free(str, TRUE); status = purple_presence_get_status(presence, PURPLE_MOOD_NAME); moodtext = purple_status_get_attr_string(status, PURPLE_MOOD_COMMENT); if (moodtext) { purple_notify_user_info_add_pair(user_info, _("Signature"), moodtext); } #ifdef DEBUG tmp = g_strdup_printf( "%s (%04X)", qq_get_ver_desc(bd->client_tag), bd->client_tag ); purple_notify_user_info_add_pair(user_info, _("Ver"), tmp); g_free(tmp); tmp = g_strdup_printf( "Ext 0x%X, Comm 0x%X", bd->ext_flag, bd->comm_flag ); purple_notify_user_info_add_pair(user_info, _("Flag"), tmp); g_free(tmp); #endif }