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

Offline joksi

  • Jr. Member
  • **
  • Posts: 10
Re: New plugin: html5_notifier (desktop notification)
« Reply #30 on: November 24, 2012, 06:47:50 PM »
Hi!

Thanks for your help, but it looks like it doesnt work.
I minimized the window but no notification shows when receiving a new mail?
I have of course enabled it in the settings.

Offline joksi

  • Jr. Member
  • **
  • Posts: 10
Re: New plugin: html5_notifier (desktop notification)
« Reply #31 on: November 24, 2012, 06:52:35 PM »
It seems the same part of the code is the problem.

        (array) $uids = $this->rc->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($this->rc->user->data['username']))
            {
                if ($basic || $sound || $desktop) {
                    $this->rc->output->command('plugin.newmail_notifier',
                        array('basic' => $basic, 'sound' => $sound, 'desktop' => $desktop,
                              'duration' => $this->rc->config->get('newmail_notifier_duration'),
                              'from' => $from,
                              'subject' => $subject,
                              'uid' => $uid));
                }
            }
        }

The foreach doesnt run at all.

Offline Tayku

  • Jr. Member
  • **
  • Posts: 46
Re: New plugin: html5_notifier (desktop notification)
« Reply #32 on: November 24, 2012, 07:03:43 PM »
I’m sure there is another possibility to get the information … but I’m no expert (my modified newmail_notify is try/error and merging from both plugins).

Offline joksi

  • Jr. Member
  • **
  • Posts: 10
Re: New plugin: html5_notifier (desktop notification)
« Reply #33 on: November 24, 2012, 07:09:28 PM »
Alec who wrote in this post earlier is a Roundcube developer, so I'm hoping he will have the time to answer.
I'm sure the problem lies in this specific row

$uids = $this->rc->imap->search_once($args['mailbox'], 'RECENT', true);

It seems it doesnt get the what it's supposed to...

Offline swsystem

  • Newbie
  • *
  • Posts: 2
Re: New plugin: html5_notifier (desktop notification)
« Reply #34 on: January 16, 2013, 09:26:50 AM »
After a bit of trying to figure out what was going on with the search_once I switched my code over to doing a search and generating an array of uids to minimise code changes in the future.

Replacing
Code: [Select]
(array) $uids = $RCMAIL->imap->search_once($args['mailbox'], 'RECENT', true);
With
Code: [Select]
$msgs = array();
$uids = array();
$RCMAIL->storage->set_mailbox($args['mailbox']);
$RCMAIL->storage->search($args['mailbox'], "RECENT", null);
$msgs = $RCMAIL->storage->list_headers($args['mailbox']);
foreach ($msgs as $msg) {
 $uids[]=$msg->uid;
}

Seems to have this working for me on roundcube version 0.8.1, I've not checked other versions.

EDIT
swapped from $RCMAIL->imap to $RCMAIL->storage as it would change the mailbox to only display the notified messages.
« Last Edit: January 16, 2013, 11:58:27 AM by swsystem »

Offline joksi

  • Jr. Member
  • **
  • Posts: 10
Re: New plugin: html5_notifier (desktop notification)
« Reply #35 on: February 11, 2013, 12:17:42 PM »
Hi

Works almost great, although I have 0.8.4 and I have tried with both ->imap and ->storage, in both cases when there is a new e-mail and you go back to Roundcube it have updated the listview only showing the new e-mail in the inbox. Can this be changed somehow?

Also it seems not really stable, sometimes the same message gets notified two times in a row (even if it has been already marked as read).

Offline swsystem

  • Newbie
  • *
  • Posts: 2
Re: New plugin: html5_notifier (desktop notification)
« Reply #36 on: February 14, 2013, 05:03:16 AM »
Hi

Works almost great, although I have 0.8.4 and I have tried with both ->imap and ->storage, in both cases when there is a new e-mail and you go back to Roundcube it have updated the listview only showing the new e-mail in the inbox. Can this be changed somehow?

Also it seems not really stable, sometimes the same message gets notified two times in a row (even if it has been already marked as read).

This is due to the search being set to RECENT, changing to to ALL at the end of the function seems to fix it.
Put the below as the last thing the show_notification function does.
Code: [Select]
$RCMAIL->storage->search($args['mailbox'], "ALL", null);
Here's my full show_notification function.

Code: [Select]
    function show_notification($args)
    {
        $RCMAIL = rcmail::get_instance();

$msgs = array();
$uids = array();
$RCMAIL->storage->set_mailbox($args['mailbox']);
$RCMAIL->storage->search($args['mailbox'], "RECENT", null);
$msgs = $RCMAIL->storage->list_headers($args['mailbox']);
foreach ($msgs as $msg) {
$uids[]=$msg->uid;
}


        foreach($uids as $uid) {
            $message = new rcube_message($uid);

    $from = $message->sender['name'] ? $message->sender['name'] : $message->sender['mailto'];
    $subject = str_replace(".", ">", $args['mailbox']).": ".$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."&_mbox=".$args['mailbox'],
                ));
            }
        }
$RCMAIL->storage->search($args['mailbox'], "ALL", null);
    }

Offline joksi

  • Jr. Member
  • **
  • Posts: 10
Re: New plugin: html5_notifier (desktop notification)
« Reply #37 on: February 14, 2013, 05:36:53 AM »
Great, that did the trick!

However, the issue with double notifications on the same messages still remains...

Offline tist

  • Jr. Member
  • **
  • Posts: 13
Re: New plugin: html5_notifier (desktop notification)
« Reply #38 on: February 27, 2013, 12:12:38 PM »
Hi there,

I updated the code and built in the display of the mailbox name (like swsystem did) :D
Maybe it's a problem of roundcube or imap, but the storage->search just works with all mailboxes except INBOX, does anybody has an idea? Otherwise I will post it in the developer-mailing-list.

http://www.stremlau.net/html5_notifier/
« Last Edit: February 27, 2013, 12:25:29 PM by tist »

Offline darknior

  • Jr. Member
  • **
  • Posts: 14
Re: New plugin: html5_notifier (desktop notification)
« Reply #39 on: February 27, 2013, 07:38:59 PM »
Thanks a lot for this update :D

Now it works fine for me ...
I can see the Desktop notification ;)

Here the translation of the end of the file :

$labels['no_mailbox'] = 'ne pas montrer le message';
$labels['short_mailbox'] = 'montrer un apperçu du message';
$labels['full_mailbox'] = 'montrer tout le message';


Think to register the file in UTF-8.

Offline shearer

  • Jr. Member
  • **
  • Posts: 15
Re: New plugin: html5_notifier (desktop notification)
« Reply #40 on: March 12, 2013, 05:19:07 AM »
how do i activate this ?

Offline Tayku

  • Jr. Member
  • **
  • Posts: 46
Re: New plugin: html5_notifier (desktop notification)
« Reply #41 on: March 17, 2013, 05:54:18 PM »
Hi there,

I updated the code and built in the display of the mailbox name (like swsystem did) :D
Maybe it's a problem of roundcube or imap, but the storage->search just works with all mailboxes except INBOX, does anybody has an idea? Otherwise I will post it in the developer-mailing-list.
Hm, since updating to version 0.3 I experienced two problems. The first is that the subject is not correctly encoding. It seems that it just prints the raw string from the subject, something like “=?UTF-8?Q?Test1_mit_B=C3=A4umen=2E?=” (should be “Test1 mit Bäumen.”). Is there a way to encode properly before returning the string?

The second problem is that the notifier notifies about any mail that is moved to another folder. Every time I move a mail, I got a notification. After sending an e-mail, I got a notification (because it’s moved automatically from Drafts to Sent). That’s not the intention of the plugin …
Could you modify the plugin such that the notification only triggers for unread mails? That would be perfect I think.

Edit:
I tested the provided newmail_notifier plugin. Unfortunately it shows the same behaviour (concerning the second problem). So the notification method in Roundcube 0.9 is broken? Hm, have to search the bugtracker for it. (Edit2:) Found it Seems like it will find its way into 0.9-final. Unfortunately it does not work. With the patch I’m getting no notifications at all (using newmail_notifier). Damn.
« Last Edit: March 17, 2013, 06:55:29 PM by Tayku »

Offline Tayku

  • Jr. Member
  • **
  • Posts: 46
Re: New plugin: html5_notifier (desktop notification)
« Reply #42 on: April 10, 2013, 08:28:21 AM »
Ok, so I used the changes made by alec in the UNSEEN bug issue, that works wonderful. But it’s only for RC1.0, though I don’t have any other problems.  (Maybe lefoyers initially provided patch would work on RC0.9.)

Now I have merged the HTML5 notifier functionality into the newmail notifier (for RC1.0 of course). That means: information about sender and subject, multiple popups, configurable time for displaying the popup. Also I added a proper MIME decoding. Now everything is fine. If someone is interested in the modified version, let me know.

Offline tist

  • Jr. Member
  • **
  • Posts: 13
Re: New plugin: html5_notifier (desktop notification)
« Reply #43 on: December 01, 2013, 11:37:20 AM »
New Version available

- added support for Firefox and other Browsers using the new Notification API
- UFT8 issues fixed

Download at: http://stremlau.net/html5_notifier/