Author Topic: New plugin: html5_notifier (desktop notification)  (Read 35350 times)

Offline Tayku

  • Jr. Member
  • **
  • Posts: 47
New plugin: html5_notifier (desktop notification)
« Reply #15 on: August 30, 2011, 01:23:13 PM »
No hurry, I can manage to change a number in source code myself. :cool:

But what I just discovered, the notification will only apply for new mails in inbox. I have a presorting on my mail server, so new mails will arrive already in appropriate folders (as roundcube does not have sorting function itself), but then the notification is not fired. There is also a problem with the title bar mail count described here. Maybe it’s related. (Would be a pity and of course a need to improve RC.)

Offline tist

  • Jr. Member
  • **
  • Posts: 13
New plugin: html5_notifier (desktop notification)
« Reply #16 on: August 31, 2011, 03:25:30 AM »
Thats what I said in #5 the "new_messages" Hook is just fired, if you have opened the right mailbox... I think it's a bug in RC, because it doesn't make any sense...

Offline Tayku

  • Jr. Member
  • **
  • Posts: 47
New plugin: html5_notifier (desktop notification)
« Reply #17 on: August 31, 2011, 09:45:34 AM »
Yes you said this, but generally it won’t work with other folders than inbox. Even if I have opend the folder “private/family” and a mail comes in there, I won’t get no notification. Same as I won’t get a title bar change to “(1) Roundcube”.
I think the failure lies in the new messages check itself: only new mails in inbox are counted, only those are notified by hook. That’s a pity and discourages pre-sorting of mails.

For now I do not sort mails that could be important. I have to sort by hand, but at least I have a nice notification. :)

Offline tist

  • Jr. Member
  • **
  • Posts: 13
New plugin: html5_notifier (desktop notification)
« Reply #18 on: August 31, 2011, 10:20:20 AM »
check_recent.inc
Quote
$check_all = !empty($_GET['_refresh']) || (bool)$RCMAIL->config->get('check_all_folders');

// list of folders to check
if ($check_all) {
    $a_mailboxes = $IMAP->list_mailboxes();
}
else {
    $a_mailboxes = (array) $current;
    if ($a_mailboxes[0] != 'INBOX')
        $a_mailboxes[] = 'INBOX';
}

// check recent/unseen counts
foreach ($a_mailboxes as $mbox_name) {
    if ($mbox_name == $current && ($status = $IMAP->mailbox_status($mbox_name))) {

This is the important code... if check_all_folders is set to true AND "private/family" is your current mailbox, it should work... but as I mentioned, in my opinion, the check ""mbox_name == $current" should be later and the hook should be fired by any mailbox (a current-check could be done - if necessary - in the plugin itself).

Oh I hope my english is "understandable" :D

Regards,
Tilman Stremlau

Offline tist

  • Jr. Member
  • **
  • Posts: 13
New plugin: html5_notifier (desktop notification)
« Reply #19 on: August 31, 2011, 05:00:25 PM »
New Version 0.2 available (download-link in first post)

changes:
- added Listbox to select showing duration
- added color to browser-conf-button

Have Fun :P

Offline Tayku

  • Jr. Member
  • **
  • Posts: 47
New plugin: html5_notifier (desktop notification)
« Reply #20 on: September 01, 2011, 12:39:39 PM »
Quote from: tist;36415
This is the important code... if check_all_folders is set to true AND "private/family" is your current mailbox, it should work... but as I mentioned, in my opinion, the check ""mbox_name == $current" should be later and the hook should be fired by any mailbox (a current-check could be done - if necessary - in the plugin itself).
That seems reasonable. I’m not firm in PHP, JavaScript or Roundcube. If you have some solution or hack, I can patch my version of Roundcube, but I’m not able to play with the code.

Quote
Oh I hope my english is "understandable" :D
Yes, maybe better than mine (bin ja auch Urdeutsch).^^

Offline corbosman

  • Sr. Member
  • ****
  • Posts: 260
New plugin: html5_notifier (desktop notification)
« Reply #21 on: September 05, 2011, 04:35:21 AM »
Checking all mailboxes for unseen messages is probably unreasonable. You can have hundreds of folders. Checking them all for unseen messages is probably not going to work well.

Offline Tayku

  • Jr. Member
  • **
  • Posts: 47
New plugin: html5_notifier (desktop notification)
« Reply #22 on: September 06, 2011, 03:35:31 AM »
So what do I do if I want automatically sorted mails? Roundcube does not offer such a possibility, so I’m using procmailrc offered by my mail provider. Roundcube also does not offer to check some preselected folders the same way like inbox. Thunderbird does have such an option: I will be notified by popup if there’s a new mail in any of those folders.

Offline thomasb

  • Newbie
  • *
  • Posts: 6
New plugin: html5_notifier (desktop notification)
« Reply #23 on: September 13, 2011, 04:43:17 AM »
Hey Tilman, maybe you could integrate your work into the yet existing newmail_notifier plugin?

Offline joksi

  • Jr. Member
  • **
  • Posts: 10
Re: New plugin: html5_notifier (desktop notification)
« Reply #24 on: November 19, 2012, 02:07:40 PM »
I have problems with this plugin, I have checked and my server do support the RECENT-flag but still no notifications are shown.
Maybe its a cmpatibility issue with Roundcube 0.8+?

It seems this part is the problem:
Code: [Select]
(array) $uids = $RCMAIL->imap->search_once($args['mailbox'], 'RECENT', true);
        foreach($uids as $uid) {
            $message = new rcube_message($uid);

    $from = $message->sender['name'] ? $message->sender['name'] : $message->sender['mailto'];
    $subject = $message->subject;

            if(strtolower($_SESSION['username']) == strtolower($RCMAIL->user->data['username']))
            {
                $RCMAIL->output->command("plugin.showNotification", array(
                    'duration' => $RCMAIL->config->get('html5_notifier_duration'),
                    'subject' => $subject,
                    'from' => $from,
                    'uid' => $uid
                ));
            }
        }

Offline alec

  • Hero Member
  • *****
  • Posts: 1,363
Re: New plugin: html5_notifier (desktop notification)
« Reply #25 on: November 19, 2012, 02:28:41 PM »
Build-in newmail_notifier plugin supports desktop notifications and is compatible with 0.8.

Offline joksi

  • Jr. Member
  • **
  • Posts: 10
Re: New plugin: html5_notifier (desktop notification)
« Reply #26 on: November 19, 2012, 02:49:04 PM »
Yes, I know, however that version just notifies that there is new mail, but this one does like Gmail with info in the notifications who sent the mail and the subject. I think that looks better and more informative, so that's why I would like to use this one but it seems that the code above doesnt get the e-mails with the RECENT-flag.

Offline joksi

  • Jr. Member
  • **
  • Posts: 10
Re: New plugin: html5_notifier (desktop notification)
« Reply #27 on: November 19, 2012, 02:50:29 PM »
Is $RCMAIL->imap->search_once($args['mailbox'], 'RECENT', true); supported at all in RC 0.8.3?

Offline joksi

  • Jr. Member
  • **
  • Posts: 10
Re: New plugin: html5_notifier (desktop notification)
« Reply #28 on: November 20, 2012, 02:05:23 PM »
Is it possible to use above code, possibly with some modifications, to make it work as intended?

Offline Tayku

  • Jr. Member
  • **
  • Posts: 47
Features of HTML5 notifier implemented into newmail_notifier
« Reply #29 on: November 24, 2012, 05:03:33 PM »
@joksi:
Using your idea, I have borrowed the responsible code for including sender/subject into the notification from the HTML5 notifier plugin. Then I inserted it into newmail_notifier. Maybe it won’t work for you because I use Roundcube 0.7.2, but the HTML5 notifier did not work either since the upgrade from 0.7 (or 0.7.1) …

The attached modified newmail_notifier does the same as html5_notifier before. The attached version has the following enhancements compared to the current newmail_notifier (from Roundcube 0.7.2, but it’s the same in 0.8.4):
  • Set duration of desktop notification
  • Clicking on the notification opens the new mail in a new window
  • display of mail sender in notification title
  • display of subject in notification message
  • display of all new messages as separate notifications (up to three in my Chrome) – useful if you get more than one message since the last check.
« Last Edit: November 24, 2012, 05:06:00 PM by Tayku »