<fim-prefix>
            // send request to server
            rcmail.http_post('plugin.enigmakeys', post, lock);
        }, function(error) {
            // failure
            rcmail.set_busy(false, null, lock);
            rcmail.display_message(rcmail.get_label('enigma.keygenerateerror'), 'error');
        });
    }
    // generate keys on the server
    else if (rcmail.env.enigma_keygen_server) {
        lock = this.set_busy(true, 'enigma.keygenerating');
        options = {_a: 'generate', _user: user, _password: password, _size: size};
        rcmail.http_post('plugin.enigmakeys', options, lock);
    }
    else {
        rcmail.display_message(rcmail.get_label('enigma.keygennosupport'), 'error');
    }
};

// Action executed after successful key generation and import
rcube_webmail.prototype.enigma_key_create_success = function()
{
    parent.rcmail.enigma_list(1);
};

// Delete key(s)
rcube_webmail.prototype.enigma_delete = function()
{
    var keys = this.keys_list.get_selection();

    if (!keys.length || !confirm(this.get_label('enigma.keyremoveconfirm')))
        return;

    var lock = this.display_message(this.get_label('enigma.keyremoving'), 'loading'),
        post = {_a: 'delete', _keys: keys};

    // send request to server
    this.http_post('plugin.enigmakeys', post, lock);
};

// Export key(s)
rcube_webmail.prototype.enigma_export = function(selected)
{
    var keys = selected ? this.keys_list.get_selection().join(',') : '*';

    if (!keys.length)
        return;
    // BUG: CWE-352 Cross-Site Request Forgery (CSRF)
    // this.goto_url('plugin.enigmakeys', {_a: 'export', _keys: keys});
    // FIXED:
 <fim-middle>   this.goto_url('plugin.enigmakeys', {_a: 'export', _keys: keys}, false, true);
};

// Submit key(s) import form
rcube_webmail.prototype.enigma_import = function()
{
    var form, file;

    if (form <fix-suffix>= this.gui_objects.importform) {
        file = document.getElementById('rcmimportfile');
        if (file && !file.value) {
            alert(this.get_label('selectimportfile'));
            return;
        }

        var lock = this.set_busy(true, 'importwait');

        form.action = this.add_url(form.action, '_unlock', lock);
        form.submit();

        this.lock_form(form, true);
   }
};

// list row selection handler
rcube_webmail.prototype.enigma_keylist_select = function(list)
{
    var id = list.get_single_selection(), url;

    if (id)
        url = '&_action=plugin.enigmakeys&_a=info&_id=' + id;

    this.enigma_loadframe(url);
    this.enable_command('plugin.enigma-key-delete', 'plugin.enigma-key-export-selected', list.selection.length > 0);
};

rcube_webmail.prototype.enigma_keylist_keypress = function(list)
{
    if (list.modkey == CONTROL_KEY)
        return;

    if (list.key_pressed == list.DELETE_KEY || list.key_pressed == list.BACKSPACE_KEY)
        this.command(<|endoftext|>