summaryrefslogtreecommitdiff
path: root/xmerge/source/activesync
diff options
context:
space:
mode:
authormarkm <markm@openoffice.org>2002-07-26 15:18:12 +0000
committermarkm <markm@openoffice.org>2002-07-26 15:18:12 +0000
commita007e73e2c8635163d2421c852d33ad58a0b9155 (patch)
tree755e322b8140a4c540bbdb2e697827a48915dff3 /xmerge/source/activesync
parentda142f8a045316d9b60eb4618d8a5bffed7d9c86 (diff)
Initial checkin
Diffstat (limited to 'xmerge/source/activesync')
-rw-r--r--xmerge/source/activesync/XMergeFactory.cpp90
-rw-r--r--xmerge/source/activesync/XMergeFactory.h34
-rw-r--r--xmerge/source/activesync/XMergeFilter.cpp442
-rw-r--r--xmerge/source/activesync/XMergeFilter.h66
-rw-r--r--xmerge/source/activesync/XMergeSync.cpp837
-rw-r--r--xmerge/source/activesync/XMergeSync.def9
-rw-r--r--xmerge/source/activesync/XMergeSync.dsw33
-rw-r--r--xmerge/source/activesync/XMergeSync.h29
-rw-r--r--xmerge/source/activesync/XMergeSync.rc75
-rw-r--r--xmerge/source/activesync/guids.txt60
-rw-r--r--xmerge/source/activesync/resource.h17
-rw-r--r--xmerge/source/activesync/stdafx.cpp7
-rw-r--r--xmerge/source/activesync/stdafx.h28
13 files changed, 1727 insertions, 0 deletions
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..411366ba18d5
--- /dev/null
+++ b/xmerge/source/activesync/XMergeFilter.cpp
@@ -0,0 +1,442 @@
+// 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)
+{
+}
+
+CXMergeFilter::~CXMergeFilter()
+{
+
+}
+
+
+//////////////////////////////////////////////////////////////////////
+// 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)
+{
+ char errMsg[50];
+
+ switch(dwMessageId)
+ {
+ case ERR_NOJAVA:
+ lstrcpy(errMsg, "Unable to locate Java 1.4 installation.");
+ break;
+
+ case ERR_BADCLASSPATH:
+ lstrcpy(errMsg, "Unable to locate XMerge Jar files.");
+ break;
+
+ case ERR_INITJAVA:
+ lstrcpy(errMsg, "Error initialising Java Runtime Environment.");
+ break;
+ }
+
+ char* buf = (char*)LocalAlloc(LMEM_FIXED | LMEM_ZEROINIT, strlen(errMsg));
+ lstrcpy(buf, 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);
+
+ // Locate Java Home
+ TCHAR* szJavaDir = GetJavaBaseDir();
+ if (szJavaDir == NULL)
+ {
+ *perr = ERR_NOJAVA;
+ return HRESULT_FROM_WIN32(E_FAIL);
+ }
+
+
+ // Make sure that there is a Java executable
+ appName += szJavaDir;
+ appName += "\\bin\\javaw.exe";
+
+ // Make sure that Java actually exists
+ 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("\"");
+
+
+ // Get the StarOffice/OpenOffice class directory
+ TCHAR* szClassPath = GetXMergeClassPath();
+ if (szClassPath == NULL)
+ {
+ *perr = ERR_BADCLASSPATH;
+ delete szJavaDir;
+
+ return HRESULT_FROM_WIN32(E_FAIL);
+ }
+
+ // Need to build the entire command line for calling out to Java
+ appArgs = appName + " -Djava.class.path=";
+ appArgs += 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 ";
+ }
+
+
+ appArgs += psf->szFullpath;
+ appArgs += " ";
+ appArgs += pdf->szFullpath;
+
+ 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))
+ {
+ delete szClassPath;
+ delete szJavaDir;
+
+ *perr = ERR_INITJAVA;
+ return HRESULT_FROM_WIN32(E_FAIL);
+ }
+
+ // Wait for the new process to work
+ WaitForSingleObject(pi.hProcess, INFINITE);
+
+ delete szClassPath;
+ delete szJavaDir;
+
+ CloseHandle(pi.hProcess);
+ CloseHandle(pi.hThread);
+
+ return HRESULT_FROM_WIN32(ERROR_NO_MORE_ITEMS);
+}
+
+
+TCHAR* CXMergeFilter::GetJavaBaseDir()
+{
+ HRESULT lRet;
+
+ HKEY hKey = NULL;
+ HKEY hDataKey = NULL;
+
+ TCHAR szClassName[_MAX_PATH] = "\0";
+ TCHAR szKeyName[_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;
+
+ /*
+ * Need to enumerate the subkeys. The current version may not be 1.4 if
+ * multiple versions are installed on the system.
+ */
+ while ((lRet = ::RegEnumKeyEx(hKey, 0, szKeyName, &dwKeyName, 0, szClassName, &dwClassName, NULL))
+ != ERROR_NO_MORE_ITEMS)
+ {
+ if(!lstrcmp(szKeyName, "1.4"))
+ break;
+ }
+
+
+ // Found a Java 1.4 installation. Can now read its home directory.
+ lRet = ::RegOpenKeyEx(hKey, _T(szKeyName), 0, KEY_READ, &hDataKey);
+ if (lRet != ERROR_SUCCESS)
+ {
+ RegCloseKey(hKey);
+ return NULL;
+ }
+
+ // Location shouldn't be greater than _MAX_PATH
+ TCHAR* szJavaHome = new TCHAR[_MAX_PATH + 1];
+ DWORD dwSize = _MAX_PATH + 1;
+
+ // Now read the JavaHome value
+ 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 Office base directory can be found in the sversion.ini file in the
+ * user's profile directory.
+ *
+ * Supposed to be platform agnostic, but not quite sure yet!
+ */
+
+ TCHAR szIniPath[MAX_PATH];
+
+ if (SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, SHGFP_TYPE_CURRENT, szIniPath) != S_OK)
+ return NULL;
+ lstrcat(szIniPath, "\\sversion.ini");
+
+
+ // Should check the existence of the file here
+ TCHAR* szSectVal;
+ WIN32_FILE_ATTRIBUTE_DATA fInfo;
+
+ if (!GetFileAttributesEx(szIniPath, GetFileExInfoStandard, &fInfo))
+ return NULL;
+
+
+ szSectVal = new char[fInfo.nFileSizeLow];
+
+ if (!GetPrivateProfileSection("Versions", szSectVal, 3000, szIniPath))
+ {
+ delete szSectVal;
+ return NULL;
+ }
+
+ char* token = szSectVal;
+ std::string clsDir;
+
+ while (*token != '\0')
+ {
+ // Clear the clsDir each time we go around
+ clsDir = "";
+
+ // Check for a compatible StarOffice/OpenOffice version
+ if (!strncmp(token, "StarOffice 6", 12) || !strncmp(token, "OpenOffice.org 1", 12))
+ {
+ char* uri = token;
+
+ // Jump past the equals sign
+ uri = strchr(uri, '=') + 1;
+
+ // Lose the file:///
+ uri += 8;
+
+ for (int j = 0; j < strlen(uri); j++)
+ {
+ switch (uri[j])
+ {
+ case '/':
+ clsDir += '\\';
+ break;
+
+ case '%':
+ // Read in the two following characters
+ char* stop;
+ char buf[3];
+ buf[0] = uri[++j]; buf[1] = uri[++j]; buf[2] = '\0';
+ clsDir += (char)strtol(buf, &stop, 16);
+ break;
+
+ default:
+ clsDir += uri[j];
+ }
+ }
+ }
+ else
+ {
+ token += strlen(token) + 1;
+ continue;
+ }
+
+
+ // Append the JAR file subdirectory
+ clsDir += "\\program\\classes\\";
+
+ // Check for the existence of the necessary JAR files
+ std::string jars[3] = { clsDir + "xmerge.jar", clsDir + "pocketword.jar", clsDir + "pexcel.jar" };
+ BOOL found = TRUE;
+
+ for (int k = 0; k < 3; k++)
+ {
+ if (!GetFileAttributesEx(jars[k].c_str(), GetFileExInfoStandard, &fInfo))
+ {
+ found = FALSE;
+ break;
+ }
+ }
+
+ if (!found)
+ {
+ token += strlen(token) + 1;
+ continue;
+ }
+
+ // All files are present so return the classpath. Add in quotes in case of spaces
+ std::string clsPath = "\"" + jars[0] + ";" + jars[1] + ";" + jars[2] + ";" + "\"";
+
+ char* cPath = new char[clsPath.length() + 1];
+ ZeroMemory(cPath, clsPath.length() + 1);
+ strcpy(cPath, clsPath.c_str());
+
+ delete szSectVal;
+
+ return cPath;
+ }
+
+ delete szSectVal;
+
+ return NULL;
+}
diff --git a/xmerge/source/activesync/XMergeFilter.h b/xmerge/source/activesync/XMergeFilter.h
new file mode 100644
index 000000000000..fedeeeb48a34
--- /dev/null
+++ b/xmerge/source/activesync/XMergeFilter.h
@@ -0,0 +1,66 @@
+// 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();
+
+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.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..4cbeb065e0f5
--- /dev/null
+++ b/xmerge/source/activesync/XMergeSync.rc
@@ -0,0 +1,75 @@
+//Microsoft Developer Studio generated resource script.
+//
+#include "resource.h"
+
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+#include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (Ireland) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENI)
+#ifdef _WIN32
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_EIRE
+#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/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/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;
+