aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordequis <dx@dxzone.com.ar>2015-05-08 00:26:19 -0300
committerdequis <dx@dxzone.com.ar>2015-05-28 02:26:30 -0300
commitfaeb521e66d825e68eb7f9eef8f32ddabbfd9c49 (patch)
treee0aad1ff01d2f8a963f39fad8520c6ed38834e92
parentdd43c6256c143e9e6a479e024cb5b7631027efba (diff)
Simplify display of gmail notifications
- Add gmail_notifications_limit hidden setting, set to 5 by default. - Don't show "snippets" in email notifications. Not very useful and they make the whole thing seem too spammy - Show sender name instead of your own email - Default values for empty subject / sender
-rw-r--r--protocols/jabber/iq.c30
-rw-r--r--protocols/jabber/jabber.c4
2 files changed, 16 insertions, 18 deletions
diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c
index 4eef6925..3e1a5dfd 100644
--- a/protocols/jabber/iq.c
+++ b/protocols/jabber/iq.c
@@ -792,6 +792,7 @@ xt_status jabber_iq_parse_gmail(struct im_connection *ic, struct xt_node *node,
char *xmlns, *from;
guint64 l_time = 0;
char *tid = NULL;
+ int max = 0;
if (!(c = xt_find_node(node->children, "mailbox")) ||
!(from = xt_find_attr(node, "from")) ||
@@ -801,12 +802,13 @@ xt_status jabber_iq_parse_gmail(struct im_connection *ic, struct xt_node *node,
return XT_HANDLED;
}
+ max = set_getint(&ic->acc->set, "gmail_notifications_limit");
c = c->children;
- while ((c = xt_find_node(c, "mail-thread-info"))) {
- struct xt_node *thread, *s;
- char *subject = NULL;
- char *snippet = NULL;
+ while ((max-- > 0) && (c = xt_find_node(c, "mail-thread-info"))) {
+ struct xt_node *s;
+ char *subject = "<no subject>";
+ char *sender = "<no sender>";
char *msg = NULL;
guint64 t_time;
@@ -816,27 +818,19 @@ xt_status jabber_iq_parse_gmail(struct im_connection *ic, struct xt_node *node,
tid = xt_find_attr(c, "tid");
}
- thread = c->children;
+ if ((s = xt_find_node(c->children, "senders")) &&
+ (s = xt_find_node_by_attr(s->children, "sender", "unread", "1"))) {
+ sender = xt_find_attr(s, "name");
+ }
- if ((s = xt_find_node(thread, "subject"))) {
+ if ((s = xt_find_node(c->children, "subject")) && s->text) {
subject = s->text;
}
- if ((s = xt_find_node(thread, "snippet"))) {
- snippet = s->text;
- }
+ msg = g_strdup_printf("New mail from %s: %s", sender, subject);
- if (subject) {
- msg = g_strdup_printf("New mail for %s. Subj: %s", from, subject);
- } else {
- msg = g_strdup_printf("New mail for %s.", from);
- }
imcb_notify_email(ic, set_getstr(&ic->acc->set, "notify_handle"), msg, 0, 0);
- if (snippet) {
- imcb_notify_email(ic, set_getstr(&ic->acc->set, "notify_handle"), snippet, 0, 0);
- }
-
c = c->next;
g_free(msg);
}
diff --git a/protocols/jabber/jabber.c b/protocols/jabber/jabber.c
index 184021dd..08da6e26 100644
--- a/protocols/jabber/jabber.c
+++ b/protocols/jabber/jabber.c
@@ -103,6 +103,10 @@ static void jabber_init(account_t *acc)
s = set_add(&acc->set, "gmail_notifications", "false", set_eval_bool, acc);
s->flags |= ACC_SET_OFFLINE_ONLY;
+ /* changing this is rarely needed so keeping it secret */
+ s = set_add(&acc->set, "gmail_notifications_limit", "5", set_eval_int, acc);
+ s->flags |= SET_HIDDEN_DEFAULT;
+
s = set_add(&acc->set, "notify_handle", NULL, NULL, acc);
s->flags |= ACC_SET_OFFLINE_ONLY | SET_NULL_OK;