From dd43c6256c143e9e6a479e024cb5b7631027efba Mon Sep 17 00:00:00 2001 From: Artem Savkov Date: Fri, 27 Mar 2015 22:23:42 -0300 Subject: Gmail notifications support through new imcb_notify_email() API --- protocols/bee_user.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'protocols/bee_user.c') diff --git a/protocols/bee_user.c b/protocols/bee_user.c index 2eb24997..562b31b3 100644 --- a/protocols/bee_user.c +++ b/protocols/bee_user.c @@ -270,6 +270,15 @@ void imcb_buddy_msg(struct im_connection *ic, const char *handle, const char *ms } } +void imcb_notify_email(struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at) +{ + if (handle != NULL) { + imcb_buddy_msg(ic, handle, msg, flags, sent_at); + } else { + imcb_log(ic, "%s", msg); + } +} + void imcb_buddy_typing(struct im_connection *ic, const char *handle, uint32_t flags) { bee_user_t *bu; -- cgit v1.2.3 From 0864a524c9fd1184874d550216beb49f6a0bef55 Mon Sep 17 00:00:00 2001 From: dequis Date: Fri, 8 May 2015 01:16:37 -0300 Subject: imcb_notify_email: change parameters to take a format string Saves some messing with g_strdup_printf for the callers, and flags/sent_at weren't used anyway. Also check if the mail_notifications setting is enabled --- protocols/bee_user.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'protocols/bee_user.c') diff --git a/protocols/bee_user.c b/protocols/bee_user.c index 562b31b3..3088de5c 100644 --- a/protocols/bee_user.c +++ b/protocols/bee_user.c @@ -270,13 +270,30 @@ void imcb_buddy_msg(struct im_connection *ic, const char *handle, const char *ms } } -void imcb_notify_email(struct im_connection *ic, const char *handle, char *msg, uint32_t flags, time_t sent_at) +void imcb_notify_email(struct im_connection *ic, char *format, ...) { + const char *handle; + va_list params; + char *msg; + + if (!set_getbool(&ic->acc->set, "mail_notifications")) { + return; + } + + va_start(params, format); + msg = g_strdup_vprintf(format, params); + va_end(params); + + /* up to the protocol to set_add this if they want to use this */ + handle = set_getstr(&ic->acc->set, "notify_handle"); + if (handle != NULL) { - imcb_buddy_msg(ic, handle, msg, flags, sent_at); + imcb_buddy_msg(ic, handle, msg, 0, 0); } else { imcb_log(ic, "%s", msg); } + + g_free(msg); } void imcb_buddy_typing(struct im_connection *ic, const char *handle, uint32_t flags) -- cgit v1.2.3 From b38f6555bd32356ac6befe329fea1764912ede96 Mon Sep 17 00:00:00 2001 From: dequis Date: Thu, 28 May 2015 00:41:37 -0300 Subject: Rename mail notification related settings for consistency - GMail notifications stuff is now just 'mail_notifications' - sed -i s/notify_handle/mail_notifications_handle/ --- protocols/bee_user.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'protocols/bee_user.c') diff --git a/protocols/bee_user.c b/protocols/bee_user.c index 3088de5c..2d63bfb4 100644 --- a/protocols/bee_user.c +++ b/protocols/bee_user.c @@ -285,7 +285,7 @@ void imcb_notify_email(struct im_connection *ic, char *format, ...) va_end(params); /* up to the protocol to set_add this if they want to use this */ - handle = set_getstr(&ic->acc->set, "notify_handle"); + handle = set_getstr(&ic->acc->set, "mail_notifications_handle"); if (handle != NULL) { imcb_buddy_msg(ic, handle, msg, 0, 0); -- cgit v1.2.3