commit 1589c2c09283cb7721cc6e426113b07b1d163343 Author: Frédéric Péters Date: Thu Feb 27 13:11:47 2014 +0100 initial 'emaildownloader' zimlet diff --git a/com_zimbra_emaildownloader.properties b/com_zimbra_emaildownloader.properties new file mode 100644 index 0000000..5914604 --- /dev/null +++ b/com_zimbra_emaildownloader.properties @@ -0,0 +1,17 @@ +# +# ***** BEGIN LICENSE BLOCK ***** +# Zimbra Collaboration Suite Web Client +# Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Zimbra, Inc. +# +# The contents of this file are subject to the Zimbra Public License +# Version 1.3 ("License"); you may not use this file except in +# compliance with the License. You may obtain a copy of the License at +# http://www.zimbra.com/license. +# +# Software distributed under the License is distributed on an "AS IS" +# basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. +# ***** END LICENSE BLOCK ***** + +EmailDownloaderZimlet_panel_label = Downloader +EmailDownloader_panel_tooltip = Drag-n-Drop to download one or more Emails(.eml), Contacts(.vcf) or Appointments(.ics) to your computer + diff --git a/com_zimbra_emaildownloader.xml b/com_zimbra_emaildownloader.xml new file mode 100644 index 0000000..009385b --- /dev/null +++ b/com_zimbra_emaildownloader.xml @@ -0,0 +1,16 @@ + + emaildownloader.js + emaildownloader.css + emaildownloader-icon.gif + com_zimbra_emaildownloader_HandlerObject + + ${msg.EmailDownloader_panel_tooltip} + + + + + + + + + diff --git a/emaildownloader-icon.gif b/emaildownloader-icon.gif new file mode 100644 index 0000000..d167540 Binary files /dev/null and b/emaildownloader-icon.gif differ diff --git a/emaildownloader.css b/emaildownloader.css new file mode 100644 index 0000000..b3c3a6d --- /dev/null +++ b/emaildownloader.css @@ -0,0 +1,6 @@ +.Imgemaildownloader-panelIcon { + background: url("emaildownloader-icon.gif") no-repeat 0 0; + width: 16px; + height: 16px; + overflow: hidden; +} \ No newline at end of file diff --git a/emaildownloader.js b/emaildownloader.js new file mode 100644 index 0000000..634b1f0 --- /dev/null +++ b/emaildownloader.js @@ -0,0 +1,99 @@ +/* + * ***** BEGIN LICENSE BLOCK ***** + * Zimbra Collaboration Suite Zimlets + * Copyright (C) 2009, 2010 Zimbra, Inc. + * + * The contents of this file are subject to the Zimbra Public License + * Version 1.3 ("License"); you may not use this file except in + * compliance with the License. You may obtain a copy of the License at + * http://www.zimbra.com/license. + * + * Software distributed under the License is distributed on an "AS IS" + * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. + * ***** END LICENSE BLOCK ***** + */ + +/** + * Allows downloading a single email message. + * + * @author Raja Rao DV + */ +function com_zimbra_emaildownloader_HandlerObject() { +} + +com_zimbra_emaildownloader_HandlerObject.prototype = new ZmZimletBase(); +com_zimbra_emaildownloader_HandlerObject.prototype.constructor = com_zimbra_emaildownloader_HandlerObject; + +/** + * Simplify handler object + * + */ +var EmailDownloaderZimlet = com_zimbra_emaildownloader_HandlerObject; + +/** + * Called by the framework on an droppedItem drop. + * + * @param {ZmConv|ZmMailMsg} droppedItem the dropped message object + */ +EmailDownloaderZimlet.prototype.doDrop = +function(droppedItem) { + var ids = []; + var msgObjs = []; + var fmt = "zip"; + if(droppedItem instanceof Array) { + for(var i =0; i < droppedItem.length; i++) { + var obj = droppedItem[i].srcObj ? droppedItem[i].srcObj : droppedItem[i]; + if(obj.type == "CONV") { + ids = ids.concat(this._getMsgIdsFromConv(obj)); + } else if(obj.type == "MSG") { + ids.push(obj.id); + } else if(obj.TYPE == "ZmContact") { + ids.push(obj.id); + } else if(obj.TYPE == "ZmAppt" || obj.type == "APPT") { + ids.push(obj.id); + } + } + } else { + var obj = droppedItem.srcObj ? droppedItem.srcObj : droppedItem; + if (obj.type == "CONV"){ + ids = this._getMsgIdsFromConv(obj); + } else if(obj.type == "MSG") { + ids.push(obj.id); + } else if(obj.TYPE == "ZmContact") { + ids.push(obj.id); + fmt = "vcf"; + } else if(obj.TYPE == "ZmAppt" || obj.type == "APPT") { + ids.push(obj.id); + fmt = "ics"; + } + } + + var url = []; + var i = 0; + var proto = location.protocol; + var port = Number(location.port); + url[i++] = proto; + url[i++] = "//"; + url[i++] = location.hostname; + if (port && ((proto == ZmSetting.PROTO_HTTP && port != ZmSetting.HTTP_DEFAULT_PORT) + || (proto == ZmSetting.PROTO_HTTPS && port != ZmSetting.HTTPS_DEFAULT_PORT))) { + url[i++] = ":"; + url[i++] = port; + } + url[i++] = "/home/"; + url[i++]= AjxStringUtil.urlComponentEncode(appCtxt.getActiveAccount().name); + url[i++] = "/?fmt="; + url[i++] = fmt; + url[i++] = "&list="; + url[i++] = ids.join(","); + url[i++] = "&filename=ZimbraItems"; + + var getUrl = url.join(""); + window.open(getUrl, "_blank"); +}; + +EmailDownloaderZimlet.prototype._getMsgIdsFromConv = +function(convSrcObj) { + convSrcObj.load(); + return convSrcObj.msgIds; +}; \ No newline at end of file