예제 #1
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 );
}
예제 #2
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);
}
예제 #3
0
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);
}
예제 #4
0
/**
 * Append user information to a PurpleNotifyUserInfo, given an MsimUser.
 * Used by msim_tooltip_text() and msim_get_info_cb() to show a user's profile.
 */
void
msim_append_user_info(MsimSession *session, PurpleNotifyUserInfo *user_info, MsimUser *user, gboolean full)
{
    PurplePresence *presence;
    gchar *str;
    guint cv;

    /* Useful to identify the account the tooltip refers to.
     *  Other prpls show this. */
    if (user->username) {
        purple_notify_user_info_add_pair(user_info, _("User"), user->username);
    }

    /* a/s/l...the vitals */
    if (user->age) {
        char age[16];
        g_snprintf(age, sizeof(age), "%d", user->age);
        purple_notify_user_info_add_pair(user_info, _("Age"), age);
    }

    if (user->gender && *user->gender) {
        purple_notify_user_info_add_pair(user_info, _("Gender"), user->gender);
    }

    if (user->location && *user->location) {
        purple_notify_user_info_add_pair(user_info, _("Location"), user->location);
    }

    /* Other information */
    if (user->headline && *user->headline) {
        purple_notify_user_info_add_pair(user_info, _("Headline"), user->headline);
    }

    if (user->buddy != NULL) {
        presence = purple_buddy_get_presence(user->buddy);

        if (purple_presence_is_status_primitive_active(presence, PURPLE_STATUS_TUNE)) {
            PurpleStatus *status;
            const char *artist, *title;

            status = purple_presence_get_status(presence, "tune");
            title = purple_status_get_attr_string(status, PURPLE_TUNE_TITLE);
            artist = purple_status_get_attr_string(status, PURPLE_TUNE_ARTIST);

            str = msim_format_now_playing(artist, title);
            if (str && *str) {
                purple_notify_user_info_add_pair(user_info, _("Song"), str);
            }
            g_free(str);
        }
    }

    /* Note: total friends only available if looked up by uid, not username. */
    if (user->total_friends) {
        char friends[16];
        g_snprintf(friends, sizeof(friends), "%d", user->total_friends);
        purple_notify_user_info_add_pair(user_info, _("Total Friends"), friends);
    }

    if (full) {
        /* Client information */
        char *client = NULL;

        str = user->client_info;
        cv = user->client_cv;

        if (str && cv != 0) {
            client = g_strdup_printf("%s (build %d)", str, cv);
        } else if (str) {
            client = g_strdup(str);
        } else if (cv) {
            client = g_strdup_printf("Build %d", cv);
        }
        if (client && *client)
            purple_notify_user_info_add_pair(user_info, _("Client Version"), client);
        g_free(client);
    }

    if (full && user->id) {
        /* TODO: link to username, if available */
        char *profile;
        purple_notify_user_info_add_section_break(user_info);
        if (user->buddy != NULL)
            profile = g_strdup_printf("<a href=\"http://myspace.com/%s\">%s</a>",
                                      purple_buddy_get_name(user->buddy), _("View web profile"));
        else
            profile = g_strdup_printf("<a href=\"http://myspace.com/%d\">%s</a>",
                                      user->id, _("View web profile"));
        purple_notify_user_info_add_pair(user_info, NULL, profile);
        g_free(profile);
    }
}