From: <svn...@op...> - 2009-04-17 22:26:47
|
Author: henrik Date: Sat Apr 18 00:26:25 2009 New Revision: 5618 URL: http://www.opensync.org/changeset/5618 Log: Port to Windows/MinGW Modified: plugins/mozilla-sync/trunk/src/mozilla-calendar.cpp plugins/mozilla-sync/trunk/src/mozilla-config.cpp plugins/mozilla-sync/trunk/src/mozilla-headers.h plugins/mozilla-sync/trunk/src/mozilla-sync-utils.h plugins/mozilla-sync/trunk/src/mozilla-sync.cpp plugins/mozilla-sync/trunk/src/mozilla-xpcom.cpp plugins/mozilla-sync/trunk/src/thunderbird-addressbook.cpp plugins/mozilla-sync/trunk/src/thunderbird-card.cpp Modified: plugins/mozilla-sync/trunk/src/mozilla-calendar.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-calendar.cpp Sat Apr 18 00:25:03 2009 (r5617) +++ plugins/mozilla-sync/trunk/src/mozilla-calendar.cpp Sat Apr 18 00:26:25 2009 (r5618) @@ -174,7 +174,7 @@ rv=mss->OpenSpecialDatabase("profile", getter_AddRefs(myConn)); - if (!myConn) ERROR("No connection"); + if (!myConn) ERROR_MSG("No connection"); LOG(10, "Got storage service"); nsCOMPtr<mozIStorageStatement> statement; @@ -213,11 +213,11 @@ #if CALENDAR_VERSION==9 if (strcmp("0.14", szSchemaVersion)!=0 ) - ERROR("Compiled for Mozilla Calendar version 0.9, which expects calendar schema [0.14] but found calendar schema [%s]", + ERROR_MSG("Compiled for Mozilla Calendar version 0.9, which expects calendar schema [0.14] but found calendar schema [%s]", szSchemaVersion); #else if (strcmp(szCompiledCalendarVersion, szSchemaVersion)!=0 ) - ERROR("Compiled for Mozilla Calendar version [%s] but found calendar schema for version [%s]", + ERROR_MSG("Compiled for Mozilla Calendar version [%s] but found calendar schema for version [%s]", szCompiledCalendarVersion, szSchemaVersion); #endif @@ -273,7 +273,7 @@ MOZ_ERROR_CHECK_FALSE(rv, "ExecuteStep"); if (myStatement->IsNull(0)) - ERROR("SELECT FROM cal_events returned a NULL id"); + ERROR_MSG("SELECT FROM cal_events returned a NULL id"); return TRUE; } @@ -295,7 +295,7 @@ MOZ_ERROR_CHECK_FALSE(rv, "ExecuteStep"); if (myStatement->IsNull(0)) - ERROR("SELECT FROM cal_events returned a NULL id"); + ERROR_MSG("SELECT FROM cal_events returned a NULL id"); return TRUE; } Modified: plugins/mozilla-sync/trunk/src/mozilla-config.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-config.cpp Sat Apr 18 00:25:03 2009 (r5617) +++ plugins/mozilla-sync/trunk/src/mozilla-config.cpp Sat Apr 18 00:26:25 2009 (r5618) @@ -144,7 +144,7 @@ if (!fProfileDir) fProfileDir=find_default_profile_directory(&szProfileDir, pSzError, pLogFunction); if (!fProfileDir) - ERROR("Advanced option profile-directory was not set, and could not be determined automatically"); + ERROR_MSG("Advanced option profile-directory was not set, and could not be determined automatically"); pMozillaConfig->szProfileDirectory=strdup(szProfileDir); pMozillaConfig->thunderbirdAddressbook=FALSE; @@ -164,7 +164,7 @@ // Do not do osync_plugin_resource_unref(pOSyncPluginResource) - it will be accessed later. But why? if ( (pMozillaConfig->szAddressbookFile==NULL) && (pMozillaConfig->szCalendarId==NULL) ) - ERROR("At least one resource must be set: contact or event"); + ERROR_MSG("At least one resource must be set: contact or event"); return TRUE; } @@ -188,12 +188,12 @@ LOG(10, "Checking configuration file"); if (! g_file_test(pMozillaConfig->szProfileDirectory, G_FILE_TEST_EXISTS) ) - ERROR("profile-directory [%s] does not exist", pMozillaConfig->szProfileDirectory); + ERROR_MSG("profile-directory [%s] does not exist", pMozillaConfig->szProfileDirectory); if (! g_file_test(pMozillaConfig->szProfileDirectory, G_FILE_TEST_IS_DIR) ) - ERROR("profile-directory [%s] is not a directory", pMozillaConfig->szProfileDirectory); + ERROR_MSG("profile-directory [%s] is not a directory", pMozillaConfig->szProfileDirectory); gchar *szABF=g_strjoin(G_DIR_SEPARATOR_S, pMozillaConfig->szProfileDirectory, pMozillaConfig->szAddressbookFile, NULL); if (! g_file_test(szABF, G_FILE_TEST_EXISTS) ) - ERROR("addressbook-file [%s] does not exist", szABF); + ERROR_MSG("addressbook-file [%s] does not exist", szABF); GFREE(szABF); LOG(1, "Warning: Cannot check calendar id"); Modified: plugins/mozilla-sync/trunk/src/mozilla-headers.h ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-headers.h Sat Apr 18 00:25:03 2009 (r5617) +++ plugins/mozilla-sync/trunk/src/mozilla-headers.h Sat Apr 18 00:26:25 2009 (r5618) @@ -27,7 +27,7 @@ ================================================================ */ - +#include <mozilla-config.h> #ifdef XPCOM_GLUE #include <nsXPCOMGlue.h> Modified: plugins/mozilla-sync/trunk/src/mozilla-sync-utils.h ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-sync-utils.h Sat Apr 18 00:25:03 2009 (r5617) +++ plugins/mozilla-sync/trunk/src/mozilla-sync-utils.h Sat Apr 18 00:26:25 2009 (r5618) @@ -28,9 +28,9 @@ ================================================================ */ -// On FreeBSD we need libgen to define "basename" which is used in LOG +// On FreeBSD and Windows/MinGW we need libgen to define "basename" which is used in LOG -#if defined(__FreeBSD__) +#if defined(__FreeBSD__) || defined(WIN32) #include <libgen.h> #endif @@ -42,7 +42,7 @@ #define LOG_SENSITIVE(level, message ...) pLogFunction(level, true, basename(__FILE__), __LINE__, __func__, message); /** Create error message in the @c pSzError passed, and return **/ -#define ERROR(message ...) { \ +#define ERROR_MSG(message ...) { \ char *__szMsg=g_strdup_printf(message); \ *pSzError=g_strdup_printf("%s(%d)%s: %s", basename(__FILE__), __LINE__, __func__, __szMsg); return FALSE; } Modified: plugins/mozilla-sync/trunk/src/mozilla-sync.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-sync.cpp Sat Apr 18 00:25:03 2009 (r5617) +++ plugins/mozilla-sync/trunk/src/mozilla-sync.cpp Sat Apr 18 00:26:25 2009 (r5618) @@ -64,6 +64,7 @@ #include <stdio.h> #include <string.h> +#include "mozilla-headers.h" #include <opensync/opensync.h> #include <opensync/opensync-format.h> @@ -74,17 +75,16 @@ #include <opensync/opensync-capabilities.h> #include <opensync/opensync-xmlformat.h> -#include "mozilla-xpcom.h" -#include "thunderbird-addressbook.h" -#include "mozilla-calendar.h" - #include "thunderbird-card.h" #include "calendar-event.h" - +#include "thunderbird-addressbook.h" +#include "mozilla-calendar.h" +#include "mozilla-xpcom.h" #include "mozilla-sync.h" -// On FreeBSD we need libgen to define "basename" which is used in LOG -#if defined(__FreeBSD__) + +// On FreeBSD and Windows/MinGW we need libgen to define "basename" which is used in LOG +#if defined(__FreeBSD__) || defined(WIN32) #include <libgen.h> #endif @@ -182,7 +182,15 @@ char *__szMsg=g_strdup_vprintf(szFormat, ap); OSyncTraceType t=TRACE_INTERNAL; if (sensitive) t=TRACE_SENSITIVE; + +#ifdef WIN32 + char *_szFile=g_strdup(szFile); + osync_trace(TRACE_INTERNAL, "%s(%d)%s: %s", basename(_szFile), iLine, szFunc, __szMsg); + g_free(_szFile); +#else osync_trace(TRACE_INTERNAL, "%s(%d)%s: %s", basename(szFile), iLine, szFunc, __szMsg); +#endif + g_free(__szMsg); va_end(ap); } Modified: plugins/mozilla-sync/trunk/src/mozilla-xpcom.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/mozilla-xpcom.cpp Sat Apr 18 00:25:03 2009 (r5617) +++ plugins/mozilla-sync/trunk/src/mozilla-xpcom.cpp Sat Apr 18 00:26:25 2009 (r5618) @@ -31,8 +31,11 @@ #include <string.h> #include <stdio.h> #include <limits.h> + +#ifndef WIN32 #include <dlfcn.h> #include <link.h> +#endif #include "mozilla-headers.h" @@ -171,15 +174,20 @@ LOG(10, "Getting GRE path"); + char szGreDirectory[PATH_MAX]; +#ifdef WIN32 + szGreDirectory=""; + // TODO TODO TODO +#else void* mod=dlopen("libxpcom.so", RTLD_LAZY); if (mod==NULL) { *pSzError=g_strdup_printf("%s(%d): dlopen was not able to load libxpcom.so", __func__, __LINE__); return FALSE; } - char szGreDirectory[PATH_MAX]; int ret=dlinfo(mod, RTLD_DI_ORIGIN, szGreDirectory); if (ret<0) { *pSzError=g_strdup_printf("%s(%d): dlinfo was not able retrieve origin of libxpcom.so [%d]", __func__, __LINE__, ret); return FALSE; } +#endif nsCString csGre; rv = NS_CStringSetData(csGre, szGreDirectory); Modified: plugins/mozilla-sync/trunk/src/thunderbird-addressbook.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/thunderbird-addressbook.cpp Sat Apr 18 00:25:03 2009 (r5617) +++ plugins/mozilla-sync/trunk/src/thunderbird-addressbook.cpp Sat Apr 18 00:26:25 2009 (r5618) @@ -411,7 +411,7 @@ rv=myAddrDatabase->GetCardFromAttribute(myAbDirectory, OPEN_SYNC_KEY, szKey, PR_FALSE, getter_AddRefs(theCard)); #endif MOZ_ERROR_CHECK_FALSE(rv, "GetCardFromAttribute"); - if (!theCard) ERROR("Could not find card with key [%s] in Thunderbird Address-book", szKey); + if (!theCard) ERROR_MSG("Could not find card with key [%s] in Thunderbird Address-book", szKey); #ifdef TBIRD_3 rv=myAddrDatabase->DeleteCard(theCard, PR_FALSE, myAbDirectory); @@ -469,7 +469,7 @@ MOZ_ERROR_CHECK_FALSE(rv, "GetCardFromAttribute"); - if (!theCard) ERROR("Could not find card with key [%s] in Thunderbird Address-book", szKey); + if (!theCard) ERROR_MSG("Could not find card with key [%s] in Thunderbird Address-book", szKey); /* PRUnichar *ln16; Modified: plugins/mozilla-sync/trunk/src/thunderbird-card.cpp ============================================================================== --- plugins/mozilla-sync/trunk/src/thunderbird-card.cpp Sat Apr 18 00:25:03 2009 (r5617) +++ plugins/mozilla-sync/trunk/src/thunderbird-card.cpp Sat Apr 18 00:26:25 2009 (r5618) @@ -343,12 +343,12 @@ // -------------------- // Parse the XML data pParserCtxt = xmlNewParserCtxt(); - if (!pParserCtxt) ERROR("Unable to create XML parser context"); + if (!pParserCtxt) ERROR_MSG("Unable to create XML parser context"); pDoc=xmlCtxtReadMemory(pParserCtxt, szXML, strlen(szXML)+1, "", NULL, XML_PARSE_NOBLANKS+XML_PARSE_NOCDATA); if (!pDoc) { pXmlError=&(pParserCtxt->lastError); - ERROR("xmlCtxtReadMemory: %s", pXmlError->message); } + ERROR_MSG("xmlCtxtReadMemory: %s", pXmlError->message); } xmlFreeParserCtxt(pParserCtxt); // -------------------- @@ -356,10 +356,10 @@ pNode=xmlDocGetRootElement(pDoc); if (!pNode) { pXmlError=xmlGetLastError(); - ERROR("xmlDocGetRootElement unable to get root node: %s", pXmlError->message); } + ERROR_MSG("xmlDocGetRootElement unable to get root node: %s", pXmlError->message); } if ( xmlStrcmp(pNode->name, (const xmlChar*)"contact") != 0 ) - ERROR("Expected <contact> root node"); + ERROR_MSG("Expected <contact> root node"); // -------------------- // First we go though the pXmlGroupDef to find exact matches @@ -367,15 +367,15 @@ // Hash tables to remember nodes we have processed (first level nodes only, eg. <contact><address>) GHashTable *pHashTableNodes=g_hash_table_new(NULL, NULL); - if (!pHashTableNodes) ERROR("Unable to create hash table for nodes"); + if (!pHashTableNodes) ERROR_MSG("Unable to create hash table for nodes"); // Hash tables to remember Thunderbird properties we have filled out GHashTable *pHashTableProperties=g_hash_table_new(NULL, NULL); - if (!pHashTableProperties) ERROR("Unable to create hash table for properties"); + if (!pHashTableProperties) ERROR_MSG("Unable to create hash table for properties"); /* Create xpath evaluation context */ xpathCtx = xmlXPathNewContext(pDoc); - if (!xpathCtx) ERROR("Unable to create XPath context"); + if (!xpathCtx) ERROR_MSG("Unable to create XPath context"); XMLGroupDef *pXmlGroupDef; for (pXmlGroupDef=&(xmlContactDef.xmlGroupDef[0]); pXmlGroupDef->szGroup; pXmlGroupDef++) { @@ -403,7 +403,7 @@ LOG(1000, "Path %s", szXPathGroup); xpathObj = xmlXPathEvalExpression((const xmlChar*)szXPathGroup, xpathCtx); - if (!xpathObj) ERROR("Unable to evaluate XPath expression [%s]", szXPathGroup); + if (!xpathObj) ERROR_MSG("Unable to evaluate XPath expression [%s]", szXPathGroup); if (!xpathObj->nodesetval) continue; if (xpathObj->nodesetval->nodeNr<1) continue; |