/soc/2012/tomkiewicz/gg: 26ba5e4e8c24: Gadu-Gadu: status refacto...
Tomasz Wasilczyk
tomkiewicz at cpw.pidgin.im
Fri Aug 17 11:44:31 EDT 2012
Changeset: 26ba5e4e8c24baa66aac5bbf09a7566afc24d704
Author: Tomasz Wasilczyk <tomkiewicz at cpw.pidgin.im>
Date: 2012-08-17 17:44 +0200
Branch: soc.2012.gg
URL: http://hg.pidgin.im/soc/2012/tomkiewicz/gg/rev/26ba5e4e8c24
Description:
Gadu-Gadu: status refactoring - polishing
diffstat:
libpurple/protocols/gg/gg.c | 35 +++++++++++++++--------------------
libpurple/protocols/gg/status.c | 11 +++++++++--
libpurple/protocols/gg/status.h | 2 ++
3 files changed, 26 insertions(+), 22 deletions(-)
diffs (126 lines):
diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c
--- a/libpurple/protocols/gg/gg.c
+++ b/libpurple/protocols/gg/gg.c
@@ -416,20 +416,13 @@ static void ggp_pubdir_handle_info(Purpl
PurpleNotifyUserInfo *user_info;
PurpleBuddy *buddy;
char *val, *who;
- const gchar *status;
user_info = purple_notify_user_info_new();
val = ggp_search_get_result(req, 0, GG_PUBDIR50_STATUS);
- status = ggp_status_to_purplestatus(atoi(val));
- if (g_strcmp0(status, "freeforchat"))
- //TODO: move to status.h or push to libpurple
- status = _("Chatty");
- else
- status = purple_primitive_get_name_from_type(
- purple_primitive_get_type_from_id(status));
- purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status);
+ purple_notify_user_info_add_pair_plaintext(user_info, _("Status"),
+ ggp_status_get_name(ggp_status_to_purplestatus(atoi(val))));
g_free(val);
who = ggp_search_get_result(req, 0, GG_PUBDIR50_UIN);
@@ -467,16 +460,16 @@ static void ggp_pubdir_handle_info(Purpl
* Include a status message, if exists and buddy is in the blist.
*/
buddy = purple_find_buddy(purple_connection_get_account(gc), who);
- if (NULL != buddy) {
- PurpleStatus *status;
- const char *msg;
+ if (NULL != buddy)
+ {
+ gchar *msg;
- status = purple_presence_get_active_status(purple_buddy_get_presence(buddy));
- msg = purple_status_get_attr_string(status, "message");
-
- if (msg != NULL) {
- purple_notify_user_info_add_pair_plaintext(user_info, _("Message"), msg);
- }
+ ggp_status_from_purplestatus(purple_presence_get_active_status(
+ purple_buddy_get_presence(buddy)), &msg);
+ if (msg != NULL)
+ purple_notify_user_info_add_pair_plaintext(user_info,
+ _("Message"), msg);
+ g_free(msg);
}
purple_notify_userinfo(gc, who, user_info, ggp_sr_close_cb, form);
@@ -1163,14 +1156,15 @@ static void ggp_tooltip_text(PurpleBuddy
{
PurpleStatus *status;
char *tmp;
- const char *msg, *name, *alias;
+ const char *name, *alias;
+ gchar *msg;
g_return_if_fail(b != NULL);
status = purple_presence_get_active_status(purple_buddy_get_presence(b));
- msg = purple_status_get_attr_string(status, "message");
name = purple_status_get_name(status);
alias = purple_buddy_get_alias(b);
+ ggp_status_from_purplestatus(status, &msg);
purple_notify_user_info_add_pair_plaintext(user_info, _("Alias"), alias);
@@ -1182,6 +1176,7 @@ static void ggp_tooltip_text(PurpleBuddy
} else {
purple_notify_user_info_add_pair_plaintext(user_info, _("Message"), msg);
}
+ g_free(msg);
/* We don't want to duplicate 'Status: Offline'. */
} else if (PURPLE_BUDDY_IS_ONLINE(b)) {
purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), name);
diff --git a/libpurple/protocols/gg/status.c b/libpurple/protocols/gg/status.c
--- a/libpurple/protocols/gg/status.c
+++ b/libpurple/protocols/gg/status.c
@@ -17,7 +17,6 @@ static inline ggp_status_session_data *
ggp_status_get_ssdata(PurpleConnection *gc);
static gchar * ggp_status_validate_description(const gchar* msg);
-static int ggp_status_from_purplestatus(PurpleStatus *status, gchar **message);
////
@@ -92,7 +91,7 @@ GList * ggp_status_types(PurpleAccount *
return types;
}
-static int ggp_status_from_purplestatus(PurpleStatus *status, gchar **message)
+int ggp_status_from_purplestatus(PurpleStatus *status, gchar **message)
{
const char *status_id = purple_status_get_id(status);
const char *status_message =
@@ -163,6 +162,14 @@ const gchar * ggp_status_to_purplestatus
}
}
+const gchar * ggp_status_get_name(const gchar *purple_status)
+{
+ if (g_strcmp0(purple_status, "freeforchat") == 0)
+ return _("Chatty");
+ return purple_primitive_get_name_from_type(
+ purple_primitive_get_type_from_id(purple_status));
+}
+
/*******************************************************************************
* Own status.
******************************************************************************/
diff --git a/libpurple/protocols/gg/status.h b/libpurple/protocols/gg/status.h
--- a/libpurple/protocols/gg/status.h
+++ b/libpurple/protocols/gg/status.h
@@ -10,7 +10,9 @@ void ggp_status_setup(PurpleConnection *
void ggp_status_cleanup(PurpleConnection *gc);
GList * ggp_status_types(PurpleAccount *account);
+int ggp_status_from_purplestatus(PurpleStatus *status, gchar **message);
const gchar * ggp_status_to_purplestatus(int status);
+const gchar * ggp_status_get_name(const gchar *purple_status);
// own status
More information about the Commits
mailing list