diff options
20 files changed, 424 insertions, 17 deletions
diff --git a/lib/native/windows-64/jmsoutlookaddrbook.dll b/lib/native/windows-64/jmsoutlookaddrbook.dll Binary files differindex 7072f4a..bb31a48 100755 --- a/lib/native/windows-64/jmsoutlookaddrbook.dll +++ b/lib/native/windows-64/jmsoutlookaddrbook.dll diff --git a/lib/native/windows-64/jmsoutlookaddrbookcomserver32.exe b/lib/native/windows-64/jmsoutlookaddrbookcomserver32.exe Binary files differindex b249bfd..c84b83c 100755 --- a/lib/native/windows-64/jmsoutlookaddrbookcomserver32.exe +++ b/lib/native/windows-64/jmsoutlookaddrbookcomserver32.exe diff --git a/lib/native/windows-64/jmsoutlookaddrbookcomserver64.exe b/lib/native/windows-64/jmsoutlookaddrbookcomserver64.exe Binary files differindex e78d5fa..94d102e 100755 --- a/lib/native/windows-64/jmsoutlookaddrbookcomserver64.exe +++ b/lib/native/windows-64/jmsoutlookaddrbookcomserver64.exe diff --git a/lib/native/windows/jmsoutlookaddrbook.dll b/lib/native/windows/jmsoutlookaddrbook.dll Binary files differindex 6e78e8d..7ce9e49 100755 --- a/lib/native/windows/jmsoutlookaddrbook.dll +++ b/lib/native/windows/jmsoutlookaddrbook.dll diff --git a/lib/native/windows/jmsoutlookaddrbookcomserver32.exe b/lib/native/windows/jmsoutlookaddrbookcomserver32.exe Binary files differindex 173e02a..aa6fecd 100755 --- a/lib/native/windows/jmsoutlookaddrbookcomserver32.exe +++ b/lib/native/windows/jmsoutlookaddrbookcomserver32.exe diff --git a/lib/native/windows/jmsoutlookaddrbookcomserver64.exe b/lib/native/windows/jmsoutlookaddrbookcomserver64.exe Binary files differindex ab3b767..e1a3150 100755 --- a/lib/native/windows/jmsoutlookaddrbookcomserver64.exe +++ b/lib/native/windows/jmsoutlookaddrbookcomserver64.exe diff --git a/src/native/addrbook/msoutlook/Logger.cxx b/src/native/addrbook/msoutlook/Logger.cxx new file mode 100644 index 0000000..438130e --- /dev/null +++ b/src/native/addrbook/msoutlook/Logger.cxx @@ -0,0 +1,108 @@ +/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+#include "Logger.h"
+#include <windows.h>
+#include <string.h>
+
+#define LOGGER_DATE_STRING_LENGTH 25
+
+/**
+ * Constructs new Logger object.
+ * @param pLogFile the filename of the log file.
+ * @param pLogPath the path of the log file.
+ */
+Logger::Logger(const char* pLogFile, const char* pLogPath)
+{
+ canWriteInFile = false;
+ if(pLogPath != NULL && strlen(pLogPath) != 0)
+ {
+ logPath = (char*)malloc((strlen(pLogPath)+1)*sizeof(char));
+ memcpy(logPath, pLogPath, strlen(pLogPath) + 1);
+ if(pLogFile != NULL && strlen(pLogFile) != 0)
+ {
+ logFile = (char*)malloc((strlen(pLogPath) + strlen(pLogFile) + 1)*sizeof(char));
+ sprintf(logFile, "%s%s", pLogPath, pLogFile);
+ file = fopen(logFile, "w");
+ if(file != NULL)
+ {
+ canWriteInFile = true;
+ }
+ }
+
+ }
+
+ if(!canWriteInFile)
+ {
+ logPath = NULL;
+ logFile = NULL;
+ file = NULL;
+ }
+}
+
+Logger::~Logger()
+{
+ if(logPath != NULL)
+ {
+ free(logPath);
+ }
+
+ if(logFile != NULL)
+ {
+ free(logFile);
+ }
+
+ if(canWriteInFile)
+ fclose(file);
+}
+
+const char* Logger::getCurrentFile()
+{
+ return "";
+}
+
+/**
+ * Returns current timestamp string.
+ */
+void Logger::getCurrentTimeString(char* dateString)
+{
+ SYSTEMTIME systemTime;
+ GetSystemTime(&systemTime);
+ sprintf(dateString,"[%u-%02u-%02u %02u:%02u:%02u.%u]",
+ systemTime.wYear,
+ systemTime.wMonth,
+ systemTime.wDay,
+ systemTime.wHour,
+ systemTime.wMinute,
+ systemTime.wSecond,
+ systemTime.wMilliseconds);
+}
+
+/**
+ * Logs a message
+ * @param message the message.
+ */
+void Logger::log(const char* message)
+{
+ if(canWriteInFile)
+ {
+ char *dateString = (char*)malloc(LOGGER_DATE_STRING_LENGTH*sizeof(char));
+ getCurrentTimeString(dateString);
+ fprintf(file, "%s %s: %s\n",dateString, getCurrentFile(), message);
+ fflush(file);
+ free(dateString);
+ }
+}
+
+/**
+ * Returns the path of the log file.
+ */
+char* Logger::getLogPath()
+{
+ return logPath;
+}
+
+
diff --git a/src/native/addrbook/msoutlook/Logger.h b/src/native/addrbook/msoutlook/Logger.h new file mode 100644 index 0000000..0b5831a --- /dev/null +++ b/src/native/addrbook/msoutlook/Logger.h @@ -0,0 +1,72 @@ +/*
+ * Jitsi, the OpenSource Java VoIP and Instant Messaging client.
+ *
+ * Distributable under LGPL license.
+ * See terms of license at gnu.org.
+ */
+#ifndef _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_LOGGER_H_
+#define _NET_JAVA_SIP_COMMUNICATOR_PLUGIN_ADDRBOOK_MSOUTLOOK_LOGGER_H_
+
+#include <stdio.h>
+
+/**
+ * Utility class for logging messages in file.
+ */
+class Logger
+{
+ /**
+ * The full file name of the log file
+ */
+ char* logFile;
+
+ /**
+ * The path of the file.
+ */
+ char* logPath;
+
+ /**
+ * The file handle.
+ */
+ FILE* file;
+
+ /**
+ * Indicates whether the log file is successfully opened or not.
+ */
+ bool canWriteInFile;
+
+ /**
+ * Returns current timestamp string.
+ */
+ void getCurrentTimeString(char*);
+
+ /**
+ * Not implemented.
+ */
+ const char* getCurrentFile();
+
+public:
+ /**
+ * Constructs new Logger object.
+ * @param pLogFile the filename of the log file.
+ * @param pLogPath the path of the log file.
+ */
+ Logger(const char* pLogFile, const char* pLogPath);
+
+ /**
+ * Destructor.
+ */
+ ~Logger();
+
+ /**
+ * Logs a message
+ * @param message the message.
+ */
+ void log(const char* message);
+
+ /**
+ * Returns the path of the log file.
+ */
+ char* getLogPath();
+};
+
+#endif
diff --git a/src/native/addrbook/msoutlook/MAPINotification.cxx b/src/native/addrbook/msoutlook/MAPINotification.cxx index 5a3a500..bdb78c5 100644 --- a/src/native/addrbook/msoutlook/MAPINotification.cxx +++ b/src/native/addrbook/msoutlook/MAPINotification.cxx @@ -11,6 +11,7 @@ #include "net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.h" #include "MsOutlookAddrBookContactSourceService.h" #include "MsOutlookAddrBookContactQuery.h" +#include "MsOutlookUtils.h" #include <mapidefs.h> #include <stdio.h> @@ -82,6 +83,7 @@ boolean MAPINotification_callCallbackMethod(LPSTR iUnknown, long objectAddr) { if(objectAddr <= 0) { + MsOutlookUtils_log("Callback object is null. We are calling insert method"); MAPINotification_jniCallInsertedMethod(iUnknown); return true; } @@ -114,12 +116,28 @@ boolean MAPINotification_callCallbackMethod(LPSTR iUnknown, long objectAddr) ptrOutlookContactCallbackMethodIdCallback, value); } + else + { + MsOutlookUtils_log("Error in MAPI Notification.[4]"); + } tmpJniEnv->DeleteLocalRef(callbackClass); } + else + { + MsOutlookUtils_log("Error in MAPI Notification.[3]"); + } + } + else + { + MsOutlookUtils_log("Error in MAPI Notification.[2]"); } MAPINotification_VM->DetachCurrentThread(); } + else + { + MsOutlookUtils_log("Error in MAPI Notification."); + } return proceed; } @@ -172,10 +190,16 @@ void MAPINotification_jniCallInsertedMethod(LPSTR iUnknown) jstring value = tmpJniEnv->NewStringUTF(iUnknown); if(MAPINotification_notificationsDelegateObject != NULL) + { tmpJniEnv->CallVoidMethod( MAPINotification_notificationsDelegateObject, MAPINotification_notificationsDelegateMethodIdInserted, value); + } + else + { + MsOutlookUtils_log("MAPI notification delegate is null."); + } if(MAPINotification_notificationsDelegateCalendarObject != NULL) tmpJniEnv->CallVoidMethod( diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx index f3d9d2f..41fb6fd 100644 --- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx +++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactQuery.cxx @@ -18,6 +18,7 @@ #include <Mapidefs.h> #include <Mapix.h> #include <windows.h> +#include "StringUtils.h" #define BODY_ENCODING_TEXT_AND_HTML ((ULONG) 0x00100000) #define DELETE_HARD_DELETE ((ULONG) 0x00000010) @@ -398,6 +399,7 @@ HRESULT MsOutlookAddrBookContactQuery_foreachMailUser( LPMAPISESSION mapiSession = MAPISession_getMapiSession(); if (!mapiSession) { + MsOutlookUtils_log("ERROR MAPI session not available. The query is aborted"); MAPISession_unlock(); return E_ABORT; } @@ -441,6 +443,10 @@ MsOutlookAddrBookContactQuery_foreachContactInMsgStoresTable callbackAddress); msgStoresTable->Release(); } + else + { + MsOutlookUtils_log("ERROR failed to get message stores table."); + } return proceed; } @@ -479,6 +485,10 @@ MsOutlookAddrBookContactQuery_foreachMailUser callbackAddress); mapiTable->Release(); } + else + { + MsOutlookUtils_log("Cannot get contents table."); + } /* Drill down the hierarchy. */ if (proceed) @@ -496,6 +506,10 @@ MsOutlookAddrBookContactQuery_foreachMailUser callbackAddress); mapiTable->Release(); } + else + { + MsOutlookUtils_log("Cannot get contents table.[2]"); + } } break; @@ -504,6 +518,7 @@ MsOutlookAddrBookContactQuery_foreachMailUser case MAPI_MAILUSER: case MAPI_MESSAGE: { + MsOutlookUtils_log("Contact found. Calling the callback."); if (MsOutlookAddrBookContactQuery_mailUserMatches( (LPMAPIPROP) iUnknown, query)) { @@ -566,7 +581,10 @@ MsOutlookAddrBookContactQuery_foreachRowInTable hResult = mapiTable->QueryRows(1, 0, &rows); if (HR_FAILED(hResult)) + { + MsOutlookUtils_log("ERROR failed to query row from msg stores table."); break; + } if (rows->cRows == 1) { @@ -623,18 +641,29 @@ MsOutlookAddrBookContactQuery_foreachRowInTable MAPIFreeBuffer(entryID); } else + { + MsOutlookUtils_log("Failed to allocate buffer."); MsOutlookAddrBookContactQuery_freeSRowSet(rows); + } } else + { + MsOutlookUtils_log("ERROR wrong type of the msg store"); MsOutlookAddrBookContactQuery_freeSRowSet(rows); + } } else { + MsOutlookUtils_log("ERROR queried rows are more than 1."); MAPIFreeBuffer(rows); break; } } } + else + { + MsOutlookUtils_log("ERROR failed to seek row from msg stores table."); + } return proceed; } @@ -1600,6 +1629,10 @@ MsOutlookAddrBookContactQuery_onForeachContactInMsgStoresTableRow MsOutlookAddrBookContactQuery_rdOpenEntryUlFlags); MAPIFreeBuffer(receiveFolderEntryID); } + else + { + MsOutlookUtils_log("Failed to get msg store receive folder."); + } if (HR_FAILED(hResult)) { hResult = MsOutlookAddrBookContactQuery_getContactsFolderEntryID( @@ -1633,10 +1666,22 @@ MsOutlookAddrBookContactQuery_onForeachContactInMsgStoresTableRow callbackAddress); contactsFolder->Release(); } + else + { + MsOutlookUtils_log("Cannot open the folder."); + } MAPIFreeBuffer(contactsFolderEntryID); } + else + { + MsOutlookUtils_log("Cannot find the folder."); + } msgStore->Release(); } + else + { + MsOutlookUtils_log("Failed to open msg store."); + } return proceed; } @@ -1675,6 +1720,7 @@ MsOutlookAddrBookContactQuery_onForeachMailUserInContainerTableRow } else { + MsOutlookUtils_log("Failed to open container table."); /* We've failed but other parts of the hierarchy may still succeed. */ proceed = JNI_TRUE; } diff --git a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx index 88754d1..d9b1e25 100644 --- a/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx +++ b/src/native/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.cxx @@ -11,7 +11,9 @@ #include "MAPINotification.h" #include "MAPISession.h" #include "MAPIBitness.h" +#include "MsOutlookUtils.h" #include <Tchar.h> +#include "StringUtils.h" typedef BOOL (STDAPICALLTYPE *LPFBINFROMHEX)(LPSTR, LPBYTE); typedef void (STDAPICALLTYPE *LPFREEPROWS)(LPSRowSet); @@ -278,12 +280,14 @@ HRESULT MsOutlookAddrBookContactSourceService_MAPIInitialize // If we've determined that we'd like to go on with MAPI, try to load it. if (HR_SUCCEEDED(hResult)) { + MsOutlookUtils_log("Loading MAPI."); MsOutlookAddrBookContactSourceService_hMapiLib = ::LoadLibrary(_T("mapi32.dll")); hResult = MAPI_E_NO_SUPPORT; if(MsOutlookAddrBookContactSourceService_hMapiLib) { + MsOutlookUtils_log("Loading MAPI functions"); // get and check function pointers MsOutlookAddrBookContactSourceService_mapiInitialize = (LPMAPIINITIALIZE) GetProcAddress( @@ -431,11 +435,17 @@ HRESULT MsOutlookAddrBookContactSourceService_MAPIInitialize } } } + else + { + MsOutlookUtils_log("ERROR - we won't load MAPI."); + } if (HR_FAILED(hResult)) { + MsOutlookUtils_log("ERROR - in MAPI native init."); if(MsOutlookAddrBookContactSourceService_hMapiLib) { + MsOutlookUtils_log("ERROR - free MAPI library."); FreeLibrary(MsOutlookAddrBookContactSourceService_hMapiLib); MsOutlookAddrBookContactSourceService_hMapiLib = NULL; } @@ -454,13 +464,18 @@ HRESULT MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer(void) HRESULT hr = E_FAIL; MAPISession_lock(); - + MsOutlookUtils_log("Init com server."); // Start COM service if((hr = MsOutlookAddrBookContactSourceService_startComServer()) == S_OK) { + MsOutlookUtils_log("COM Server started."); // Start COM client ComClient_start(); } + else + { + MsOutlookUtils_log("Failed to start COM Server."); + } MAPISession_unlock(); @@ -537,6 +552,7 @@ HRESULT MsOutlookAddrBookContactSourceService_NativeMAPIInitialize (jlong version, jlong flags, void * deletedMethod, void * insertedMethod, void * updatedMethod) { + MsOutlookUtils_log("MAPI native init."); MAPINotification_registerNativeNotificationsDelegate( deletedMethod, insertedMethod, updatedMethod); @@ -620,11 +636,31 @@ HRESULT MsOutlookAddrBookContactSourceService_startComServer(void) memset(&processInfo, 0, sizeof(processInfo)); startupInfo.dwFlags = STARTF_USESHOWWINDOW; startupInfo.wShowWindow = SW_HIDE; - + char* loggerPath = MsOutlookUtils_getLoggerPath(); + int loggerPathLenght = 0; + char* comServerWithLogger; + char* appNameWithLogger; + if(loggerPath != NULL) + { + loggerPathLenght = strlen(loggerPath); + comServerWithLogger + = (char*) malloc( + (FILENAME_MAX + loggerPathLenght) * sizeof(char)); + appNameWithLogger + = (char*) malloc( + (FILENAME_MAX + loggerPathLenght) * sizeof(char)); + sprintf(comServerWithLogger, "%s %s", comServer, loggerPath); + sprintf(appNameWithLogger, "%s %s", applicationName, loggerPath); + } + else + { + comServerWithLogger = comServer; + appNameWithLogger = applicationName; + } // Test 2 files: 0 for the build version, 1 for the git source version. char * serverExec[2]; - serverExec[0] = comServer; - serverExec[1] = applicationName; + serverExec[0] = comServerWithLogger; + serverExec[1] = appNameWithLogger; for(int i = 0; i < 2; ++i) { // Create the COM server @@ -637,10 +673,21 @@ HRESULT MsOutlookAddrBookContactSourceService_startComServer(void) { MsOutlookAddrBookContactSourceService_comServerHandle = processInfo.hProcess; - + MsOutlookUtils_log("COM Server started successful.[1]"); + if(loggerPath != NULL) + { + free(comServerWithLogger); + free(appNameWithLogger); + } + MsOutlookUtils_log("COM Server started successful.[2]"); return S_OK; } } + if(loggerPath != NULL) + { + free(comServerWithLogger); + free(appNameWithLogger); + } } return E_FAIL; diff --git a/src/native/addrbook/msoutlook/MsOutlookUtils.cxx b/src/native/addrbook/msoutlook/MsOutlookUtils.cxx index 86e501a..5855cf2 100644 --- a/src/native/addrbook/msoutlook/MsOutlookUtils.cxx +++ b/src/native/addrbook/msoutlook/MsOutlookUtils.cxx @@ -21,7 +21,9 @@ #include <Mapidefs.h> #include <Mapix.h> #include <windows.h> +#include "Logger.h" +static Logger* logger = NULL; HRESULT @@ -402,3 +404,28 @@ MsOutlookUtils_IMAPIProp_GetProps( return javaProps; } + +void MsOutlookUtils_createLogger(const char* logFile, const char* logPath) +{ + logger = new Logger(logFile, logPath); +} + +void MsOutlookUtils_log(const char* message) +{ + if(logger != NULL) + logger->log(message); +} + + +void MsOutlookUtils_deleteLogger() +{ + if(logger != NULL) + free(logger); +} + +char* MsOutlookUtils_getLoggerPath() +{ + if(logger != NULL) + return logger->getLogPath(); + return NULL; +} diff --git a/src/native/addrbook/msoutlook/MsOutlookUtils.h b/src/native/addrbook/msoutlook/MsOutlookUtils.h index 023d4d1..331ff03 100644 --- a/src/native/addrbook/msoutlook/MsOutlookUtils.h +++ b/src/native/addrbook/msoutlook/MsOutlookUtils.h @@ -10,6 +10,14 @@ #include <mapidefs.h> #include <jni.h> +void MsOutlookUtils_createLogger(const char* logFile, const char* logPath); + +void MsOutlookUtils_log(const char* message); + +void MsOutlookUtils_deleteLogger(); + +char* MsOutlookUtils_getLoggerPath(); + HRESULT MsOutlookUtils_getFolderEntryIDByType (LPMDB msgStore, diff --git a/src/native/addrbook/msoutlook/com/ComClient.cxx b/src/native/addrbook/msoutlook/com/ComClient.cxx index af29b3c..52e5439 100644 --- a/src/native/addrbook/msoutlook/com/ComClient.cxx +++ b/src/native/addrbook/msoutlook/com/ComClient.cxx @@ -9,8 +9,10 @@ #include "../MAPIBitness.h" #include "MsOutlookAddrBookServerClassFactory.h" #include "MsOutlookAddrBookClientClassFactory.h" +#include "../MsOutlookUtils.h" #include "TypeLib.h" + #include <process.h> #include <stdio.h> @@ -43,6 +45,7 @@ void ComClient_start(void) { HRESULT hr = E_FAIL; + MsOutlookUtils_log("Starting COM client."); if((hr = CoInitializeEx(NULL, COINIT_MULTITHREADED)) == S_OK || hr == S_FALSE) { @@ -65,17 +68,22 @@ void ComClient_start(void) = new MsOutlookAddrBookClientClassFactory(); if(ComClient_classFactory->registerClassObject() != S_OK) { + MsOutlookUtils_log("Failed to start COM client.[1]"); ComClient_classFactory->Release(); ComClient_classFactory = NULL; } ::CoResumeClassObjects(); - + MsOutlookUtils_log("COM Client is started."); retry = 0; } Sleep(1000); --retry; } } + else + { + MsOutlookUtils_log("Failed to start COM client."); + } } diff --git a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx index 6a7300e..07f7d0b 100644 --- a/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx +++ b/src/native/addrbook/msoutlook/com/MsOutlookAddrBookServer.cxx @@ -15,7 +15,7 @@ #include "../StringUtils.h" #include "../MsOutlookAddrBookContactQuery.h" #include "../MsOutlookCalendar.h" - +#include "../MsOutlookUtils.h" /** * Instanciates a new MsOutlookAddrBookServer. */ @@ -113,6 +113,7 @@ HRESULT STDMETHODCALLTYPE MsOutlookAddrBookServer::foreachMailUser( HRESULT hr = E_FAIL; + MsOutlookUtils_log("Executing query."); IMsOutlookAddrBookClient * msOutlookAddrBookClient = NULL; if((hr = CoCreateInstance( CLSID_MsOutlookAddrBookClient, @@ -129,6 +130,10 @@ HRESULT STDMETHODCALLTYPE MsOutlookAddrBookServer::foreachMailUser( msOutlookAddrBookClient->Release(); } + else + { + MsOutlookUtils_log("Error can't access the COM client."); + } free(charQuery); @@ -217,6 +222,7 @@ boolean MsOutlookAddrBookServer::foreachMailUserCallback( if(callbackClient) { + MsOutlookUtils_log("Contact received. The contact will be send to the client."); LPWSTR iUnknownW = StringUtils::MultiByteToWideChar(iUnknown); BSTR res = SysAllocString(iUnknownW); @@ -226,6 +232,10 @@ boolean MsOutlookAddrBookServer::foreachMailUserCallback( SysFreeString(res); free(iUnknownW); } + else + { + MsOutlookUtils_log("No callback client"); + } return (hr == S_OK); } diff --git a/src/native/addrbook/msoutlook/com/server/Server.cxx b/src/native/addrbook/msoutlook/com/server/Server.cxx index 841c96e..8bb761c 100644 --- a/src/native/addrbook/msoutlook/com/server/Server.cxx +++ b/src/native/addrbook/msoutlook/com/server/Server.cxx @@ -11,6 +11,7 @@ #include "../MsOutlookAddrBookClient.h" #include "../MsOutlookAddrBookServerClassFactory.h" #include "../TypeLib.h" +#include "../../MsOutlookUtils.h" #include <stdio.h> #include <TlHelp32.h> @@ -29,12 +30,19 @@ int main(int argc, char** argv) { HRESULT hr = E_FAIL; + + if(argc > 1) + { + MsOutlookUtils_createLogger("msoutlookaddrbook_server.log",argv[1]); + } + + MsOutlookUtils_log("Starting the Outlook Server."); if((hr = ::CoInitializeEx(NULL, COINIT_MULTITHREADED)) != S_OK && hr != S_FALSE) { + MsOutlookUtils_log("Error in initialization of the Outlook Server.[1]"); return hr; } - MAPISession_initLock(); if(MsOutlookAddrBookContactSourceService_NativeMAPIInitialize( MAPI_INIT_VERSION, @@ -44,6 +52,7 @@ int main(int argc, char** argv) (void*) Server_updated) != S_OK) { + MsOutlookUtils_log("Error in native MAPI initialization of the Outlook Server.[2]"); CoUninitialize(); return hr; } @@ -52,22 +61,36 @@ int main(int argc, char** argv) LPTYPELIB typeLib = TypeLib_loadRegTypeLib(path); if(typeLib != NULL) { + + MsOutlookUtils_log("TLB initialized."); ClassFactory *classObject = new MsOutlookAddrBookServerClassFactory(); if(classObject != NULL) { + MsOutlookUtils_log("Server object created."); hr = classObject->registerClassObject(); hr = ::CoResumeClassObjects(); + MsOutlookUtils_log("Server started."); waitParentProcessStop(); + MsOutlookUtils_log("Stop waiting.[3]"); hr = ::CoSuspendClassObjects(); hr = classObject->revokeClassObject(); classObject->Release(); } + else + { + MsOutlookUtils_log("Error - server object can't be created."); + } TypeLib_releaseTypeLib(typeLib); } + else + { + MsOutlookUtils_log("Error - TLB isn't initialized."); + } MsOutlookAddrBookContactSourceService_NativeMAPIUninitialize(); + MsOutlookUtils_deleteLogger(); MAPISession_freeLock(); CoUninitialize(); @@ -80,9 +103,11 @@ int main(int argc, char** argv) */ void waitParentProcessStop() { + MsOutlookUtils_log("Waits parent process to stop."); HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if(handle != INVALID_HANDLE_VALUE) { + MsOutlookUtils_log("Valid handle is found."); PROCESSENTRY32 processEntry; memset(&processEntry, 0, sizeof(processEntry)); processEntry.dwSize = sizeof(PROCESSENTRY32); @@ -111,6 +136,7 @@ void waitParentProcessStop() WaitForSingleObject(parentHandle, INFINITE); GetExitCodeProcess(parentHandle, &exitCode); } + MsOutlookUtils_log("Stop waiting.[1]"); CloseHandle(parentHandle); return; } @@ -119,6 +145,11 @@ void waitParentProcessStop() } CloseHandle(handle); } + else + { + MsOutlookUtils_log("Error - not valid handle found."); + } + MsOutlookUtils_log("Stop waiting.[2]"); } /** diff --git a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx index 0987a62..87b4ebf 100644 --- a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx +++ b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactQuery.cxx @@ -93,6 +93,7 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac jstring query, jobject callback) { + MsOutlookUtils_log("Executing query."); const char *nativeQuery = jniEnv->GetStringUTFChars(query, NULL); IMsOutlookAddrBookServer * iServer = ComClient_getIServer(); @@ -100,11 +101,15 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac { LPWSTR unicodeQuery = StringUtils::MultiByteToWideChar(nativeQuery); BSTR comQuery = SysAllocString(unicodeQuery); - + MsOutlookUtils_log("Sending the query to server."); iServer->foreachMailUser(comQuery, (long)(intptr_t)callback); SysFreeString(comQuery); free(unicodeQuery); } + else + { + MsOutlookUtils_log("Failed to execute the query because the COM Server is not available."); + } jniEnv->ReleaseStringUTFChars(query, nativeQuery); } diff --git a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx index afe9461..db4138d 100644 --- a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx +++ b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.cxx @@ -12,22 +12,27 @@ #include "MsOutlookMAPIHResultException.h" #include "MAPINotification.h" #include "MAPIBitness.h" +#include "MsOutlookUtils.h" JNIEXPORT void JNICALL Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_MAPIInitialize (JNIEnv *jniEnv, jclass clazz, jlong version, jlong flags, - jobject notificationsDelegate) + jobject notificationsDelegate, jstring logPath) { HRESULT hr; MAPINotification_registerJniNotificationsDelegate( jniEnv, notificationsDelegate); + const char* logFileString = jniEnv->GetStringUTFChars(logPath, NULL); + MsOutlookUtils_createLogger("msoutlookaddrbook.log", logFileString); + jniEnv->ReleaseStringUTFChars(logPath, logFileString); hr = MsOutlookAddrBookContactSourceService_MAPIInitializeCOMServer(); if (HR_FAILED(hr)) { + MsOutlookUtils_log("Failed to init COM Server"); // Report any possible error regardless of where it has come from. MsOutlookMAPIHResultException_throwNew( jniEnv, @@ -43,6 +48,7 @@ Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContac MAPINotification_unregisterJniNotificationsDelegate(jniEnv); MsOutlookAddrBookContactSourceService_MAPIUninitializeCOMServer(); + MsOutlookUtils_deleteLogger(); } /** diff --git a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h index 10b142f..25dd38e 100644 --- a/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h +++ b/src/native/addrbook/msoutlook/net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService.h @@ -7,15 +7,13 @@ #ifdef __cplusplus extern "C" { #endif - /* * Class: net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService * Method: MAPIInitialize - * Signature: (JJ)V + * Signature: (JJLnet/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService/NotificationsDelegate;Ljava/lang/String;)V */ -JNIEXPORT void JNICALL
- Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_MAPIInitialize
- (JNIEnv *, jclass, jlong, jlong, jobject); +JNIEXPORT void JNICALL Java_net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService_MAPIInitialize + (JNIEnv *, jclass, jlong, jlong, jobject, jstring); /* * Class: net_java_sip_communicator_plugin_addrbook_msoutlook_MsOutlookAddrBookContactSourceService diff --git a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java index 094b36e..4da53a0 100644 --- a/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java +++ b/src/net/java/sip/communicator/plugin/addrbook/msoutlook/MsOutlookAddrBookContactSourceService.java @@ -128,10 +128,26 @@ public class MsOutlookAddrBookContactSourceService { if(!isMAPIInitialized) { + String logFileName = ""; + if(logger.isTraceEnabled()) + { + String homeLocation = System.getProperty( + "net.java.sip.communicator.SC_LOG_DIR_LOCATION"); + String dirName = System.getProperty( + "net.java.sip.communicator.SC_HOME_DIR_NAME"); + + if(homeLocation != null && dirName != null) + { + logFileName = homeLocation + "\\" + dirName + + "\\log\\"; + } + } + MAPIInitialize( MAPI_INIT_VERSION, MAPI_MULTITHREAD_NOTIFICATIONS, - notificationDelegate); + notificationDelegate, + logFileName); isMAPIInitialized = true; } } @@ -174,7 +190,8 @@ public class MsOutlookAddrBookContactSourceService private static native void MAPIInitialize( long version, long flags, - NotificationsDelegate callback) + NotificationsDelegate callback, + String logFileName) throws MsOutlookMAPIHResultException; /** |