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
00043
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
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
00064
00065
00066
00067
00068
00069 #define ADDIN_CONTEXT "Microsoft/Office/Outlook/Addins/FunambolAddin.Addin"
00070
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
00078 #define LAST_COMPATIBLE_VERSION 60011 // "6.0.11" is the latest version compatible with this addin
00079
00080
00081
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
00095 #define AMP_SYNC4J L"&Sync4j"
00096 #define CAPTION_S4J L"Sync4j Outlook Client"
00097
00098
00099
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
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< 1,Caddin, &__uuidof(_CommandBarButtonEvents)> ButtonSyncEvent;
00154 typedef IDispEventSimpleImpl< 2,Caddin, &__uuidof(_CommandBarButtonEvents)> ItemSynchronizationEvent;
00155 typedef IDispEventSimpleImpl< 3,Caddin, &__uuidof(_CommandBarButtonEvents)> ItemGotoEvent;
00156 typedef IDispEventSimpleImpl< 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
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), 0x01, OnClickButton, &OnClickButtonInfo)
00173 SINK_ENTRY_INFO(2, __uuidof(_CommandBarButtonEvents), 0x01, OnClickSynchronization, &OnClickSynchronizationInfo)
00174 SINK_ENTRY_INFO(3, __uuidof(_CommandBarButtonEvents), 0x01, OnClickGoto, &OnClickGotoInfo)
00175 SINK_ENTRY_INFO(4, __uuidof(_CommandBarButtonEvents), 0x01, OnClickConfiguration, &OnClickConfigurationInfo)
00176 END_SINK_MAP()
00177
00178
00179 STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
00180
00181
00182 void __stdcall OnClickButton (IDispatch* Ctrl,VARIANT_BOOL * CancelDefault);
00183 void __stdcall OnClickSynchronization(IDispatch* Ctrl,VARIANT_BOOL * CancelDefault);
00184 void __stdcall OnClickGoto (IDispatch* Ctrl,VARIANT_BOOL * CancelDefault);
00185 void __stdcall OnClickConfiguration (IDispatch* Ctrl,VARIANT_BOOL * CancelDefault);
00186
00187
00188 public:
00189
00190
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_