From 67bfa4467929aa588dfc346a1d329dc9297d839c Mon Sep 17 00:00:00 2001 From: Gary Kramlich Date: Mon, 20 Mar 2023 22:28:16 -0500 Subject: Remove PurpleProtocolClient->tooltip_text as it is barely used and we're scaling back our tooltip usage Testing Done: Compiled Reviewed at https://reviews.imfreedom.org/r/2370/ --- finch/gntblist.c | 6 -- libpurple/protocols/bonjour/bonjour.c | 68 ------------------ libpurple/protocols/facebook/facebook.c | 23 ------- libpurple/protocols/gg/gg.c | 39 ----------- libpurple/protocols/jabber/jabber.c | 118 -------------------------------- libpurple/purpleprotocolclient.c | 18 ----- libpurple/purpleprotocolclient.h | 18 ----- 7 files changed, 290 deletions(-) diff --git a/finch/gntblist.c b/finch/gntblist.c index b6037ba231..9af27689bb 100644 --- a/finch/gntblist.c +++ b/finch/gntblist.c @@ -1579,7 +1579,6 @@ tooltip_for_buddy(PurpleBuddy *buddy, GString *str, gboolean full) PurpleContactInfo *info = NULL; PurpleNotifyUserInfo *user_info; PurplePresence *presence = NULL; - PurpleProtocol *protocol = NULL; const char *alias = purple_buddy_get_alias(buddy); char *tmp, *strip; @@ -1599,11 +1598,6 @@ tooltip_for_buddy(PurpleBuddy *buddy, GString *str, gboolean full) purple_notify_user_info_add_pair_plaintext(user_info, _("Account"), tmp); g_free(tmp); - protocol = purple_account_get_protocol(account); - if (protocol) { - purple_protocol_client_tooltip_text(PURPLE_PROTOCOL_CLIENT(protocol), buddy, user_info, full); - } - if (purple_prefs_get_bool("/finch/blist/idletime")) { PurplePresence *pre = purple_buddy_get_presence(buddy); if (purple_presence_is_idle(pre)) { diff --git a/libpurple/protocols/bonjour/bonjour.c b/libpurple/protocols/bonjour/bonjour.c index e7115e56e7..79e74a79a8 100644 --- a/libpurple/protocols/bonjour/bonjour.c +++ b/libpurple/protocols/bonjour/bonjour.c @@ -388,73 +388,6 @@ bonjour_set_buddy_icon(G_GNUC_UNUSED PurpleProtocolServer *protocol_server, bonjour_dns_sd_update_buddy_icon(bd->dns_sd_data); } -static void -bonjour_tooltip_text(G_GNUC_UNUSED PurpleProtocolClient *client, - PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, - G_GNUC_UNUSED gboolean full) -{ - PurplePresence *presence; - PurpleStatus *status; - BonjourBuddy *bb = purple_buddy_get_protocol_data(buddy); - const char *status_description; - const char *message; - - presence = purple_buddy_get_presence(buddy); - status = purple_presence_get_active_status(presence); - message = purple_status_get_attr_string(status, "message"); - - if (purple_presence_is_available(presence)) - status_description = purple_status_get_name(status); - else if (purple_presence_is_idle(presence)) - status_description = _("Idle"); - else - status_description = purple_status_get_name(status); - - purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status_description); - if (message != NULL) { - /* TODO: Check whether it's correct to call add_pair_html, - or if we should be using add_pair_plaintext */ - purple_notify_user_info_add_pair_html(user_info, _("Message"), message); - } - - if (bb == NULL) { - purple_debug_error("bonjour", "Got tooltip request for a buddy without protocol data.\n"); - return; - } - - /* Only show first/last name if there is a nickname set (to avoid duplication) */ - if (bb->nick != NULL && *bb->nick != '\0') { - if (bb->first != NULL && *bb->first != '\0') { - /* TODO: Check whether it's correct to call add_pair_html, - or if we should be using add_pair_plaintext */ - purple_notify_user_info_add_pair_html(user_info, _("First name"), bb->first); - } - if (bb->last != NULL && *bb->last != '\0') { - /* TODO: Check whether it's correct to call add_pair_html, - or if we should be using add_pair_plaintext */ - purple_notify_user_info_add_pair_html(user_info, _("Last name"), bb->last); - } - } - - if (bb->email != NULL && *bb->email != '\0') { - /* TODO: Check whether it's correct to call add_pair_html, - or if we should be using add_pair_plaintext */ - purple_notify_user_info_add_pair_html(user_info, _("Email"), bb->email); - } - - if (bb->AIM != NULL && *bb->AIM != '\0') { - /* TODO: Check whether it's correct to call add_pair_html, - or if we should be using add_pair_plaintext */ - purple_notify_user_info_add_pair_html(user_info, _("AIM Account"), bb->AIM); - } - - if (bb->jid != NULL && *bb->jid != '\0') { - /* TODO: Check whether it's correct to call add_pair_html, - or if we should be using add_pair_plaintext */ - purple_notify_user_info_add_pair_html(user_info, _("XMPP Account"), bb->jid); - } -} - static void bonjour_do_group_change(PurpleBuddy *buddy, const char *new_group) { @@ -681,7 +614,6 @@ bonjour_protocol_class_finalize(G_GNUC_UNUSED BonjourProtocolClass *klass) static void bonjour_protocol_client_iface_init(PurpleProtocolClientInterface *client_iface) { - client_iface->tooltip_text = bonjour_tooltip_text; client_iface->convo_closed = bonjour_convo_closed; client_iface->get_max_message_size = bonjour_get_max_message_size; } diff --git a/libpurple/protocols/facebook/facebook.c b/libpurple/protocols/facebook/facebook.c index a38a906db8..48d342e664 100644 --- a/libpurple/protocols/facebook/facebook.c +++ b/libpurple/protocols/facebook/facebook.c @@ -1160,28 +1160,6 @@ fb_status_types(G_GNUC_UNUSED PurpleProtocol *protocol, return g_list_reverse(types); } -static void -fb_client_tooltip_text(G_GNUC_UNUSED PurpleProtocolClient *client, - PurpleBuddy *buddy, PurpleNotifyUserInfo *info, - G_GNUC_UNUSED gboolean full) -{ - const gchar *name; - PurplePresence *presence; - PurpleStatus *status; - - presence = purple_buddy_get_presence(buddy); - status = purple_presence_get_active_status(presence); - - if (!PURPLE_BUDDY_IS_ONLINE(buddy)) { - /* Prevent doubles statues for Offline buddies */ - /* See: pidgin_get_tooltip_text() in gtkblist.c */ - purple_notify_user_info_remove_last_item(info); - } - - name = purple_status_get_name(status); - purple_notify_user_info_add_pair_plaintext(info, _("Status"), name); -} - static GList * fb_client_blist_node_menu(G_GNUC_UNUSED PurpleProtocolClient *client, PurpleBlistNode *node) @@ -1608,7 +1586,6 @@ facebook_protocol_class_finalize(G_GNUC_UNUSED FacebookProtocolClass *klass) static void facebook_protocol_client_iface_init(PurpleProtocolClientInterface *iface) { - iface->tooltip_text = fb_client_tooltip_text; iface->blist_node_menu = fb_client_blist_node_menu; iface->offline_message = fb_client_offline_message; } diff --git a/libpurple/protocols/gg/gg.c b/libpurple/protocols/gg/gg.c index 65407e150b..e183370b4d 100644 --- a/libpurple/protocols/gg/gg.c +++ b/libpurple/protocols/gg/gg.c @@ -756,44 +756,6 @@ ggp_normalize(G_GNUC_UNUSED PurpleProtocolClient *client, return normalized; } -/* TODO: - * - move to status.c ? - * - add information about not adding to his buddy list (not_a_friend) - */ -static void -ggp_tooltip_text(G_GNUC_UNUSED PurpleProtocolClient *client, PurpleBuddy *b, - PurpleNotifyUserInfo *user_info, - G_GNUC_UNUSED gboolean full) -{ - PurpleStatus *status; - char *tmp; - const char *name, *alias; - gchar *msg; - - g_return_if_fail(b != NULL); - - status = purple_presence_get_active_status(purple_buddy_get_presence(b)); - 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); - - if (msg != NULL) { - if (PURPLE_BUDDY_IS_ONLINE(b)) { - tmp = g_strdup_printf("%s: %s", name, msg); - purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), tmp); - g_free(tmp); - } 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); - } -} - static void ggp_login(G_GNUC_UNUSED PurpleProtocol *protocol, PurpleAccount *account) { PurpleConnection *gc = purple_account_get_connection(account); @@ -1303,7 +1265,6 @@ static void ggp_protocol_client_iface_init(PurpleProtocolClientInterface *client_iface) { client_iface->list_emblem = ggp_list_emblem; - client_iface->tooltip_text = ggp_tooltip_text; client_iface->buddy_free = ggp_buddy_free; client_iface->normalize = ggp_normalize; client_iface->offline_message = ggp_offline_message; diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c index f844f175bf..6c09a44271 100644 --- a/libpurple/protocols/jabber/jabber.c +++ b/libpurple/protocols/jabber/jabber.c @@ -1507,123 +1507,6 @@ jabber_list_emblem(G_GNUC_UNUSED PurpleProtocolClient *client, PurpleBuddy *b) return NULL; } -static void -jabber_tooltip_add_resource_text(JabberBuddyResource *jbr, - PurpleNotifyUserInfo *user_info, gboolean multiple_resources) -{ - char *text = NULL; - char *res = NULL; - char *label, *value; - const char *state; - - if(jbr->status) { - text = g_markup_escape_text(jbr->status, -1); - } - - if(jbr->name) - res = g_strdup_printf(" (%s)", jbr->name); - - state = jabber_buddy_state_get_name(jbr->state); - if (text != NULL && !purple_utf8_strcasecmp(state, text)) { - g_free(text); - text = NULL; - } - - label = g_strdup_printf("%s%s", _("Status"), (res ? res : "")); - value = g_strdup_printf("%s%s%s", state, (text ? ": " : ""), (text ? text : "")); - - purple_notify_user_info_add_pair_html(user_info, label, value); - g_free(label); - g_free(value); - g_free(text); - - /* if the resource is idle, show that */ - /* only show it if there is more than one resource available for - the buddy, since the "general" idleness will be shown anyway, - this way we can see see the idleness of lower-priority resources */ - if (jbr->idle && multiple_resources) { - gchar *idle_str = - purple_str_seconds_to_string(time(NULL) - jbr->idle); - label = g_strdup_printf("%s%s", _("Idle"), (res ? res : "")); - purple_notify_user_info_add_pair_plaintext(user_info, label, idle_str); - g_free(idle_str); - g_free(label); - } - g_free(res); -} - -static void -jabber_tooltip_text(G_GNUC_UNUSED PurpleProtocolClient *client, PurpleBuddy *b, - PurpleNotifyUserInfo *user_info, gboolean full) -{ - JabberBuddy *jb; - PurpleAccount *account; - PurpleConnection *gc; - JabberStream *js; - - g_return_if_fail(b != NULL); - - account = purple_buddy_get_account(b); - g_return_if_fail(account != NULL); - - gc = purple_account_get_connection(account); - g_return_if_fail(gc != NULL); - - js = purple_connection_get_protocol_data(gc); - g_return_if_fail(js != NULL); - - jb = jabber_buddy_find(js, purple_buddy_get_name(b), FALSE); - - if(jb) { - JabberBuddyResource *jbr = NULL; - const char *sub; - GList *l; - gboolean multiple_resources = - jb->resources && g_list_next(jb->resources); - JabberBuddyResource *top_jbr = jabber_buddy_find_resource(jb, NULL); - - /* resource-specific info for the top resource */ - if (top_jbr) { - jabber_tooltip_add_resource_text(top_jbr, user_info, - multiple_resources); - } - - for(l=jb->resources; l; l = l->next) { - jbr = l->data; - /* the remaining resources */ - if (jbr != top_jbr) { - jabber_tooltip_add_resource_text(jbr, user_info, - multiple_resources); - } - } - - if (full) { - if(jb->subscription & JABBER_SUB_FROM) { - if(jb->subscription & JABBER_SUB_TO) - sub = _("Both"); - else if(jb->subscription & JABBER_SUB_PENDING) - sub = _("From (To pending)"); - else - sub = _("From"); - } else { - if(jb->subscription & JABBER_SUB_TO) - sub = _("To"); - else if(jb->subscription & JABBER_SUB_PENDING) - sub = _("None (To pending)"); - else - sub = _("None"); - } - - purple_notify_user_info_add_pair_html(user_info, _("Subscription"), sub); - - } - - if(!PURPLE_BUDDY_IS_ONLINE(b) && jb->error_msg) { - purple_notify_user_info_add_pair_html(user_info, _("Error"), jb->error_msg); - } - } -} - static GList * jabber_status_types(G_GNUC_UNUSED PurpleProtocol *protocol, G_GNUC_UNUSED PurpleAccount *account) @@ -3244,7 +3127,6 @@ static void jabber_protocol_client_iface_init(PurpleProtocolClientInterface *client_iface) { client_iface->list_emblem = jabber_list_emblem; - client_iface->tooltip_text = jabber_tooltip_text; client_iface->blist_node_menu = jabber_blist_node_menu; client_iface->convo_closed = jabber_convo_closed; client_iface->normalize = jabber_client_normalize; diff --git a/libpurple/purpleprotocolclient.c b/libpurple/purpleprotocolclient.c index eb173405a6..bcb058c50b 100644 --- a/libpurple/purpleprotocolclient.c +++ b/libpurple/purpleprotocolclient.c @@ -53,24 +53,6 @@ purple_protocol_client_list_emblem(PurpleProtocolClient *client, return NULL; } -void -purple_protocol_client_tooltip_text(PurpleProtocolClient *client, - PurpleBuddy *buddy, - PurpleNotifyUserInfo *user_info, - gboolean full) -{ - PurpleProtocolClientInterface *iface = NULL; - - g_return_if_fail(PURPLE_IS_PROTOCOL_CLIENT(client)); - g_return_if_fail(PURPLE_IS_BUDDY(buddy)); - g_return_if_fail(user_info != NULL); - - iface = PURPLE_PROTOCOL_CLIENT_GET_IFACE(client); - if(iface != NULL && iface->tooltip_text != NULL) { - iface->tooltip_text(client, buddy, user_info, full); - } -} - GList * purple_protocol_client_blist_node_menu(PurpleProtocolClient *client, PurpleBlistNode *node) diff --git a/libpurple/purpleprotocolclient.h b/libpurple/purpleprotocolclient.h index 1d1c74acc3..d3d4c8758c 100644 --- a/libpurple/purpleprotocolclient.h +++ b/libpurple/purpleprotocolclient.h @@ -53,7 +53,6 @@ G_DECLARE_INTERFACE(PurpleProtocolClient, purple_protocol_client, PURPLE, * @list_emblem: Fills the four char**'s with string identifiers * for "emblems" that the UI will interpret and display as * relevant. - * @tooltip_text: Allows the protocol to add text to a buddy's tooltip. * @blist_node_menu: Returns a list of #PurpleActionMenu structs, which * represent extra actions to be shown in (for example) the * right-click menu for @node. @@ -116,9 +115,6 @@ struct _PurpleProtocolClientInterface { /*< public >*/ const gchar *(*list_emblem)(PurpleProtocolClient *client, PurpleBuddy *buddy); - void (*tooltip_text)(PurpleProtocolClient *client, PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, - gboolean full); - GList *(*blist_node_menu)(PurpleProtocolClient *client, PurpleBlistNode *node); void (*buddy_free)(PurpleProtocolClient *client, PurpleBuddy *buddy); @@ -154,20 +150,6 @@ G_BEGIN_DECLS */ const gchar *purple_protocol_client_list_emblem(PurpleProtocolClient *client, PurpleBuddy *buddy); -/** - * purple_protocol_client_tooltip_text: - * @client: The #PurpleProtocolClient instance. - * @buddy: The #PurpleBuddy instance. - * @user_info: The #PurpleNotifyUserInfo instance. - * @full: Whether or not additional info should be added. - * - * Asks @client to update @user_info for @buddy. If @full is %TRUE then - * more detailed information will added. - * - * Since: 3.0.0 - */ -void purple_protocol_client_tooltip_text(PurpleProtocolClient *client, PurpleBuddy *buddy, PurpleNotifyUserInfo *user_info, gboolean full); - /** * purple_protocol_client_blist_node_menu: * @client: The #PurpleProtocolClient instance. -- cgit v1.2.1