示例#1
0
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);
}
示例#2
0
static void flist_get_profile_cb(FListWebRequestData *req_data, gpointer user_data,
        JsonObject *root, const gchar *error_message) {
    FListAccount *fla = user_data;
    FListProfiles *flp = _flist_profiles(fla);
    gboolean success;

    flp->profile_request = NULL;

    if(!root) {
        purple_debug_warning(FLIST_DEBUG, "We requested a profile from the Web API, but failed. Error Message: %s\n", error_message);
        success = FALSE;
    } else {
        success = flist_process_profile(fla, root);
    }

    if(success) {
        g_free(flp->character); flp->character = NULL;
        purple_notify_user_info_destroy(flp->profile_info); flp->profile_info = NULL;
    } else {
        JsonObject *json = json_object_new();
        json_object_set_string_member(json, "character", flp->character);
        flist_request(fla->pc, "PRO", json);
        json_object_unref(json);
    }
}
示例#3
0
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;
    }
}
示例#4
0
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);
}
示例#5
0
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);
}
示例#6
0
/*------------------------------------------------------------------------
 * 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 );
}
示例#7
0
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);
}
示例#8
0
void flist_profile_unload(PurpleConnection *pc) {
    FListAccount *fla = pc->proto_data;
    FListProfiles *flp = _flist_profiles(fla);

    if(flp->global_profile_request) {
        flist_web_request_cancel(flp->global_profile_request);
        flp->global_profile_request = NULL;
    }
    
    if(flp->priority_profile_fields) {
        g_slist_free(flp->priority_profile_fields);
        flp->priority_profile_fields = NULL;
    }

    if(flp->category_list) {
        g_slist_free(flp->category_list);
        flp->category_list = NULL;
    }
    if(flp->category_table) {
        g_hash_table_destroy(flp->category_table);
        flp->category_table = NULL;
    }
    
    if(flp->profile_request) {
        flist_web_request_cancel(flp->profile_request);
        flp->profile_request = NULL;
    }
    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) flp->profile_request = NULL;
    
    g_free(flp);
    //TODO: lots of memory leaks here to cleanup?
}
示例#9
0
gboolean flist_process_PRD(PurpleConnection *pc, JsonObject *root) {
    FListAccount *fla = pc->proto_data;
    FListProfiles *flp = _flist_profiles(fla);
    const gchar *type;
    const gchar *key;
    gchar *value, *unescaped;

    if(!flp->character) {
        purple_debug_error(FLIST_DEBUG, "Profile information received, but we are not expecting profile information.\n");
        return TRUE;
    }

    type = json_object_get_string_member(root, "type");
    if(!g_strcmp0(type, "start")) { /* we don't care! */
        if(flp->table) g_hash_table_destroy(flp->table);
        flp->table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
        return TRUE;
    }
    if(!g_strcmp0(type, "end")) {
        flist_show_profile(pc, flp->character, flp->table, FALSE, flp->profile_info);
        g_free(flp->character); flp->character = NULL;
        if(flp->table) {
            g_hash_table_destroy(flp->table); flp->table = NULL;
        }
        purple_notify_user_info_destroy(flp->profile_info); flp->profile_info = NULL;
        return TRUE;
    }
    if(!flp->table) {
        return TRUE; //this should never happen
    }

    key = json_object_get_string_member(root, "key");
    unescaped = flist_html_unescape_utf8(json_object_get_string_member(root, "value"));
    value = purple_markup_escape_text(unescaped, strlen(unescaped));
    g_hash_table_replace(flp->table, g_strdup(key), value);

    purple_debug_info(FLIST_DEBUG, "Profile information received for %s. Key: %s. Value: %s.\n", flp->character, key, value);

    g_free(unescaped);

    return TRUE;
}
示例#10
0
文件: purple.c 项目: KimCM/Heliotrope
void heliotrope_xfire_tooltip_text(PurpleBuddy *buddy) {
  PurplePlugin *prpl;
  PurplePluginProtocolInfo *prpl_info;
  PurpleAccount *account;
  PurpleNotifyUserInfo *user_info;
  PurplePresence *presence;

  user_info = purple_notify_user_info_new();

  account = purple_buddy_get_account(buddy);
  presence = purple_buddy_get_presence(buddy);

  prpl = purple_find_prpl(purple_account_get_protocol_id(account));
  prpl_info = PURPLE_PLUGIN_PROTOCOL_INFO(prpl);
  if (prpl_info && prpl_info->tooltip_text) {
    prpl_info->tooltip_text(buddy, user_info, 0);
  }

  purple_notify_user_info_destroy(user_info);
}
示例#11
0
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);

}
示例#12
0
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);
}
示例#13
0
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);
	}
}
示例#14
0
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);
}
示例#15
0
文件: msgs.c 项目: bf4/pidgin-mac
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));
}