D:/develop/v65/clients/outlook/install/output/export/funambol/clients/outlook/Addin/addin.h

00001 /*
00002  * Funambol is a mobile platform developed by Funambol, Inc. 
00003  * Copyright (C) 2003 - 2007 Funambol, Inc.
00004  * 
00005  * This program is free software; you can redistribute it and/or modify it under
00006  * the terms of the GNU Affero General Public License version 3 as published by
00007  * the Free Software Foundation with the addition of the following permission 
00008  * added to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED
00009  * WORK IN WHICH THE COPYRIGHT IS OWNED BY FUNAMBOL, FUNAMBOL DISCLAIMS THE 
00010  * WARRANTY OF NON INFRINGEMENT  OF THIRD PARTY RIGHTS.
00011  * 
00012  * This program is distributed in the hope that it will be useful, but WITHOUT
00013  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00014  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00015  * details.
00016  * 
00017  * You should have received a copy of the GNU Affero General Public License 
00018  * along with this program; if not, see http://www.gnu.org/licenses or write to
00019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00020  * MA 02110-1301 USA.
00021  * 
00022  * You can contact Funambol, Inc. headquarters at 643 Bair Island Road, Suite 
00023  * 305, Redwood City, CA 94063, USA, or at email address info@funambol.com.
00024  * 
00025  * The interactive user interfaces in modified source and object code versions
00026  * of this program must display Appropriate Legal Notices, as required under
00027  * Section 5 of the GNU Affero General Public License version 3.
00028  * 
00029  * In accordance with Section 7(b) of the GNU Affero General Public License
00030  * version 3, these Appropriate Legal Notices must retain the display of the
00031  * "Powered by Funambol" logo. If the display of the logo is not reasonably 
00032  * feasible for technical reasons, the Appropriate Legal Notices must display
00033  * the words "Powered by Funambol".
00034  */
00035 
00036 
00037 
00038 #ifndef __ADDIN_H_
00039 #define __ADDIN_H_
00040 
00041 #include "resource.h"      // main symbols
00042 
00043 // ----------------------- definitions -------------------------------
00044 #define PROGRAM_NAME                        "Funambol Outlook Plug-in"
00045 #define PROGRAM_NAME_EXE                    "OutlookPlugin.exe"             // The application to run
00046 #define PLUGIN_UI_TITLE                     "Funambol Outlook Plug-in"      // The UI windows title (must be unique!)
00047 #define PLUGIN_UI_CLASSNAME                 "FunambolApp"                   // The UI windows classname
00048 #define FUN                                 "FUN"
00049 #define PARAM_OUTLOOK_SYNC                  "sync"                          // The command-line parameter passed to PROGRAM_NAME_EXE application
00050                                                                             // It's used to start automatically the sync.
00051 #define PARAM_OUTLOOK_OPTIONS               "options"                       // It's used to open automatically the options dialog.
00052 
00053 
00054 #define FUNAMBOL                           L"Funa&mbol"
00055 #define CAPTION                            L"Funambol Outlook Plug-in"
00056 #define BUTTON_SYNCHRONIZE                 L"&Sync All        Ctrl+S"
00057 #define BUTTON_GOTO_PLUGIN                 L"&Go to...        Ctrl+G"
00058 #define BUTTON_CONFIGURATION               L"Op&tions...     Ctrl+T"
00059 #define TOOLTIP                            L"Sync All"
00060 
00061 
00062 //
00063 // Win registry keys:
00064 // ------------------
00065 // HKLM keys -> general (read only) settings
00066 // HKCU keys -> current user settings
00067 //
00068 //                                          // The path in win registry to store Addin state (installed-installing...)
00069 #define ADDIN_CONTEXT                       "Microsoft/Office/Outlook/Addins/FunambolAddin.Addin"
00070                                             // The path in win registry for plugin settings
00071 #define PLUGIN_CONTEXT                      "Funambol/OutlookClient"
00072 #define PROPERTY_STATE                      "State"                     // The state of addin
00073 #define PROPERTY_PATH                       "installDir"                // The path of application
00074 #define PROPERTY_NUM_INSTANCES              "numInstances"              // #instances of Addin for different users
00075 #define PROPERTY_SW_VERSION                 "swv"                       // Software version
00076 
00077                                                                         // **** change this value when addin need to be reinstalled ****
00078 #define LAST_COMPATIBLE_VERSION             60011                       // "6.0.11" is the latest version compatible with this addin
00079                                                                         // *************************************************************
00080 
00081 // Possible addin states:
00082 #define ADDIN_STATE_OK                      "ok"
00083 #define ADDIN_STATE_INSTALLING              "installing"
00084 #define ADDIN_STATE_IN_PROGRESS             "in progress"
00085 #define ADDIN_STATE_FAILED                  "failed"
00086 #define ADDIN_STATE_UNINSTALLED             "uninstalled"
00087 
00088 
00089 #define LOG_FILENAME                        "FunambolAddin.log"
00090 #define LOG_DEFAULT_PATH                    "C:"                // Normally not used, see openlog()
00091 #define TEMP_ENV                            "TEMP"
00092 #define MAX_LOG_SIZE                        1000000                     // 1 MB
00093 
00094 // Still used to remove Sync4j menu that could be left for error...
00095 #define AMP_SYNC4J                         L"&Sync4j"
00096 #define CAPTION_S4J                        L"Sync4j Outlook Client"
00097 
00098 
00099 // Error messages:
00100 #define ERR_OPEN_EXPLORER                   "Error opening Outlook UI."
00101 #define ERR_COM_POINTER                     "COM Pointer Error. Code = %08lx: %ls"
00102 #define ERR_OPEN_APPLICATION                "Error opening Outlook application."
00103 #define ERR_GET_COMMANDBARS                 "Error getting CommandBars."
00104 #define ERR_UNREG_DLL                       "Could not unregister Addin DLL."
00105 #define ERR_ADD_NEW_MENUBAR                 "Error adding a new MenuBar."
00106 #define ERR_ADD_NEW_COMMANDBAR              "Error adding a new CommandBar."
00107 #define ERR_GET_COMMANDBAR                  "Error getting CommandBar."
00108 #define ERR_GET_MENUBAR                     "Error getting MenuBar."
00109 #define ERR_ADD_BUTTON1                     "Error adding first Button."
00110 #define ERR_ADD_BUTTON2                     "Error adding second Button."
00111 #define ERR_ADD_BUTTON3                     "Error adding third Button."
00112 #define ERR_LINK_ICON                       "Error linking Commandbar icon Button."
00113 #define ERR_LINK_BUTTON1                    "Error inking Menubar first Button."
00114 #define ERR_LINK_BUTTON2                    "Error inking Menubar second Button."
00115 #define ERR_LINK_BUTTON3                    "Error inking Menubar third Button."
00116 #define ERR_UNLINK_ICON                     "Error un-linking Commandbar icon Button."
00117 #define ERR_UNLINK_BUTTON1                  "Error un-inking Menubar first Button."
00118 #define ERR_UNLINK_BUTTON2                  "Error un-inking Menubar second Button."
00119 #define ERR_UNLINK_BUTTON3                  "Error un-inking Menubar third Button."
00120 #define ERR_REMOVING_ADDIN                  "Error occurred removing Addin from Outlook."
00121 #define ERR_INSTALL_DIR_KEY                 "Could not retrieve path of %s under reg key %s/%s."
00122 
00123 #define ERR_CODE_BAD_POINTER                0x80004003
00124 
00125 
00126 
00127 // -----------------------------------------------------------------
00128 
00129 extern _ATL_FUNC_INFO OnClickButtonInfo;
00130 extern _ATL_FUNC_INFO OnClickSynchronizationInfo;
00131 extern _ATL_FUNC_INFO OnClickGotoInfo;
00132 extern _ATL_FUNC_INFO OnClickConfigurationInfo;
00133 
00134 static void toWindows(char* str);
00135 
00136 
00137 //
00138 // ------------------------------- Caddin class --------------------------------------------
00139 //
00140 class ATL_NO_VTABLE Caddin : public CComObjectRootEx<CComSingleThreadModel>,
00141                              public CComCoClass<Caddin, &CLSID_addin>,
00142                              public ISupportErrorInfo,
00143                              public IDispatchImpl<Iaddin, &IID_Iaddin, &LIBID_FUNAMBOLADDINLib>,
00144                              public IDispatchImpl<_IDTExtensibility2, &IID__IDTExtensibility2, &LIBID_AddInDesignerObjects>,
00145                              public IDispEventSimpleImpl<1,Caddin,&__uuidof(_CommandBarButtonEvents)>,
00146                              public IDispEventSimpleImpl<2,Caddin,&__uuidof(_CommandBarButtonEvents)>,
00147                              public IDispEventSimpleImpl<3,Caddin,&__uuidof(_CommandBarButtonEvents)>,
00148                              public IDispEventSimpleImpl<4,Caddin,&__uuidof(_CommandBarButtonEvents)>
00149 {
00150 
00151 public:
00152 
00153     typedef IDispEventSimpleImpl</*nID =*/ 1,Caddin, &__uuidof(_CommandBarButtonEvents)> ButtonSyncEvent;
00154     typedef IDispEventSimpleImpl</*nID =*/ 2,Caddin, &__uuidof(_CommandBarButtonEvents)> ItemSynchronizationEvent;
00155     typedef IDispEventSimpleImpl</*nID =*/ 3,Caddin, &__uuidof(_CommandBarButtonEvents)> ItemGotoEvent;
00156     typedef IDispEventSimpleImpl</*nID =*/ 4,Caddin, &__uuidof(_CommandBarButtonEvents)> ItemConfigurationEvent;
00157 
00158     Caddin(){}
00159 
00160     DECLARE_REGISTRY_RESOURCEID(IDR_ADDIN)
00161     DECLARE_PROTECT_FINAL_CONSTRUCT()
00162 
00163     BEGIN_COM_MAP(Caddin)
00164         COM_INTERFACE_ENTRY(Iaddin)
00165         //DEL   COM_INTERFACE_ENTRY(IDispatch)
00166         COM_INTERFACE_ENTRY(ISupportErrorInfo)
00167         COM_INTERFACE_ENTRY2(IDispatch, Iaddin)
00168         COM_INTERFACE_ENTRY(_IDTExtensibility2)
00169     END_COM_MAP()
00170 
00171     BEGIN_SINK_MAP(Caddin)
00172         SINK_ENTRY_INFO(1, __uuidof(_CommandBarButtonEvents),/*dispid*/ 0x01, OnClickButton,          &OnClickButtonInfo)
00173         SINK_ENTRY_INFO(2, __uuidof(_CommandBarButtonEvents),/*dispid*/ 0x01, OnClickSynchronization, &OnClickSynchronizationInfo)
00174         SINK_ENTRY_INFO(3, __uuidof(_CommandBarButtonEvents),/*dispid*/ 0x01, OnClickGoto,            &OnClickGotoInfo)
00175         SINK_ENTRY_INFO(4, __uuidof(_CommandBarButtonEvents),/*dispid*/ 0x01, OnClickConfiguration,   &OnClickConfigurationInfo)
00176     END_SINK_MAP()
00177 
00178     // ISupportsErrorInfo
00179     STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00180 
00181     // Iaddin
00182     void __stdcall OnClickButton         (IDispatch* /*Office::_CommandBarButton**/ Ctrl,VARIANT_BOOL * CancelDefault);
00183     void __stdcall OnClickSynchronization(IDispatch* /*Office::_CommandBarButton**/ Ctrl,VARIANT_BOOL * CancelDefault);
00184     void __stdcall OnClickGoto           (IDispatch* /*Office::_CommandBarButton**/ Ctrl,VARIANT_BOOL * CancelDefault);
00185     void __stdcall OnClickConfiguration  (IDispatch* /*Office::_CommandBarButton**/ Ctrl,VARIANT_BOOL * CancelDefault);
00186 
00187 
00188 public:
00189 
00190     // _IDTExtensibility2
00191     STDMETHOD(OnConnection)     (IDispatch* Application, ext_ConnectMode ConnectMode, IDispatch* AddInInst, SAFEARRAY** custom);
00192     STDMETHOD(OnDisconnection)  (ext_DisconnectMode RemoveMode, SAFEARRAY** custom);
00193     STDMETHOD(OnStartupComplete)(SAFEARRAY** custom);
00194     STDMETHOD(OnBeginShutdown)  (SAFEARRAY** custom);
00195     STDMETHOD(OnAddInsUpdate)   (SAFEARRAY** custom){ return E_NOTIMPL; }
00196 
00197     HRESULT AddNewMenubar   (_CommandBars *pCmdBars);
00198     HRESULT AddNewCommandBar(_CommandBars *pCmdBars);
00199 
00200     HRESULT __stdcall Caddin::DispAdviseControls  (void);
00201     HRESULT __stdcall Caddin::DispUnadviseControls(void);
00202 
00203     void  launchSyncClientOutlook  (const char* parameter);
00204     char* readPropertyValueFromHKLM(const char* context, const char* prop);
00205     int   setCurrentSwv();
00206     char* readAddinSwv();
00207     bool  swvNotCompatible(const char* currentVersion, const char* oldVersion);
00208 
00209     HRESULT removeAddin();
00210     bool    isAddinInstalled();
00211 
00212     int     saveAddinState(char* state);
00213     bool    checkErrorsLastTime();
00214     void    errorMsgBox();
00215     void    openLog();
00216     void    manageComErrors(_com_error &e);
00217 
00218     bool    isLastInstance();
00219     void    updateAddinInstances(bool increment);
00220 
00221 
00222 private:
00223     LPDISPATCH      m_pParentApp;
00224     _ApplicationPtr applicationPtr;
00225 
00226 };
00227 
00228 #endif //__ADDIN_H_

Generated on Mon Feb 4 09:50:49 2008 for Funambol Outlook Plug-in Library by  doxygen 1.5.2