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/yahoo/yahoo.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 728803fb..2e7c4831 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -122,7 +122,13 @@ static char *byahoo_strip(const char *in) static void byahoo_init(account_t *acc) { - set_add(&acc->set, "mail_notifications", "false", set_eval_bool, acc); + set_t *s; + + s = set_add(&acc->set, "mail_notifications", "false", set_eval_bool, acc); + s->flags |= ACC_SET_OFFLINE_ONLY; + + s = set_add(&acc->set, "notify_handle", NULL, NULL, acc); + s->flags |= ACC_SET_OFFLINE_ONLY | SET_NULL_OK; acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE; } @@ -144,6 +150,10 @@ static void byahoo_login(account_t *acc) imcb_log(ic, "Connecting"); yd->y2_id = yahoo_init(acc->user, acc->pass); yahoo_login(yd->y2_id, yd->current_status); + + if (set_getbool(&acc->set, "mail_notifications") && set_getstr(&acc->set, "notify_handle")) { + imcb_add_buddy(ic, set_getstr(&acc->set, "notify_handle"), NULL); + } } static void byahoo_logout(struct im_connection *ic) @@ -948,13 +958,17 @@ void ext_yahoo_game_notify(int id, const char *me, const char *who, int stat, co void ext_yahoo_mail_notify(int id, const char *from, const char *subj, int cnt) { struct im_connection *ic = byahoo_get_ic_by_id(id); + char *msg; + + if (set_getbool(&ic->acc->set, "mail_notifications")) { + if (from && subj) { + msg = g_strdup_printf("Received e-mail message from %s with subject `%s'", from, subj); + } else if (cnt > 0) { + msg = g_strdup_printf("Received %d new e-mails", cnt); + } - if (!set_getbool(&ic->acc->set, "mail_notifications")) { - ; /* The user doesn't care. */ - } else if (from && subj) { - imcb_log(ic, "Received e-mail message from %s with subject `%s'", from, subj); - } else if (cnt > 0) { - imcb_log(ic, "Received %d new e-mails", cnt); + imcb_notify_email(ic, set_getstr(&ic->acc->set, "notify_handle"), msg, 0, 0); + g_free(msg); } } -- 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/yahoo/yahoo.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 2e7c4831..2df454f3 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -958,17 +958,11 @@ void ext_yahoo_game_notify(int id, const char *me, const char *who, int stat, co void ext_yahoo_mail_notify(int id, const char *from, const char *subj, int cnt) { struct im_connection *ic = byahoo_get_ic_by_id(id); - char *msg; - if (set_getbool(&ic->acc->set, "mail_notifications")) { - if (from && subj) { - msg = g_strdup_printf("Received e-mail message from %s with subject `%s'", from, subj); - } else if (cnt > 0) { - msg = g_strdup_printf("Received %d new e-mails", cnt); - } - - imcb_notify_email(ic, set_getstr(&ic->acc->set, "notify_handle"), msg, 0, 0); - g_free(msg); + if (from && subj) { + imcb_notify_email(ic, "Received e-mail message from %s with subject `%s'", from, subj); + } else if (cnt > 0) { + imcb_notify_email(ic, "Received %d new e-mails", cnt); } } -- 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/yahoo/yahoo.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'protocols/yahoo') diff --git a/protocols/yahoo/yahoo.c b/protocols/yahoo/yahoo.c index 2df454f3..9da12949 100644 --- a/protocols/yahoo/yahoo.c +++ b/protocols/yahoo/yahoo.c @@ -127,7 +127,7 @@ static void byahoo_init(account_t *acc) s = set_add(&acc->set, "mail_notifications", "false", set_eval_bool, acc); s->flags |= ACC_SET_OFFLINE_ONLY; - s = set_add(&acc->set, "notify_handle", NULL, NULL, acc); + s = set_add(&acc->set, "mail_notifications_handle", NULL, NULL, acc); s->flags |= ACC_SET_OFFLINE_ONLY | SET_NULL_OK; acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE; @@ -151,8 +151,8 @@ static void byahoo_login(account_t *acc) yd->y2_id = yahoo_init(acc->user, acc->pass); yahoo_login(yd->y2_id, yd->current_status); - if (set_getbool(&acc->set, "mail_notifications") && set_getstr(&acc->set, "notify_handle")) { - imcb_add_buddy(ic, set_getstr(&acc->set, "notify_handle"), NULL); + if (set_getbool(&acc->set, "mail_notifications") && set_getstr(&acc->set, "mail_notifications_handle")) { + imcb_add_buddy(ic, set_getstr(&acc->set, "mail_notifications_handle"), NULL); } } -- cgit v1.2.3