summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2014-02-27 12:11:47 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2014-02-27 12:11:47 (GMT)
commit1589c2c09283cb7721cc6e426113b07b1d163343 (patch)
treee8489c5a70d3a6628696d40887849e16c7c2b42c
downloadcom_zimbra_emaildownloader-1589c2c09283cb7721cc6e426113b07b1d163343.zip
com_zimbra_emaildownloader-1589c2c09283cb7721cc6e426113b07b1d163343.tar.gz
com_zimbra_emaildownloader-1589c2c09283cb7721cc6e426113b07b1d163343.tar.bz2
initial 'emaildownloader' zimlet
-rw-r--r--com_zimbra_emaildownloader.properties17
-rw-r--r--com_zimbra_emaildownloader.xml16
-rw-r--r--emaildownloader-icon.gifbin0 -> 104 bytes
-rw-r--r--emaildownloader.css6
-rw-r--r--emaildownloader.js99
5 files changed, 138 insertions, 0 deletions
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 @@
+<zimlet name="com_zimbra_emaildownloader" version="1.0" label="Downloader" description="Drag-n-Drop to download one or more Emails(.eml), Contacts(.vcf) or Appointments(.ics) to your computer">
+ <include>emaildownloader.js</include>
+ <includeCSS>emaildownloader.css</includeCSS>
+ <resource>emaildownloader-icon.gif</resource>
+ <handlerObject>com_zimbra_emaildownloader_HandlerObject</handlerObject>
+ <zimletPanelItem label="${msg.EmailDownloaderZimlet_panel_label}" icon="emaildownloader-panelIcon">
+ <toolTipText>${msg.EmailDownloader_panel_tooltip}</toolTipText>
+ <dragSource type="ZmConv" />
+ <dragSource type="ZmMailMsg"/>
+ <dragSource type="ZmContact" />
+ <dragSource type="ZmAppt" />
+
+ </zimletPanelItem>
+</zimlet>
+
+
diff --git a/emaildownloader-icon.gif b/emaildownloader-icon.gif
new file mode 100644
index 0000000..d167540
--- /dev/null
+++ b/emaildownloader-icon.gif
Binary files 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