| Welcome to the Zimbra :: Forums! | |
Welcome, if you would like to post a comment please register.
We also encourage you to explore all things Zimbra with our team and members of the community.
|  | 
02-17-2010, 11:15 PM
| | | trying to create zimbra desktop mapi.dll for Office->File->SendTo function old problem
[Open|Micro]Office->File->SendTo => composing new mail window with file uploaded
To handle this we need our own mapi.dll, like thunderdird have.
Idea is to use thunderbird source, and link functions to Zimbra Desktop(v1.0.4)
Problem - i can't choose how to interact with ZD. Two ways is obvious:
modify ZD source, to implement some sort of cli argument, or create some Zimlet, and work with browser(prism) URL address from OS.
Zimlet is less intrusive, so it look more preferred. So it will be
Office->Mapi.dll->prism(with custom URL)->zimlet(read custom url)->UploadFile_to_composing_form
Does that way seems possible?
How custom URL(i think it named TAGs?) is processed? ZimbraTagLib is responsible for that?
Trying to figure out fileUpload mechanism from Drag'n'Drop Zimlet, but can't figure out where it get file path.
Last edited by sady; 02-19-2010 at 07:04 AM..
Reason: not obvious title
| 
02-19-2010, 07:03 AM
| | | so....
DnD zimlet create hidden upload "input"(for file name) field and hidden "Upload" button.
Then firefox DnD extension find that hidden input field, and when you drop file on page (if that page have that field), put "file:///home/user/..../file.txt" string in "input" field, and then press hidden "Upload" button, which trigger Zimlet DnD. js class, which trigger AjxPost class, which make firefox POST method on address "http://server.com/servicel/upload?fmt=extended" with that files data, and then "Compose" form is redraw.
I going to rewrite dnd firefox extension, to trigger page open event, instead the "drop" event, then parse customized url, with file name in it(like "http://server.com/?view=compose&uploadFile=file:///home/user/.../file.txt") then search "uploadFile" field in url, and do same thing, as dnd firefox extension usually do.
Then i need to call from Windows OS Zimbra Desktop prism, with that customized url.
I'm lame in web programming, if you have ideas how to do this tack better, please, post reply  | 
04-16-2010, 08:58 AM
| | | almost solved.
Two elements was created -
1) Firefox(prism) extension. http://sadys.narod2.ru/Soft/ZimbraSendTo.xpi
It read command line argument "-sendfile". When that argument gettet extension search on page "New mail" button, press it, and add file by DnDzimlet mechanism
2) VisualBasic macros.
Which is save current document in temp dir, and pass that file name to "...\zdclient.exe -sendfile <...>" command
Bugs:
- can send file only if your ZimbraDesktop already started. If no zdclient.exe process currently active there will be no "New mail" button to find by extension (nothing happen)
- can create new mail only if user currently on "Mail" tab. If he\she view Calendar or Contacts - nothing happen (same reason - can't find button on page).
- you need to update zdclient.exe location in VBS for each installation manualy
Extension (javascript)
Sorry, it testing version, so it's dirty Code: const STATE_START = Components.interfaces.nsIWebProgress.STATE_START;
const STATE_STOP = Components.interfaces.nsIWebProgress.STATE_STOP;
window.addEventListener("load", function(e) {
var timeOnce = window.setTimeout("myRegister()",70000);
},
false );
window.addEventListener("unload",function() {
browser.removeProgressListener(myListener, STATE_START);
},
false );
function myRegister() {
Components.utils.reportError("Registration!");
};
function mySendFile(testfile) {
//initMouseEvent( 'type', bubbles, cancelable, windowObject, detail, screenX, screenY, clientX, clientY, ctrlKey, altKey, shiftKey, metaKey, button, relatedTarget )
var btn = content.document.getElementById('zb__CLV__NEW_MENU');
var evObj = document.createEvent('MouseEvents');
evObj.initMouseEvent( 'mousedown', true, true, window, 1, 217, 207, 214, 90, false, false, false, false, 0, null );
btn.dispatchEvent(evObj)
evObj.initMouseEvent( 'mouseup', true, true, window, 1, 217, 207, 214, 90, false, false, false, false, 0, null );
btn.dispatchEvent(evObj)
//evObj.initMouseEvent( 'click', true, true, window, 1, 217, 207, 214, 90, false, false, false, false, 0, null );
//evObj.initMouseEvent( 'click', true, true, window, 1, 12, 345, 7, 220, false, false, true, false, 0, null );
//btn.dispatchEvent(evObj)
//Components.utils.reportError();
/*//var testfile = "C:\\sadytest.xpi";
Components.utils.reportError("1");
var myTestCompon = Components. classes ['@mozilla.org/commandlinehandler/general-startup;1?type=sadytest']. getService();
Components.utils.reportError("2");
var myFile = myTestCompon.getFileName();
Components.utils.reportError("3");
Components.utils.reportError(testfile);
*/
// try {
var inputName = "_attFile_";
var inputSize = 50;
var ownDoc = content.document;
var ulEle = ownDoc.getElementById('zdnd_ul');
ulEle.innerHTML = '';
// if (files.length > 0) {
// for (var i = 0; i < files.length; i++) {
var li = ulEle.ownerDocument.createElement('LI');
var input = ulEle.ownerDocument.createElement('INPUT');
input.type = 'file';
input.name = inputName;
input.size = inputSize;
//input.value = files[i];
input.value = testfile;
li.appendChild(input);
ulEle.appendChild(li);
// }
/* } catch (e) {
alert("catch");
}
*/
zUploadService.uploadFiles(ownDoc.getElementById("zDnDBut"));
}
function CommandLineObserver() {
this.register();
}
CommandLineObserver.prototype = {
observe: function(aSubject, aTopic, aData) {
//Components.utils.reportError("Debug me!");
var cmdLine = aSubject.QueryInterface(Components.interfaces.nsICommandLine);
var myfilename = cmdLine.handleFlagWithParam("sendfile", false);
if (myfilename)
{
mySendFile(myfilename);
cmdLine.preventDefault = true;
}
},
register: function() {
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.addObserver(this, "commandline-args-changed", false);
},
unregister: function() {
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.removeObserver(this, "commandline-args-changed");
}
}
var observer = new CommandLineObserver();
// Because we haven't yet registered a CommandLineObserver when the application is
// launched the first time, we simulate a notification here.
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.notifyObservers(window.arguments[0], "commandline-args-changed", null);
addEventListener("unload", observer.unregister, false); Extension component(witch listen for cli args update) Code: const nsISupports = Components.interfaces.nsISupports;
const nsICategoryManager = Components.interfaces.nsICategoryManager;
const nsIComponentRegistrar = Components.interfaces.nsIComponentRegistrar;
const nsICommandLine = Components.interfaces.nsICommandLine;
const nsICommandLineHandler = Components.interfaces.nsICommandLineHandler;
const nsIFactory = Components.interfaces.nsIFactory;
const nsIModule = Components.interfaces.nsIModule;
const nsIWindowWatcher = Components.interfaces.nsIWindowWatcher;
// CHANGEME: change the contract id, CID, and category to be unique
// to your application.
const clh_contractID = "@mozilla.org/commandlinehandler/general-startup;1?type=sadytest";
const clh_CID = Components.ID("{f0699fa5-0ec3-4cd3-9775-34cadb5f9223}");
// category names are sorted alphabetically. Typical command-line handlers use a
// category that begins with the letter "m".
const clh_category = "m-sadytest";
/**
* Utility functions
*/
/**
* Opens a chrome window.
* @param aChromeURISpec a string specifying the URI of the window to open.
* @param aArgument an argument to pass to the window (may be null)
*/
/**
* The XPCOM component that implements nsICommandLineHandler.
* It also implements nsIFactory to serve as its own singleton factory.
*/
const sadytestHandler = {
/* nsISupports */
QueryInterface : function clh_QI(iid)
{
if (iid.equals(nsICommandLineHandler) ||
iid.equals(nsIFactory) ||
iid.equals(nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
},
/* nsICommandLineHandler */
//handle : function clh_handle(cmdLine)
handle : function (cmdLine)
{
var observerService = Components.classes["@mozilla.org/observer-service;1"]
.getService(Components.interfaces.nsIObserverService);
observerService.notifyObservers(cmdLine, "commandline-args-changed", null);
},
// CHANGEME: change the help info as appropriate, but
// follow the guidelines in nsICommandLineHandler.idl
// specifically, flag descriptions should start at
// character 24, and lines should be wrapped at
// 72 characters with embedded newlines,
// and finally, the string should end with a newline
helpInfo : " -sendfile <file> Open Compose Window " +
" with file attached\n",
/* nsIFactory */
//createInstance : function clh_CI(outer, iid)
createInstance : function (outer, iid)
{
if (outer != null)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return this.QueryInterface(iid);
},
lockFactory : function clh_lock(lock)
{
/* no-op */
}
};
/**
* The XPCOM glue that implements nsIModule
*/
const sadytestHandlerModule = {
/* nsISupports */
//QueryInterface : function mod_QI(iid)
QueryInterface : function (iid)
{
if (iid.equals(nsIModule) ||
iid.equals(nsISupports))
return this;
throw Components.results.NS_ERROR_NO_INTERFACE;
},
/* nsIModule */
//getClassObject : function mod_gch(compMgr, cid, iid)
getClassObject : function (compMgr, cid, iid)
{
if (cid.equals(clh_CID))
return sadytestHandler.QueryInterface(iid);
throw Components.results.NS_ERROR_NOT_REGISTERED;
},
registerSelf : function mod_regself(compMgr, fileSpec, location, type)
{
compMgr.QueryInterface(nsIComponentRegistrar);
compMgr.registerFactoryLocation(clh_CID,
"sadytestHandler",
clh_contractID,
fileSpec,
location,
type);
var catMan = Components.classes["@mozilla.org/categorymanager;1"].
getService(nsICategoryManager);
catMan.addCategoryEntry("command-line-handler",
clh_category,
clh_contractID, true, true);
},
unregisterSelf : function mod_unreg(compMgr, location, type)
{
compMgr.QueryInterface(nsIComponentRegistrar);
compMgr.unregisterFactoryLocation(clh_CID, location);
var catMan = Components.classes["@mozilla.org/categorymanager;1"].
getService(nsICategoryManager);
catMan.deleteCategoryEntry("command-line-handler", clh_category);
},
canUnload : function (compMgr)
{
return true;
}
};
/* The NSGetModule function is the magic entry point that XPCOM uses to find what XPCOM objects
* this component provides
*/
function NSGetModule(comMgr, fileSpec)
{
return sadytestHandlerModule;
} Visual Basic Code: Sub Makro1()
Dim directory As String
Dim ZimbraPath As String
ZimbraPath = "C:\Zimbra\win32\prism\zdclient.exe"
directory = Environ$("TEMP")
ChangeFileOpenDirectory _
directory
ActiveDocument.SaveAs FileName:=ActiveDocument.Name, FileFormat:=wdFormatDocument, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
' MsgBox (ActiveDocument.Path & "\" & ActiveDocument.Name)
Shell (ZimbraPath & " -sendfile " & """" & directory & "\" _
& ActiveDocument.Name & """")
End Sub
Last edited by sady; 04-16-2010 at 09:24 AM..
| | Thread Tools | Search this Thread | | | | | Display Modes | Linear Mode | | Why Join? Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.  |