aboutsummaryrefslogtreecommitdiffstats
path: root/protocols/nogaim.c
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-12-08 19:31:05 -0300
committerdequis <dx@dxzone.com.ar>2016-03-20 00:58:05 -0300
commita42fda42abad6af64ac9a905856ee9a3095954cd (patch)
tree25ed1239ee6f58f39fa98d54ea02c1c1999bff92 /protocols/nogaim.c
parent14f912d4c1e818d39234c874036e4fe60227d1dc (diff)
Add imcb_buddy_nick_change(), like nick_hint but stronger
nick_hint only works when creating new users, it's a no-op after the user is online. This new function takes care of nick changes after that. It also helps clean up couple of hacks in irc_im.c \o/
Diffstat (limited to 'protocols/nogaim.c')
-rw-r--r--protocols/nogaim.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/protocols/nogaim.c b/protocols/nogaim.c
index a5eda2e0..a1aba51f 100644
--- a/protocols/nogaim.c
+++ b/protocols/nogaim.c
@@ -478,9 +478,8 @@ void imcb_remove_buddy(struct im_connection *ic, const char *handle, char *group
bee_user_free(ic->bee, bee_user_by_handle(ic->bee, ic, handle));
}
-/* Mainly meant for ICQ (and now also for Jabber conferences) to allow IM
- modules to suggest a nickname for a handle. */
-void imcb_buddy_nick_hint(struct im_connection *ic, const char *handle, const char *nick)
+/* Implements either imcb_buddy_nick_hint() or imcb_buddy_nick_change() depending on the value of 'change' */
+static void buddy_nick_hint_or_change(struct im_connection *ic, const char *handle, const char *nick, gboolean change)
{
bee_t *bee = ic->bee;
bee_user_t *bu = bee_user_by_handle(bee, ic, handle);
@@ -492,11 +491,24 @@ void imcb_buddy_nick_hint(struct im_connection *ic, const char *handle, const ch
g_free(bu->nick);
bu->nick = g_strdup(nick);
- if (bee->ui->user_nick_hint) {
+ if (change && bee->ui->user_nick_change) {
+ bee->ui->user_nick_change(bee, bu, nick);
+ } else if (!change && bee->ui->user_nick_hint) {
bee->ui->user_nick_hint(bee, bu, nick);
}
}
+/* Soft variant, for newly created users. Does nothing if it's already online */
+void imcb_buddy_nick_hint(struct im_connection *ic, const char *handle, const char *nick)
+{
+ buddy_nick_hint_or_change(ic, handle, nick, FALSE);
+}
+
+/* Hard variant, always changes the nick */
+void imcb_buddy_nick_change(struct im_connection *ic, const char *handle, const char *nick)
+{
+ buddy_nick_hint_or_change(ic, handle, nick, TRUE);
+}
struct imcb_ask_cb_data {
struct im_connection *ic;