diff options
Diffstat (limited to 'protocols/jabber')
| -rw-r--r-- | protocols/jabber/iq.c | 30 | ||||
| -rw-r--r-- | protocols/jabber/jabber.c | 4 | 
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; | 
