-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc11852
commit 9861369
Showing
23 changed files
with
675 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/config/config.inc.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* Copyright (c) 2013 Tilman Stremlau <[email protected]> | ||
* | ||
* Permission to use, copy, modify, and distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
![ScreenShot](/screenshot.png) | ||
|
||
HTML5_Notifier is a Roundcube plugin. | ||
|
||
It displays Desktop Notifications like the ones you might know from Google Mail. Just keep Roundcube opened in a (minimized) tab and enjoy getting notifications every time a new mail arrives. | ||
|
||
It just works in modern browsers like Google Chrome, SRWare Iron or Firefox, because "Desktop Notification" is a new feature in HTML5. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
0.2 | ||
- added Listbox to select showing duration | ||
- added color to browser-conf-button | ||
|
||
0.3 | ||
- updated to work with roundcube 0.8 and 0.9 | ||
- added display of mailbox | ||
|
||
0.4 | ||
- updated to work with Firefox and the new Notification API | ||
- fixed UTF-8 issues | ||
|
||
0.5 (thanks to nicolas-joubert!) | ||
- add ability to exclude some directories |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
{ | ||
"name": "kitist/html5_notifier", | ||
"type": "roundcube-plugin", | ||
"description": "Desktop Notifications for Roundcube", | ||
"keywords": ["notification","desktop","mail"], | ||
"homepage": "https://github.com/kitist/html5_notifier", | ||
"license": "GPL-3.0+", | ||
"authors": [ | ||
{ | ||
"name": "Tilman Stremlau", | ||
"email": "[email protected]", | ||
"homepage": "http://stremlau.net", | ||
"role": "Developer" | ||
} | ||
], | ||
"repositories": [ | ||
{ | ||
"type": "composer", | ||
"url": "http://plugins.roundcube.net" | ||
} | ||
], | ||
"require": { | ||
"php": ">=5.3.0", | ||
"roundcube/plugin-installer": ">=0.1.3" | ||
}, | ||
"extra": { | ||
"roundcube": { | ||
"min-version": "0.8.0" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/** | ||
* html5_notifier | ||
* Shows a desktop notification every time a new (recent) mail comes in | ||
* | ||
* @version 0.5.0 - 19.12.2013 | ||
* @author Tilman Stremlau <[email protected]> | ||
* @website stremlau.net/html5_notifier | ||
* @licence GNU GPL | ||
* | ||
**/ | ||
|
||
function rcmail_show_notification(message) | ||
{ | ||
if (use_notifications) | ||
{ | ||
if ("Notification" in window) { | ||
var notification = new Notification(rcmail.gettext('notification_title', 'html5_notifier').replace('[from]', message.from), { | ||
icon: './plugins/html5_notifier/images/new_mail.png', | ||
body: message.subject | ||
}); | ||
notification.onclick = function() { | ||
if(message.opentype == '1') { | ||
rcmail.open_window('?_task=mail&_action=show&_uid='+message.uid); | ||
} else { | ||
window.open('?_task=mail&_action=show&_extwin=1&_uid='+message.uid); | ||
} | ||
} | ||
if (parseInt(message.duration) > 0) | ||
{ | ||
setTimeout(function(){ notification.close(); }, (parseInt(message.duration)*1000)); | ||
} | ||
} | ||
} | ||
} | ||
|
||
function rcmail_browser_notifications() | ||
{ | ||
if ("Notification" in window && Notification.permission) { | ||
if (Notification.permission === "granted") { | ||
rcmail.display_message(rcmail.gettext('ok_notifications', 'html5_notifier'), 'notice'); | ||
} | ||
else { | ||
Notification.requestPermission(rcmail_check_notifications); | ||
} | ||
} | ||
else if (window.webkitNotifications) { | ||
if (window.webkitNotifications.checkPermission() == 0) | ||
{ | ||
rcmail.display_message(rcmail.gettext('ok_notifications', 'html5_notifier'), 'notice'); | ||
} | ||
else | ||
{ | ||
window.webkitNotifications.requestPermission(rcmail_check_notifications); | ||
} | ||
} | ||
else | ||
{ | ||
rcmail.display_message(rcmail.gettext('no_notifications', 'html5_notifier'), 'error'); | ||
} | ||
} | ||
|
||
function rcmail_browser_notifications_test() { | ||
if (use_notifications) | ||
{ | ||
rcmail.display_message(rcmail.gettext('check_ok', 'html5_notifier'), 'notice'); | ||
|
||
var message = new Object(); | ||
message.duration = 8; | ||
message.uid = 0; | ||
message.subject = 'It Works!'; | ||
message.from = 'TESTMAN'; | ||
message.opentype = $('select[name=_html5_notifier_popuptype]').val(); | ||
rcmail_show_notification(message); | ||
} | ||
else | ||
{ | ||
if ("Notification" in window && Notification.permission) { | ||
if (Notification.permission == 'denied') { | ||
rcmail.display_message(rcmail.gettext('check_fail_blocked', 'html5_notifier'), 'error'); | ||
return false; | ||
} | ||
} | ||
else if (window.webkitNotifications) | ||
{ | ||
if (window.webkitNotifications.checkPermission() == 2) | ||
{ | ||
rcmail.display_message(rcmail.gettext('check_fail_blocked', 'html5_notifier'), 'error'); | ||
return false; | ||
} | ||
} | ||
rcmail.display_message(rcmail.gettext('check_fail', 'html5_notifier'), 'error'); | ||
} | ||
} | ||
|
||
function rcmail_browser_notifications_colorate() { | ||
if ("Notification" in window && Notification.permission) { | ||
var broco = $('#rcmfd_html5_notifier_browser_conf'); | ||
if (broco) | ||
{ | ||
switch (Notification.permission) | ||
{ | ||
case 'granted': broco.css('color', 'green'); break; | ||
case 'default': broco.css('color', 'orange'); break; | ||
case 'denied': broco.css('color', 'red'); break; | ||
} | ||
} | ||
} | ||
else if (window.webkitNotifications) | ||
{ | ||
var broco = $('#rcmfd_html5_notifier_browser_conf'); | ||
if (broco) | ||
{ | ||
switch (window.webkitNotifications.checkPermission()) | ||
{ | ||
case 0: broco.css('color', 'green'); break; | ||
case 1: broco.css('color', 'orange'); break; | ||
case 2: broco.css('color', 'red'); break; | ||
} | ||
} | ||
} | ||
} | ||
|
||
var use_notifications = false; | ||
|
||
var rcmail_check_notifications = function(e) | ||
{ | ||
if ("Notification" in window && Notification.permission) { | ||
if (Notification.permission === "granted") { | ||
use_notifications = true; | ||
} | ||
} | ||
else if (window.webkitNotifications) | ||
{ | ||
if (window.webkitNotifications.checkPermission() == 0) { | ||
use_notifications = true; | ||
} | ||
} | ||
rcmail_browser_notifications_colorate(); | ||
} | ||
|
||
if (window.rcmail) | ||
{ | ||
rcmail.addEventListener('plugin.showNotification', rcmail_show_notification); | ||
rcmail.addEventListener('init', rcmail_check_notifications); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
<?php | ||
/** | ||
* html5_notifier | ||
* Shows a desktop notification every time a new (recent) mail comes in | ||
* | ||
* @version 0.5.0 - 19.12.2013 | ||
* @author Tilman Stremlau <[email protected]> | ||
* @website stremlau.net/html5_notifier | ||
* @licence GNU GPL | ||
* | ||
**/ | ||
|
||
class html5_notifier extends rcube_plugin | ||
{ | ||
public $task = '?(?!login|logout).*'; | ||
|
||
function init() | ||
{ | ||
$RCMAIL = rcmail::get_instance(); | ||
|
||
if(file_exists("./plugins/html5_notifier/config/config.inc.php")) | ||
{ | ||
$this->load_config('config/config.inc.php'); | ||
} | ||
|
||
$this->add_hook('preferences_list', array($this, 'prefs_list')); | ||
$this->add_hook('preferences_save', array($this, 'prefs_save')); | ||
|
||
if ($RCMAIL->config->get('html5_notifier_duration').'' != '0') | ||
{ | ||
$this->add_hook('new_messages', array($this, 'show_notification')); | ||
} | ||
|
||
$this->include_script("html5_notifier.js"); | ||
|
||
if ($RCMAIL->action != 'check-recent') | ||
{ | ||
$this->add_texts('localization', array('notification_title', 'ok_notifications', 'no_notifications', 'check_ok', 'check_fail', 'check_fail_blocked')); //PR�ZESIEREN | ||
} | ||
} | ||
|
||
function show_notification($args) | ||
{ | ||
$RCMAIL = rcmail::get_instance(); | ||
|
||
//$search = $RCMAIL->config->get('html5_notifier_only_new', false) ?'NEW' : 'RECENT'; | ||
$deleted = $RCMAIL->config->get('skip_deleted') ? 'UNDELETED ' : ''; | ||
$search = $deleted . 'UNSEEN UID ' . $args['diff']['new']; | ||
|
||
$RCMAIL->storage->set_folder($args['mailbox']); | ||
$RCMAIL->storage->search($args['mailbox'], $search, null); | ||
$msgs = (array) $RCMAIL->storage->list_messages($args['mailbox']); | ||
$excluded_directories = preg_split("/(,|;| )+/", $RCMAIL->config->get('html5_notifier_excluded_directories')); | ||
|
||
foreach ($msgs as $msg) { | ||
$from = $msg->get('from'); | ||
$mbox = ''; | ||
switch ($RCMAIL->config->get('html5_notifier_smbox')) { | ||
case 1: $mbox = array_pop(explode('.', str_replace('INBOX.', '', $args['mailbox']))); break; | ||
case 2: $mbox = str_replace('.', '/', str_replace('INBOX.', '', $args['mailbox'])); break; | ||
} | ||
$subject = ((!empty($mbox)) ? rcube_charset::convert($mbox, 'UTF7-IMAP') . ': ' : '') . $msg->get('subject'); | ||
|
||
if(strtolower($_SESSION['username']) == strtolower($RCMAIL->user->data['username']) && !in_array($args['mailbox'], $excluded_directories)) | ||
{ | ||
$RCMAIL->output->command("plugin.showNotification", array( | ||
'duration' => $RCMAIL->config->get('html5_notifier_duration'), | ||
'opentype' => $RCMAIL->config->get('html5_notifier_popuptype'), | ||
'subject' => $subject, | ||
'from' => $from, | ||
'uid' => $msg->uid.'&_mbox='.$args['mailbox'], | ||
)); | ||
} | ||
} | ||
$RCMAIL->storage->search($args['mailbox'], "ALL", null); | ||
} | ||
|
||
function prefs_list($args) | ||
{ | ||
if($args['section'] == 'mailbox') | ||
{ | ||
$RCMAIL = rcmail::get_instance(); | ||
|
||
$field_id = 'rcmfd_html5_notifier'; | ||
|
||
$select_duration = new html_select(array('name' => '_html5_notifier_duration', 'id' => $field_id)); | ||
$select_duration->add($this->gettext('off'), '0'); | ||
$times = array('3', '5', '8', '10', '12', '15', '20', '25', '30'); | ||
foreach ($times as $time) | ||
$select_duration->add($time.' '.$this->gettext('seconds'), $time); | ||
$select_duration->add($this->gettext('durable'), '-1'); | ||
|
||
$select_smbox = new html_select(array('name' => '_html5_notifier_smbox', 'id' => $field_id)); | ||
$select_smbox->add($this->gettext('no_mailbox'), '0'); | ||
$select_smbox->add($this->gettext('short_mailbox'), '1'); | ||
$select_smbox->add($this->gettext('full_mailbox'), '2'); | ||
|
||
$content = $select_duration->show($RCMAIL->config->get('html5_notifier_duration').''); | ||
$content .= $select_smbox->show($RCMAIL->config->get('html5_notifier_smbox').''); | ||
$content .= html::a(array('href' => '#', 'id' => 'rcmfd_html5_notifier_browser_conf', 'onclick' => 'rcmail_browser_notifications(); return false;'), $this->gettext('conf_browser')).' '; | ||
$content .= html::a(array('href' => '#', 'onclick' => 'rcmail_browser_notifications_test(); return false;'), $this->gettext('test_browser')); | ||
$args['blocks']['new_message']['options']['html5_notifier'] = array( | ||
'title' => html::label($field_id, rcube::Q($this->gettext('shownotifies'))), | ||
'content' => $content, | ||
); | ||
|
||
$check_only_new = new html_checkbox(array('name' => '_html5_notifier_only_new', 'id' => $field_id . '_only_new', 'value' => 1)); | ||
$content = $check_only_new->show($RCMAIL->config->get('html5_notifier_only_new', false)); | ||
$args['blocks']['new_message']['options']['html5_notifier_only_new'] = array( | ||
'title' => html::label($field_id, rcube::Q($this->gettext('onlynew'))), | ||
'content' => $content, | ||
); | ||
|
||
$input_excluded = new html_inputfield(array('name' => '_html5_notifier_excluded_directories', 'id' => $field_id . '_excluded')); | ||
$args['blocks']['new_message']['options']['html5_notifier_excluded_directories'] = array( | ||
'title' => html::label($field_id, rcube::Q($this->gettext('excluded_directories'))), | ||
'content' => $input_excluded->show($RCMAIL->config->get('html5_notifier_excluded_directories').''), | ||
); | ||
|
||
$select_type = new html_select(array('name' => '_html5_notifier_popuptype', 'id' => $field_id . '_popuptype')); | ||
$select_type->add($this->gettext('new_tab'), '0'); | ||
$select_type->add($this->gettext('new_window'), '1'); | ||
$args['blocks']['new_message']['options']['html5_notifier_popuptype'] = array( | ||
'title' => html::label($field_id, rcube::Q($this->gettext('notifier_popuptype'))), | ||
'content' => $select_type->show($RCMAIL->config->get('html5_notifier_popuptype').'') | ||
); | ||
|
||
$RCMAIL->output->add_script("$(document).ready(function(){ rcmail_browser_notifications_colorate(); });"); | ||
} | ||
return $args; | ||
} | ||
|
||
function prefs_save($args) | ||
{ | ||
if($args['section'] == 'mailbox') | ||
{ | ||
$args['prefs']['html5_notifier_only_new'] = !empty($_POST['_html5_notifier_only_new']); | ||
$args['prefs']['html5_notifier_duration'] = rcube_utils::get_input_value('_html5_notifier_duration', rcube_utils::INPUT_POST); | ||
$args['prefs']['html5_notifier_smbox'] = rcube_utils::get_input_value('_html5_notifier_smbox', rcube_utils::INPUT_POST); | ||
$args['prefs']['html5_notifier_excluded_directories'] = rcube_utils::get_input_value('_html5_notifier_excluded_directories', rcube_utils::INPUT_POST); | ||
$args['prefs']['html5_notifier_popuptype'] = rcube_utils::get_input_value('_html5_notifier_popuptype', rcube_utils::INPUT_POST); | ||
return $args; | ||
} | ||
} | ||
} | ||
?> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
$labels = array(); | ||
$labels['shownotifies'] = 'Oznámení na ploše'; | ||
$labels['onlynew'] = 'Zobrazit pouze nové zprávy'; | ||
$labels['conf_browser'] = 'Nastavit prohlížeč'; | ||
$labels['test_browser'] = 'Test'; | ||
$labels['excluded_directories'] = 'Neoznamovat nové zprávy ve složkách'; | ||
$labels['check_ok'] = 'Nastavení prohlížeče je v pořádku.'; | ||
$labels['check_fail'] = 'Nebylo možné zobrazit upozornění, klikněte prosím na "Nastavit prohlížeč"!'; | ||
$labels['check_fail_blocked'] = 'Váš prohlížeč blokuje oznámení na ploše, prosím, nastavte oprávnění pro stránku v prohlížeči!'; | ||
$labels['no_notifications'] = 'Váš prohlížeč nepodporuje oznámení na ploše!'; | ||
$labels['ok_notifications'] = 'Stránka má potřebná oprávnění. Oznámení na ploše by mělo fungovat.'; | ||
$labels['notification_title'] = 'Nový mail od [from]'; | ||
|
||
$labels['seconds'] = 'vteřin'; | ||
$labels['off'] = 'vypnuté'; | ||
$labels['durable'] = 'trvale'; | ||
|
||
$labels['no_mailbox'] = 'nezobrazovat složky'; | ||
$labels['short_mailbox'] = 'zobrazit zkrácené názvy složek'; | ||
$labels['full_mailbox'] = 'zobrazit dlouhé názvy složek'; | ||
|
||
$labels['notifier_popuptype'] = 'Jak otevřít zprávu při kliknutí na oznámení'; | ||
$labels['new_tab'] = 'V nové záložce'; | ||
$labels['new_window'] = 'V novém okně'; | ||
?> |
Oops, something went wrong.