diff options
Diffstat (limited to 'deluge/plugins/Notifications/deluge_notifications/data')
-rw-r--r-- | deluge/plugins/Notifications/deluge_notifications/data/config.ui | 641 | ||||
-rw-r--r-- | deluge/plugins/Notifications/deluge_notifications/data/notifications.js | 522 |
2 files changed, 1163 insertions, 0 deletions
diff --git a/deluge/plugins/Notifications/deluge_notifications/data/config.ui b/deluge/plugins/Notifications/deluge_notifications/data/config.ui new file mode 100644 index 0000000..399cc9e --- /dev/null +++ b/deluge/plugins/Notifications/deluge_notifications/data/config.ui @@ -0,0 +1,641 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.1 --> +<interface> + <requires lib="gtk+" version="3.0"/> + <object class="GtkAdjustment" id="adjustment1"> + <property name="lower">1</property> + <property name="upper">65535</property> + <property name="value">25</property> + <property name="step_increment">1</property> + <property name="page_increment">10</property> + </object> + <object class="GtkWindow" id="window"> + <property name="can_focus">False</property> + <child type="titlebar"> + <placeholder/> + </child> + <child> + <object class="GtkBox" id="prefs_box"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkViewport" id="viewport1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="resize_mode">queue</property> + <child> + <object class="GtkNotebook" id="notebook1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="show_border">False</property> + <child> + <object class="GtkBox" id="vbox2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">start</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkFrame" id="frame2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">start</property> + <property name="margin_left">9</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="left_padding">12</property> + <property name="right_padding">10</property> + <child> + <object class="GtkBox" id="vbox1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkCheckButton" id="blink_enabled"> + <property name="label" translatable="yes">Tray icon blinks enabled</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="popup_enabled"> + <property name="label" translatable="yes">Popups enabled</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkBox" id="hbox2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckButton" id="sound_enabled"> + <property name="label" translatable="yes">Sound enabled</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="halign">start</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="on_sound_enabled_toggled" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkFileChooserButton" id="sound_path"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="create_folders">False</property> + <signal name="update-preview" handler="on_sound_path_update_preview" swapped="no"/> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="padding">2</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">2</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label6"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="margin_top">5</property> + <property name="xpad">5</property> + <property name="label" translatable="yes"><b>UI Notifications</b></property> + <property name="use_markup">True</property> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="frame3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">start</property> + <property name="margin_left">10</property> + <property name="margin_top">7</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="left_padding">12</property> + <property name="right_padding">10</property> + <child> + <object class="GtkTable" id="prefs_table"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="n_rows">7</property> + <property name="n_columns">4</property> + <property name="column_spacing">2</property> + <property name="row_spacing">2</property> + <child> + <placeholder/> + </child> + <child> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">Hostname:</property> + </object> + <packing> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="smtp_host"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">2</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Port:</property> + <property name="justify">right</property> + </object> + <packing> + <property name="left_attach">2</property> + <property name="right_attach">3</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkSpinButton" id="smtp_port"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="max_length">5</property> + <property name="width_chars">5</property> + <property name="adjustment">adjustment1</property> + <property name="climb_rate">1</property> + <property name="numeric">True</property> + </object> + <packing> + <property name="left_attach">3</property> + <property name="right_attach">4</property> + <property name="top_attach">1</property> + <property name="bottom_attach">2</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">Username:</property> + </object> + <packing> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="smtp_user"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">4</property> + <property name="top_attach">2</property> + <property name="bottom_attach">3</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">Password:</property> + </object> + <packing> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="smtp_pass"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="visibility">False</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">4</property> + <property name="top_attach">3</property> + <property name="bottom_attach">4</property> + </packing> + </child> + <child> + <object class="GtkFrame" id="frame1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="valign">start</property> + <property name="label_xalign">0</property> + <property name="shadow_type">none</property> + <child> + <object class="GtkAlignment" id="alignment4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="bottom_padding">10</property> + <child> + <object class="GtkBox" id="hbox1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">2</property> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="shadow_type">in</property> + <child> + <object class="GtkTreeView" id="smtp_recipients"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="headers_visible">False</property> + <property name="enable_grid_lines">horizontal</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVButtonBox" id="vbuttonbox1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">5</property> + <property name="layout_style">start</property> + <child> + <object class="GtkButton" id="add_button"> + <property name="label">gtk-add</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + <signal name="clicked" handler="on_add_button_clicked" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="delete_button"> + <property name="label">gtk-delete</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + <signal name="clicked" handler="on_delete_button_clicked" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="padding">3</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_bottom">3</property> + <property name="ypad">0</property> + <property name="label" translatable="yes"><b>Recipients</b></property> + <property name="use_markup">True</property> + </object> + </child> + </object> + <packing> + <property name="right_attach">4</property> + <property name="top_attach">6</property> + <property name="bottom_attach">7</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="smtp_tls"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="halign">start</property> + <property name="draw_indicator">True</property> + <child> + <object class="GtkLabel" id="label9"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Server requires TLS/SSL</property> + </object> + </child> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">4</property> + <property name="top_attach">5</property> + <property name="bottom_attach">6</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label8"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="label" translatable="yes">From:</property> + </object> + <packing> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkEntry" id="smtp_from"> + <property name="visible">True</property> + <property name="can_focus">True</property> + </object> + <packing> + <property name="left_attach">1</property> + <property name="right_attach">4</property> + <property name="top_attach">4</property> + <property name="bottom_attach">5</property> + </packing> + </child> + <child> + <object class="GtkCheckButton" id="smtp_enabled"> + <property name="label" translatable="yes">Enabled</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">False</property> + <property name="draw_indicator">True</property> + <signal name="toggled" handler="on_enabled_toggled" swapped="no"/> + </object> + <packing> + <property name="right_attach">4</property> + </packing> + </child> + </object> + </child> + </object> + </child> + <child type="label"> + <object class="GtkLabel" id="label7"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="halign">start</property> + <property name="xpad">5</property> + <property name="label" translatable="yes"><b>Email Notifications</b></property> + <property name="use_markup">True</property> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + <child type="tab"> + <object class="GtkLabel" id="settings_page_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Settings</property> + </object> + <packing> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <object class="GtkBox" id="vbox5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">15</property> + <property name="margin_right">10</property> + <property name="margin_bottom">10</property> + <property name="orientation">vertical</property> + <child> + <placeholder/> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkTreeView" id="subscriptions_treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="enable_grid_lines">horizontal</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label12"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">This configuration does not mean that you'll actually receive notifications for all these events.</property> + <property name="justify">fill</property> + <property name="wrap">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="padding">2</property> + <property name="position">2</property> + </packing> + </child> + </object> + <packing> + <property name="position">1</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel" id="subscriptions_page_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Subscriptions</property> + </object> + <packing> + <property name="position">1</property> + <property name="tab_fill">False</property> + </packing> + </child> + <child> + <object class="GtkBox" id="sounds_page"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="margin_left">15</property> + <property name="margin_right">10</property> + <property name="margin_bottom">10</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow3"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkTreeView" id="sounds_treeview"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child internal-child="selection"> + <object class="GtkTreeSelection"/> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkHButtonBox" id="hbuttonbox1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">10</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="sounds_revert_button"> + <property name="label">gtk-revert-to-saved</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + <signal name="clicked" handler="on_sounds_revert_button_clicked" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="sounds_edit_button"> + <property name="label">gtk-edit</property> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_stock">True</property> + <signal name="clicked" handler="on_sounds_edit_button_clicked" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="padding">5</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="position">2</property> + </packing> + </child> + <child type="tab"> + <object class="GtkLabel" id="sounds_page_label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Sound Customization</property> + </object> + <packing> + <property name="position">2</property> + <property name="tab_fill">False</property> + </packing> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/deluge/plugins/Notifications/deluge_notifications/data/notifications.js b/deluge/plugins/Notifications/deluge_notifications/data/notifications.js new file mode 100644 index 0000000..4b87e55 --- /dev/null +++ b/deluge/plugins/Notifications/deluge_notifications/data/notifications.js @@ -0,0 +1,522 @@ +/** + * notifications.js + * + * Copyright (c) Omar Alvarez 2014 <omar.alvarez@udc.es> + * + * This file is part of Deluge and is licensed under GNU General Public License 3.0, or later, with + * the additional special exception to link portions of this program with the OpenSSL library. + * See LICENSE for more details. + * + */ + +Ext.ns('Deluge.ux.preferences'); + +/** + * @class Deluge.ux.preferences.NotificationsPage + * @extends Ext.Panel + */ +Deluge.ux.preferences.NotificationsPage = Ext.extend(Ext.Panel, { + title: _('Notifications'), + header: false, + layout: 'fit', + border: false, + + initComponent: function () { + Deluge.ux.preferences.NotificationsPage.superclass.initComponent.call( + this + ); + + this.emailNotiFset = new Ext.form.FieldSet({ + xtype: 'fieldset', + border: false, + title: _('Email Notifications'), + autoHeight: true, + defaultType: 'textfield', + style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;', + width: '85%', + labelWidth: 1, + }); + + this.chkEnableEmail = this.emailNotiFset.add({ + fieldLabel: '', + labelSeparator: '', + name: 'enable_email', + xtype: 'checkbox', + boxLabel: _('Enabled'), + listeners: { + check: function (object, checked) { + this.setSmtpDisabled(!checked); + }, + scope: this, + }, + }); + + this.hBoxHost = this.emailNotiFset.add({ + fieldLabel: '', + labelSeparator: '', + name: 'host', + xtype: 'container', + layout: 'hbox', + disabled: true, + items: [ + { + xtype: 'label', + text: _('Hostname:'), + margins: '6 0 0 6', + }, + { + xtype: 'textfield', + margins: '2 0 0 4', + }, + ], + }); + + this.hBoxPort = this.emailNotiFset.add({ + fieldLabel: '', + labelSeparator: '', + name: 'port', + xtype: 'container', + layout: 'hbox', + disabled: true, + items: [ + { + xtype: 'label', + text: _('Port:'), + margins: '6 0 0 6', + }, + { + xtype: 'spinnerfield', + margins: '2 0 0 34', + width: 64, + decimalPrecision: 0, + minValue: 0, + maxValue: 65535, + }, + ], + }); + + this.hBoxUser = this.emailNotiFset.add({ + fieldLabel: '', + labelSeparator: '', + name: 'username', + xtype: 'container', + layout: 'hbox', + disabled: true, + items: [ + { + xtype: 'label', + text: _('Username:'), + margins: '6 0 0 6', + }, + { + xtype: 'textfield', + margins: '2 0 0 3', + }, + ], + }); + + this.hBoxPassword = this.emailNotiFset.add({ + fieldLabel: '', + labelSeparator: '', + name: 'password', + xtype: 'container', + layout: 'hbox', + disabled: true, + items: [ + { + xtype: 'label', + text: _('Password:'), + margins: '6 0 0 6', + }, + { + xtype: 'textfield', + inputType: 'password', + margins: '2 0 0 5', + }, + ], + }); + + this.hBoxFrom = this.emailNotiFset.add({ + fieldLabel: '', + labelSeparator: '', + name: 'from', + xtype: 'container', + layout: 'hbox', + disabled: true, + items: [ + { + xtype: 'label', + text: _('From:'), + margins: '6 0 0 6', + }, + { + xtype: 'textfield', + margins: '2 0 0 28', + }, + ], + }); + + this.chkTLS = this.emailNotiFset.add({ + fieldLabel: '', + labelSeparator: '', + name: 'enable_tls_ssl', + xtype: 'checkbox', + disabled: true, + boxLabel: _('Server requires TLS/SSL'), + }); + + this.recipientsFset = new Ext.form.FieldSet({ + xtype: 'fieldset', + border: false, + title: _('Recipients'), + autoHeight: true, + defaultType: 'editorgrid', + style: 'margin-top: 3px; margin-bottom: 0px; padding-bottom: 0px;', + autoWidth: true, + items: [ + { + fieldLabel: '', + name: 'recipients', + margins: '2 0 5 5', + height: 130, + hideHeaders: true, + width: 260, + disabled: true, + autoExpandColumn: 'recipient', + bbar: { + items: [ + { + text: _('Add'), + iconCls: 'icon-add', + handler: this.onAddClick, + scope: this, + }, + { + text: _('Remove'), + iconCls: 'icon-remove', + handler: this.onRemoveClick, + scope: this, + }, + ], + }, + viewConfig: { + emptyText: _('Add an recipient...'), + deferEmptyText: false, + }, + colModel: new Ext.grid.ColumnModel({ + columns: [ + { + id: 'recipient', + header: _('Recipient'), + dataIndex: 'recipient', + sortable: true, + hideable: false, + editable: true, + editor: { + xtype: 'textfield', + }, + }, + ], + }), + selModel: new Ext.grid.RowSelectionModel({ + singleSelect: false, + moveEditorOnEnter: false, + }), + store: new Ext.data.ArrayStore({ + autoDestroy: true, + fields: [{ name: 'recipient' }], + }), + listeners: { + afteredit: function (e) { + e.record.commit(); + }, + }, + setEmptyText: function (text) { + if (this.viewReady) { + this.getView().emptyText = text; + this.getView().refresh(); + } else { + Ext.apply(this.viewConfig, { emptyText: text }); + } + }, + loadData: function (data) { + this.getStore().loadData(data); + if (this.viewReady) { + this.getView().updateHeaders(); + } + }, + }, + ], + }); + + this.edGridSubs = new Ext.grid.EditorGridPanel({ + xtype: 'editorgrid', + autoHeight: true, + autoExpandColumn: 'event', + viewConfig: { + emptyText: _('Loading events...'), + deferEmptyText: false, + }, + colModel: new Ext.grid.ColumnModel({ + defaults: { + renderer: function ( + value, + meta, + record, + rowIndex, + colIndex, + store + ) { + if (Ext.isNumber(value) && parseInt(value) !== value) { + return value.toFixed(6); + } else if (Ext.isBoolean(value)) { + return ( + '<div class="x-grid3-check-col' + + (value ? '-on' : '') + + '" style="width: 20px;"> </div>' + ); + } + return value; + }, + }, + columns: [ + { + id: 'event', + header: 'Event', + dataIndex: 'event', + sortable: true, + hideable: false, + }, + { + id: 'email', + header: _('Email'), + dataIndex: 'email', + sortable: true, + hideable: false, + menuDisabled: true, + width: 40, + }, + ], + }), + store: new Ext.data.ArrayStore({ + autoDestroy: true, + fields: [ + { + name: 'event', + }, + { + name: 'email', + }, + ], + }), + listeners: { + cellclick: function (grid, rowIndex, colIndex, e) { + var record = grid.getStore().getAt(rowIndex); + var field = grid.getColumnModel().getDataIndex(colIndex); + var value = record.get(field); + + if (colIndex == 1) { + if (Ext.isBoolean(value)) { + record.set(field, !value); + record.commit(); + } + } + }, + beforeedit: function (e) { + if (Ext.isBoolean(e.value)) { + return false; + } + + return e.record.get('enabled'); + }, + afteredit: function (e) { + e.record.commit(); + }, + }, + setEmptyText: function (text) { + if (this.viewReady) { + this.getView().emptyText = text; + this.getView().refresh(); + } else { + Ext.apply(this.viewConfig, { emptyText: text }); + } + }, + setSub: function (eventName) { + var store = this.getStore(); + var index = store.find('event', eventName); + store.getAt(index).set('email', true); + store.getAt(index).commit(); + }, + loadData: function (data) { + this.getStore().loadData(data); + if (this.viewReady) { + this.getView().updateHeaders(); + } + }, + }); + + this.tabPanSettings = this.add({ + xtype: 'tabpanel', + activeTab: 0, + items: [ + { + title: _('Settings'), + items: [this.emailNotiFset, this.recipientsFset], + autoScroll: true, + }, + { + title: _('Subscriptions'), + items: this.edGridSubs, + }, + ], + }); + + this.on('show', this.updateConfig, this); + }, + + updateConfig: function () { + deluge.client.notifications.get_handled_events({ + success: function (events) { + var data = []; + var keys = Ext.keys(events); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + data.push([events[key][0], false]); + } + this.edGridSubs.loadData(data); + }, + scope: this, + }); + deluge.client.notifications.get_config({ + success: function (config) { + this.chkEnableEmail.setValue(config['smtp_enabled']); + this.setSmtpDisabled(!config['smtp_enabled']); + + this.hBoxHost.getComponent(1).setValue(config['smtp_host']); + this.hBoxPort.getComponent(1).setValue(config['smtp_port']); + this.hBoxUser.getComponent(1).setValue(config['smtp_user']); + this.hBoxPassword.getComponent(1).setValue(config['smtp_pass']); + this.hBoxFrom.getComponent(1).setValue(config['smtp_from']); + this.chkTLS.setValue(config['smtp_tls']); + + var data = []; + var keys = Ext.keys(config['smtp_recipients']); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + data.push([config['smtp_recipients'][key]]); + } + this.recipientsFset.getComponent(0).loadData(data); + + data = []; + keys = Ext.keys(config['subscriptions']['email']); + for (var i = 0; i < keys.length; i++) { + var key = keys[i]; + this.edGridSubs.setSub( + config['subscriptions']['email'][key] + ); + } + }, + scope: this, + }); + }, + + onApply: function () { + var config = {}; + + config['smtp_enabled'] = this.chkEnableEmail.getValue(); + config['smtp_host'] = this.hBoxHost.getComponent(1).getValue(); + config['smtp_port'] = Number(this.hBoxPort.getComponent(1).getValue()); + config['smtp_user'] = this.hBoxUser.getComponent(1).getValue(); + config['smtp_pass'] = this.hBoxPassword.getComponent(1).getValue(); + config['smtp_from'] = this.hBoxFrom.getComponent(1).getValue(); + config['smtp_tls'] = this.chkTLS.getValue(); + + var recipientsList = []; + var store = this.recipientsFset.getComponent(0).getStore(); + + for (var i = 0; i < store.getCount(); i++) { + var record = store.getAt(i); + var recipient = record.get('recipient'); + recipientsList.push(recipient); + } + + config['smtp_recipients'] = recipientsList; + + var subscriptions = {}; + var eventList = []; + store = this.edGridSubs.getStore(); + + for (var i = 0; i < store.getCount(); i++) { + var record = store.getAt(i); + var ev = record.get('event'); + var email = record.get('email'); + if (email) { + eventList.push(ev); + } + } + + subscriptions['email'] = eventList; + config['subscriptions'] = subscriptions; + + deluge.client.notifications.set_config(config); + }, + + onOk: function () { + this.onApply(); + }, + + onAddClick: function () { + var store = this.recipientsFset.getComponent(0).getStore(); + var Recipient = store.recordType; + var i = new Recipient({ + recipient: '', + }); + this.recipientsFset.getComponent(0).stopEditing(); + store.insert(0, i); + this.recipientsFset.getComponent(0).startEditing(0, 0); + }, + + onRemoveClick: function () { + var selections = this.recipientsFset + .getComponent(0) + .getSelectionModel() + .getSelections(); + var store = this.recipientsFset.getComponent(0).getStore(); + + this.recipientsFset.getComponent(0).stopEditing(); + for (var i = 0; i < selections.length; i++) store.remove(selections[i]); + store.commitChanges(); + }, + + setSmtpDisabled: function (disable) { + this.hBoxHost.setDisabled(disable); + this.hBoxPort.setDisabled(disable); + this.hBoxUser.setDisabled(disable); + this.hBoxPassword.setDisabled(disable); + this.hBoxFrom.setDisabled(disable); + this.chkTLS.setDisabled(disable); + this.recipientsFset.getComponent(0).setDisabled(disable); + }, + + onDestroy: function () { + deluge.preferences.un('show', this.updateConfig, this); + + Deluge.ux.preferences.NotificationsPage.superclass.onDestroy.call(this); + }, +}); + +Deluge.plugins.NotificationsPlugin = Ext.extend(Deluge.Plugin, { + name: 'Notifications', + + onDisable: function () { + deluge.preferences.removePage(this.prefsPage); + }, + + onEnable: function () { + this.prefsPage = deluge.preferences.addPage( + new Deluge.ux.preferences.NotificationsPage() + ); + }, +}); + +Deluge.registerPlugin('Notifications', Deluge.plugins.NotificationsPlugin); |