Ignore:
Timestamp:
2015-05-28T05:26:24Z (9 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
faeb521
Parents:
3d31618
git-author:
Artem Savkov <artem.savkov@…> (28-03-15 01:23:42)
git-committer:
dequis <dx@…> (28-05-15 05:26:24)
Message:

Gmail notifications support through new imcb_notify_email() API

File:
1 edited

Legend:

Unmodified
Added
Removed
  • protocols/yahoo/yahoo.c

    r3d31618 rdd43c62  
    123123static void byahoo_init(account_t *acc)
    124124{
    125         set_add(&acc->set, "mail_notifications", "false", set_eval_bool, acc);
     125        set_t *s;
     126
     127        s = set_add(&acc->set, "mail_notifications", "false", set_eval_bool, acc);
     128        s->flags |= ACC_SET_OFFLINE_ONLY;
     129
     130        s = set_add(&acc->set, "notify_handle", NULL, NULL, acc);
     131        s->flags |= ACC_SET_OFFLINE_ONLY | SET_NULL_OK;
    126132
    127133        acc->flags |= ACC_FLAG_AWAY_MESSAGE | ACC_FLAG_STATUS_MESSAGE;
     
    145151        yd->y2_id = yahoo_init(acc->user, acc->pass);
    146152        yahoo_login(yd->y2_id, yd->current_status);
     153
     154        if (set_getbool(&acc->set, "mail_notifications") && set_getstr(&acc->set, "notify_handle")) {
     155                imcb_add_buddy(ic, set_getstr(&acc->set, "notify_handle"), NULL);
     156        }
    147157}
    148158
     
    949959{
    950960        struct im_connection *ic = byahoo_get_ic_by_id(id);
    951 
    952         if (!set_getbool(&ic->acc->set, "mail_notifications")) {
    953                 ; /* The user doesn't care. */
    954         } else if (from && subj) {
    955                 imcb_log(ic, "Received e-mail message from %s with subject `%s'", from, subj);
    956         } else if (cnt > 0) {
    957                 imcb_log(ic, "Received %d new e-mails", cnt);
     961        char *msg;
     962
     963        if (set_getbool(&ic->acc->set, "mail_notifications")) {
     964                if (from && subj) {
     965                        msg = g_strdup_printf("Received e-mail message from %s with subject `%s'", from, subj);
     966                } else if (cnt > 0) {
     967                        msg = g_strdup_printf("Received %d new e-mails", cnt);
     968                }
     969
     970                imcb_notify_email(ic, set_getstr(&ic->acc->set, "notify_handle"), msg, 0, 0);
     971                g_free(msg);
    958972        }
    959973}
Note: See TracChangeset for help on using the changeset viewer.