diff options
| author | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-08-30 09:12:57 +0000 |
|---|---|---|
| committer | alec <alec@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-08-30 09:12:57 +0000 |
| commit | 77475c07839ce8fff72a4d00f8045888933cd43e (patch) | |
| tree | 6281d4d0fd8be1f49534a8ddaf53713bc0ec404e /plugins/enigma/enigma.js | |
| parent | 8717e5314d76b81eb129d6bd0f7c957df22c0be5 (diff) | |
- Enigma plugin: initial commit
git-svn-id: https://svn.roundcube.net/trunk@3921 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'plugins/enigma/enigma.js')
| -rw-r--r-- | plugins/enigma/enigma.js | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/plugins/enigma/enigma.js b/plugins/enigma/enigma.js new file mode 100644 index 000000000..609e78114 --- /dev/null +++ b/plugins/enigma/enigma.js @@ -0,0 +1,134 @@ +/* Enigma Plugin */ + +if (window.rcmail) +{ + rcmail.addEventListener('init', function(evt) + { + if (rcmail.env.task == 'settings') { + rcmail.register_command('plugin.enigma', function() { rcmail.goto_url('plugin.enigma') }, true); + rcmail.register_command('plugin.enigma-key-import', function() { rcmail.enigma_key_import() }, true); + rcmail.register_command('plugin.enigma-key-export', function() { rcmail.enigma_key_export() }, true); + + if (rcmail.gui_objects.keyslist) + { + var p = rcmail; + rcmail.keys_list = new rcube_list_widget(rcmail.gui_objects.keyslist, + {multiselect:false, draggable:false, keyboard:false}); + rcmail.keys_list.addEventListener('select', function(o){ p.enigma_key_select(o); }); + rcmail.keys_list.init(); + rcmail.keys_list.focus(); + } + + if (rcmail.env.action == 'edit-prefs') { + rcmail.enable_command('search', 'reset-search', true); + rcmail.addEventListener('beforesearch', 'enigma_search', rcmail); + rcmail.addEventListener('beforereset-search', 'enigma_search_reset', rcmail); + } + else if (rcmail.env.action == 'plugin.enigma') { + rcmail.register_command('plugin.enigma-import', function() { rcmail.enigma_import() }, true); + rcmail.register_command('plugin.enigma-export', function() { rcmail.enigma_export() }, true); + } + } + }); +} + +/*********************************************************/ +/********* Enigma Settings methods *********/ +/*********************************************************/ + +// Display key(s) import form +rcube_webmail.prototype.enigma_key_import = function() +{ + this.enigma_loadframe(null, '&_a=keyimport'); +}; + +// Submit key(s) form +rcube_webmail.prototype.enigma_import = function() +{ + var form, file; + if (form = this.gui_objects.importform) { + file = document.getElementById('rcmimportfile'); + if (file && !file.value) { + alert(this.get_label('selectimportfile')); + return; + } + form.submit(); + this.set_busy(true, 'importwait'); + this.lock_form(form, true); + } +}; + +// list row selection handler +rcube_webmail.prototype.enigma_key_select = function(list) +{ + var id; + if (id = list.get_single_selection()) + this.enigma_loadframe(id); +}; + +// load key frame +rcube_webmail.prototype.enigma_loadframe = function(id, url) +{ + var frm, win; + if (this.env.contentframe && window.frames && (frm = window.frames[this.env.contentframe])) { + if (!id && !url && (win = window.frames[this.env.contentframe])) { + if (win.location && win.location.href.indexOf(this.env.blankpage)<0) + win.location.href = this.env.blankpage; + return; + } + this.set_busy(true); + if (!url) + url = '&_a=keyinfo&_id='+id; + frm.location.href = this.env.comm_path+'&_action=plugin.enigma&_framed=1' + url; + } +}; + +rcube_webmail.prototype.enigma_search = function(props) +{ + if (!props && this.gui_objects.qsearchbox) + props = this.gui_objects.qsearchbox.value; + + if (props) { +// if (this.gui_objects.search_filter) + // addurl += '&_filter=' + this.gui_objects.search_filter.value; + this.env.current_page = 1; + this.set_busy(true, 'searching'); + this.enigma_loadframe(); + + // reload page (for keys list refresh) + this.http_post('plugin.enigma', + {'_a': 'keysearch', '_q': urlencode(props)}, + true); + } + + // skip default 'search' command action + return false; +} + +rcube_webmail.prototype.enigma_search_reset = function(props) +{ + var s = this.env.search_request; + this.reset_qsearch(); + + if (s) { + this.enigma_loadframe(); + // reload page (for keys list refresh) + } + + // skip default 'reset-search' command action + return false; +} + +/*********************************************************/ +/********* Enigma Message methods *********/ +/*********************************************************/ + +// Import attached keys/certs file +rcube_webmail.prototype.enigma_import_attachment = function(mime_id) +{ + this.set_busy(true, 'loading'); + this.http_post('plugin.enigmaimport', '_uid='+this.env.uid+'&_mbox=' + +urlencode(this.env.mailbox)+'&_part='+urlencode(mime_id), true); + + return false; +}; |
