diff options
Diffstat (limited to 'xmerge/source/activesync')
-rw-r--r-- | xmerge/source/activesync/BIN/xmergesync.dll | bin | 0 -> 86016 bytes | |||
-rw-r--r-- | xmerge/source/activesync/XMergeFactory.cpp | 90 | ||||
-rw-r--r-- | xmerge/source/activesync/XMergeFactory.h | 34 | ||||
-rw-r--r-- | xmerge/source/activesync/XMergeFilter.cpp | 495 | ||||
-rw-r--r-- | xmerge/source/activesync/XMergeFilter.h | 73 | ||||
-rw-r--r-- | xmerge/source/activesync/XMergeSync.cpp | 837 | ||||
-rw-r--r-- | xmerge/source/activesync/XMergeSync.def | 9 | ||||
-rw-r--r-- | xmerge/source/activesync/XMergeSync.dsp | 143 | ||||
-rw-r--r-- | xmerge/source/activesync/XMergeSync.dsw | 33 | ||||
-rw-r--r-- | xmerge/source/activesync/XMergeSync.h | 29 | ||||
-rw-r--r-- | xmerge/source/activesync/XMergeSync.rc | 80 | ||||
-rw-r--r-- | xmerge/source/activesync/exports.map | 12 | ||||
-rw-r--r-- | xmerge/source/activesync/guids.txt | 60 | ||||
-rw-r--r-- | xmerge/source/activesync/makefile.mk | 72 | ||||
-rw-r--r-- | xmerge/source/activesync/resource.h | 17 | ||||
-rw-r--r-- | xmerge/source/activesync/stdafx.cpp | 7 | ||||
-rw-r--r-- | xmerge/source/activesync/stdafx.h | 28 |
17 files changed, 2019 insertions, 0 deletions
diff --git a/xmerge/source/activesync/BIN/xmergesync.dll b/xmerge/source/activesync/BIN/xmergesync.dll Binary files differnew file mode 100644 index 000000000000..768dea87d2bd --- /dev/null +++ b/xmerge/source/activesync/BIN/xmergesync.dll diff --git a/xmerge/source/activesync/XMergeFactory.cpp b/xmerge/source/activesync/XMergeFactory.cpp new file mode 100644 index 000000000000..1c59cd79a8a0 --- /dev/null +++ b/xmerge/source/activesync/XMergeFactory.cpp @@ -0,0 +1,90 @@ +// XMergeFactory.cpp: implementation of the CXMergeFactory class. +// +////////////////////////////////////////////////////////////////////// + +#include "stdafx.h" + +#include "XMergeFilter.h" +#include "XMergeFactory.h" + +////////////////////////////////////////////////////////////////////// +// IUnknown implementation +////////////////////////////////////////////////////////////////////// +STDMETHODIMP CXMergeFactory::QueryInterface(REFIID riid, void **ppvObject) +{ + if(ppvObject == NULL) + return E_INVALIDARG; + + if(::IsEqualIID(riid, IID_IUnknown) || ::IsEqualIID(riid, IID_IClassFactory)) + { + *ppvObject = static_cast<IClassFactory*>(this); + } + else + { + *ppvObject = NULL; + return E_NOINTERFACE; + } + + reinterpret_cast<IUnknown*>(*ppvObject)->AddRef(); + return S_OK; +} + + +STDMETHODIMP_(ULONG) CXMergeFactory::AddRef() +{ + return ::InterlockedIncrement(&m_cRef); +} + + +STDMETHODIMP_(ULONG) CXMergeFactory::Release() +{ + if(::InterlockedDecrement(&m_cRef) == 0) + { + delete this; + return 0; + } + + return m_cRef; +} + + +////////////////////////////////////////////////////////////////////// +// IUnknown implementation +////////////////////////////////////////////////////////////////////// +STDMETHODIMP CXMergeFactory::CreateInstance(IUnknown *pUnkOuter, REFIID iid, void **ppvObject) +{ + if (ppvObject == NULL) + return E_INVALIDARG; + + if (pUnkOuter != NULL) // cannot aggregate + { + *ppvObject = NULL; + return CLASS_E_NOAGGREGATION; + } + + if (iid == IID_ICeFileFilter) + { + CXMergeFilter *pFilter = new CXMergeFilter(); + if(pFilter == NULL) + { + *ppvObject = NULL; + return E_OUTOFMEMORY; + } + + HRESULT hr = pFilter->QueryInterface(iid, ppvObject); + pFilter->Release(); + + return hr; + } + + return E_INVALIDARG; +} + + +STDMETHODIMP CXMergeFactory::LockServer(BOOL fLock) +{ + _Module.LockServer(fLock); + return S_OK; +} + + diff --git a/xmerge/source/activesync/XMergeFactory.h b/xmerge/source/activesync/XMergeFactory.h new file mode 100644 index 000000000000..bb24e8aab14e --- /dev/null +++ b/xmerge/source/activesync/XMergeFactory.h @@ -0,0 +1,34 @@ +// XMergeFactory.h: interface for the CXMergeFactory class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_XMERGEFACTORY_H__3150043C_57FB_4BC8_9104_379506FA6B9F__INCLUDED_) +#define AFX_XMERGEFACTORY_H__3150043C_57FB_4BC8_9104_379506FA6B9F__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +class CXMergeFactory : public IClassFactory +{ +private: + LONG m_cRef; + virtual ~CXMergeFactory() {}; + +public: + CXMergeFactory() : m_cRef(1) {}; // Set reference count when first created + + + /********** IUnknown methods **********/ + STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject); + STDMETHODIMP_(ULONG) AddRef(void); + STDMETHODIMP_(ULONG) Release(); + + + /********** IUnknown methods **********/ + STDMETHODIMP CreateInstance(IUnknown* pUnkOuter, REFIID riid, void **ppvObject); + STDMETHODIMP LockServer(BOOL fLock); +}; + +#endif // !defined(AFX_XMERGEFACTORY_H__3150043C_57FB_4BC8_9104_379506FA6B9F__INCLUDED_) diff --git a/xmerge/source/activesync/XMergeFilter.cpp b/xmerge/source/activesync/XMergeFilter.cpp new file mode 100644 index 000000000000..a02f11d03ad3 --- /dev/null +++ b/xmerge/source/activesync/XMergeFilter.cpp @@ -0,0 +1,495 @@ +// XMergeFilter.cpp: implementation of the CXMergeFilter class. +// +////////////////////////////////////////////////////////////////////// + + +#include "stdafx.h" + +#include "XMergeFilter.h" + +#include <string> + + +#define ERR_NOJAVA 1 +#define ERR_BADCLASSPATH 2 +#define ERR_INITJAVA 3 + + +const LPTSTR CXMergeFilter::m_pszPSWExportCLSID = _T("{BDD611C3-7BAB-460F-8711-5B9AC9EF6020}"); +const LPTSTR CXMergeFilter::m_pszPSWExportExt = _T("sxw"); +const LPTSTR CXMergeFilter::m_pszPSWExportDesc = _T("OpenOffice.org Writer XML Document"); +const LPTSTR CXMergeFilter::m_pszPSWExportShortDesc = _T("OpenOffice.org Writer"); + +const LPTSTR CXMergeFilter::m_pszPSWImportCLSID = _T("{CB43F086-838D-4FA4-B5F6-3406B9A57439}"); +const LPTSTR CXMergeFilter::m_pszPSWImportExt = _T("psw"); +const LPTSTR CXMergeFilter::m_pszPSWImportDesc = _T("Pocket Word Document - Pocket PC"); +const LPTSTR CXMergeFilter::m_pszPSWImportShortDesc = _T("Pocket Word"); + +const LPTSTR CXMergeFilter::m_pszPXLExportCLSID = _T("{C6AB3E74-9F4F-4370-8120-A8A6FABB7A7C}"); +const LPTSTR CXMergeFilter::m_pszPXLExportExt = _T("sxc"); +const LPTSTR CXMergeFilter::m_pszPXLExportDesc = _T("OpenOffice.org Calc XML Document"); +const LPTSTR CXMergeFilter::m_pszPXLExportShortDesc = _T("OpenOffice.org Calc"); + +const LPTSTR CXMergeFilter::m_pszPXLImportCLSID = _T("{43887C67-4D5D-4127-BAAC-87A288494C7C}"); +const LPTSTR CXMergeFilter::m_pszPXLImportExt = _T("pxl"); +const LPTSTR CXMergeFilter::m_pszPXLImportDesc = _T("Pocket Excel Document - Pocket PC"); +const LPTSTR CXMergeFilter::m_pszPXLImportShortDesc = _T("Pocket Excel"); + + +////////////////////////////////////////////////////////////////////// +// Construction/Destruction +////////////////////////////////////////////////////////////////////// + +CXMergeFilter::CXMergeFilter() : m_cRef(1) +{ + m_bHaveExcel = FALSE; + m_bHaveWord = FALSE; + + m_szClasspath = NULL; + m_szJavaBaseDir = NULL; +} + +CXMergeFilter::~CXMergeFilter() +{ + if (m_szClasspath != NULL) + { + delete m_szClasspath; + } + + if (m_szJavaBaseDir != NULL) + { + delete m_szJavaBaseDir; + } + +} + + +////////////////////////////////////////////////////////////////////// +// IUnknown Methods +////////////////////////////////////////////////////////////////////// + +STDMETHODIMP CXMergeFilter::QueryInterface(REFIID riid, void **ppvObject) +{ + if(ppvObject == NULL) + return E_INVALIDARG; + + if (::IsEqualIID(riid, IID_IUnknown)) + { + *ppvObject = static_cast<IUnknown *>(this); + } + else if (::IsEqualIID(riid, IID_ICeFileFilter)) + { + *ppvObject = static_cast<ICeFileFilter *>(this); + } + else + { + *ppvObject = NULL; + return E_NOINTERFACE; + } + + reinterpret_cast<IUnknown *>(*ppvObject)->AddRef(); + return S_OK; +} + + +STDMETHODIMP_(ULONG) CXMergeFilter::AddRef() +{ + return ::InterlockedIncrement(&m_cRef); +} + + +STDMETHODIMP_(ULONG) CXMergeFilter::Release() +{ + if(::InterlockedDecrement(&m_cRef) == 0) + { + delete this; + return 0; + } + return m_cRef; +} + + +////////////////////////////////////////////////////////////////////// +// ICeFileFilter +////////////////////////////////////////////////////////////////////// + +STDMETHODIMP CXMergeFilter::FilterOptions(HWND hwndParent) +{ + // We don't currently allow any options + return HRESULT_FROM_WIN32(NOERROR); +} + +STDMETHODIMP CXMergeFilter::FormatMessage(DWORD dwFlags, DWORD dwMessageId, + DWORD dwLanguageId, LPTSTR lpBuffer, DWORD nSize, + va_list *Arguments, DWORD *pcb) +{ + TCHAR errMsg[1024]; + + HKEY hKey = NULL; + DWORD dwSize = 1024; + + + long lRet = 0; + + // Attempt to find the messages in the registry + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Sun Microsystems\\StarOffice\\XMergeSync\\Messages\\Error"), + 0, KEY_READ, &hKey); + if (lRet != ERROR_SUCCESS) + { + // Try the user's portion of the registry + lRet = ::RegOpenKeyEx(HKEY_CURRENT_USER, _T("Software\\Sun Microsystems\\StarOffice\\XMergeSync\\Messages\\Error"), + 0, KEY_READ, &hKey); + if (lRet != ERROR_SUCCESS) + { + hKey = NULL; + } + } + + + switch(dwMessageId) + { + case ERR_NOJAVA: + lRet = ::RegQueryValueEx(hKey, _T("Java"), 0, NULL, (LPBYTE)errMsg, &dwSize); + if (lRet != ERROR_SUCCESS) + { + lstrcpy(errMsg, "Unable to locate Java 1.4/1.5 installation."); + } + break; + + case ERR_BADCLASSPATH: + lRet = ::RegQueryValueEx(hKey, _T("Classpath"), 0, NULL, (LPBYTE)errMsg, &dwSize); + if (lRet != ERROR_SUCCESS) + { + lstrcpy(errMsg, "Unable to locate XMerge Jar files."); + } + break; + + case ERR_INITJAVA: + lRet = ::RegQueryValueEx(hKey, _T("JavaInit"), 0, NULL, (LPBYTE)errMsg, &dwSize); + if (lRet != ERROR_SUCCESS) + { + lstrcpy(errMsg, "Error initialising the Java Runtime Environment."); + } + break; + } + + char* buf = (char*)LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, (lstrlen(errMsg) + 1) * sizeof(TCHAR)); + lstrcpyn(buf, errMsg, lstrlen(errMsg)); + + *(char**)lpBuffer = buf; + *pcb = strlen(errMsg); + + return HRESULT_FROM_WIN32(NOERROR); +} + + +STDMETHODIMP CXMergeFilter::NextConvertFile(int nConversion, CFF_CONVERTINFO *pci, + CFF_SOURCEFILE *psf, CFF_DESTINATIONFILE *pdf, + volatile BOOL *pbCancel, CF_ERROR *perr) +{ + std::string appArgs; + std::string appName; + + STARTUPINFO si; + PROCESS_INFORMATION pi; + + ZeroMemory( &si, sizeof(si) ); + ZeroMemory( &pi, sizeof(pi) ); + + si.cb = sizeof(si); + + + /* + * First step: Locate Java and establish the classpath. If these can't + * be done succesfully, then avoid all further processing. + */ + + // Locate Java Home if it hasn't already been done. + if (m_szJavaBaseDir == NULL) + { + m_szJavaBaseDir = GetJavaBaseDir(); + + if (m_szJavaBaseDir == NULL) + { + *perr = ERR_NOJAVA; + return HRESULT_FROM_WIN32(E_FAIL); + } + } + + // Get the StarOffice/OpenOffice class directory + if (m_szClasspath == NULL) + { + m_szClasspath = GetXMergeClassPath(); + + if (m_szClasspath == NULL) + { + *perr = ERR_BADCLASSPATH; + return HRESULT_FROM_WIN32(E_FAIL); + } + } + + + /* + * Second step: Check the files we're going to process. If we don't have + * an XMerge plugin for the file then we can't convert. + */ + if ((!lstrcmp(psf->szExtension, "sxw") || !lstrcmp(psf->szExtension, "psw")) + && !m_bHaveWord) + { + *perr = ERR_BADCLASSPATH; + return HRESULT_FROM_WIN32(E_FAIL); + } + else if ((!lstrcmp(psf->szExtension, "sxc") || !lstrcmp(psf->szExtension, "pxl")) + && !m_bHaveExcel) + { + *perr = ERR_BADCLASSPATH; + return HRESULT_FROM_WIN32(E_FAIL); + } + + + /* + * Third step: Locate the Java executable and build and execute the command + * line to carry out the conversion. + */ + + // Find the Java executable and make sure it exists + appName += m_szJavaBaseDir; + appName += "\\bin\\javaw.exe"; + + if (GetFileAttributes(appName.c_str()) == INVALID_FILE_SIZE) + { + *perr = ERR_NOJAVA; + return HRESULT_FROM_WIN32(E_FAIL); + } + + // Wrap the executable path in quotes in case of spaces + appName.insert(0, "\""); + appName.append("\""); + + + + // Need to build the entire command line for calling out to Java + appArgs = appName + " -Djava.class.path="; + appArgs += m_szClasspath; + appArgs += " org.openoffice.xmerge.util.ActiveSyncDriver "; + + if (!lstrcmp(psf->szExtension, "sxw")) + { + appArgs += "staroffice/sxw "; + appArgs += "application/x-pocket-word "; + } + else if(!lstrcmp(psf->szExtension, "psw")) + { + appArgs += "application/x-pocket-word "; + appArgs += "staroffice/sxw "; + } + else if(!lstrcmp(psf->szExtension, "sxc")) + { + appArgs += "staroffice/sxc "; + appArgs += "application/x-pocket-excel "; + } + else if(!lstrcmp(psf->szExtension, "pxl")) + { + appArgs += "application/x-pocket-excel "; + appArgs += "staroffice/sxc "; + } + + + // ActiveSync sometimes gives out long file names, especially when automatically syncing + appArgs += "\""; + appArgs += psf->szFullpath; + appArgs += "\" \""; + appArgs += pdf->szFullpath; + appArgs += "\""; + + if(!CreateProcess(NULL, + (char*)appArgs.c_str(), + NULL, // No Process Attributes + NULL, // No Thread Attributes + FALSE, // Don't want this process getting handles + CREATE_NO_WINDOW, // No console + NULL, // No special environment + NULL, // Current Working Directory is okay + &si, + &pi)) + { + *perr = ERR_INITJAVA; + return HRESULT_FROM_WIN32(E_FAIL); + } + + // Wait for the new process to work + WaitForSingleObject(pi.hProcess, INFINITE); + + CloseHandle(pi.hProcess); + CloseHandle(pi.hThread); + + return HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS); +} + + +typedef HRESULT (WINAPI *SHGETFOLDERPATH)( HWND, int, HANDLE, DWORD, LPTSTR ); + + +TCHAR* CXMergeFilter::GetJavaBaseDir() +{ + HRESULT lRet; + + HKEY hKey = NULL; + HKEY hDataKey = NULL; + + TCHAR szClassName[_MAX_PATH] = "\0"; + TCHAR szKeyName[_MAX_PATH] = "\0"; + TCHAR szCurrentJava[_MAX_PATH] = "\0"; + DWORD dwClassName = _MAX_PATH; + DWORD dwKeyName = _MAX_PATH; + + /* + * Java leaves registry keys at HKLM\SOFTWARE\JavaSoft. + * + * Check for a JRE installation first + */ + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\JavaSoft\\Java Runtime Environment"), 0, KEY_READ, &hKey); + if (lRet != ERROR_SUCCESS) + return NULL; + + // Locations shouldn't be greater than _MAX_PATH + TCHAR* szJavaHome = new TCHAR[_MAX_PATH + 1]; + DWORD dwSize = _MAX_PATH + 1; + + /* use current version */ + lRet = ::RegQueryValueEx(hKey, _T("CurrentVersion"), 0, NULL, (LPBYTE)szCurrentJava, &dwSize); + + /* + for (DWORD i = 0; lRet != ERROR_NO_MORE_ITEMS; i++) + { + lRet = ::RegEnumKeyEx(hKey, i, szKeyName, &dwKeyName, 0, szClassName, &dwClassName, NULL); + if(!strncmp(szKeyName, "1.4", 3)) + break; + dwKeyName = _MAX_PATH; + } + // Found a Java 1.4 installation. Can now read its home directory. + */ + + + lRet = ::RegOpenKeyEx(hKey, _T(szCurrentJava), 0, KEY_READ, &hDataKey); + if (lRet != ERROR_SUCCESS) + { + RegCloseKey(hKey); + delete [] szJavaHome; + return NULL; + } + + + // Now read the JavaHome value + dwSize = _MAX_PATH + 1; + lRet = ::RegQueryValueEx(hDataKey, _T("JavaHome"), 0, NULL, (LPBYTE)szJavaHome, &dwSize); + if (lRet != ERROR_SUCCESS) + { + RegCloseKey(hDataKey); + RegCloseKey(hKey); + delete [] szJavaHome; + return NULL; + } + + RegCloseKey(hDataKey); + RegCloseKey(hKey); + + + // Check that the directory exists before returning it + DWORD dwAttrs = GetFileAttributes(szJavaHome); + + if (((dwAttrs & FILE_ATTRIBUTE_DIRECTORY) != FILE_ATTRIBUTE_DIRECTORY) || dwAttrs == INVALID_FILE_SIZE) + { + delete [] szJavaHome; + return NULL; + } + + return szJavaHome; +} + + + +TCHAR* CXMergeFilter::GetXMergeClassPath() +{ + /* + * The DLL will be installed by setup in the program directory of + * the installation. The XMerge Jar files, if present, will be + * located in the classes directory below program. + */ + + TCHAR szJarPath[MAX_PATH]; + TCHAR szTmpPath[MAX_PATH]; + + ZeroMemory(szJarPath, MAX_PATH); + ZeroMemory(szTmpPath, MAX_PATH); + + WIN32_FILE_ATTRIBUTE_DATA fInfo; + + std::string clsPath; + + + // Get the location of the module. + GetModuleFileName(_Module.m_hInst, szTmpPath, MAX_PATH); + + // Strip off the xmergesync.dll component + _strlwr(szTmpPath); + char* modName = strstr(szTmpPath, "xmergesync.dll"); + strncpy(szJarPath, szTmpPath, modName - szTmpPath); + + // Append the classes directory + strncat(szJarPath, "classes\\", 8); + + + // The core xmerge.jar must be present + ZeroMemory(szTmpPath, MAX_PATH); + _snprintf(szTmpPath, MAX_PATH, "%s%s\0", szJarPath, "xmerge.jar"); + + if (!GetFileAttributesEx(szTmpPath, GetFileExInfoStandard, &fInfo)) + { + return NULL; + } + else + { + clsPath += szTmpPath; + clsPath += ";"; + } + + + // Now check for Pocket Word + ZeroMemory(szTmpPath, MAX_PATH); + _snprintf(szTmpPath, MAX_PATH, "%s%s\0", szJarPath, "pocketword.jar"); + + if (!GetFileAttributesEx(szTmpPath, GetFileExInfoStandard, &fInfo)) + { + m_bHaveWord = FALSE; + } + else + { + m_bHaveWord = TRUE; + clsPath += szTmpPath; + clsPath += ";"; + } + + // Now check for Pocket Excel + ZeroMemory(szTmpPath, MAX_PATH); + _snprintf(szTmpPath, MAX_PATH, "%s%s\0", szJarPath, "pexcel.jar"); + + if (!GetFileAttributesEx(szTmpPath, GetFileExInfoStandard, &fInfo)) + { + m_bHaveExcel = FALSE; + } + else + { + m_bHaveExcel = TRUE; + clsPath += szTmpPath; + clsPath += ";"; + } + + // Quotes may be need around the ClassPath + clsPath.insert(0, "\""); + clsPath += "\""; + + + // Return the data + return _strdup(clsPath.c_str()); +} diff --git a/xmerge/source/activesync/XMergeFilter.h b/xmerge/source/activesync/XMergeFilter.h new file mode 100644 index 000000000000..54128f325125 --- /dev/null +++ b/xmerge/source/activesync/XMergeFilter.h @@ -0,0 +1,73 @@ +// XMergeFilter.h: interface for the CXMergeFilter class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_XMERGEFILTER_H__25C39F6B_A1D7_408E_8F58_9CBEE9A666CC__INCLUDED_) +#define AFX_XMERGEFILTER_H__25C39F6B_A1D7_408E_8F58_9CBEE9A666CC__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + + + + +class CXMergeFilter : public ICeFileFilter +{ +protected: + long m_cRef; + +private: + TCHAR* GetXMergeClassPath(); + TCHAR* GetJavaBaseDir(); + + TCHAR* m_szJavaBaseDir; + TCHAR* m_szClasspath; + + BOOL m_bHaveExcel; + BOOL m_bHaveWord; + + +public: + static const LPTSTR m_pszPSWExportCLSID; + static const LPTSTR m_pszPSWExportExt; + static const LPTSTR m_pszPSWExportDesc; + static const LPTSTR m_pszPSWExportShortDesc; + + static const LPTSTR m_pszPSWImportCLSID; + static const LPTSTR m_pszPSWImportExt; + static const LPTSTR m_pszPSWImportDesc; + static const LPTSTR m_pszPSWImportShortDesc; + + static const LPTSTR m_pszPXLExportCLSID; + static const LPTSTR m_pszPXLExportExt; + static const LPTSTR m_pszPXLExportDesc; + static const LPTSTR m_pszPXLExportShortDesc; + + static const LPTSTR m_pszPXLImportCLSID; + static const LPTSTR m_pszPXLImportExt; + static const LPTSTR m_pszPXLImportDesc; + static const LPTSTR m_pszPXLImportShortDesc; + +public: + CXMergeFilter(); + virtual ~CXMergeFilter(); + + + /********** IUnknown methods **********/ + STDMETHODIMP QueryInterface(REFIID iid, void **ppvObject); + STDMETHODIMP_(ULONG) AddRef(); + STDMETHODIMP_(ULONG) Release(); + + /********** ICeFileFilter methods *********/ + STDMETHODIMP FilterOptions(HWND hwndParent); + STDMETHODIMP FormatMessage(DWORD dwFlags, DWORD dwMessageId, DWORD dwLanguageId, + LPTSTR lpBuffer, DWORD nSize, va_list *Arguments, DWORD *pcb); + STDMETHODIMP NextConvertFile(int nConversion, CFF_CONVERTINFO *pci, + CFF_SOURCEFILE *psf, CFF_DESTINATIONFILE *pdf, + volatile BOOL *pbCancel, CF_ERROR *perr); + +}; + +#endif // !defined(AFX_XMERGEFILTER_H__25C39F6B_A1D7_408E_8F58_9CBEE9A666CC__INCLUDED_) diff --git a/xmerge/source/activesync/XMergeSync.cpp b/xmerge/source/activesync/XMergeSync.cpp new file mode 100644 index 000000000000..469c15b2f292 --- /dev/null +++ b/xmerge/source/activesync/XMergeSync.cpp @@ -0,0 +1,837 @@ + +#include "stdafx.h" + +#include "XMergeFilter.h" +#include "XMergeFactory.h" + + +CXMergeSyncModule _Module; + + +////////////////////////////////////////////////////////////////////// +// DLL Functions +////////////////////////////////////////////////////////////////////// +BOOL WINAPI DllMain(HANDLE hInst, ULONG ulReason, LPVOID lpReserved) +{ + switch (ulReason) + { + case DLL_PROCESS_ATTACH: + _Module.m_hInst = reinterpret_cast<HINSTANCE>(hInst); + break; + + case DLL_PROCESS_DETACH: + _Module.m_hInst = NULL; + break; + + case DLL_THREAD_ATTACH: + break; + + case DLL_THREAD_DETACH: + break; + } + + return TRUE; +} + + +STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv) +{ + // Create the factory object + CXMergeFactory *pFactory = new CXMergeFactory(); + if (pFactory == NULL) + { + *ppv = NULL; + return E_OUTOFMEMORY; + } + + HRESULT hr = pFactory->QueryInterface(riid, ppv); + pFactory->Release(); + + return hr; +} + + +STDAPI DllCanUnloadNow() +{ + if (_Module.GetLockCount() == 0) + return S_OK; + + return S_FALSE; +} + + +// Utility function to close open keys during registration +static _signalRegError(long lRet, HKEY hKey, HKEY hDataKey) +{ + if (hKey) + ::RegCloseKey(hKey); + + + if (hDataKey) + ::RegCloseKey(hDataKey); + + return HRESULT_FROM_WIN32(lRet); +} + + +STDAPI DllRegisterServer() +{ + HKEY hKey = NULL; + HKEY hDataKey = NULL; + + long lRet = 0; + TCHAR sTemp[_MAX_PATH + 1] = "\0"; + + + /* + * Following calls create the HKEY_CLASSES_ROOT\CLSID entry for the Writer export filter. + * + * Note that import are export are relative to the WinCE device, so files are + * exported to the desktop format. + */ + + // Get a handle to the CLSID key + lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + // Create the CLSID key for the XMergeFilter + lRet = ::RegCreateKeyEx(hKey, CXMergeFilter::m_pszPSWExportCLSID, 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hKey, _T(""), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWExportShortDesc, + (::_tcslen(CXMergeFilter::m_pszPSWExportShortDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + // Create the DefaultIcon key. For the moment, use one of the Async supplied ones + lRet = ::RegCreateKeyEx(hKey, _T("DefaultIcon"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0"), + (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) + * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + // Create the InprocServer32 key + lRet = ::RegCreateKeyEx(hKey, _T("InProcServer32"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, _T("ThreadingModel"), 0, REG_SZ, (LPBYTE)_T("Apartment"), 10); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + // Create the key for the DLL file. First find the filename of the dll + if (!::GetModuleFileName((HMODULE)_Module.m_hInst, sTemp, (_MAX_PATH + 1))) + { + lRet = ::GetLastError(); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + } + + + lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, + (::_tcslen(sTemp) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + // Setup the PegasusFilter key values + lRet = ::RegCreateKeyEx(hKey, _T("PegasusFilter"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, _T("Description"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWExportDesc, + (::_tcslen(CXMergeFilter::m_pszPSWExportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + lRet = ::RegSetValueEx(hDataKey, _T("Export"), 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + lRet = ::RegSetValueEx(hDataKey, _T("NewExtension"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWExportExt, + (::_tcslen(CXMergeFilter::m_pszPSWExportExt) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + + + /* + * Following calls create the entries for the filter in + * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters + */ + + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), + 0, KEY_ALL_ACCESS, &hKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + _snprintf(sTemp, _MAX_PATH + 1, "%c%s\\InstalledFilters\0", '.', CXMergeFilter::m_pszPSWImportExt); + lRet = ::RegCreateKeyEx(hKey, _T(sTemp), + 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, CXMergeFilter::m_pszPSWExportCLSID, 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + + /* + * Following calls create the HKEY_CLASSES_ROOT\CLSID entry for the Writer import filter. + * + * Note that import are export are relative to the WinCE device, so files are + * exported to the desktop format. + */ + // Get a handle to the CLSID key + lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + // Create the CLSID key for the XMergeFilter + lRet = ::RegCreateKeyEx(hKey, CXMergeFilter::m_pszPSWImportCLSID, 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hKey, _T(""), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWImportShortDesc, + (::_tcslen(CXMergeFilter::m_pszPSWImportShortDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + // Create the DefaultIcon key. For the moment, use one of the Async supplied ones + lRet = ::RegCreateKeyEx(hKey, _T("DefaultIcon"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0"), + (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) + * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + // Create the InprocServer32 key + lRet = ::RegCreateKeyEx(hKey, _T("InProcServer32"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, _T("ThreadingModel"), 0, REG_SZ, (LPBYTE)_T("Apartment"), 10); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + // Create the key for the DLL file. First find the filename of the dll + if (!::GetModuleFileName((HMODULE)_Module.m_hInst, sTemp, (_MAX_PATH + 1))) + { + lRet = ::GetLastError(); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + } + + + lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, + (::_tcslen(sTemp) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + // Setup the PegasusFilter key values + lRet = ::RegCreateKeyEx(hKey, _T("PegasusFilter"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, _T("Description"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWImportDesc, + (::_tcslen(CXMergeFilter::m_pszPSWImportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + lRet = ::RegSetValueEx(hDataKey, _T("Import"), 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + lRet = ::RegSetValueEx(hDataKey, _T("NewExtension"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPSWImportExt, + (::_tcslen(CXMergeFilter::m_pszPSWImportExt) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + /* + * Following calls create the entries for the filter in + * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters + */ + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), + 0, KEY_ALL_ACCESS, &hKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + // Add in defaults for import and export + _snprintf(sTemp, _MAX_PATH +1, "%c%s\0", '.', CXMergeFilter::m_pszPSWExportExt); + lRet = ::RegCreateKeyEx(hKey, _T(sTemp), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, _T("DefaultImport"), 0, REG_SZ, + (LPBYTE)CXMergeFilter::m_pszPSWImportCLSID, + (::_tcslen(CXMergeFilter::m_pszPSWImportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + lRet = ::RegSetValueEx(hDataKey, _T("DefaultExport"), 0, REG_SZ, (LPBYTE)_T("Binary Copy"), + (::_tcslen(_T("Binary Copy")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + ::RegCloseKey(hDataKey); + + // Update registered filters + _snprintf(sTemp, _MAX_PATH + 1, "%c%s\\InstalledFilters\0", '.', CXMergeFilter::m_pszPSWExportExt); + lRet = ::RegCreateKeyEx(hKey, _T(sTemp), + 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + lRet = ::RegSetValueEx(hDataKey, CXMergeFilter::m_pszPSWImportCLSID, 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + + /* + * Following calls create the HKEY_CLASSES_ROOT\CLSID entry for the Calc export filter. + * + * Note that import are export are relative to the WinCE device, so files are + * exported to the desktop format. + */ + + // Get a handle to the CLSID key + lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + // Create the CLSID key for the XMerge Filter + lRet = ::RegCreateKeyEx(hKey, CXMergeFilter::m_pszPXLExportCLSID, 0, _T(""), + 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hKey, _T(""), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLExportShortDesc, + (::_tcslen(CXMergeFilter::m_pszPXLExportShortDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + // Create the DefaultIcon key. For the moment, use one of the Async supplied ones + lRet = ::RegCreateKeyEx(hKey, _T("DefaultIcon"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0"), + (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) + * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + // Create the InprocServer32 key + lRet = ::RegCreateKeyEx(hKey, _T("InProcServer32"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, _T("ThreadingModel"), 0, REG_SZ, (LPBYTE)_T("Apartment"), 10); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + // Create the key for the DLL file. First find the filename of the dll + if (!::GetModuleFileName((HMODULE)_Module.m_hInst, sTemp, (_MAX_PATH + 1))) + { + lRet = ::GetLastError(); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + } + + + lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, + (::_tcslen(sTemp) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + // Setup the PegasusFilter key values + lRet = ::RegCreateKeyEx(hKey, _T("PegasusFilter"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, _T("Description"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLExportDesc, + (::_tcslen(CXMergeFilter::m_pszPXLExportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + lRet = ::RegSetValueEx(hDataKey, _T("Export"), 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + lRet = ::RegSetValueEx(hDataKey, _T("NewExtension"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLExportExt, + (::_tcslen(CXMergeFilter::m_pszPXLExportExt) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + + + /* + * Following calls create the entries for the filter in + * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters + */ + + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), + 0, KEY_ALL_ACCESS, &hKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + _snprintf(sTemp, _MAX_PATH + 1, "%c%s\\InstalledFilters\0", '.', CXMergeFilter::m_pszPXLImportExt); + lRet = ::RegCreateKeyEx(hKey, _T(sTemp), + 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, CXMergeFilter::m_pszPXLExportCLSID, 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + + /* + * Following calls create the HKEY_CLASSES_ROOT\CLSID entry for the Calc import filter. + * + * Note that import are export are relative to the WinCE device, so files are + * exported to the desktop format. + */ + // Get a handle to the CLSID key + lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + // Create the CLSID key for the XMergeFilter + lRet = ::RegCreateKeyEx(hKey, CXMergeFilter::m_pszPXLImportCLSID, 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hKey, _T(""), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLImportShortDesc, + (::_tcslen(CXMergeFilter::m_pszPXLImportShortDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + // Create the DefaultIcon key. For the moment, use one of the Async supplied ones + lRet = ::RegCreateKeyEx(hKey, _T("DefaultIcon"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0"), + (::_tcslen(_T("C:\\Program Files\\Microsoft ActiveSync\\pwdcnv.dll,0")) + * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + // Create the InprocServer32 key + lRet = ::RegCreateKeyEx(hKey, _T("InProcServer32"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, _T("ThreadingModel"), 0, REG_SZ, (LPBYTE)_T("Apartment"), 10); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + // Create the key for the DLL file. First find the filename of the dll + if (!::GetModuleFileName((HMODULE)_Module.m_hInst, sTemp, (_MAX_PATH + 1))) + { + lRet = ::GetLastError(); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + } + + + lRet = ::RegSetValueEx(hDataKey, NULL, 0, REG_SZ, (LPBYTE)sTemp, + (::_tcslen(sTemp) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + // Setup the PegasusFilter key values + lRet = ::RegCreateKeyEx(hKey, _T("PegasusFilter"), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, _T("Description"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLImportDesc, + (::_tcslen(CXMergeFilter::m_pszPXLImportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + lRet = ::RegSetValueEx(hDataKey, _T("Import"), 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + lRet = ::RegSetValueEx(hDataKey, _T("NewExtension"), 0, REG_SZ, (LPBYTE)CXMergeFilter::m_pszPXLImportExt, + (::_tcslen(CXMergeFilter::m_pszPXLImportExt) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + + /* + * Following calls create the entries for the filter in + * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters + */ + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), + 0, KEY_ALL_ACCESS, &hKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + // Add in defaults for import and export + _snprintf(sTemp, _MAX_PATH +1, "%c%s\0", '.', CXMergeFilter::m_pszPXLExportExt); + lRet = ::RegCreateKeyEx(hKey, _T(sTemp), 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, _T("DefaultImport"), 0, REG_SZ, + (LPBYTE)CXMergeFilter::m_pszPXLImportCLSID, + (::_tcslen(CXMergeFilter::m_pszPSWImportDesc) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + lRet = ::RegSetValueEx(hDataKey, _T("DefaultExport"), 0, REG_SZ, (LPBYTE)_T("Binary Copy"), + (::_tcslen(_T("Binary Copy")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + ::RegCloseKey(hDataKey); + + // Update registered filters + + + _snprintf(sTemp, _MAX_PATH + 1, "%c%s\\InstalledFilters\0", '.', CXMergeFilter::m_pszPXLExportExt); + lRet = ::RegCreateKeyEx(hKey, _T(sTemp), + 0, _T(""), 0, KEY_ALL_ACCESS, NULL, &hDataKey, NULL); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, CXMergeFilter::m_pszPXLImportCLSID, 0, REG_SZ, (LPBYTE)_T(""), (1 * sizeof(TCHAR))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + ::RegCloseKey(hKey); hKey = NULL; + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + + return HRESULT_FROM_WIN32(lRet); +} + + +STDAPI DllUnregisterServer() +{ + long lRet = 0; + HKEY hKey = NULL; + HKEY hDataKey = NULL; + + TCHAR szClassName[_MAX_PATH] = "\0"; + TCHAR szKeyName[_MAX_PATH] = "\0"; + DWORD dwClassName = _MAX_PATH; + DWORD dwKeyName = _MAX_PATH; + + /* + * Remove HKEY_CLASS_ROOT\CLSID\{XXX} entry for the export and import filters + * + * Windows 95/98/Me allow one step deletion of a key and all subkeys. + * Windows NT/2000/XP do not so the subkeys must be deleted individually. + */ + lRet = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, _T("CLSID"), 0, KEY_ALL_ACCESS, &hKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + // First up, the Writer export filter + lRet = ::RegOpenKeyEx(hKey, CXMergeFilter::m_pszPSWExportCLSID, 0, KEY_ALL_ACCESS, &hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + while ((lRet = ::RegEnumKeyEx(hDataKey, 0, szKeyName, &dwKeyName, 0, szClassName, &dwClassName, NULL)) + != ERROR_NO_MORE_ITEMS) + { + lRet = ::RegDeleteKey(hDataKey, szKeyName); + + ::lstrcpy(szKeyName, "\0"); + ::lstrcpy(szClassName, "\0"); + + dwClassName = _MAX_PATH; + dwKeyName = _MAX_PATH; + } + + ::RegCloseKey(hDataKey); hDataKey = NULL; + + lRet = ::RegDeleteKey(hKey, CXMergeFilter::m_pszPSWExportCLSID); + if (lRet != ERROR_SUCCESS && lRet != ERROR_FILE_NOT_FOUND) + return _signalRegError(lRet, hKey, hDataKey); + + + + // Next, the Writer import filter + lRet = ::RegOpenKeyEx(hKey, CXMergeFilter::m_pszPSWImportCLSID, 0, KEY_ALL_ACCESS, &hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + while ((lRet = ::RegEnumKeyEx(hDataKey, 0, szKeyName, &dwKeyName, 0, szClassName, &dwClassName, NULL)) + != ERROR_NO_MORE_ITEMS) + { + lRet = ::RegDeleteKey(hDataKey, szKeyName); + + ::lstrcpy(szKeyName, "\0"); + ::lstrcpy(szClassName, "\0"); + + dwClassName = _MAX_PATH; + dwKeyName = _MAX_PATH; + } + + ::RegCloseKey(hDataKey); hDataKey = NULL; + + lRet = ::RegDeleteKey(hKey, CXMergeFilter::m_pszPSWImportCLSID); + if (lRet != ERROR_SUCCESS && lRet != ERROR_FILE_NOT_FOUND) + return _signalRegError(lRet, hKey, hDataKey); + + + // Next up, the Calc export filter + lRet = ::RegOpenKeyEx(hKey, CXMergeFilter::m_pszPXLExportCLSID, 0, KEY_ALL_ACCESS, &hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + while ((lRet = ::RegEnumKeyEx(hDataKey, 0, szKeyName, &dwKeyName, 0, szClassName, &dwClassName, NULL)) + != ERROR_NO_MORE_ITEMS) + { + lRet = ::RegDeleteKey(hDataKey, szKeyName); + + ::lstrcpy(szKeyName, "\0"); + ::lstrcpy(szClassName, "\0"); + + dwClassName = _MAX_PATH; + dwKeyName = _MAX_PATH; + } + + ::RegCloseKey(hDataKey); hDataKey = NULL; + + lRet = ::RegDeleteKey(hKey, CXMergeFilter::m_pszPXLExportCLSID); + if (lRet != ERROR_SUCCESS && lRet != ERROR_FILE_NOT_FOUND) + return _signalRegError(lRet, hKey, hDataKey); + + + // Next, the Calc import filter + lRet = ::RegOpenKeyEx(hKey, CXMergeFilter::m_pszPXLImportCLSID, 0, KEY_ALL_ACCESS, &hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + while ((lRet = ::RegEnumKeyEx(hDataKey, 0, szKeyName, &dwKeyName, 0, szClassName, &dwClassName, NULL)) + != ERROR_NO_MORE_ITEMS) + { + lRet = ::RegDeleteKey(hDataKey, szKeyName); + + ::lstrcpy(szKeyName, "\0"); + ::lstrcpy(szClassName, "\0"); + + dwClassName = _MAX_PATH; + dwKeyName = _MAX_PATH; + } + + ::RegCloseKey(hDataKey); hDataKey = NULL; + + lRet = ::RegDeleteKey(hKey, CXMergeFilter::m_pszPXLImportCLSID); + if (lRet != ERROR_SUCCESS && lRet != ERROR_FILE_NOT_FOUND) + return _signalRegError(lRet, hKey, hDataKey); + + ::RegCloseKey(hKey); hKey = NULL; + + + + /* + * Remove the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows CE Services\Filters + */ + lRet = ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\Microsoft\\Windows CE Services\\Filters"), + 0, KEY_ALL_ACCESS, &hKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + + // Remove the Writer export filter from the Writer import file extension subkey. + _snprintf(szKeyName, _MAX_PATH, ".%s\\InstalledFilters", CXMergeFilter::m_pszPSWImportExt); + lRet = ::RegOpenKeyEx(hKey, _T(szKeyName), 0, KEY_ALL_ACCESS, &hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegDeleteValue(hDataKey, CXMergeFilter::m_pszPSWExportCLSID); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + ::lstrcpyn(szKeyName, "\0", _MAX_PATH); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + // Remove the Writer import filter from the Writer export file extension subkey. + _snprintf(szKeyName, _MAX_PATH, ".%s\\InstalledFilters", CXMergeFilter::m_pszPSWExportExt); + lRet = ::RegOpenKeyEx(hKey, _T(szKeyName), 0, KEY_ALL_ACCESS, &hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegDeleteValue(hDataKey, CXMergeFilter::m_pszPSWImportCLSID); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + ::lstrcpyn(szKeyName, "\0", _MAX_PATH); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + // Make Binary Copy the default for Writer export file extension subkey DefaultImport + _snprintf(szKeyName, _MAX_PATH, ".%s\0", CXMergeFilter::m_pszPSWExportExt); + lRet = ::RegOpenKeyEx(hKey, _T(szKeyName), 0, KEY_ALL_ACCESS, &hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, _T("DefaultImport"), 0, REG_SZ, (LPBYTE)_T("Binary Copy"), + (::_tcslen(_T("Binary Copy")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + ::lstrcpyn(szKeyName, "\0", _MAX_PATH); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + // Remove the Calc export filter from the Calc import file extension subkey. + _snprintf(szKeyName, _MAX_PATH, ".%s\\InstalledFilters", CXMergeFilter::m_pszPXLImportExt); + lRet = ::RegOpenKeyEx(hKey, _T(szKeyName), 0, KEY_ALL_ACCESS, &hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegDeleteValue(hDataKey, CXMergeFilter::m_pszPXLExportCLSID); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + ::lstrcpyn(szKeyName, "\0", _MAX_PATH); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + // Remove the Calc import filter from the Calc export file extension subkey. + _snprintf(szKeyName, _MAX_PATH, ".%s\\InstalledFilters", CXMergeFilter::m_pszPXLExportExt); + lRet = ::RegOpenKeyEx(hKey, _T(szKeyName), 0, KEY_ALL_ACCESS, &hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegDeleteValue(hDataKey, CXMergeFilter::m_pszPXLImportCLSID); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + ::lstrcpyn(szKeyName, "\0", _MAX_PATH); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + // Make Binary Copy the default for Calc export file extension subkey DefaultImport + _snprintf(szKeyName, _MAX_PATH, ".%s\0", CXMergeFilter::m_pszPXLExportExt); + lRet = ::RegOpenKeyEx(hKey, _T(szKeyName), 0, KEY_ALL_ACCESS, &hDataKey); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + lRet = ::RegSetValueEx(hDataKey, _T("DefaultImport"), 0, REG_SZ, (LPBYTE)_T("Binary Copy"), + (::_tcslen(_T("Binary Copy")) * sizeof(TCHAR) + (1 * sizeof(TCHAR)))); + if (lRet != ERROR_SUCCESS) + return _signalRegError(lRet, hKey, hDataKey); + + ::lstrcpyn(szKeyName, "\0", _MAX_PATH); + ::RegCloseKey(hDataKey); hDataKey = NULL; + + + + ::RegCloseKey(hKey); hKey = NULL; + + return HRESULT_FROM_WIN32(lRet); +} + + +////////////////////////////////////////////////////////////////////// +// CXMergeSyncModule methods +////////////////////////////////////////////////////////////////////// +CXMergeSyncModule::CXMergeSyncModule () +{ +} + +CXMergeSyncModule::~CXMergeSyncModule () +{ +} + +long CXMergeSyncModule::LockServer(BOOL fLock) +{ + if(fLock) + return ::InterlockedIncrement(&m_lLocks); + else + return ::InterlockedDecrement(&m_lLocks); +} + +long CXMergeSyncModule::GetLockCount() +{ + return m_lLocks + m_lObjs; +} + diff --git a/xmerge/source/activesync/XMergeSync.def b/xmerge/source/activesync/XMergeSync.def new file mode 100644 index 000000000000..89de774085f8 --- /dev/null +++ b/xmerge/source/activesync/XMergeSync.def @@ -0,0 +1,9 @@ +
+LIBRARY "XMERGESYNC.DLL"
+DESCRIPTION 'XMerge Desktop Synchronization Module'
+
+EXPORTS
+ DllCanUnloadNow PRIVATE
+ DllGetClassObject PRIVATE
+ DllRegisterServer PRIVATE
+ DllUnregisterServer PRIVATE
diff --git a/xmerge/source/activesync/XMergeSync.dsp b/xmerge/source/activesync/XMergeSync.dsp new file mode 100644 index 000000000000..3c13e028e50b --- /dev/null +++ b/xmerge/source/activesync/XMergeSync.dsp @@ -0,0 +1,143 @@ +# Microsoft Developer Studio Project File - Name="XMergeSync" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102
+
+CFG=XMergeSync - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "XMergeSync.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "XMergeSync.mak" CFG="XMergeSync - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "XMergeSync - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE "XMergeSync - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""$/XMergeSync", BAAAAAAA"
+# PROP Scc_LocalPath "."
+CPP=cl.exe
+MTL=midl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "XMergeSync - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XMERGESYNC_EXPORTS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /O2 /I "C:\Program Files\Windows CE Tools\wce300\Pocket PC 2002\support\ActiveSync\inc" /I "C:\Java\j2sdk1.4.0\include" /I "C:\Java\j2sdk1.4.0\include\win32" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XMERGESYNC_EXPORTS" /YX /FD /c
+# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x1809 /d "NDEBUG"
+# ADD RSC /l 0x1809 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
+
+!ELSEIF "$(CFG)" == "XMergeSync - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XMERGESYNC_EXPORTS" /YX /FD /GZ /c
+# ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /I "C:\Program Files\Windows CE Tools\wce300\Pocket PC 2002\support\ActiveSync\inc" /I "C:\Java\j2sdk1.4.0\include" /I "C:\Java\j2sdk1.4.0\include\win32" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "XMERGESYNC_EXPORTS" /FR /YX /FD /GZ /c
+# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
+# ADD BASE RSC /l 0x1809 /d "_DEBUG"
+# ADD RSC /l 0x1809 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept /libpath:"C:\Java\j2sdk1.4.0\lib"
+
+!ENDIF
+
+# Begin Target
+
+# Name "XMergeSync - Win32 Release"
+# Name "XMergeSync - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=.\stdafx.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\XMergeFactory.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\XMergeFilter.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\XMergeSync.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\XMergeSync.def
+# End Source File
+# Begin Source File
+
+SOURCE=.\XMergeSync.rc
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=.\stdafx.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\XMergeFactory.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\XMergeFilter.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\XMergeSync.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/xmerge/source/activesync/XMergeSync.dsw b/xmerge/source/activesync/XMergeSync.dsw new file mode 100644 index 000000000000..eca2ade60ac1 --- /dev/null +++ b/xmerge/source/activesync/XMergeSync.dsw @@ -0,0 +1,33 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "XMergeSync"=.\XMergeSync.dsp - Package Owner=<4>
+
+Package=<5>
+{{{
+ begin source code control
+ "$/XMergeSync", BAAAAAAA
+ .
+ end source code control
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/xmerge/source/activesync/XMergeSync.h b/xmerge/source/activesync/XMergeSync.h new file mode 100644 index 000000000000..4242b755c1fa --- /dev/null +++ b/xmerge/source/activesync/XMergeSync.h @@ -0,0 +1,29 @@ +// XMergeSyncModule.h: interface for the CXMergeSyncModule class. +// +////////////////////////////////////////////////////////////////////// + +#if !defined(AFX_XMERGESYNCMODULE_H__0788DA0C_4DCB_4876_9722_F9EAF1EB5462__INCLUDED_) +#define AFX_XMERGESYNCMODULE_H__0788DA0C_4DCB_4876_9722_F9EAF1EB5462__INCLUDED_ + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + + +// Used to keep track of the dll + +class CXMergeSyncModule +{ +protected: + long m_lLocks; + long m_lObjs; + +public: + long GetLockCount(); + long LockServer(BOOL fLock); + HINSTANCE m_hInst; + CXMergeSyncModule(); + virtual ~CXMergeSyncModule(); +}; + +#endif // !defined(AFX_XMERGESYNCMODULE_H__0788DA0C_4DCB_4876_9722_F9EAF1EB5462__INCLUDED_) diff --git a/xmerge/source/activesync/XMergeSync.rc b/xmerge/source/activesync/XMergeSync.rc new file mode 100644 index 000000000000..b355bcad7adc --- /dev/null +++ b/xmerge/source/activesync/XMergeSync.rc @@ -0,0 +1,80 @@ +//Microsoft Developer Studio generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +<<<<<<< XMergeSync.rc +// #include "afxres.h" +======= +//#include "afxres.h" +>>>>>>> 1.1.12.1 + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (Ireland) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENI) +#ifdef _WIN32 +//LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_EIRE +LANGUAGE 0x9, 0x1 +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE DISCARDABLE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE DISCARDABLE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE DISCARDABLE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// String Table +// + +STRINGTABLE DISCARDABLE +BEGIN + IDS_NOJAVA "Unable to find JRE 1.4 installation." + IDS_BADCLASSPATH "Unable to locate necessary Jar files." +END + +#endif // English (Ireland) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/xmerge/source/activesync/exports.map b/xmerge/source/activesync/exports.map new file mode 100644 index 000000000000..8cda3e4980ad --- /dev/null +++ b/xmerge/source/activesync/exports.map @@ -0,0 +1,12 @@ +UDK_3_0_0 { + global: + GetVersionInfo; + DllCanUnloadNow; + DllGetClassObject; + DllRegisterServer; + DllUnregisterServer; + + local: + *; +}; + diff --git a/xmerge/source/activesync/guids.txt b/xmerge/source/activesync/guids.txt new file mode 100644 index 000000000000..1bde5587c169 --- /dev/null +++ b/xmerge/source/activesync/guids.txt @@ -0,0 +1,60 @@ +INTERFACENAME = { /* bdd611c3-7bab-460f-8711-5b9ac9ef6020 - StarWriter Export*/ + 0xbdd611c3, + 0x7bab, + 0x460f, + {0x87, 0x11, 0x5b, 0x9a, 0xc9, 0xef, 0x60, 0x20} + }; +INTERFACENAME = { /* cb43f086-838d-4fa4-b5f6-3406b9a57439 - Pocket Word Import */ + 0xcb43f086, + 0x838d, + 0x4fa4, + {0xb5, 0xf6, 0x34, 0x06, 0xb9, 0xa5, 0x74, 0x39} + }; +INTERFACENAME = { /* c6ab3e74-9f4f-4370-8120-a8a6fabb7a7c - StarCalc Export*/ + 0xc6ab3e74, + 0x9f4f, + 0x4370, + {0x81, 0x20, 0xa8, 0xa6, 0xfa, 0xbb, 0x7a, 0x7c} + }; +INTERFACENAME = { /* 43887c67-4d5d-4127-baac-87a288494c7c - Pocket Excel Import*/ + 0x43887c67, + 0x4d5d, + 0x4127, + {0xba, 0xac, 0x87, 0xa2, 0x88, 0x49, 0x4c, 0x7c} + }; +INTERFACENAME = { /* 300b7580-50f6-448b-aabb-9b823cab6e88 */ + 0x300b7580, + 0x50f6, + 0x448b, + {0xaa, 0xbb, 0x9b, 0x82, 0x3c, 0xab, 0x6e, 0x88} + }; +INTERFACENAME = { /* e88b223c-ffb4-456f-b93b-0f59594b228e */ + 0xe88b223c, + 0xffb4, + 0x456f, + {0xb9, 0x3b, 0x0f, 0x59, 0x59, 0x4b, 0x22, 0x8e} + }; +INTERFACENAME = { /* 8a538ec1-7d68-4ad0-9cf9-6e4d9f8c6ff0 */ + 0x8a538ec1, + 0x7d68, + 0x4ad0, + {0x9c, 0xf9, 0x6e, 0x4d, 0x9f, 0x8c, 0x6f, 0xf0} + }; +INTERFACENAME = { /* 7b613acf-9d1b-4bb9-b58e-15e0f5e21765 */ + 0x7b613acf, + 0x9d1b, + 0x4bb9, + {0xb5, 0x8e, 0x15, 0xe0, 0xf5, 0xe2, 0x17, 0x65} + }; +INTERFACENAME = { /* fbf4de58-cfe8-4244-bf73-6162035ae0c6 */ + 0xfbf4de58, + 0xcfe8, + 0x4244, + {0xbf, 0x73, 0x61, 0x62, 0x03, 0x5a, 0xe0, 0xc6} + }; +INTERFACENAME = { /* 62bf28c1-ce42-4b56-a218-980e8c4ba080 */ + 0x62bf28c1, + 0xce42, + 0x4b56, + {0xa2, 0x18, 0x98, 0x0e, 0x8c, 0x4b, 0xa0, 0x80} + }; diff --git a/xmerge/source/activesync/makefile.mk b/xmerge/source/activesync/makefile.mk new file mode 100644 index 000000000000..18d904f5e158 --- /dev/null +++ b/xmerge/source/activesync/makefile.mk @@ -0,0 +1,72 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ = ..$/.. +PRJNAME = xmerge +#PACKAGE = com$/sun$/star$/documentconversion$/XSLTFilter +TARGET = xmergesync +ENABLE_EXCEPTIONS=TRUE +LIBTARGET=NO +.IF "$(POCKETPCSDK_HOME)" != "" +SOLARINC+=-I$(POCKETPCSDK_HOME)$/support$/ActiveSync$/inc +.ENDIF # "$(POCKETPCSDK_HOME)" != "" + +# --- Settings ----------------------------------------------------- +.INCLUDE: settings.mk + +.IF 0 +.IF "$(GUI)" == "WNT" +.IF "$(POCKETPCSDK_HOME)" != "" + +RCFILES=XMergeSync.rc + +SLOFILES= \ + $(SLO)$/XMergeFactory.obj \ + $(SLO)$/XMergeSync.obj \ + $(SLO)$/XMergeFilter.obj +LIBNAME=$(TARGET) +SHL1TARGETDEPN=makefile.mk +SHL1OBJS=$(SLOFILES) $(RES)$/xmergesync.res +SHL1TARGET=$(LIBNAME) +SHL1IMPLIB=i$(LIBNAME) +SHL1DEF=XMergeSync.def +USE_DEFFILE=true + +SHL1STDLIBS= uuid.lib Advapi32.lib + +.ENDIF # "$(POCKETPCSDK_HOME)" != "" +.ENDIF +.ENDIF + + +# --- Targets ------------------------------------------------------ +.INCLUDE : target.mk + +ALLTAR : + .IF "$(GUI)" == "WNT" + $(COPY) BIN$/xmergesync.dll $(BIN) + .ENDIF diff --git a/xmerge/source/activesync/resource.h b/xmerge/source/activesync/resource.h new file mode 100644 index 000000000000..c670835a7455 --- /dev/null +++ b/xmerge/source/activesync/resource.h @@ -0,0 +1,17 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Developer Studio generated include file. +// Used by XMergeSync.rc +// +#define IDS_NOJAVA 1 +#define IDS_BADCLASSPATH 2 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1000 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/xmerge/source/activesync/stdafx.cpp b/xmerge/source/activesync/stdafx.cpp new file mode 100644 index 000000000000..eefe5176aad4 --- /dev/null +++ b/xmerge/source/activesync/stdafx.cpp @@ -0,0 +1,7 @@ +// +// stdafx.cpp : source file that includes just the standard includes +// stdafx.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information +// +#include "stdafx.h" + diff --git a/xmerge/source/activesync/stdafx.h b/xmerge/source/activesync/stdafx.h new file mode 100644 index 000000000000..26faa277a87c --- /dev/null +++ b/xmerge/source/activesync/stdafx.h @@ -0,0 +1,28 @@ +// +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, +// but are changed infrequently +// +#pragma once + +#include <windows.h> +#include <shlobj.h> +#include <stdio.h> +#include <tchar.h> +#include <time.h> + +#define INITGUIDS +#include <initguid.h> + +#include <cesync.h> +#include <replfilt.h> + +#include "XMergeSync.h" + +// +// This declares the one & only instance of the CXMergeSyncModule class. +// You can access any public members of this class through the +// global _Module. (Its definition is in XMergeSync.cpp.) +// +extern CXMergeSyncModule _Module; + |