aboutsummaryrefslogtreecommitdiffstats
path: root/protocols
diff options
context:
space:
mode:
Diffstat (limited to 'protocols')
-rw-r--r--protocols/bee.h1
-rw-r--r--protocols/nogaim.c20
-rw-r--r--protocols/nogaim.h1
3 files changed, 18 insertions, 4 deletions
diff --git a/protocols/bee.h b/protocols/bee.h
index 4a053845..d22e4d85 100644
--- a/protocols/bee.h
+++ b/protocols/bee.h
@@ -130,6 +130,7 @@ typedef struct bee_ui_funcs {
void (*ft_finished)(struct im_connection *ic, struct file_transfer *ft);
void (*log)(bee_t *bee, const char *tag, const char *msg);
+ gboolean (*user_nick_change)(bee_t *bee, bee_user_t *bu, const char *hint);
} bee_ui_funcs_t;
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;
diff --git a/protocols/nogaim.h b/protocols/nogaim.h
index 3b271b45..40b1ed7b 100644
--- a/protocols/nogaim.h
+++ b/protocols/nogaim.h
@@ -323,6 +323,7 @@ G_MODULE_EXPORT void imcb_add_buddy(struct im_connection *ic, const char *handle
G_MODULE_EXPORT void imcb_remove_buddy(struct im_connection *ic, const char *handle, char *group);
G_MODULE_EXPORT void imcb_rename_buddy(struct im_connection *ic, const char *handle, const char *realname);
G_MODULE_EXPORT void imcb_buddy_nick_hint(struct im_connection *ic, const char *handle, const char *nick);
+G_MODULE_EXPORT void imcb_buddy_nick_change(struct im_connection *ic, const char *handle, const char *nick);
G_MODULE_EXPORT void imcb_buddy_action_response(bee_user_t *bu, const char *action, char * const args[], void *data);
G_MODULE_EXPORT void imcb_buddy_typing(struct im_connection *ic, const char *handle, guint32 flags);