Mercurial > pidgin.yaz
diff libpurple/protocols/mxit/roster.c @ 30837:8e9b04071e79
propagate from branch 'im.pidgin.pidgin' (head 9166d0ffe82472b17cee09aabbef61d8ec6e3e44)
to branch 'im.pidgin.soc.2010.icq-tlc' (head 4c9bb4231e46e234d01e6dc64bf4be49fb12c27c)
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 12 Aug 2010 15:30:11 +0000 |
parents | 18a903a3b474 |
children | a8cc50c2279f |
line wrap: on
line diff
--- a/libpurple/protocols/mxit/roster.c Tue Aug 10 17:53:07 2010 +0000 +++ b/libpurple/protocols/mxit/roster.c Thu Aug 12 15:30:11 2010 +0000 @@ -44,12 +44,12 @@ /* statuses (reference: libpurple/status.h) */ static struct status { - PurpleStatusPrimitive primative; + PurpleStatusPrimitive primitive; int mxit; const char* id; const char* name; } const mxit_statuses[] = { - /* primative, no, id, name */ + /* primitive, no, id, name */ { PURPLE_STATUS_OFFLINE, MXIT_PRESENCE_OFFLINE, "offline", N_( "Offline" ) }, /* 0 */ { PURPLE_STATUS_AVAILABLE, MXIT_PRESENCE_ONLINE, "online", N_( "Available" ) }, /* 1 */ { PURPLE_STATUS_AWAY, MXIT_PRESENCE_AWAY, "away", N_( "Away" ) }, /* 2 */ @@ -74,7 +74,7 @@ const struct status* status = &mxit_statuses[i]; /* add mxit status (reference: "libpurple/status.h") */ - type = purple_status_type_new_with_attrs( status->primative, status->id, _( status->name ), TRUE, TRUE, FALSE, + type = purple_status_type_new_with_attrs( status->primitive, status->id, _( status->name ), TRUE, TRUE, FALSE, "message", _( "Message" ), purple_value_new( PURPLE_TYPE_STRING ), NULL ); @@ -145,6 +145,11 @@ {"hot", N_("Hot"), NULL}, {"sick", N_("Sick"), NULL}, {"sleepy", N_("Sleepy"), NULL}, + {"bored", N_("Bored"), NULL}, + {"cold", N_("Cold"), NULL}, + {"confused", N_("Confused"), NULL}, + {"hungry", N_("Hungry"), NULL}, + {"stressed", N_("Stressed"), NULL}, /* Mark the last record. */ { NULL, NULL, NULL } }; @@ -213,6 +218,16 @@ return _( "Sick" ); case MXIT_MOOD_SLEEPY : return _( "Sleepy" ); + case MXIT_MOOD_BORED : + return _( "Bored" ); + case MXIT_MOOD_COLD : + return _( "Cold" ); + case MXIT_MOOD_CONFUSED : + return _( "Confused" ); + case MXIT_MOOD_HUNGRY : + return _( "Hungry" ); + case MXIT_MOOD_STRESSED : + return _( "Stressed" ); case MXIT_MOOD_NONE : default : return ""; @@ -292,7 +307,7 @@ * XXX: libPurple does not currently provide an API to change or rename the group name * for a specific buddy. One option is to remove the buddy from the list and re-adding * him in the new group, but by doing that makes the buddy go offline and then online - * again. This is really not ideal and very iretating, but how else then? + * again. This is really not ideal and very irritating, but how else then? */ /* create new buddy */ @@ -358,7 +373,7 @@ * So if this MXit contact isn't in a group, pretend it is. */ if ( *contact->groupname == '\0' ) { - strcpy( contact->groupname, MXIT_DEFAULT_GROUP ); + g_strlcpy( contact->groupname, MXIT_DEFAULT_GROUP, sizeof( contact->groupname ) ); } /* find or create a group for this contact */ @@ -428,15 +443,14 @@ * @param mood The new mood for the contact * @param customMood The custom mood identifier * @param statusMsg This is the contact's status message - * @param avatarId This is the contact's avatar id */ -void mxit_update_buddy_presence( struct MXitSession* session, const char* username, short presence, short mood, const char* customMood, const char* statusMsg, const char* avatarId ) +void mxit_update_buddy_presence( struct MXitSession* session, const char* username, short presence, short mood, const char* customMood, const char* statusMsg ) { PurpleBuddy* buddy = NULL; struct contact* contact = NULL; - purple_debug_info( MXIT_PLUGIN_ID, "mxit_update_buddy_presence: user='%s' presence=%i mood=%i customMood='%s' statusMsg='%s' avatar='%s'\n", - username, presence, mood, customMood, statusMsg, avatarId ); + purple_debug_info( MXIT_PLUGIN_ID, "mxit_update_buddy_presence: user='%s' presence=%i mood=%i customMood='%s' statusMsg='%s'\n", + username, presence, mood, customMood, statusMsg ); if ( ( presence < MXIT_PRESENCE_OFFLINE ) || ( presence > MXIT_PRESENCE_DND ) ) { purple_debug_info( MXIT_PLUGIN_ID, "mxit_update_buddy_presence: invalid presence state %i\n", presence ); @@ -458,7 +472,7 @@ contact->mood = mood; /* validate mood */ - if (( contact->mood < MXIT_MOOD_NONE ) || ( contact->mood > MXIT_MOOD_SLEEPY )) + if (( contact->mood < MXIT_MOOD_NONE ) || ( contact->mood > MXIT_MOOD_STRESSED )) contact->mood = MXIT_MOOD_NONE; g_strlcpy( contact->customMood, customMood, sizeof( contact->customMood ) ); @@ -472,7 +486,46 @@ if ( statusMsg[0] != '\0' ) contact->statusMsg = g_markup_escape_text( statusMsg, -1 ); - /* update avatarId */ + /* update the buddy's status (reference: "libpurple/prpl.h") */ + if ( contact->statusMsg ) + purple_prpl_got_user_status( session->acc, username, mxit_statuses[contact->presence].id, "message", contact->statusMsg, NULL ); + else + purple_prpl_got_user_status( session->acc, username, mxit_statuses[contact->presence].id, NULL ); + + /* update the buddy's mood */ + if ( contact->mood == MXIT_MOOD_NONE ) + purple_prpl_got_user_status_deactive( session->acc, username, "mood" ); + else + purple_prpl_got_user_status( session->acc, username, "mood", PURPLE_MOOD_NAME, mxit_moods[contact->mood-1].mood, NULL ); +} + + +/*------------------------------------------------------------------------ + * Update the buddy's avatar. + * Either a presence update packet was received from the MXit server, or a profile response. + * + * @param session The MXit session object + * @param username The contact which presence to update + * @param avatarId This is the contact's avatar id + */ +void mxit_update_buddy_avatar( struct MXitSession* session, const char* username, const char* avatarId ) +{ + PurpleBuddy* buddy = NULL; + struct contact* contact = NULL; + + purple_debug_info( MXIT_PLUGIN_ID, "mxit_update_buddy_avatar: user='%s' avatar='%s'\n", username, avatarId ); + + /* find the buddy information for this contact (reference: "libpurple/blist.h") */ + buddy = purple_find_buddy( session->acc, username ); + if ( !buddy ) { + purple_debug_warning( MXIT_PLUGIN_ID, "mxit_update_buddy_presence: unable to find the buddy '%s'\n", username ); + return; + } + + contact = purple_buddy_get_protocol_data( buddy ); + if ( !contact ) + return; + if ( ( contact->avatarId ) && ( g_ascii_strcasecmp( contact->avatarId, avatarId ) == 0 ) ) { /* avatar has not changed - do nothing */ } @@ -486,18 +539,6 @@ } else /* clear current avatar */ purple_buddy_icons_set_for_user( session->acc, username, NULL, 0, NULL ); - - /* update the buddy's status (reference: "libpurple/prpl.h") */ - if ( contact->statusMsg ) - purple_prpl_got_user_status( session->acc, username, mxit_statuses[contact->presence].id, "message", contact->statusMsg, NULL ); - else - purple_prpl_got_user_status( session->acc, username, mxit_statuses[contact->presence].id, NULL ); - - /* update the buddy's mood */ - if ( contact->mood == MXIT_MOOD_NONE ) - purple_prpl_got_user_status_deactive( session->acc, username, "mood" ); - else - purple_prpl_got_user_status( session->acc, username, "mood", PURPLE_MOOD_NAME, mxit_moods[contact->mood-1].mood, NULL ); }