00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef __ADDIN_H_
00039 #define __ADDIN_H_
00040
00041 #include "resource.h"
00042 #include "customization.h"
00043
00044
00045 #define PROGRAM_NAME_EXE "OutlookPlugin.exe" // The application to run
00046 #define PLUGIN_UI_CLASSNAME "FunambolApp" // The UI windows classname
00047 #define FUN "FUN"
00048 #define PARAM_OUTLOOK_SYNC "sync" // The command-line parameter passed to PROGRAM_NAME_EXE application
00049
00050 #define PARAM_OUTLOOK_OPTIONS "options" // It's used to open automatically the options dialog.
00051
00052
00053 #define BUTTON_SYNCHRONIZE L"&Sync All Ctrl+F7"
00054 #define BUTTON_GOTO_PLUGIN L"&Go to... Ctrl+F8"
00055 #define BUTTON_CONFIGURATION L"Op&tions... Ctrl+F9"
00056 #define TOOLTIP L"Sync All"
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066 #define ADDIN_CONTEXT "Microsoft/Office/Outlook/Addins/FunambolAddin.Addin"
00067
00068 #define PLUGIN_CONTEXT "Funambol/OutlookClient"
00069 #define PROPERTY_STATE "State" // The state of addin
00070 #define PROPERTY_PATH "installDir" // The path of application
00071 #define PROPERTY_NUM_INSTANCES "numInstances" // #instances of Addin for different users
00072 #define PROPERTY_SW_VERSION "swv" // Software version
00073
00074
00075 #define LAST_COMPATIBLE_VERSION 70104 // "7.1.4" is the latest version compatible with this addin
00076
00077
00078
00079 #define ADDIN_STATE_OK "ok"
00080 #define ADDIN_STATE_INSTALLING "installing"
00081 #define ADDIN_STATE_IN_PROGRESS "in progress"
00082 #define ADDIN_STATE_FAILED "failed"
00083 #define ADDIN_STATE_UNINSTALLED "uninstalled"
00084
00085
00086 #define LOG_FILENAME "FunambolAddin.log"
00087 #define LOG_DEFAULT_PATH "C:" // Normally not used, see openlog()
00088 #define TEMP_ENV "TEMP"
00089 #define MAX_LOG_SIZE 1000000 // 1 MB
00090
00091
00092 #define AMP_SYNC4J L"&Sync4j"
00093 #define CAPTION_S4J L"Sync4j Outlook Client"
00094
00095
00096
00097 #define ERR_OPEN_EXPLORER "Error opening Outlook UI."
00098 #define ERR_COM_POINTER "COM Pointer Error. Code = %08lx: %ls"
00099 #define ERR_OPEN_APPLICATION "Error opening Outlook application."
00100 #define ERR_GET_COMMANDBARS "Error getting CommandBars."
00101 #define ERR_UNREG_DLL "Could not unregister Addin DLL."
00102 #define ERR_ADD_NEW_MENUBAR "Error adding a new MenuBar."
00103 #define ERR_ADD_NEW_COMMANDBAR "Error adding a new CommandBar."
00104 #define ERR_GET_COMMANDBAR "Error getting CommandBar."
00105 #define ERR_GET_MENUBAR "Error getting MenuBar."
00106 #define ERR_ADD_BUTTON1 "Error adding first Button."
00107 #define ERR_ADD_BUTTON2 "Error adding second Button."
00108 #define ERR_ADD_BUTTON3 "Error adding third Button."
00109 #define ERR_LINK_ICON "Error linking Commandbar icon Button."
00110 #define ERR_LINK_BUTTON1 "Error inking Menubar first Button."
00111 #define ERR_LINK_BUTTON2 "Error inking Menubar second Button."
00112 #define ERR_LINK_BUTTON3 "Error inking Menubar third Button."
00113 #define ERR_UNLINK_ICON "Error un-linking Commandbar icon Button."
00114 #define ERR_UNLINK_BUTTON1 "Error un-inking Menubar first Button."
00115 #define ERR_UNLINK_BUTTON2 "Error un-inking Menubar second Button."
00116 #define ERR_UNLINK_BUTTON3 "Error un-inking Menubar third Button."
00117 #define ERR_REMOVING_ADDIN "Error occurred removing Addin from Outlook."
00118 #define ERR_INSTALL_DIR_KEY "Could not retrieve path of %s under reg key %s/%s."
00119
00120 #define ERR_CODE_BAD_POINTER 0x80004003
00121
00122
00123
00124
00125
00126 extern _ATL_FUNC_INFO OnClickButtonInfo;
00127 extern _ATL_FUNC_INFO OnClickSynchronizationInfo;
00128 extern _ATL_FUNC_INFO OnClickGotoInfo;
00129 extern _ATL_FUNC_INFO OnClickConfigurationInfo;
00130
00131 static void toWindows(char* str);
00132
00133
00134
00135
00136
00137 class ATL_NO_VTABLE Caddin : public CComObjectRootEx<CComSingleThreadModel>,
00138 public CComCoClass<Caddin, &CLSID_addin>,
00139 public ISupportErrorInfo,
00140 public IDispatchImpl<Iaddin, &IID_Iaddin, &LIBID_FUNAMBOLADDINLib>,
00141 public IDispatchImpl<_IDTExtensibility2, &IID__IDTExtensibility2, &LIBID_AddInDesignerObjects>,
00142 public IDispEventSimpleImpl<1,Caddin,&__uuidof(_CommandBarButtonEvents)>,
00143 public IDispEventSimpleImpl<2,Caddin,&__uuidof(_CommandBarButtonEvents)>,
00144 public IDispEventSimpleImpl<3,Caddin,&__uuidof(_CommandBarButtonEvents)>,
00145 public IDispEventSimpleImpl<4,Caddin,&__uuidof(_CommandBarButtonEvents)>
00146 {
00147
00148 public:
00149
00150 typedef IDispEventSimpleImpl< 1,Caddin, &__uuidof(_CommandBarButtonEvents)> ButtonSyncEvent;
00151 typedef IDispEventSimpleImpl< 2,Caddin, &__uuidof(_CommandBarButtonEvents)> ItemSynchronizationEvent;
00152 typedef IDispEventSimpleImpl< 3,Caddin, &__uuidof(_CommandBarButtonEvents)> ItemGotoEvent;
00153 typedef IDispEventSimpleImpl< 4,Caddin, &__uuidof(_CommandBarButtonEvents)> ItemConfigurationEvent;
00154
00155 Caddin(){}
00156
00157 DECLARE_REGISTRY_RESOURCEID(IDR_ADDIN)
00158 DECLARE_PROTECT_FINAL_CONSTRUCT()
00159
00160 BEGIN_COM_MAP(Caddin)
00161 COM_INTERFACE_ENTRY(Iaddin)
00162
00163 COM_INTERFACE_ENTRY(ISupportErrorInfo)
00164 COM_INTERFACE_ENTRY2(IDispatch, Iaddin)
00165 COM_INTERFACE_ENTRY(_IDTExtensibility2)
00166 END_COM_MAP()
00167
00168 BEGIN_SINK_MAP(Caddin)
00169 SINK_ENTRY_INFO(1, __uuidof(_CommandBarButtonEvents), 0x01, OnClickButton, &OnClickButtonInfo)
00170 SINK_ENTRY_INFO(2, __uuidof(_CommandBarButtonEvents), 0x01, OnClickSynchronization, &OnClickSynchronizationInfo)
00171 SINK_ENTRY_INFO(3, __uuidof(_CommandBarButtonEvents), 0x01, OnClickGoto, &OnClickGotoInfo)
00172 SINK_ENTRY_INFO(4, __uuidof(_CommandBarButtonEvents), 0x01, OnClickConfiguration, &OnClickConfigurationInfo)
00173 END_SINK_MAP()
00174
00175
00176 STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00177
00178
00179 void __stdcall OnClickButton (IDispatch* Ctrl,VARIANT_BOOL * CancelDefault);
00180 void __stdcall OnClickSynchronization(IDispatch* Ctrl,VARIANT_BOOL * CancelDefault);
00181 void __stdcall OnClickGoto (IDispatch* Ctrl,VARIANT_BOOL * CancelDefault);
00182 void __stdcall OnClickConfiguration (IDispatch* Ctrl,VARIANT_BOOL * CancelDefault);
00183
00184
00185 public:
00186
00187
00188 STDMETHOD(OnConnection) (IDispatch* Application, ext_ConnectMode ConnectMode, IDispatch* AddInInst, SAFEARRAY** custom);
00189 STDMETHOD(OnDisconnection) (ext_DisconnectMode RemoveMode, SAFEARRAY** custom);
00190 STDMETHOD(OnStartupComplete)(SAFEARRAY** custom);
00191 STDMETHOD(OnBeginShutdown) (SAFEARRAY** custom);
00192 STDMETHOD(OnAddInsUpdate) (SAFEARRAY** custom){ return E_NOTIMPL; }
00193
00194 HRESULT AddNewMenubar (_CommandBars *pCmdBars);
00195 HRESULT AddNewCommandBar(_CommandBars *pCmdBars);
00196
00197 HRESULT __stdcall Caddin::DispAdviseControls (void);
00198 HRESULT __stdcall Caddin::DispUnadviseControls(void);
00199
00200 void launchSyncClientOutlook (const char* parameter);
00201 char* readPropertyValueFromHKLM(const char* context, const char* prop);
00202 int setCurrentSwv();
00203 char* readAddinSwv();
00204 bool swvNotCompatible(const char* currentVersion, const char* oldVersion);
00205
00206 HRESULT removeAddin();
00207 bool isAddinInstalled();
00208
00209 int saveAddinState(char* state);
00210 bool checkErrorsLastTime();
00211 void errorMsgBox();
00212 void openLog();
00213 void manageComErrors(_com_error &e);
00214
00215 bool isLastInstance();
00216 void updateAddinInstances(bool increment);
00217
00218
00219 private:
00220 LPDISPATCH m_pParentApp;
00221 _ApplicationPtr applicationPtr;
00222
00223 };
00224
00225 #endif //__ADDIN_H_