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

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

Generated on Fri Nov 9 12:21:26 2007 for Funambol Outlook Plug-in Library by  doxygen 1.5.2