Results 1 to 3 of 3

Thread: trying to create zimbra desktop mapi.dll

  1. #1
    Join Date
    Jun 2009
    Posts
    6
    Rep Power
    6

    Default 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

  2. #2
    Join Date
    Jun 2009
    Posts
    6
    Rep Power
    6

    Default

    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

  3. #3
    Join Date
    Jun 2009
    Posts
    6
    Rep Power
    6

    Default

    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.

Similar Threads

  1. [SOLVED] Important Mta Issue!!!!!!!!
    By borngunners in forum Migration
    Replies: 2
    Last Post: 01-05-2010, 05:44 AM
  2. [SOLVED] parts_decode_ext error
    By jsabater in forum Administrators
    Replies: 7
    Last Post: 10-13-2008, 07:24 AM
  3. Zimbra spam system
    By rajahd in forum Administrators
    Replies: 9
    Last Post: 04-16-2008, 07:25 PM
  4. Fedora Core 3, Clean Install - Not working!
    By pcjackson in forum Installation
    Replies: 17
    Last Post: 03-05-2006, 06:38 PM
  5. Mail logs
    By Rick Baker in forum Installation
    Replies: 8
    Last Post: 01-17-2006, 03:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •