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