diff -urN ../roundcubemail-1.6.4.orig/program/js/app.js ./program/js/app.js --- ../roundcubemail-1.6.4.orig/program/js/app.js 2023-10-16 12:23:06.000000000 +0300 +++ ./program/js/app.js 2023-10-24 16:53:51.574886000 +0300 @@ -65,6 +65,7 @@ this.env = { attachments: {}, request_timeout: 180, // seconds + search_request_timeout: 600, // seconds draft_autosave: 0, // seconds comm_path: './', recipients_separator: ',', // @deprecated @@ -9104,6 +9105,7 @@ // send request return $.ajax({ + timeout: (action == "search" ? this.env.search_request_timeout : this.env.request_timeout) * 1000, type: type, url: url, data: data, dataType: 'json', success: function(data) { ref.http_response(data); }, error: function(o, status, err) { ref.http_error(o, status, err, lock, action); } diff -urN ../roundcubemail-1.6.4.orig/program/js/app.min.js ./program/js/app.min.js --- ../roundcubemail-1.6.4.orig/program/js/app.min.js 2023-10-16 12:23:06.000000000 +0300 +++ ./program/js/app.min.js 2023-10-24 16:53:56.210219000 +0300 @@ -1,35 +1 @@ -/** - * Roundcube Webmail Client Script - * - * This file is part of the Roundcube Webmail client - * - * @licstart The following is the entire license notice for the - * JavaScript code in this file. - * - * Copyright (C) The Roundcube Dev Team - * Copyright (C) Kolab Systems AG - * - * The JavaScript code in this page is free software: you can - * redistribute it and/or modify it under the terms of the GNU - * General Public License (GNU GPL) as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) - * any later version. The code is distributed WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU GPL for more details. - * - * As additional permission under GNU GPL version 3 section 7, you - * may distribute non-source (e.g., minimized or compacted) forms of - * that code without the copy of the GNU GPL normally required by - * section 4, provided you include this license notice and a URL - * through which recipients can access the Corresponding Source. - * - * @licend The above is the entire license notice - * for the JavaScript code in this file. - * - * @author Thomas Bruederli - * @author Aleksander 'A.L.E.C' Machniak - * @author Charles McNulty - * - * @requires jquery.js, common.js, list.js - */ -function rcube_webmail(){this.labels={},this.buttons={},this.buttons_sel={},this.gui_objects={},this.gui_containers={},this.commands={},this.command_handlers={},this.onloads=[],this.messages={},this.group2expand={},this.http_request_jobs={},this.menu_stack=[],this.menu_buttons={},this.entity_selectors=[],this.image_style={},this.uploads={},this.dblclick_time=500,this.message_time=5e3,this.preview_delay_select=400,this.preview_delay_click=60,this.identifier_expr=/[^0-9a-z_-]/gi,this.uploadTimeout=0,this.env={attachments:{},request_timeout:180,draft_autosave:0,comm_path:"./",recipients_separator:",",recipients_delimiter:", ",popup_width:1150,popup_width_small:900,thread_padding:"15px"},this.ref="rcmail";var ref=this;$.ajaxSetup({cache:!1,timeout:1e3*this.env.request_timeout,error:function(e,t,s){ref.http_error(e,t,s)},beforeSend:function(e){e.setRequestHeader("X-Roundcube-Request",ref.env.request_token)}}),$(window).on("beforeunload",function(){ref.unload=!0}),this.set_env=function(e,t){if(null==e||"object"!=typeof e||t)this.env[e]=t;else for(var s in e)this.env[s]=e[s]},this.add_label=function(e,t){"string"==typeof e?this.labels[e]=t:"object"==typeof e&&$.extend(this.labels,e)},this.register_button=function(e,t,s,i,n,a){t={id:t,type:s};i&&(t.act=i),n&&(t.sel=n),a&&(t.over=a),this.buttons[e]||(this.buttons[e]=[]),this.buttons[e].push(t),this.loaded&&(this.init_button(e,t),this.set_button(e,this.commands[e]?"act":"pas"))},this.register_menu_button=function(e,t){var s;this.menu_buttons[t]?this.menu_buttons[t][0].push(e):(s=[],$("#"+t).find("a").each(function(){var e=$(this),t=e.attr("onclick"),t=t&&String(t).match(/rcmail\.command\(\'([^']+)/)?RegExp.$1:function(){return e.is(".active")};s.push(t)}),s.length&&(this.menu_buttons[t]=[[e],s])),this.set_menu_buttons()},this.set_menu_buttons=function(){clearTimeout(this.menu_buttons_timeout),this.menu_buttons_timeout=setTimeout(function(){$.each(ref.menu_buttons,function(){var t=!0;$.each(this[1],function(){var e="function"==typeof this;if(e&&this()||!e&&ref.commands[this])return t=!1}),$(this[0]).add($(this[0]).parent(".dropbutton")).addClass(t?"disabled":"active").removeClass(t?"active":"disabled")})},50)},this.gui_object=function(e,t){this.gui_objects[e]=this.loaded?rcube_find_object(t):t},this.gui_container=function(e,t){this.gui_containers[e]=t},this.add_element=function(e,t){this.gui_containers[t]&&this.gui_containers[t].jquery&&this.gui_containers[t].append(e)},this.register_command=function(e,t,s){this.command_handlers[e]=t,s&&this.enable_command(e,!0)},this.add_onload=function(e){this.onloads.push(e)},this.init=function(){var n,searchfilter;for(n in this.task=this.env.task,this.env.blankpage||(this.env.blankpage="javascript:false;"),this.gui_containers)this.gui_containers[n]=$("#"+this.gui_containers[n]);for(n in this.gui_objects)this.gui_objects[n]=rcube_find_object(this.gui_objects[n]);switch(this.init_buttons(),this.is_framed()&&parent.rcmail.unlock_frame(),this.enable_command("close","logout","mail","addressbook","settings","save-pref","compose","undo","about","switch-task","menu-open","menu-close","menu-save",!0),this.set_button(this.task,"sel"),this.env.permaurl&&this.enable_command("permaurl","extwin",!0),this.task){case"mail":this.enable_command("list","checkmail","add-contact","search","reset-search","collapse-folder","import-messages",!0),this.gui_objects.messagelist&&(this.msglist_setup(this.env.layout),this.env.widescreen_list_template=[{className:"threads",cells:["threads"]},{className:"subject",cells:["fromto","date","size","status","subject"]},{className:"flags",cells:["flag","attachment"]}],this.message_list=new rcube_list_widget(this.gui_objects.messagelist,{multiselect:!0,multiexpand:!0,draggable:!0,keyboard:!0,column_movable:this.env.col_movable,dblclick_time:this.dblclick_time}),this.message_list.addEventListener("initrow",function(e){ref.init_message_row(e)}).addEventListener("dblclick",function(e){ref.msglist_dbl_click(e)}).addEventListener("keypress",function(e){ref.msglist_keypress(e)}).addEventListener("select",function(e){ref.msglist_select(e)}).addEventListener("dragstart",function(e){ref.drag_start(e)}).addEventListener("dragmove",function(e){ref.drag_move(e)}).addEventListener("dragend",function(e){ref.drag_end(e)}).addEventListener("expandcollapse",function(e){ref.msglist_expand(e)}).addEventListener("column_replace",function(e){ref.msglist_set_coltypes(e)}).init(),$(this.message_list.thead).on("click","a.sortcol",function(e){return ref.command("sort",$(this).attr("rel"),this)}),this.enable_command("toggle_status","toggle_flag","sort",!0),this.enable_command("set-listmode",this.env.threads&&!this.is_multifolder_listing()),searchfilter=$(this.gui_objects.search_filter).val(),searchfilter&&"ALL"!=searchfilter?this.filter_mailbox(searchfilter):this.command("list"),$(this.gui_objects.qsearchbox).val(this.env.search_text).focusin(function(){ref.message_list.blur()})),this.set_button_titles(),this.env.message_commands=["show","reply","reply-all","reply-list","move","copy","delete","open","mark","edit","viewsource","bounce","print","load-attachment","download-attachment","show-headers","hide-headers","download","forward","forward-inline","forward-attachment","change-format"],"show"==this.env.action||"preview"==this.env.action?(this.enable_command(this.env.message_commands,this.env.uid),this.enable_command("reply-list",this.env.list_post),"show"==this.env.action&&this.http_request("pagenav",{_uid:this.env.uid,_mbox:this.env.mailbox,_search:this.env.search_request},this.display_message("","loading")),0 a",this.gui_objects.attachments).not(".drop").on("dragstart",function(e){var t,s=this.href,e=e.originalEvent.dataTransfer;e&&(s=s.replace(/^https?:\/\//,function(e){return e+urlencode(ref.env.username)+"@"}),(t=$(this).clone()).children().remove(),e.setData("roundcube-uri",s),e.setData("roundcube-name",t.text().trim()))}),this.check_mailvelope(this.env.action)):"compose"==this.env.action?(this.env.address_group_stack=[],this.env.compose_commands=["send-attachment","remove-attachment","send","cancel","toggle-editor","list-addresses","pushgroup","search","reset-search","extwin","insert-response","menu-open","menu-close","load-attachment","download-attachment","open-attachment","rename-attachment"],this.env.drafts_mailbox&&this.env.compose_commands.push("savedraft"),this.enable_command(this.env.compose_commands,!0),$.merge(this.env.compose_commands,["add-recipient","firstpage","previouspage","nextpage","lastpage"]),window.googie&&(this.env.editor_config.spellchecker=googie,this.env.editor_config.spellcheck_observer=function(e){ref.spellcheck_state()},this.env.compose_commands.push("spellcheck"),this.enable_command("spellcheck",!0)),this.editor_init(null,this.env.composebody),this.init_messageform(),this.check_mailvelope(this.env.action)):"bounce"==this.env.action?(this.init_messageform_inputs(),this.env.compose_commands=[]):"get"==this.env.action?(this.enable_command("download",!0),this.enable_command("image-scale","image-rotate",!!/^image\//.test(this.env.mimetype)),this.enable_command("print","application/pdf"!=this.env.mimetype||!bw.mz||75<=bw.vendver),this.env.is_message&&(this.enable_command("reply","reply-all","edit","viewsource","forward","forward-inline","forward-attachment","bounce",!0),this.env.list_post)&&this.enable_command("reply-list",!0),this.env.mimetype.startsWith("image/")&&$(this.gui_objects.messagepartframe).on("load",function(){var e=$(this).contents();e.find("img").length&&e.find("head").append('')})):"print"==this.env.action&&this.env.uid&&(this.check_mailvelope(this.env.action),this.env.is_pgp_content||this.env.pgp_mime_part||this.print_dialog()),this.gui_objects.mailboxlist&&(this.env.unread_counts={},this.gui_objects.folderlist=this.gui_objects.mailboxlist,this.http_request("getunread",{_page:this.env.current_page})),this.gui_objects.contactslist&&(this.contact_list=new rcube_list_widget(this.gui_objects.contactslist,{multiselect:!0,draggable:!1,keyboard:!0}),this.contact_list.addEventListener("initrow",function(e){ref.triggerEvent("insertrow",{cid:e.uid,row:e})}).addEventListener("select",function(e){ref.compose_recipient_select(e)}).addEventListener("dblclick",function(e){ref.compose_add_recipient()}).addEventListener("keypress",function(e){e.key_pressed!=e.ENTER_KEY||ref.compose_add_recipient()||e.last_selected&&"G"==String(e.last_selected).charAt(0)&&$(e.rows[e.last_selected].obj).find("a").first().click()}).init(),$("#_to,#_cc,#_bcc").focus(function(){ref.env.focused_field=this})),this.gui_objects.addressbookslist&&(this.gui_objects.folderlist=this.gui_objects.addressbookslist,this.enable_command("list-addresses",!0)),this.env.mdn_request&&this.env.uid&&this.mdn_request_dialog(this.env.uid,this.env.mailbox),this.is_framed()||this.env.extwin||this.browser_capabilities_check();break;case"addressbook":this.env.address_group_stack=[],this.gui_objects.folderlist&&(this.env.contactfolders=$.extend($.extend({},this.env.address_sources),this.env.contactgroups)),this.enable_command("add","import",this.env.writable_source),this.enable_command("list","listgroup","pushgroup","popgroup","listsearch","search","reset-search","advanced-search",!0),this.gui_objects.contactslist&&(this.contact_list=new rcube_list_widget(this.gui_objects.contactslist,{multiselect:!0,draggable:!!this.gui_objects.folderlist,keyboard:!0}),this.contact_list.addEventListener("initrow",function(e){ref.triggerEvent("insertrow",{cid:e.uid,row:e})}).addEventListener("keypress",function(e){ref.list_keypress(e)}).addEventListener("select",function(e){ref.contactlist_select(e)}).addEventListener("dragstart",function(e){ref.drag_start(e)}).addEventListener("dragmove",function(e){ref.drag_move(e)}).addEventListener("dragend",function(e){ref.drag_end(e)}).init(),$(this.gui_objects.qsearchbox).focusin(function(){ref.contact_list.blur()}),this.update_group_commands(),this.command("list")),this.gui_objects.savedsearchlist&&(this.savedsearchlist=new rcube_treelist_widget(this.gui_objects.savedsearchlist,{id_prefix:"rcmli",id_encode:this.html_identifier_encode,id_decode:this.html_identifier_decode}),this.savedsearchlist.addEventListener("select",function(e){ref.triggerEvent("selectfolder",{folder:e.id,prefix:"rcmli"})})),this.set_page_buttons(),this.env.cid&&(this.enable_command("show","edit","qrcode",!0),this.gui_objects.editform)&&$("input.groupmember").change(function(){ref.group_member_change(this.checked?"add":"del",ref.env.cid,ref.env.source,this.value)}),this.gui_objects.editform?(this.enable_command("save",!0),"add"!=this.env.action&&"edit"!=this.env.action&&"search"!=this.env.action||this.init_contact_form()):"print"==this.env.action&&this.print_dialog();break;case"settings":this.enable_command("show","save",!0),"identities"==this.env.action?this.enable_command("add",this.env.identities_level<2):"edit-identity"==this.env.action||"add-identity"==this.env.action?(this.enable_command("save","edit",!0),this.enable_command("delete",this.env.identities_level<2),"edit-identity"==this.env.action&&this.check_mailvelope(this.env.action)):"folders"==this.env.action?this.enable_command("subscribe","unsubscribe","create-folder","rename-folder",!0):"edit-folder"==this.env.action&&this.gui_objects.editform?(this.enable_command("save","folder-size",!0),parent.rcmail.env.exists=this.env.messagecount,parent.rcmail.enable_command("purge",this.env.messagecount)):"responses"==this.env.action&&this.enable_command("add",!0),this.gui_objects.identitieslist?(this.identity_list=new rcube_list_widget(this.gui_objects.identitieslist,{multiselect:!1,draggable:!1,keyboard:!0}),this.identity_list.addEventListener("select",function(e){ref.identity_select(e)}).addEventListener("keypress",function(e){ref.list_keypress(e)}).init().focus()):this.gui_objects.sectionslist?(this.sections_list=new rcube_list_widget(this.gui_objects.sectionslist,{multiselect:!1,draggable:!1,keyboard:!0}),this.sections_list.addEventListener("select",function(e){ref.section_select(e)}).init().focus()):this.gui_objects.subscriptionlist?this.init_subscription_list():this.gui_objects.responseslist&&(this.responses_list=new rcube_list_widget(this.gui_objects.responseslist,{multiselect:!1,draggable:!1,keyboard:!0}),this.responses_list.addEventListener("select",function(e){ref.response_select(e)}).addEventListener("keypress",function(e){ref.list_keypress(e)}).init().focus());break;case"login":var tz,tz_name,input_user=$("#rcmloginuser"),input_tz=$("#rcmlogintz");(""==input_user.val()?input_user:$("#rcmloginpwd")).focus(),window.jstz&&(tz=jstz.determine())&&(tz_name=tz.name()),input_tz.val(tz_name||(new Date).getStdTimezoneOffset()/-60),$("form").submit(function(){$("[type=submit]",this).prop("disabled",!0),ref.clear_messages(),ref.display_message("","loading")})}this.gui_objects.editform&&$("input,select,textarea",this.gui_objects.editform).not(":hidden").not(":disabled").first().select().focus(),bw.ie&&$("input[type=file]").keydown(function(e){"13"==e.keyCode&&e.preventDefault()}),this.loaded=!0,this.env.lastrefresh=new Date,this.pending_message&&this.display_message.apply(this,this.pending_message),this.gui_objects.folderlist&&window.rcube_treelist_widget&&this.gui_objects.folderlist!=this.gui_objects.addressbookslist&&(this.treelist=new rcube_treelist_widget(this.gui_objects.folderlist,{selectable:!0,id_prefix:"rcmli",parent_focus:!0,id_encode:this.html_identifier_encode,id_decode:this.html_identifier_decode,check_droptarget:function(e){return!e.virtual&&ref.check_droptarget(e.id)}}),this.treelist.addEventListener("collapse",function(e){ref.folder_collapsed(e)}).addEventListener("expand",function(e){ref.folder_collapsed(e)}).addEventListener("beforeselect",function(e){return!ref.busy}).addEventListener("select",function(e){ref.triggerEvent("selectfolder",{folder:e.id,prefix:"rcmli"}),ref.mark_all_read_state()})),this.gui_objects.filedrop&&this.env.filedrop&&window.FormData&&($(document.body).on("dragover dragleave drop",function(e){return ref.document_drag_hover(e,"dragover"==e.type)}),$(this.gui_objects.filedrop).addClass("droptarget").on("dragover dragleave",function(e){return ref.file_drag_hover(e,"dragover"==e.type)}).get(0).addEventListener("drop",function(e){return ref.file_dropped(e)},!1));var body_mouseup=function(e){return ref.doc_mouse_up(e)};for(n in $(document.body).mouseup(body_mouseup).keydown(function(e){return ref.doc_keypress(e)}),rcube_webmail.set_iframe_events({mouseup:body_mouseup}),this.triggerEvent("init",{task:this.task,action:this.env.action}),this.onloads)"string"==typeof this.onloads[n]?eval(this.onloads[n]):"function"==typeof this.onloads[n]&&this.onloads[n]();$("[data-popup]").each(function(){ref.register_menu_button(this,$(this).data("popup"))}),this.start_refresh(),this.start_keepalive()},this.log=function(e){this.env.devel_mode&&window.console&&console.log&&console.log(e)},this.command=function(e,t,s,i,n){if(!s||!s.blur||i&&rcube_event.is_keyboard(i)||s.blur(),this.busy&&("reset-search"!=e||"search"!=this.last_command)&&!e.match(/^menu-/))return!1;if(s&&s.href&&String(s.href).indexOf("#")<0&&rcube_event.get_modifier(i))return!0;if(!n&&!this.commands[e])return this.is_framed()&&parent.rcmail.command(e,t),!1;if("mail"==this.task&&"compose"==this.env.action&&!this.env.server_error&&"save-pref"!=e&&($.inArray(e,this.env.compose_commands)<0||e.startsWith("compose-encrypted")&&ref.mailvelope_editor)&&!this.compose_skip_unsavedcheck&&!this.env.is_sent&&this.cmp_hash!=this.compose_field_hash())return this.confirm_dialog(this.get_label("notsentwarning"),"discard",function(){ref.remove_compose_data(ref.env.compose_id),ref.compose_skip_unsavedcheck=!0,ref.command(e,t,s,i)}),!1;if(this.last_command=e,this.command_aborted=!1,this.triggerEvent("actionbefore",{props:t,action:e,originalEvent:i}),void 0!==(n=this.triggerEvent("before"+e,t||i))){if(!1===n)return!1;t=n}return n="function"==typeof this.command_handlers[e]?this.command_handlers[e](t,s,i):"string"==typeof this.command_handlers[e]?window[this.command_handlers[e]](t,s,i):this.command_handler(e,t,s,i),this.command_aborted||!1!==this.triggerEvent("after"+e,t)||(n=!1),this.triggerEvent("actionafter",{props:t,action:e,aborted:this.command_aborted,ret:n,originalEvent:i}),!1!==n&&!(s&&!0!==n||!0===this.command_aborted)},this.command_handler=function(e,t,s,i){var n,a,r,o;switch(e){case"logout":case"mail":case"addressbook":case"settings":this.switch_task(e);break;case"about":this.redirect("?_task=settings&_action=about",!1);break;case"permaurl":if(s&&s.href&&s.target)return!0;this.env.permaurl&&(parent.location.href=this.env.permaurl);break;case"extwin":"compose"==this.env.action?(m=this.gui_objects.messageform,(l=this.open_window(""))&&(this.save_compose_form_local(),this.compose_skip_unsavedcheck=!0,$("[name='_action']",m).val("compose"),m.action=this.url("mail/compose",{_id:this.env.compose_id,_extwin:1}),m.target=l.name,m.submit())):this.open_window(this.env.permaurl,!0);break;case"change-format":n=this.env.permaurl+"&_format="+t,"preview"==this.env.action&&(n=n.replace(/_action=show/,"_action=preview")+"&_framed=1"),this.env.extwin&&(n+="&_extwin=1"),location.href=n;break;case"menu-open":t&&"attachmentmenu"==t.menu&&((d=this.env.attachments[t.id])&&d.mimetype&&(d=d.mimetype),this.enable_command("open-attachment",d&&this.env.mimetypes&&0<=$.inArray(d,this.env.mimetypes))),this.show_menu(t,t.show||void 0,i);break;case"menu-close":this.hide_menu(t,i);break;case"menu-save":return this.triggerEvent(e,{props:t,originalEvent:i}),!1;case"open":if(r=this.get_single_uid())return s.href=this.url("show",this.params_from_uid(r,{_extwin:1})),!0;break;case"close":this.env.extwin&&window.close();break;case"list":t&&""!=t&&this.reset_qsearch(!0),"compose"==this.env.action&&this.env.extwin?window.close():"mail"==this.task?(this.list_mailbox(t,t?1:""),this.set_button_titles()):"addressbook"==this.task&&this.list_contacts(t);break;case"set-listmode":this.set_list_options(null,void 0,void 0,"threads"==t?1:0);break;case"sort":var l=this.env.sort_order,c=this.env.disabled_sort_col?this.env.sort_col:t;this.env.disabled_sort_order||(l=this.env.sort_col==c&&"ASC"==l?"DESC":"ASC"),this.set_list_sorting(c,l),this.list_mailbox("","",c+"_"+l);break;case"nextpage":this.list_page("next");break;case"lastpage":this.list_page("last");break;case"previouspage":this.list_page("prev");break;case"firstpage":this.list_page("first");break;case"expunge":this.env.exists&&this.expunge_mailbox(this.env.mailbox);break;case"purge":case"empty-mailbox":this.env.exists&&this.purge_mailbox(this.env.mailbox);break;case"show":"mail"==this.task?!(r=this.get_single_uid())||this.env.uid&&r==this.env.uid||((c=this.get_message_mailbox(r))==this.env.drafts_mailbox?this.open_compose_step({_draft_uid:r,_mbox:c}):this.show_message(r)):"addressbook"==this.task?!(_=t||this.get_single_cid())||"show"==this.env.action&&_==this.env.cid||this.load_contact(_,"show"):"settings"==this.task&&this.goto_url("settings/"+t,{_framed:0});break;case"add":"addressbook"==this.task?this.load_contact(0,"add"):"settings"==this.task&&"responses"==this.env.action?this.load_response(0,"add-response"):"settings"==this.task&&this.load_identity(0,"add-identity");break;case"edit":"addressbook"==this.task&&(_=this.get_single_cid())?this.load_contact(_,"edit"):"mail"==this.task&&(r=this.get_single_uid())&&((n={_mbox:this.get_message_mailbox(r)})[n._mbox==this.env.drafts_mailbox&&"new"!=t?"_draft_uid":"_uid"]=r,this.open_compose_step(n));break;case"save":if(m=this.gui_objects.editform){if((o=$("[name='_pagesize']",m))&&o.length&&isNaN(parseInt(o.val()))){this.alert_dialog(this.get_label("nopagesizewarning"),function(){o.focus()});break}if("reload"==t)m.action+="&_reload=1";else if("settings"==this.task&&this.env.identities_level%2==0&&(o=$("[name='_email']",m))&&o.length&&!rcube_check_email(o.val())){this.alert_dialog(this.get_label("noemailwarning"),function(){o.focus()});break}parent.rcmail&&parent.rcmail.env.source&&(m.action=this.add_url(m.action,"_orig_source",parent.rcmail.env.source)),m.submit()}break;case"delete":"mail"==this.task?this.delete_messages(i):"addressbook"==this.task?this.delete_contacts():"settings"==this.task&&"responses"==this.env.action?this.delete_response():"settings"==this.task&&this.delete_identity();break;case"move":case"moveto":"mail"==this.task?this.move_messages(t,i):"addressbook"==this.task&&this.move_contacts(t,i);break;case"copy":"mail"==this.task?this.copy_messages(t,i):"addressbook"==this.task&&this.copy_contacts(t,i);break;case"mark":t&&this.mark_message(t);break;case"toggle_status":case"toggle_flag":a="toggle_flag"==e?"flagged":"read",(r=t)&&("flagged"==a?this.message_list.rows[r].flagged&&(a="unflagged"):this.message_list.rows[r].deleted?a="undelete":this.message_list.rows[r].unread||(a="unread"),this.mark_message(a,r));break;case"add-contact":this.add_contact(t);break;case"load-remote":if(this.env.uid){if(t&&this.env.sender){this.add_contact(this.env.sender,!0,t);break}this.show_message(this.env.uid,!0,"preview"==this.env.action)}break;case"load-attachment":case"open-attachment":case"download-attachment":var h,d=this.env.attachments[t];return"compose"==this.env.action?(h={_file:t,_id:this.env.compose_id},d=d?d.mimetype:""):h={_mbox:this.env.mailbox,_uid:this.env.uid,_part:t},"download-attachment"!=e&&d&&this.env.mimetypes&&0<=$.inArray(d,this.env.mimetypes)&&this.open_window(this.url("get",$.extend({_frame:1,_framed:0},h)))||(h._download=1,this.compose_skip_unsavedcheck=1,this.goto_url("get",h,!1,!0),this.compose_skip_unsavedcheck=0),!0;case"select-all":this.select_all_mode=!t,this.dummy_select=!0;l=this["addressbook"==this.task?"contact_list":"message_list"];"invert"==t?l.invert_selection():l.select_all("page"==t?"":t),this.dummy_select=null;break;case"select-none":this.select_all_mode=!1,this["addressbook"==this.task?"contact_list":"message_list"].clear_selection();break;case"expand-all":this.env.autoexpand_threads=1,this.message_list.expand_all();break;case"expand-unread":this.env.autoexpand_threads=2,this.message_list.collapse_all(),this.expand_unread();break;case"collapse-all":this.env.autoexpand_threads=0,this.message_list.collapse_all();break;case"nextmessage":this.env.next_uid&&this.show_message(this.env.next_uid,!1,"preview"==this.env.action);break;case"lastmessage":this.env.last_uid&&this.show_message(this.env.last_uid);break;case"previousmessage":this.env.prev_uid&&this.show_message(this.env.prev_uid,!1,"preview"==this.env.action);break;case"firstmessage":this.env.first_uid&&this.show_message(this.env.first_uid);break;case"compose":if(n={},"mail"==this.task)n={_mbox:this.env.mailbox,_search:this.env.search_request},t&&(n._to=t);else if("addressbook"==this.task)if(t&&0").attr("src",this.url("import",{_framed:1,_target:this.env.source}));this.import_state=null,this.import_dialog=this.simple_dialog(p,"importcontacts",function(e){var t,s=p[0].contentWindow,i=null;(i=s.rcmail.gui_objects.importformmap||s.rcmail.gui_objects.importform)&&((t=s.$("#rcmimportfile")[0])&&!t.value?s.rcmail.alert_dialog(s.rcmail.get_label("selectimportfile")):(t=s.rcmail.set_busy(!0,"importwait"),$('[name="_unlock"]',i).val(t),i.submit(),s.rcmail.lock_form(i,!0),$(e.target).attr("disabled",!0).next().focus()))},{close:function(e,t){$(this).remove(),"reload"==ref.import_state&&ref.command("list")},button:"import",width:500,height:300});break;case"export":0"+this.get_label("loading")+""),this.triggerEvent("openwindow",{url:e,handle:r}),setTimeout(function(){r&&r.focus()},10),r;this.display_message("windowopenerror","warning")},this.init_message_row=function(s){var e={},t=s.uid,i=(null!=this.env.status_col?"status":"msg")+"icn"+s.id;t&&this.env.messages[t]&&$.extend(s,this.env.messages[t]),(s.icon=document.getElementById(i))&&(e.icon=function(e){ref.command("toggle_status",t)}),null!=this.env.status_col?s.msgicon=document.getElementById("msgicn"+s.id):s.msgicon=s.icon,null!=this.env.flagged_col&&(s.flagicon=document.getElementById("flagicn"+s.id))&&(e.flagicon=function(e){ref.command("toggle_flag",t)}),!s.depth&&s.has_children&&(s.expando=document.getElementById("rcmexpando"+s.id))&&(e.expando=function(e){ref.expand_message_row(e,t)}),$.each(e,function(e,t){s[e].onclick=function(e){return t(e),rcube_event.cancel(e)},bw.touch&&s[e].addEventListener&&s[e].addEventListener("touchend",function(e){if(1==e.changedTouches.length)return t(e),rcube_event.cancel(e)},!1)}),this.triggerEvent("insertrow",{uid:t,row:s})},this.add_message_row=function(e,t,s,i){if(!this.gui_objects.messagelist||!this.message_list)return!1;if(s.mbox!=this.env.mailbox&&!s.skip_mbox_check)return!1;if(this.message_list.rows[e])return!1;this.env.messages[e]||(this.env.messages[e]={}),$.extend(this.env.messages[e],{deleted:s.deleted?1:0,replied:s.answered?1:0,unread:s.seen?0:1,forwarded:s.forwarded?1:0,flagged:s.flagged?1:0,has_children:s.has_children?1:0,depth:s.depth||0,unread_children:s.unread_children||0,flagged_children:s.flagged_children||0,parent_uid:s.parent_uid||0,selected:this.select_all_mode||this.message_list.in_selection(e),ml:s.ml?1:0,ctype:s.ctype,mbox:s.mbox,flags:s.extra_flags});var n,a,r,o,l,c="",h="",d="",_="",u=this.message_list,m=u.rows,p=this.env.messages[e],f=this.html_identifier(e,!0),g="message"+(s.seen?"":" unread")+(s.deleted?" deleted":"")+(s.flagged?" flagged":"")+(p.selected?" selected":""),v={cols:[],style:{},id:"rcmrow"+f,uid:e},b=this.env.msglist_layout,y=this.env.msglist_cols;for(n in"widescreen"==b?this.env.status_col=null:0<=(n=$.inArray("status",y))&&(this.env.status_col=n),o="msgicon",null===this.env.status_col&&(o+=" status",s.deleted?(c+=" deleted",h+=this.get_label("deleted")+" "):s.seen?0  ',m[p.parent_uid]&&!1===m[p.parent_uid].expanded||!(0!=this.env.autoexpand_threads&&2!=this.env.autoexpand_threads||m[p.parent_uid]&&m[p.parent_uid].expanded)?(v.style.display="none",p.expanded=!1):p.expanded=!0,g+=" thread expanded"):p.has_children&&(void 0===p.expanded&&(1==this.env.autoexpand_threads||2==this.env.autoexpand_threads&&p.unread_children)&&(p.expanded=!0),_='
  
',g+=" thread"+(p.expanded?" expanded":"")),s.unread_children&&s.seen&&!p.expanded&&(g+=" unroot"),s.flagged_children)&&!p.expanded&&(g+=" flaggedroot"),d+='',v.className=g,t.subject&&(f=s.mbox==this.env.drafts_mailbox?"compose":"show",m=s.mbox==this.env.drafts_mailbox?"_draft_uid":"_uid",(h={_mbox:s.mbox})[m]=e,t.subject=''+t.subject+""),y)r=y[n],a={className:String(r).toLowerCase(),events:{}},this.env.coltypes[r]&&this.env.coltypes[r].hidden&&(a.className+=" hidden"),r="flag"==r?(o=s.flagged?"flagged":"unflagged",l=this.get_label(o),''):"attachment"==r?(l=this.get_label("withattachment"),s.attachmentClass?'':"multipart/report"==s.ctype?'':"multipart/encrypted"==s.ctype||"application/pkcs7-mime"==s.ctype?'':s.hasattachment||!s.hasnoattachment&&/application\/|multipart\/(m|signed)/.test(s.ctype)?'':" "):"status"==r?(l="",s.deleted?l=this.get_label(o="deleted"):s.seen?o=0'):"threads"==r?_:"subject"==r?d+t[r]:"priority"==r?0'):" ":"folder"==r?''+t[r]+"":t[r],a.innerHTML=r,v.cols.push(a);"widescreen"==b&&(v=this.widescreen_message_row(v,e,p)),u.insert_row(v,i),i&&this.env.pagesize&&u.rowcount>this.env.pagesize&&(e=u.get_last_row(),u.remove_row(e),u.clear_selection(e))},this.widescreen_message_row=function(a,e,t){var r=document.createElement("tr");return r.id=a.id,r.uid=a.uid,r.className=a.className,a.style&&$.extend(r.style,a.style),$.each(this.env.widescreen_list_template,function(){if(ref.env.threading||"threads"!=this.className){var e,t,s,i,n=document.createElement("td");for(this.className&&(n.className=this.className),e=0;this.cells&&e a").prop("rel","arrival"==e?"arrival":"date"),this.env.sort_col=e,this.env.sort_order=t},this.set_list_options=function(e,t,s,i,n){var a,r={};if(void 0===t&&(t=this.env.sort_col),s=s||this.env.sort_order,this.env.sort_col==t&&this.env.sort_order==s||(a=1,this.set_list_sorting(t,s)),this.env.threading!=i&&(a=1,r._threads=i),n&&this.env.layout!=n&&(this.triggerEvent("layout-change",{old_layout:this.env.layout,new_layout:n}),a=1,this.env.layout=r._layout=n,this.msglist_setup(this.env.layout)),e&&e.length){for(var o,l,c=[],h=this.env.listcols,d=0;ds.depth?(n=i-s.depth,2&a[t][n]||(a[t][n]=a[t][n]?a[t][n]+2:2)):i!=s.depth||2&a[t][0]||(a[t][0]+=2),!(s.depth>i));t--);a.push(new Array(s.depth)),a[a.length-1][0]=1,r.push(s.uid)}else{if(a.length){for(t in a)this.set_tree_icons(r[t],a[t]);a=[],r=[]}if(e&&l!=o[e].obj)break}l=l.nextSibling}if(a.length)for(t in a)this.set_tree_icons(r[t],a[t])},this.set_tree_icons=function(e,t){for(var s=[],i="",n=t.length,a=0;a':i+='
';i&&$("#rcmtab"+this.html_identifier(e,!0)).html(i)},this.update_thread_root=function(e,t){if(this.env.threading){var s=this.message_list.find_root(e);if(e!=s){e=this.message_list.rows[s];if("read"==t&&e.unread_children)e.unread_children--;else if("unread"==t&&e.has_children)e.unread_children=(e.unread_children||0)+1;else if("unflagged"==t&&e.flagged_children)e.flagged_children--;else{if("flagged"!=t||!e.has_children)return;e.flagged_children=(e.flagged_children||0)+1}this.set_message_icon(s),this.set_unread_children(s),this.set_flagged_children(s)}}},this.update_thread=function(e){if(!this.env.threading||!this.message_list.rows[e])return 0;var t,s,i=0,n=this.message_list,a=n.rows,r=a[e],o=a[e].depth,l=[];for(r.depth||i--,r.depth&&r.unread&&(a[s=n.find_root(e)].unread_children--,this.set_unread_children(s)),r.depth&&r.flagged&&(a[s=n.find_root(e)].flagged_children--,this.set_flagged_children(s)),s=r.parent_uid,r=r.obj.nextSibling;r;){if(1==r.nodeType&&(t=a[r.uid])){if(!t.depth||t.depth<=o)break;t.depth--,$("#rcmtab"+t.id).width(15*t.depth).html(""),t.depth?(t.depth==o&&(t.parent_uid=s),t.unread&&l.length&&l[l.length-1].unread_children++):(i++,t.parent_uid=0,t.has_children&&($("#"+t.id+" .leaf").first().attr("id","rcmexpando"+t.id).attr("class","none"!=t.obj.style.display?"expanded":"collapsed").mousedown({uid:t.uid},function(e){return ref.expand_message_row(e,e.data.uid)}),t.unread_children=0,l.push(t)),"none"==t.obj.style.display&&$(t.obj).show())}r=r.nextSibling}for(t=0;t"+s+"";t='",ref.pagejump||(ref.pagejump=$('
').appendTo(document.body).on("click","li",function(){ref.busy||$(a).val($(this).text()).change()})),ref.pagejump.data("count")!=s&&ref.pagejump.html(t),ref.pagejump.attr("rel","#"+this.id).data("count",s),ref.show_menu("pagejump-selector",!0,e),$(this).keydown()}).on("keydown keyup click",function(e){var t=$("#pagejump-selector"),s=$("ul",t),i=$("li",s),n=(s.height(),parseInt(this.value));if(27!=e.which&&9!=e.which&&13!=e.which&&!t.is(":visible"))return ref.show_menu("pagejump-selector",!0,e);if("keydown"==e.type)if(40==e.which)i.length>n&&(this.value=n+=1);else if(38==e.which)1n-1&&(this.value=--n);else{if(13==e.which)return $(this).change();if(27==e.which||9==e.which)return ref.hide_menu("pagejump-selector",e),$(a).val(ref.env.current_page)}$("li.selected",s).removeClass("selected"),(e=$(i[n-1])).length&&(e.addClass("selected"),$("#pagejump-selector").scrollTop(s.height()/i.length*(n-1)-t.height()/2))}).on("change",function(e){var t=parseInt(this.value);t&&t!=ref.env.current_page&&!ref.busy&&(ref.hide_menu("pagejump-selector",e),ref.list_page(t))})},this.update_pagejumper=function(){$("input.rcpagejumper").val(this.env.current_page).prop("disabled",this.env.pagecount<2)},this.check_mailvelope=function(e){window.mailvelope?this.mailvelope_load(e):$(window).on("mailvelope",function(){ref.mailvelope_load(e)})},this.mailvelope_load=function(t){function s(e){ref.mailvelope_keyring=e,ref.mailvelope_init(t,e)}var i=this.env.mailvelope_main_keyring?void 0:this.env.user_id;mailvelope.getVersion().then(function(e){return mailvelope.VERSION=e,mailvelope.VERSION_MAJOR=Math.floor(parseFloat(e)),mailvelope.getKeyring(i)}).then(s,function(e){i?mailvelope.createKeyring(i).then(s,function(e){console.error(e)}):console.error(e)})},this.mailvelope_init=function(e,t){var s,i,n,a,r,o;window.mailvelope&&("show"==e||"preview"==e||"print"==e?this.env.is_pgp_content?(s=$(this.env.is_pgp_content).text(),ref.mailvelope_display_container(this.env.is_pgp_content,s,t)):this.env.pgp_mime_part&&(i=this.display_message("loadingdata","loading"),n=this.env.pgp_mime_container,$.ajax({type:"GET",url:this.url("get",{_mbox:this.env.mailbox,_uid:this.env.uid,_part:this.env.pgp_mime_part}),error:function(e,t,s){ref.http_error(e,t,s,i)},success:function(e){ref.mailvelope_display_container(n,e,t,i)}})):"compose"==e?(this.env.compose_commands.push("compose-encrypted"),a=2<=mailvelope.VERSION_MAJOR,r=0<$('[name="_is_html"]').val(),a&&this.env.compose_commands.push("compose-encrypted-signed"),this.env.pgp_mime_message?(o=this.set_busy(!0,this.get_label("loadingdata")),$.ajax({type:"GET",url:this.url("get",this.env.pgp_mime_message),error:function(e,t,s){ref.http_error(e,t,s,o),ref.enable_command("compose-encrypted",!r),a&&ref.enable_command("compose-encrypted-signed",!r)},success:function(e){ref.set_busy(!1,null,o),r&&(ref.command("toggle-editor",{html:!1,noconvert:!0}),$("#"+ref.env.composebody).val("")),ref.compose_encrypted({quotedMail:e}),ref.enable_command("compose-encrypted",!0),ref.enable_command("compose-encrypted-signed",!1)}})):(this.enable_command("compose-encrypted",!r),a&&this.enable_command("compose-encrypted-signed",!r)),this.addEventListener("actionafter",function(e){e.ret&&"toggle-editor"==e.action&&(ref.enable_command("compose-encrypted",!e.props.html),a)&&ref.enable_command("compose-encrypted-signed",!e.props.html)})):"edit-identity"==e&&ref.mailvelope_identity_keygen())},this.compose_encrypted_signed=function(e){(e=e||{}).signMsg=!0,this.compose_encrypted(e)},this.compose_encrypted=function(e){var t,s=$("#"+this.env.composebody).parent();ref.mailvelope_editor?(ref.mailvelope_editor=null,ref.set_button("compose-encrypted","act"),s.removeClass("mailvelope").find("iframe:not([aria-hidden=true])").remove(),$("#"+ref.env.composebody).show(),$("[name='_pgpmime']").remove(),ref.enable_command("toggle-editor","insert-response",!0),ref.enable_command("spellcheck",!!window.googie),ref.enable_command("insert-sig",!!(ref.env.signatures&&ref.env.identity&&ref.env.signatures[ref.env.identity])),ref.triggerEvent("compose-encrypted",{active:!1})):(this.spellcheck_state()&&this.editor.spellcheck_stop(),t=e.quotedMail?{quotedMail:e.quotedMail,quotedMailIndent:!1}:{predefinedText:$("#"+this.env.composebody).val()},e.signMsg&&(t.signMsg=e.signMsg),"reply"==this.env.compose_mode&&(t.quotedMailIndent=!0,t.quotedMailHeader=this.env.compose_reply_header),mailvelope.createEditorContainer("#"+s.attr("id"),ref.mailvelope_keyring,t).then(function(e){ref.mailvelope_editor=e,ref.set_button("compose-encrypted","sel"),s.addClass("mailvelope"),$("#"+ref.env.composebody).hide(),ref.enable_command("spellcheck","insert-sig","toggle-editor","insert-response",!1),ref.triggerEvent("compose-encrypted",{active:!0}),$.isEmptyObject(ref.env.attachments)||("draft"==ref.env.compose_mode&&1==Object.keys(ref.env.attachments).length&&"encrypted.asc"==ref.env.attachments[Object.keys(ref.env.attachments)[0]].name||ref.alert_dialog(ref.get_label("encryptnoattachments")),$.each(ref.env.attachments,function(e,t){ref.remove_from_attachment_list(e)}))},function(e){console.error(e),console.log(t)}))},this.mailvelope_submit_messageform=function(a,r){var o=[],l=($.each(["to","cc","bcc"],function(e,t){for(var s,i=$('[name="_'+t+'"]').val().trim();i.length&&rcube_check_email(i,!0);)s=RegExp.$2.replace(/^<+/,"").replace(/>+$/,""),o.push(s),i=i.substr(i.indexOf(s)+s.length+1).replace(/^\s*,\s*/,"")}),0"+ref.get_label("searchpubkeyservers")+"

","encryptedsendialog",function(){ref.mailvelope_search_pubkeys(n,function(){return!0})},{button:"search"}),!1):l?(s=[],i=ref.env.identities[$("[name='_from'] option:selected").val()],$.each(ref.env.identities,function(e,t){s.push(t.email)}),void ref.mailvelope_keyring.validKeyForAddress(s).then(function(e){if(valid_sender=null,$.each(e,function(e,t){if(!1!==t&&(valid_sender=e)==i)return!1}),!valid_sender&&!confirm(ref.get_label("nopubkeyforsender")))return!1;o.push(valid_sender),ref.mailvelope_editor.encrypt(o).then(function(e){var t=ref.gui_objects.messageform,s=$("[name='_pgpmime']",t),i=ref.set_busy(!0,a||r?"savingmessage":"sendingmessage");t.target=ref.get_save_target(i),t._draft.value=a?"1":"",t.action=ref.add_url(t.action,"_unlock",i),t.action=ref.add_url(t.action,"_framed",1),r&&(t.action=ref.add_url(t.action,"_saveonly",1)),(s=s.length?s:$('').appendTo(t)).val(e),t.submit()},function(e){console.log(e)})},function(e){console.error(e)})):(o.length||ref.alert_dialog(ref.get_label("norecipientwarning"),function(){$("[name='_to']").focus()}),!1)},function(e){console.error(e)}),!1},this.mailvelope_display_container=function(t,e,s,i){function n(e){$(t+" > iframe").remove(),ref.hide_message(i),ref.display_message(e.message,"error")}mailvelope.createDisplayContainer(t,e,s,{senderAddress:this.env.sender}).then(function(e){if(e.error&&e.error.message)return n(e.error);ref.hide_message(i),$(t).children().not("iframe").hide(),$(ref.gui_objects.messagebody).addClass("mailvelope"),ref.env.pgp_mime_part&&$("#attach"+ref.env.pgp_mime_part).remove(),setTimeout(function(){$(window).resize()},10)},n)},this.mailvelope_search_pubkeys=function(e,t,s){var n=[],a=new PublicKey(this.env.keyservers),r=ref.display_message("","loading");$.each(e,function(e,s){var i=$.Deferred();a.search(s,function(e,t){null!==t?i.resolve([s]):i.resolve([s].concat(e))}),n.push(i)}),$.when.apply($,n).then(function(){var i=[],n=[];$.each(arguments,function(e,t){var s=t.shift();t.length?n=n.concat(t):i.push(s)}),ref.hide_message(r),t(!0),n.length&&ref.mailvelope_key_import_dialog(n,s),i.length&&ref.display_message(ref.get_label("nopubkeyfor").replace("$email",i.join(", ")),"warning")}).fail(function(){console.error("Pubkey lookup failed with",arguments),ref.hide_message(r),ref.display_message("pubkeysearcherror","error"),t(!1)})},this.mailvelope_key_import_dialog=function(e,a){var n=$("
").addClass("listing pgpkeyimport");$.each(e,function(e,t){var s=$("
").addClass("key"),i=(t.revoked&&s.addClass("revoked"),t.disabled&&s.addClass("disabled"),t.expired&&s.addClass("expired"),s.append($("