diff options
author | George Hazan <ghazan@miranda.im> | 2022-01-26 18:39:36 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2022-01-26 18:39:36 +0300 |
commit | 571a42dfc1c3b3d374d0239e1f139fcfd3a5b06c (patch) | |
tree | d7c11d869677becea6291e3cd25b0f6e5c95d3b1 /protocols/LotusNotify/src | |
parent | 1a8b125e5f9859b9e99c59cf0cf946bc583ccef1 (diff) |
fixes #3007 (LotusNotify: падение при выборе аккаунта)
Diffstat (limited to 'protocols/LotusNotify/src')
-rw-r--r-- | protocols/LotusNotify/src/LotusNotify.cpp | 944 | ||||
-rw-r--r-- | protocols/LotusNotify/src/debug.h | 2 | ||||
-rw-r--r-- | protocols/LotusNotify/src/options.cpp | 602 | ||||
-rw-r--r-- | protocols/LotusNotify/src/stdafx.h | 23 | ||||
-rw-r--r-- | protocols/LotusNotify/src/version.h | 2 |
5 files changed, 781 insertions, 792 deletions
diff --git a/protocols/LotusNotify/src/LotusNotify.cpp b/protocols/LotusNotify/src/LotusNotify.cpp index 2f7bb85054..4c86622fa0 100644 --- a/protocols/LotusNotify/src/LotusNotify.cpp +++ b/protocols/LotusNotify/src/LotusNotify.cpp @@ -17,11 +17,8 @@ There is no warranty. INT_PTR SetStatus(WPARAM wParam, LPARAM lParam); -#define MAX_FIELD 256 -#define MAX_SETTING_STR 512 -#define STATUS_COUNT 9 +int LotusNotifyOptInit(WPARAM wParam, LPARAM); -char MODULENAME[64] = {0}; //init at init_pluginname(); CMPlugin g_plugin; HINSTANCE hLotusDll; @@ -36,17 +33,17 @@ HANDLE hCheckEvent = nullptr; static HWND hTimerWnd = (HWND)nullptr; static UINT TID = (UINT)2006; -char settingServer[MAX_SETTING_STR] = "", settingServerSec[MAX_SETTING_STR] = "", settingDatabase[MAX_SETTING_STR] = "", - settingCommand[MAX_SETTING_STR] = "", settingParameters[MAX_SETTING_STR] = "", settingPassword[MAX_SETTING_STR] = ""; +char settingServer[MAX_SETTING_STR] = "", settingServerSec[MAX_SETTING_STR] = "", settingDatabase[MAX_SETTING_STR] = ""; +char settingCommand[MAX_SETTING_STR] = "", settingParameters[MAX_SETTING_STR] = "", settingPassword[MAX_SETTING_STR] = ""; wchar_t settingFilterSubject[MAX_SETTING_STR] = TEXT(""), settingFilterSender[MAX_SETTING_STR] = TEXT(""), settingFilterTo[MAX_SETTING_STR] = TEXT(""); COLORREF settingBgColor, settingFgColor; int settingInterval = 0, settingInterval1 = 0; uint32_t settingNewestID = 0; -uint8_t settingSetColours = 0, settingShowError = 1, settingIniAnswer = -1, settingIniCheck = 0, - settingOnceOnly = 0, settingNonClickedOnly = 0, settingNewest = 0, settingEvenNonClicked = 0, settingKeepConnection = 1; +uint8_t settingSetColours = 0, settingShowError = 1, settingIniAnswer = -1, settingIniCheck = 0; +uint8_t settingOnceOnly = 0, settingNonClickedOnly = 0, settingNewest = 0, settingEvenNonClicked = 0, settingKeepConnection = 1; BOOL settingStatus[STATUS_COUNT]; -BOOL bMirandaCall=FALSE; +BOOL bMirandaCall = FALSE; struct HISTORIA *first = nullptr; BOOL running = FALSE; @@ -61,7 +58,7 @@ wchar_t *startuperrors[] = { LPGENW("Unable to initialize Notes."), LPGENW("Lotus Notes Extension Manager was not registered. Authentication function will not work properly"), LPGENW("In notes.ini file there is no required entry EXTMGR_ADDINS=plugindllnamewithout\".dll\"") - }; +}; ///////////////////////////////////////////////////////////////////////////////////////// @@ -90,26 +87,26 @@ extern "C" __declspec(dllexport) const MUUID MirandaInterfaces[] = { MIID_PROTOC ///////////////////////////////////////////////////////////////////////////////////////// // authentication callback futnction from extension manager called by nnotes.dll -STATUS LNPUBLIC __stdcall EMCallBack (EMRECORD * pData) +STATUS LNPUBLIC __stdcall EMCallBack(EMRECORD *pData) { VARARG_PTR pArgs; uint32_t maxPwdLen; - uint32_t * retLength; - char * retPassword; - char * fileName; - char * ownerName; + uint32_t *retLength; + char *retPassword; + char *fileName; + char *ownerName; if (pData->EId != EM_GETPASSWORD) return (ERR_EM_CONTINUE); //asking for password? if (pData->Status != NOERROR) return (ERR_EM_CONTINUE); - pArgs= pData->Ap; - maxPwdLen = VARARG_GET (pArgs, uint32_t); - retLength = VARARG_GET (pArgs, uint32_t *); - retPassword = VARARG_GET (pArgs, char *); - fileName = VARARG_GET (pArgs, char *); - ownerName = VARARG_GET (pArgs, char *); + pArgs = pData->Ap; + maxPwdLen = VARARG_GET(pArgs, uint32_t); + retLength = VARARG_GET(pArgs, uint32_t *); + retPassword = VARARG_GET(pArgs, char *); + fileName = VARARG_GET(pArgs, char *); + ownerName = VARARG_GET(pArgs, char *); strncpy(retPassword, settingPassword, mir_strlen(settingPassword)); //set our password - retPassword[mir_strlen(settingPassword)]='\0'; + retPassword[mir_strlen(settingPassword)] = '\0'; *retLength = (uint32_t)mir_strlen(retPassword);//and his length return ERR_BSAFE_EXTERNAL_PASSWORD; } @@ -117,12 +114,12 @@ STATUS LNPUBLIC __stdcall EMCallBack (EMRECORD * pData) //Main entry point for Ext Manager of Lotus API. called by nnotes.dll //It don't work (don't know why), and Mirandas Load function is called with value 1 or 0 as parameter... -__declspec(dllexport)STATUS LNPUBLIC MainEntryPoint (void) +__declspec(dllexport)STATUS LNPUBLIC MainEntryPoint(void) { - STATUS rc = EMRegister1 (EM_GETPASSWORD, EM_REG_BEFORE | EM_REG_AFTER, EMCallBack, 0, &hLotusRegister); //Extension Manager must know that we are here - if(rc) { + STATUS rc = EMRegister1(EM_GETPASSWORD, EM_REG_BEFORE | EM_REG_AFTER, EMCallBack, 0, &hLotusRegister); //Extension Manager must know that we are here + if (rc) { //Extension magager don't know who we are :( - startuperror+=8; + startuperror += 8; // Get the info from the .ini file } return rc; @@ -135,7 +132,8 @@ void ExtClear() STATUS status; if (0 != hLotusRegister) { status = EMDeregister1(&hLotusRegister); //we was registered, so let's unregister - } else { + } + else { status = NOERROR; } log_p(L"ExtClear() status=%d", status); @@ -144,13 +142,12 @@ void ExtClear() //check if msg was clicked and exists on msgs list -struct HISTORIA* getEl(uint32_t id) +struct HISTORIA *getEl(uint32_t id) { - for(struct HISTORIA *cur = first; cur != nullptr; cur = cur->next) - { - if(cur->noteID == id) + for (struct HISTORIA *cur = first; cur != nullptr; cur = cur->next) + if (cur->noteID == id) return cur; - } + return nullptr; } @@ -158,7 +155,7 @@ struct HISTORIA* getEl(uint32_t id) //creates new entry on list of msgs void addNewId(uint32_t id) { - struct HISTORIA* nowy = (struct HISTORIA*)mir_alloc(sizeof(struct HISTORIA)) ; + struct HISTORIA *nowy = (struct HISTORIA *)mir_alloc(sizeof(struct HISTORIA)); assert(nowy); nowy->noteID = id; nowy->next = first; @@ -169,9 +166,9 @@ void addNewId(uint32_t id) //add popup handle. This queue is used to close popups with same msg -void addPopup(uint32_t id,HWND hWnd) +void addPopup(uint32_t id, HWND hWnd) { - struct POPUPSQUEUE* nowy = (struct POPUPSQUEUE*)mir_alloc(sizeof(struct POPUPSQUEUE)) ; + struct POPUPSQUEUE *nowy = (struct POPUPSQUEUE *)mir_alloc(sizeof(struct POPUPSQUEUE)); struct HISTORIA *elem = getEl(id); assert(nowy); nowy->hWnd = hWnd; @@ -184,10 +181,10 @@ void addPopup(uint32_t id,HWND hWnd) void deletePopupsHandles(struct POPUPSQUEUE **firstpq, BOOL closePopup) { struct POPUPSQUEUE *curpq = *firstpq, *delpq; - while(curpq != nullptr) { + while (curpq != nullptr) { delpq = curpq; curpq = curpq->next; - if(closePopup) + if (closePopup) PUDeletePopup(delpq->hWnd); mir_free(delpq); } @@ -199,68 +196,32 @@ void deletePopupsHandles(struct POPUPSQUEUE **firstpq, BOOL closePopup) void deleteElements() { struct HISTORIA *cur = first, *del; - while(cur != nullptr) - { + while (cur != nullptr) { del = cur; cur = cur->next; - deletePopupsHandles(&(del->pq),FALSE); + deletePopupsHandles(&(del->pq), FALSE); mir_free(del); first = cur; } first = nullptr; } - -//set plugin name -void init_pluginname() -{ - char text[MAX_PATH], *p, *q; - WIN32_FIND_DATAA ffd; - - // Try to find name of the file having original letter sizes - GetModuleFileNameA(g_plugin.getInst(), text, sizeof(text)); - - HANDLE hFind = FindFirstFileA(text, &ffd); - if(hFind != INVALID_HANDLE_VALUE) { - strncpy_s(text, _countof(text), ffd.cFileName, mir_strlen(ffd.cFileName)); - FindClose(hFind); - } - // Check if we have relative or full path - if(p = strrchr(text, '\\')) { - p++; - } else { - p = text; - } - if(q = strrchr(p, '.')) { - *q = '\0'; - } - if((q = strstr(p, "debug")) && mir_strlen(q) == 5) { - *q = '\0'; - } - - // copy to static variable - strncpy_s(MODULENAME, _countof(MODULENAME), p, mir_strlen(p)); - assert(mir_strlen(MODULENAME)>0); - -} - - BOOL strrep(char *src, char *needle, char *newstring) { char *found, begining[MAX_SETTING_STR], tail[MAX_SETTING_STR]; //strset(begining,' '); //strset(tail,' '); - if(!(found=strstr(src,needle))) + if (!(found = strstr(src, needle))) return FALSE; - size_t pos = (found-src); + size_t pos = (found - src); strncpy_s(begining, _countof(begining), src, pos); - begining[pos]='\0'; + begining[pos] = '\0'; pos += mir_strlen(needle); - strncpy_s(tail, _countof(tail), src+pos, _countof(tail)); - begining[pos]='\0'; + strncpy_s(tail, _countof(tail), src + pos, _countof(tail)); + begining[pos] = '\0'; pos = sprintf(src, "%s%s%s", begining, newstring, tail); //!!!!!!!!!!!!!!!! return TRUE; @@ -270,11 +231,11 @@ BOOL strrep(char *src, char *needle, char *newstring) //check if given string contain filter string //param field= 0-sender // 1-subject -BOOL checkFilters(wchar_t* str, int field) +BOOL checkFilters(wchar_t *str, int field) { wchar_t buff[512] = L""; wchar_t *strptr = nullptr; - switch(field) { + switch (field) { case 0: wcsncpy_s(buff, settingFilterSender, _TRUNCATE); break; @@ -286,15 +247,12 @@ BOOL checkFilters(wchar_t* str, int field) break; } - - while(strptr = wcschr(buff, ';')) - { + while (strptr = wcschr(buff, ';')) { wchar_t tmp[512] = TEXT(""), *ptr; - wcsncpy_s(tmp, buff, (strptr-buff)); + wcsncpy_s(tmp, buff, (strptr - buff)); wcsncpy_s(buff, strptr + 1, _TRUNCATE); - if(wcsstr(wcslwr(ptr=wcsdup(str)),wcslwr(tmp))) - { + if (wcsstr(wcslwr(ptr = wcsdup(str)), wcslwr(tmp))) { free(ptr); return TRUE; } @@ -305,20 +263,20 @@ BOOL checkFilters(wchar_t* str, int field) //subfunction called from popup plugin callback function -void Click(HWND hWnd,BOOL execute) +void Click(HWND hWnd, BOOL execute) { - POPUPATT *pid = (POPUPATT*)PUGetPluginData(hWnd); - if(settingOnceOnly&&settingNonClickedOnly) - (getEl(pid->id))->clicked=TRUE;//add to msgs list + POPUPATT *pid = (POPUPATT *)PUGetPluginData(hWnd); + if (settingOnceOnly && settingNonClickedOnly) + (getEl(pid->id))->clicked = TRUE;//add to msgs list - deletePopupsHandles((&(getEl(pid->id))->pq),TRUE); + deletePopupsHandles((&(getEl(pid->id))->pq), TRUE); - if(settingNewest && (pid->id > settingNewestID) ){ - g_plugin.setDword("LNNewestID", settingNewestID=pid->id); + if (settingNewest && (pid->id > settingNewestID)) { + g_plugin.setDword("LNNewestID", settingNewestID = pid->id); } - if(execute && settingCommand[0] ) { - char tmpcommand[2*MAX_SETTING_STR]; - char tmpparameters[2*MAX_SETTING_STR]; + if (execute && settingCommand[0]) { + char tmpcommand[2 * MAX_SETTING_STR]; + char tmpparameters[2 * MAX_SETTING_STR]; strncpy_s(tmpcommand, _countof(tmpcommand), settingCommand, _countof(tmpcommand)); strncpy_s(tmpparameters, _countof(tmpparameters), settingParameters, _countof(tmpparameters)); strrep(tmpcommand, "%OID%", pid->strNote); @@ -332,108 +290,98 @@ void Click(HWND hWnd,BOOL execute) //popup plugin callback function static LRESULT CALLBACK PopupDlgProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { - switch(message) { - case WM_COMMAND: + switch (message) { + case WM_COMMAND: + if (HIWORD(wParam) == STN_CLICKED)//client clicked on popup with left mouse button { + Click(hWnd, TRUE); - if (HIWORD(wParam) == STN_CLICKED)//client clicked on popup with left mouse button - { - Click(hWnd,TRUE); - - //system(settingCommand); - //if(!settingOnceOnly) - //addNewId(noteID); - return TRUE; - } - - break; + //system(settingCommand); + //if(!settingOnceOnly) + //addNewId(noteID); + return TRUE; } - case WM_RBUTTONUP: - { - Click(hWnd,FALSE); - break; - } + break; + + case WM_RBUTTONUP: + Click(hWnd, FALSE); + break; - case UM_INITPOPUP: + case UM_INITPOPUP: { - POPUPATT *pid = (POPUPATT*)PUGetPluginData(hWnd); - addPopup(pid->id,hWnd); + POPUPATT *pid = (POPUPATT *)PUGetPluginData(hWnd); + addPopup(pid->id, hWnd); //PUDeletePopUp(hWnd); - break; } + break; - case UM_FREEPLUGINDATA: + case UM_FREEPLUGINDATA: { - POPUPATT *mpd = (POPUPATT*)PUGetPluginData(hWnd); + POPUPATT *mpd = (POPUPATT *)PUGetPluginData(hWnd); if (mpd > 0) free(mpd); - return TRUE; //TRUE or FALSE is the same, it gets ignored. } - - default: - break; + return TRUE; //TRUE or FALSE is the same, it gets ignored. } return DefWindowProc(hWnd, message, wParam, lParam); } - //check notes.ini if it has entry about our plugin //return TRUE if notes.ini is set correctly //give bInfo=TRUE to show MsgBoxes BOOL checkNotesIniFile(BOOL bInfo) { - char tmp[MAXENVVALUE+1], tmp1[MAXENVVALUE+1]; - (OSGetEnvironmentString1) ("EXTMGR_ADDINS", tmp, MAXENVVALUE);//get current setting - strncpy_s(tmp1,_countof(tmp1),tmp,sizeof(tmp1));//copy temporary - assert(mir_strlen(tmp1)>0); + char tmp[MAXENVVALUE + 1], tmp1[MAXENVVALUE + 1]; + (OSGetEnvironmentString1)("EXTMGR_ADDINS", tmp, MAXENVVALUE);//get current setting + strncpy_s(tmp1, _countof(tmp1), tmp, sizeof(tmp1));//copy temporary + assert(mir_strlen(tmp1) > 0); - char* PLUGINNAME_lower = _strlwr(mir_strdup(MODULENAME)); + char *PLUGINNAME_lower = _strlwr(mir_strdup(MODULENAME)); //is there our plugin as safe? - if(strstr(tmp1,PLUGINNAME_lower) == nullptr) - { - if(!settingIniCheck && !bInfo) + if (strstr(tmp1, PLUGINNAME_lower) == nullptr) { + if (!settingIniCheck && !bInfo) return FALSE; - if(!settingIniAnswer || bInfo){ - switch(MessageBox(nullptr, TranslateT("This utility check your notes.ini file if it's set to authenticate this plugin as safe. Plugin is not added as Lotus Extension, so plugin built-in authentication will not work properly. Do you want to add plugin as Lotus Extension (modify notes.ini by adding \"EXTMGR_ADDINS=PLUGINNAME\")?"), TranslateT("LotusNotify plugin configuration"), MB_YESNO)) - { - case IDYES: - { - settingIniAnswer=1; - break; - } - case IDNO: - { - settingIniAnswer=-1; - break; - } + if (!settingIniAnswer || bInfo) { + switch (MessageBox(nullptr, TranslateT("This utility check your notes.ini file if it's set to authenticate this plugin as safe. Plugin is not added as Lotus Extension, so plugin built-in authentication will not work properly. Do you want to add plugin as Lotus Extension (modify notes.ini by adding \"EXTMGR_ADDINS=PLUGINNAME\")?"), TranslateT("LotusNotify plugin configuration"), MB_YESNO)) { + case IDYES: + settingIniAnswer = 1; + break; + + case IDNO: + settingIniAnswer = -1; + break; } } - if(settingIniAnswer == 1) - { - if(mir_strlen(tmp) > 0) { + if (settingIniAnswer == 1) { + if (mir_strlen(tmp) > 0) { strcat_s(tmp, _countof(tmp), ","); strcat_s(tmp, _countof(tmp), PLUGINNAME_lower); //add our plugin to extensions - } else { + } + else { strncpy_s(tmp, _countof(tmp), PLUGINNAME_lower, mir_strlen(PLUGINNAME_lower)); //set our plugin as extension } - (OSSetEnvironmentVariable1) ("EXTMGR_ADDINS", tmp); //set notes.ini entry - if(bInfo) { + (OSSetEnvironmentVariable1)("EXTMGR_ADDINS", tmp); //set notes.ini entry + if (bInfo) { MessageBox(nullptr, TranslateT("notes.ini modified correctly. Miranda restart required."), TranslateT("LotusNotify plugin configuration"), MB_OK); - } else{ + } + else { ErMsgT(TranslateT("notes.ini modified correctly. Miranda restart required.")); } return TRUE; - } else { if(settingIniAnswer == 0xFF) - return FALSE; } - } else { + else { + if (settingIniAnswer == 0xFF) + return FALSE; + } + } + else { //setting set already - if(bInfo) + if (bInfo) MessageBox(nullptr, TranslateT("notes.ini seem to be set correctly."), TranslateT("LotusNotify plugin configuration"), MB_OK); return TRUE; } @@ -444,9 +392,9 @@ BOOL checkNotesIniFile(BOOL bInfo) //popup plugin to show popup function -void showMsg(wchar_t* sender,wchar_t* text, uint32_t id, char *strUID) +void showMsg(wchar_t *sender, wchar_t *text, uint32_t id, char *strUID) { - POPUPATT * mpd = (POPUPATT*)malloc(sizeof(POPUPATT)); + POPUPATT *mpd = (POPUPATT *)malloc(sizeof(POPUPATT)); mpd->id = id; strncpy_s(mpd->strNote, _countof(mpd->strNote), strUID, mir_strlen(strUID)); @@ -454,30 +402,30 @@ void showMsg(wchar_t* sender,wchar_t* text, uint32_t id, char *strUID) ppd.lchIcon = LoadIcon(g_plugin.getInst(), MAKEINTRESOURCE(IDI_ICON1)); wcscpy_s(ppd.lpwzContactName, _countof(ppd.lpwzContactName), sender); wcscpy_s(ppd.lpwzText, _countof(ppd.lpwzText), text); - if(settingSetColours) { + if (settingSetColours) { ppd.colorBack = settingBgColor; ppd.colorText = settingFgColor; } ppd.PluginWindowProc = PopupDlgProc; - ppd.iSeconds=settingInterval1; + ppd.iSeconds = settingInterval1; ppd.PluginData = mpd; PUAddPopupW(&ppd); } //what to do with error msg -void ErMsgW(wchar_t* msg) +void ErMsgW(wchar_t *msg) { - wchar_t* msgT = mir_wstrdup(msg); + wchar_t *msgT = mir_wstrdup(msg); ErMsgT(msgT); mir_free(msgT); } ///TODO wchar_t->wchar_t and test -void ErMsgT(wchar_t* msg) +void ErMsgT(wchar_t *msg) { log_p(L"Error: %S", msg); - if(settingShowError && !isPopupWaiting) { - wchar_t buffer[256+14]; + if (settingShowError && !isPopupWaiting) { + wchar_t buffer[256 + 14]; wcsncpy_s(buffer, L"LotusNotify: ", _TRUNCATE); wcscat_s(buffer, msg); isPopupWaiting = TRUE; @@ -493,33 +441,33 @@ void ErMsgByLotusCode(STATUS erno) char far error_text_LMBCS[200]; char far error_text_UNICODEatCHAR[400]; wchar_t far error_text_UNICODE[200]; - uint16_t text_len; + uint16_t text_len; - text_len = OSLoadString1(NULLHANDLE, erno, error_text_LMBCS, sizeof(error_text_LMBCS)-1); - OSTranslate1(OS_TRANSLATE_LMBCS_TO_UNICODE, error_text_LMBCS, (uint16_t)mir_strlen(error_text_LMBCS), error_text_UNICODEatCHAR, sizeof(error_text_UNICODEatCHAR)-1); + text_len = OSLoadString1(NULLHANDLE, erno, error_text_LMBCS, sizeof(error_text_LMBCS) - 1); + OSTranslate1(OS_TRANSLATE_LMBCS_TO_UNICODE, error_text_LMBCS, (uint16_t)mir_strlen(error_text_LMBCS), error_text_UNICODEatCHAR, sizeof(error_text_UNICODEatCHAR) - 1); memcpy(error_text_UNICODE, error_text_UNICODEatCHAR, sizeof(error_text_UNICODE)); ErMsgW(error_text_UNICODE); } -int check() { +int check() +{ log_p(L"check: Entering check function. running=%d", running); - if(startuperror) { - int cnt; - for(cnt = 0; cnt <= 4; cnt++) - if(startuperror >> cnt & 1) + if (startuperror) { + for (int cnt = 0; cnt <= 4; cnt++) + if (startuperror >> cnt & 1) ErMsgT(TranslateW(startuperrors[cnt])); return 1; } - if (Plugin_Terminated || Miranda_IsTerminated()){ + if (Plugin_Terminated || Miranda_IsTerminated()) { log_p(L"check: Plugin_Terminated (=%d) OR Miranda_IsTerminated()", Plugin_Terminated); return 0; } - if(running) { + if (running) { ErMsgT(TranslateT("Now checking Lotus, try again later")); return 1; } @@ -536,24 +484,24 @@ int check() { //before pure lotus notes api functions call -void checkthread(void*) +void checkthread(void *) { STATUS error = NOERROR; - char fullpath[255]; + char fullpath[255]; DBHANDLE db_handle = NULLHANDLE; /* database handle */ char UserName[MAXUSERNAME + 1]; HANDLE hTable; uint32_t noteID = 0L; - BOOL fFirst = TRUE; + BOOL fFirst = TRUE; NOTEHANDLE note_handle; - uint16_t field_len; + uint16_t field_len; char field_date[MAXALPHATIMEDATE + 1]; char field_lotus_LMBCS[MAX_FIELD]; char field_lotus_UNICODEatCHAR[MAX_FIELD * sizeof(wchar_t)]; - wchar_t field_from_UNICODE[MAX_FIELD], field_subject_UNICODE[MAX_FIELD], field_to_UNICODE[MAX_FIELD],field_copy_UNICODE[MAX_FIELD]; + wchar_t field_from_UNICODE[MAX_FIELD], field_subject_UNICODE[MAX_FIELD], field_to_UNICODE[MAX_FIELD], field_copy_UNICODE[MAX_FIELD]; mir_cslock lck(checkthreadCS); log(L"checkthread: inside new check thread"); @@ -625,10 +573,10 @@ void checkthread(void*) BLOCKID bhAttachment; uint32_t cSize = 0; uint32_t attSize = 0; - OID retNoteOID; - TIMEDATE retModified; /* modified timedate */ - uint16_t retNoteClass; /* note class */ - TIMEDATE sendDate; + OID retNoteOID; + TIMEDATE retModified; /* modified timedate */ + uint16_t retNoteClass; /* note class */ + TIMEDATE sendDate; char strLink[4 * 16]; if (Plugin_Terminated || Miranda_IsTerminated()) { @@ -675,7 +623,7 @@ void checkthread(void*) #endif // remember newest id depending on options set - if (settingNewest&&settingEvenNonClicked && (noteID > settingNewestID)) + if (settingNewest && settingEvenNonClicked && (noteID > settingNewestID)) g_plugin.setDword("LNNewestID", settingNewestID = noteID); //if(((!settingOnceOnly||(settingOnceOnly&&settingNonClickedOnly))&&existElem(noteID))||(settingNewest&&settingNewestID>=noteID)) @@ -700,7 +648,7 @@ void checkthread(void*) retNoteOID.File.Innards[0], retNoteOID.Note.Innards[1], retNoteOID.Note.Innards[0] - ); + ); log_p(L"checkthread: got noteInfo, built link: %S", strLink); @@ -749,17 +697,17 @@ void checkthread(void*) , field_copy_UNICODE , field_subject_UNICODE , attSize - ); + ); #else //do not put private user data into log log_p(L"checkthread: MAIL INFO (sizes): date=[%S], from=[%d], to=[%d], cc=[%d], sub=[%d], attSize=[%d]" - ,field_date - ,mir_wstrlen(field_from_UNICODE) - ,mir_wstrlen(field_to_UNICODE) - ,mir_wstrlen(field_copy_UNICODE) - ,mir_wstrlen(field_subject_UNICODE) - ,attSize - ); + , field_date + , mir_wstrlen(field_from_UNICODE) + , mir_wstrlen(field_to_UNICODE) + , mir_wstrlen(field_copy_UNICODE) + , mir_wstrlen(field_subject_UNICODE) + , attSize + ); #endif @@ -882,607 +830,27 @@ void decodeServer(char *tmp) } } - -//fill combo in options dlgbox with all known servers -void fillServersList(HWND hwndDlg) -{ - HANDLE hServerList = NULLHANDLE; - uint8_t far *pServerList; /* Pointer to start of Server List */ - uint16_t wServerCount; /* Number of servers in list. */ - uint16_t far *pwServerLength; /* Index to array of servername lens */ - uint8_t far *pServerName; - STATUS error = NOERROR; /* Error return from API routines. */ - char ServerString[MAXPATH]; /* String to hold server names. */ - LPSTR szServerString = ServerString; - - if (!hLotusDll) { - return; - } - - error = NSGetServerList1(nullptr, &hServerList); - if (error == NOERROR) { - - pServerList = (uint8_t far *) OSLockObject1(hServerList); - wServerCount = (uint16_t)*pServerList; - - pwServerLength = (uint16_t *)(pServerList + sizeof(uint16_t)); - - pServerName = (uint8_t far *) pServerList + sizeof(wServerCount) + ((wServerCount)* sizeof(uint16_t)); - - for (USHORT i = 0; i < wServerCount; pServerName += pwServerLength[i], i++) { - memmove(szServerString, pServerName, pwServerLength[i]); - szServerString[pwServerLength[i]] = '\0'; - decodeServer(ServerString); - SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, (LPARAM)szServerString); - } - OSUnlockObject1(hServerList); - OSMemFree1(hServerList); - - } - else { - ErMsgByLotusCode(error); - } -} - - -//gets default settings from notes.ini file -static void lookupLotusDefaultSettings(HWND hwndDlg) -{ - char tmp[MAXENVVALUE + 1]; - // Get the info from the .ini file - if (hLotusDll) { - if (OSGetEnvironmentString1("MailFile", tmp, MAXENVVALUE)) //path to mail file - SetDlgItemTextA(hwndDlg, IDC_DATABASE, tmp); //and set fields in opt. dialog - if (OSGetEnvironmentString1("MailServer", tmp, MAXENVVALUE)) //server name - { - decodeServer(tmp); - SetDlgItemTextA(hwndDlg, IDC_SERVER, tmp); - } - } - -} - -// get variables values stored in db. -static void LoadSettings() -{ - settingInterval = (INT)g_plugin.getDword("LNInterval", 15); - settingInterval1 = (INT)g_plugin.getDword("LNInterval1", 0); - settingKeepConnection = g_plugin.getByte("LNKeepConnection", 1); - - DBVARIANT dbv; - if (!g_plugin.getString("LNDatabase", &dbv)) { - strncpy_s(settingDatabase, _countof(settingDatabase), dbv.pszVal, _countof(settingDatabase)); - db_free(&dbv); - } - if (!g_plugin.getString("LNServer", &dbv)) { - strncpy_s(settingServer, _countof(settingServer), dbv.pszVal, _countof(settingServer)); - db_free(&dbv); - } - if (!g_plugin.getString("LNServerSec", &dbv)) { - strncpy_s(settingServerSec, _countof(settingServerSec), dbv.pszVal, _countof(settingServerSec)); - db_free(&dbv); - } - if (!g_plugin.getString("LNPassword", &dbv)) { - strncpy_s(settingPassword, _countof(settingPassword), dbv.pszVal, _countof(settingPassword)); - db_free(&dbv); - } - if (!g_plugin.getString("LNCommand", &dbv)) { - strncpy_s(settingCommand, _countof(settingCommand), dbv.pszVal, _countof(settingCommand)); - db_free(&dbv); - } - if (!g_plugin.getString("LNParameters", &dbv)) { - strncpy_s(settingParameters, _countof(settingParameters), dbv.pszVal, _countof(settingParameters)); - db_free(&dbv); - } - - if (!g_plugin.getWString("LNFilterSender", &dbv)) { - wcsncpy_s(settingFilterSender, dbv.pwszVal, _TRUNCATE); - db_free(&dbv); - } - if (!g_plugin.getWString("LNFilterSubject", &dbv)) { - wcsncpy_s(settingFilterSubject, dbv.pwszVal, _TRUNCATE); - db_free(&dbv); - } - if (!g_plugin.getWString("LNFilterTo", &dbv)) { - wcsncpy_s(settingFilterTo, dbv.pwszVal, _TRUNCATE); - db_free(&dbv); - } - - settingOnceOnly = g_plugin.getByte("LNOnceOnly", 0); - - settingNonClickedOnly = g_plugin.getByte("LNNonClickedOnly", 1); - settingShowError = g_plugin.getByte("LNShowError", 1); - settingSetColours = g_plugin.getByte("LNSetColours", 0); - settingBgColor = (COLORREF)g_plugin.getDword("LNBgColor", (uint32_t)0xFFFFFF); - settingFgColor = (COLORREF)g_plugin.getDword("LNFgColor", (uint32_t)0x000000); - settingNewest = g_plugin.getByte("LNNewest", 0); - settingEvenNonClicked = g_plugin.getByte("LNEvenNonClicked", 0); - settingNewestID = (uint32_t)g_plugin.getDword("LNNewestID", 0); - settingIniAnswer = g_plugin.getByte("LNIniAnswer", 0); - settingIniCheck = g_plugin.getByte("LNIniCheck", 0); - - for (int i = 0; i < STATUS_COUNT; i++) { - char buff[128]; - mir_snprintf(buff, "LNStatus%d", i); - settingStatus[i] = (g_plugin.getByte(buff, 0) == 1); - } - //lookupLotusDefaultSettings(); -} - -static void SaveSettings(HWND hwndDlg) -{ - char buff[128]; - GetDlgItemTextA(hwndDlg, IDC_SERVER, settingServer, _countof(settingServer)); - g_plugin.setString("LNServer", settingServer); - g_plugin.setString("LNServerSec", settingServerSec); - g_plugin.setString("LNPassword", settingPassword); - g_plugin.setString("LNDatabase", settingDatabase); - g_plugin.setDword("LNInterval", settingInterval); - g_plugin.setDword("LNInterval1", settingInterval1); - g_plugin.setByte("LNKeepConnection", settingKeepConnection); - g_plugin.setString("LNCommand", settingCommand); - g_plugin.setString("LNParameters", settingParameters); - g_plugin.setByte("LNOnceOnly", settingOnceOnly); - g_plugin.setByte("LNNonClickedOnly", settingNonClickedOnly); - g_plugin.setByte("LNShowError", settingShowError); - g_plugin.setByte("LNSetColours", settingSetColours); - g_plugin.setDword("LNBgColor", (uint32_t)settingBgColor); - g_plugin.setDword("LNFgColor", (uint32_t)settingFgColor); - g_plugin.setByte("LNNewest", settingNewest); - g_plugin.setByte("LNEvenNonClicked", settingEvenNonClicked); - g_plugin.setByte("LNIniCheck", settingIniCheck); - g_plugin.setByte("LNIniAnswer", settingIniAnswer); - - for (int i = 0; i < STATUS_COUNT; i++) { - mir_snprintf(buff, "LNStatus%d", i); - settingStatus[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_STATUS), i) ? TRUE : FALSE); - g_plugin.setByte(buff, settingStatus[i] ? 1 : 0); - } - - settingFilterSender[0] = 0; - for (int i = 0; i < SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER, CB_GETCOUNT, 0, 0); i++) { - wchar_t text[512] = TEXT(""); - SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER, CB_GETLBTEXT, (WPARAM)i, (LPARAM)text); - wcscat_s(settingFilterSender, _countof(settingFilterSender), text); - wcscat_s(settingFilterSender, _countof(settingFilterSender), TEXT(";")); - } - g_plugin.setWString("LNFilterSender", settingFilterSender); - - settingFilterSubject[0] = 0; - for (int i = 0; i < SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT, CB_GETCOUNT, 0, 0); i++) { - wchar_t text[512] = TEXT(""); - SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT, CB_GETLBTEXT, (WPARAM)i, (LPARAM)text); - wcscat_s(settingFilterSubject, _countof(settingFilterSubject), text); - wcscat_s(settingFilterSubject, _countof(settingFilterSubject), TEXT(";")); - } - g_plugin.setWString("LNFilterSubject", settingFilterSubject); - - settingFilterTo[0] = 0; - for (int i = 0; i < SendDlgItemMessage(hwndDlg, IDC_FILTER_TO, CB_GETCOUNT, 0, 0); i++) { - wchar_t text[512] = TEXT(""); - SendDlgItemMessage(hwndDlg, IDC_FILTER_TO, CB_GETLBTEXT, (WPARAM)i, (LPARAM)text); - wcscat_s(settingFilterTo, _countof(settingFilterTo), text); - wcscat_s(settingFilterTo, _countof(settingFilterTo), TEXT(";")); - } - g_plugin.setWString("LNFilterTo", settingFilterTo); -} - -//callback function to speak with user interactions in options page -static INT_PTR CALLBACK DlgProcLotusNotifyConnectionOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static bool bInit = false; - - switch (msg) { - case WM_INITDIALOG://initialize dialog, so set properties from db. - bInit = true; - TranslateDialogDefault(hwndDlg);//translate miranda function - LoadSettings(); - CheckDlgButton(hwndDlg, IDC_BUTTON_CHECK, settingIniCheck ? BST_CHECKED : BST_UNCHECKED); - SetDlgItemTextA(hwndDlg, IDC_SERVER, settingServer); - SetDlgItemTextA(hwndDlg, IDC_SERVERSEC, settingServerSec); - SetDlgItemTextA(hwndDlg, IDC_DATABASE, settingDatabase); - SetDlgItemTextA(hwndDlg, IDC_PASSWORD, settingPassword); - SetDlgItemInt(hwndDlg, IDC_INTERVAL, settingInterval, FALSE); - CheckDlgButton(hwndDlg, IDC_KEEP_CONNEXION_ON_ERROR, settingKeepConnection ? BST_CHECKED : BST_UNCHECKED); - bInit = false; - break; - - case WM_COMMAND://user changed something, so get changes to variables - if (!bInit) { - switch (HIWORD(wParam)) { - case EN_CHANGE: // text is modified in an edit ctrl - case BN_CLICKED: // a checkbox is modified - PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - } - switch (LOWORD(wParam)) { - case IDC_BUTTON_DETECT: - lookupLotusDefaultSettings(hwndDlg); - GetDlgItemTextA(hwndDlg, IDC_SERVER, settingServer, _countof(settingServer)); - GetDlgItemTextA(hwndDlg, IDC_DATABASE, settingDatabase, _countof(settingDatabase)); - break; - case IDC_BUTTON_CHECK: - settingIniCheck = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_BUTTON_CHECK); - checkNotesIniFile(TRUE); - break; - case IDC_DATABASE: - GetDlgItemTextA(hwndDlg, IDC_DATABASE, settingDatabase, _countof(settingDatabase)); - break; - case IDC_SERVER: - switch (HIWORD(wParam)) { - case CBN_SELCHANGE: - { - int i = SendDlgItemMessage(hwndDlg, IDC_SERVER, CB_GETCURSEL, 0, 0); - char text[MAXENVVALUE]; - SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_GETLBTEXT, (WPARAM)i, (LPARAM)text); - SetDlgItemTextA(hwndDlg, IDC_SERVER, text); - if (!bInit) { - PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - break; - } - - case CBN_DROPDOWN: - SendDlgItemMessage(hwndDlg, IDC_SERVER, CB_RESETCONTENT, 0, 0); - fillServersList(hwndDlg); - SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, (LPARAM)settingServer); - SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_SELECTSTRING, -1, (LPARAM)settingServer); - break; - } - break; - case IDC_SERVERSEC: - GetDlgItemTextA(hwndDlg, IDC_SERVERSEC, settingServerSec, _countof(settingServerSec)); - break; - case IDC_PASSWORD: - GetDlgItemTextA(hwndDlg, IDC_PASSWORD, settingPassword, _countof(settingPassword)); - break; - case IDC_INTERVAL: - settingInterval = GetDlgItemInt(hwndDlg, IDC_INTERVAL, nullptr, FALSE); - break; - case IDC_KEEP_CONNEXION_ON_ERROR: - settingKeepConnection = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_KEEP_CONNEXION_ON_ERROR); - break; - } - break; - - case WM_NOTIFY://apply changes so write it to db - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_RESET: - LoadSettings(); - return TRUE; - - case PSN_APPLY: - SaveSettings(hwndDlg); - return TRUE; - } - break; - } //id from - - break; //switch(msg) - - } - return FALSE; -} - -static INT_PTR CALLBACK DlgProcLotusNotifyPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static bool bInit = false; - - switch (msg) { - case WM_INITDIALOG://initialize dialog, so set properties from db. - bInit = true; - TranslateDialogDefault(hwndDlg);//translate miranda function - LoadSettings(); - - CheckDlgButton(hwndDlg, IDC_SETCOLOURS, settingSetColours ? BST_CHECKED : BST_UNCHECKED); - SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingBgColor); - EnableWindow(GetDlgItem(hwndDlg, IDC_BGCOLOR), settingSetColours != 0); - SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingFgColor); - EnableWindow(GetDlgItem(hwndDlg, IDC_FGCOLOR), settingSetColours != 0); - - SetDlgItemInt(hwndDlg, IDC_INTERVAL1, settingInterval1, TRUE); - CheckDlgButton(hwndDlg, IDC_ONCEONLY, settingOnceOnly ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_NONCLICKEDONLY, settingNonClickedOnly ? BST_CHECKED : BST_UNCHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_NONCLICKEDONLY), settingOnceOnly != 0); - CheckDlgButton(hwndDlg, IDC_SHOWERROR, settingShowError ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_NEWEST, settingNewest ? BST_CHECKED : BST_UNCHECKED); - CheckDlgButton(hwndDlg, IDC_REMEMBEREVENNONCLICKED, settingEvenNonClicked ? BST_CHECKED : BST_UNCHECKED); - EnableWindow(GetDlgItem(hwndDlg, IDC_REMEMBEREVENNONCLICKED), settingNewest != 0); - SetDlgItemTextA(hwndDlg, IDC_COMMAND, settingCommand); - SetDlgItemTextA(hwndDlg, IDC_PARAMETERS, settingParameters); - - bInit = FALSE; - break; - - case WM_COMMAND://user changed something, so get changes to variables - if (!bInit) { - switch (HIWORD(wParam)) { - case EN_CHANGE: // text is modified in an edit ctrl - case BN_CLICKED: // a checkbox is modified - case CPN_COLOURCHANGED: // a color has changed - PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - } - switch (LOWORD(wParam)) { - case IDC_SETCOLOURS: - settingSetColours = IsDlgButtonChecked(hwndDlg, IDC_SETCOLOURS); - EnableWindow(GetDlgItem(hwndDlg, IDC_BGCOLOR), settingSetColours); - EnableWindow(GetDlgItem(hwndDlg, IDC_FGCOLOR), settingSetColours); - break; - case IDC_BGCOLOR: - settingBgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0); - break; - case IDC_FGCOLOR: - settingFgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_GETCOLOUR, 0, 0); - break; - case IDC_INTERVAL1: - settingInterval1 = GetDlgItemInt(hwndDlg, IDC_INTERVAL1, nullptr, TRUE); - break; - case IDC_ONCEONLY: - settingOnceOnly = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_ONCEONLY); - EnableWindow(GetDlgItem(hwndDlg, IDC_NONCLICKEDONLY), settingOnceOnly); - break; - case IDC_NONCLICKEDONLY: - settingNonClickedOnly = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_NONCLICKEDONLY); - break; - case IDC_SHOWERROR: - settingShowError = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_SHOWERROR); - break; - case IDC_NEWEST: - settingNewest = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_NEWEST); - EnableWindow(GetDlgItem(hwndDlg, IDC_REMEMBEREVENNONCLICKED), settingNewest); - break; - case IDC_REMEMBEREVENNONCLICKED: - settingEvenNonClicked = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_REMEMBEREVENNONCLICKED); - break; - case IDC_COMMAND: - GetDlgItemTextA(hwndDlg, IDC_COMMAND, settingCommand, _countof(settingCommand)); - break; - case IDC_PARAMETERS: - GetDlgItemTextA(hwndDlg, IDC_PARAMETERS, settingParameters, _countof(settingParameters)); - break; - case IDC_BUTTON_CLEAR: - deleteElements(); - break; - } - break; - - case WM_NOTIFY://apply changes so write it to db - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - { - switch (((LPNMHDR)lParam)->code) { - case PSN_RESET: - LoadSettings(); - return TRUE; - case PSN_APPLY: - SaveSettings(hwndDlg); - - return TRUE; - break; - } - //KillTimer(hTimerWnd,TID); - //if(settingInterval!=0) - // SetTimer(hTimerWnd, TID, settingInterval*60000, (TIMERPROC)atTime); - - break; - } //case 0 - } //id from - - break; //switch(msg) - - } - return FALSE; -} - -static INT_PTR CALLBACK DlgProcLotusNotifyMiscOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) -{ - static bool bInit = false; - - wchar_t* strptr; - LVITEM lvI = { 0 }; - LVCOLUMN lvc = { 0 }; - switch (msg) { - case WM_INITDIALOG://initialize dialog, so set properties from db. - { - wchar_t buff[512]; - bInit = true; - TranslateDialogDefault(hwndDlg);//translate miranda function - LoadSettings(); - - //fill filter combos - - wcsncpy_s(buff, settingFilterSender, _TRUNCATE); - while (strptr = wcschr(buff, TEXT(';'))) { - wchar_t tmp[512] = TEXT(""); - wcsncpy_s(tmp, buff, (strptr - buff)); - SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER, CB_ADDSTRING, 0, (LPARAM)tmp); - wcsncpy_s(buff, strptr + 1, _TRUNCATE); - } - - wcsncpy_s(buff, settingFilterSubject, _TRUNCATE); - while (strptr = wcschr(buff, TEXT(';'))) { - wchar_t tmp[512] = TEXT(""); - wcsncpy_s(tmp, buff, (strptr - buff)); - SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT, CB_ADDSTRING, 0, (LPARAM)tmp); - wcsncpy_s(buff, strptr + 1, _TRUNCATE); - } - - wcsncpy_s(buff, settingFilterTo, _TRUNCATE); - while (strptr = wcschr(buff, TEXT(';'))) { - wchar_t tmp[512] = TEXT(""); - wcsncpy_s(tmp, buff, (strptr - buff)); - SendDlgItemMessage(hwndDlg, IDC_FILTER_TO, CB_ADDSTRING, 0, (LPARAM)tmp); - wcsncpy_s(buff, strptr + 1, _TRUNCATE); - } - - // initialise and fill listbox - HWND hwndList = GetDlgItem(hwndDlg, IDC_STATUS); - ListView_DeleteAllItems(hwndList); - - SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); - - // Initialize the LVCOLUMN structure. - // The mask specifies that the format, width, text, and - // subitem members of the structure are valid. - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; - lvc.fmt = LVCFMT_LEFT; - - lvc.iSubItem = 0; - lvc.pszText = TranslateT("Status"); - lvc.cx = 120; // width of column in pixels - ListView_InsertColumn(hwndList, 0, &lvc); - - // Some code to create the list-view control. - // Initialize LVITEM members that are common to all items. - lvI.mask = LVIF_TEXT; - for (int i = 0; i < STATUS_COUNT; i++) { - lvI.pszText = Clist_GetStatusModeDescription(ID_STATUS_ONLINE + i, 0); - lvI.iItem = i; - ListView_InsertItem(hwndList, &lvI); - ListView_SetCheckState(hwndList, i, settingStatus[i]); - } - - bInit = false; - break; - } - case WM_COMMAND://user changed something, so get changes to variables - { - if (!bInit && (HIWORD(wParam) == EN_CHANGE)) { - PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - char tmp[255]; - int index, size; - switch (LOWORD(wParam)) { - case IDC_BUTTON_ADD_SENDER_FILTER: - GetDlgItemTextA(hwndDlg, IDC_FILTER_SENDER, tmp, _countof(tmp)); - if (strlen(tmp) > 0) { - SendDlgItemMessageA(hwndDlg, IDC_FILTER_SENDER, CB_ADDSTRING, 0, (LPARAM)tmp); - PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - break; - case IDC_BUTTON_REMOVE_SENDER_FILTER: - index = SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER, CB_GETCURSEL, 0, 0); - size = SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER, CB_DELETESTRING, index, 0); - SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER, CB_SETCURSEL, min(index, size - 1), 0); - PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case IDC_BUTTON_ADD_SUBJECT_FILTER: - GetDlgItemTextA(hwndDlg, IDC_FILTER_SUBJECT, tmp, _countof(tmp)); - if (strlen(tmp) > 0) { - SendDlgItemMessageA(hwndDlg, IDC_FILTER_SUBJECT, CB_ADDSTRING, 0, (LPARAM)tmp); - PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - break; - case IDC_BUTTON_REMOVE_SUBJECT_FILTER: - index = SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT, CB_GETCURSEL, 0, 0); - size = SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT, CB_DELETESTRING, index, 0); - SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT, CB_SETCURSEL, min(index, size - 1), 0); - PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - case IDC_BUTTON_ADD_TO_FILTER: - GetDlgItemTextA(hwndDlg, IDC_FILTER_TO, tmp, _countof(tmp)); - if (strlen(tmp) > 0) { - SendDlgItemMessageA(hwndDlg, IDC_FILTER_TO, CB_ADDSTRING, 0, (LPARAM)tmp); - PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - break; - case IDC_BUTTON_REMOVE_TO_FILTER: - index = SendDlgItemMessage(hwndDlg, IDC_FILTER_TO, CB_GETCURSEL, 0, 0); - size = SendDlgItemMessage(hwndDlg, IDC_FILTER_TO, CB_DELETESTRING, index, 0); - SendDlgItemMessage(hwndDlg, IDC_FILTER_TO, CB_SETCURSEL, min(index, size - 1), 0); - PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - break; - } - break; - } - case WM_NOTIFY://apply changes so write it to db - if (bInit) { - break; - } - switch (((LPNMHDR)lParam)->idFrom) { - case 0: - switch (((LPNMHDR)lParam)->code) { - case PSN_RESET: - LoadSettings(); - return TRUE; - - case PSN_APPLY: - SaveSettings(hwndDlg); - return TRUE; - } - - break; - } //id from - - if (GetDlgItem(hwndDlg, IDC_STATUS) == ((LPNMHDR)lParam)->hwndFrom) { - switch (((LPNMHDR)lParam)->code) { - case LVN_ITEMCHANGED: - { - NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; - if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) { - SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); - } - break; - - } - break; - } - } - break; //switch(msg) - - } - return FALSE; -} - - -//options page on miranda called -int LotusNotifyOptInit(WPARAM wParam, LPARAM) -{ - OPTIONSDIALOGPAGE odp = {}; - odp.szGroup.w = LPGENW("Plugins"); - odp.szTitle.w = _A2W(__PLUGIN_NAME); - odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE; - - odp.szTab.w = LPGENW("Connection"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_LOTUS_CONECTION); - odp.pfnDlgProc = DlgProcLotusNotifyConnectionOpts; - g_plugin.addOptions(wParam, &odp); - - odp.szTab.w = LPGENW("Popup"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_LOTUS_POPUP); - odp.pfnDlgProc = DlgProcLotusNotifyPopupOpts; - g_plugin.addOptions(wParam, &odp); - - odp.szTab.w = LPGENW("Miscellaneous"); - odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_LOTUS_MISC); - odp.pfnDlgProc = DlgProcLotusNotifyMiscOpts; - g_plugin.addOptions(wParam, &odp); - return 0; -} - - //gives protocol avainable statuses INT_PTR GetCaps(WPARAM wParam, LPARAM) { - if (wParam == PFLAGNUM_1) + switch (wParam) { + case PFLAGNUM_1: return 0; - if (wParam == PFLAGNUM_2) + + case PFLAGNUM_2: return PF2_ONLINE; // add the possible statuses here. - if (wParam == PFLAGNUM_3) + + case PFLAGNUM_3: return 0; + } + return 0; } - //gives name to protocol module INT_PTR GetName(WPARAM wParam, LPARAM lParam) { - strncpy((char*)lParam, MODULENAME, wParam); + strncpy((char *)lParam, MODULENAME, wParam); return 0; } @@ -1669,7 +1037,6 @@ int CMPlugin::Load() } bMirandaCall = TRUE; - init_pluginname(); logRegister(); log_p(L"Load: Entering LotusNotify.dll Load() bMirandaCall=%d MODULENAME=[%S]", bMirandaCall, MODULENAME); @@ -1678,8 +1045,7 @@ int CMPlugin::Load() HookEvent("LotusNotify/Check", eventCheck); //hook function to menu click event - if (!second) //if its first plugin instance - { + if (!second) { //if its first plugin instance //function that will be called on menu click CreateServiceFunction("LotusNotify/MenuCommand", PluginMenuCommand); diff --git a/protocols/LotusNotify/src/debug.h b/protocols/LotusNotify/src/debug.h index 838c922564..4dc5a66b0d 100644 --- a/protocols/LotusNotify/src/debug.h +++ b/protocols/LotusNotify/src/debug.h @@ -1,7 +1,5 @@ #pragma once -extern char MODULENAME[]; - void logRegister(void); void logUnregister(void); void log(const wchar_t* szText); diff --git a/protocols/LotusNotify/src/options.cpp b/protocols/LotusNotify/src/options.cpp new file mode 100644 index 0000000000..8fd39984b3 --- /dev/null +++ b/protocols/LotusNotify/src/options.cpp @@ -0,0 +1,602 @@ +/* +Miranda plugin template, originally by Richard Hughes +http://miranda-icq.sourceforge.net/ + +This file is placed in the public domain. Anybody is free to use or +modify it as they wish with no restriction. +There is no warranty. +*/ + +#include "stdafx.h" + +#include "debug.h" +#include "resource.h" +#include "version.h" +#include "lotusnotes.h" +#include "LotusNotify.h" + +//gets default settings from notes.ini file +static void lookupLotusDefaultSettings(HWND hwndDlg) +{ + char tmp[MAXENVVALUE + 1]; + // Get the info from the .ini file + if (hLotusDll) { + if (OSGetEnvironmentString1("MailFile", tmp, MAXENVVALUE)) //path to mail file + SetDlgItemTextA(hwndDlg, IDC_DATABASE, tmp); //and set fields in opt. dialog + + if (OSGetEnvironmentString1("MailServer", tmp, MAXENVVALUE)) { //server name + decodeServer(tmp); + SetDlgItemTextA(hwndDlg, IDC_SERVER, tmp); + } + } +} + +// get variables values stored in db. +void LoadSettings() +{ + settingInterval = (INT)g_plugin.getDword("LNInterval", 15); + settingInterval1 = (INT)g_plugin.getDword("LNInterval1", 0); + settingKeepConnection = g_plugin.getByte("LNKeepConnection", 1); + + DBVARIANT dbv; + if (!g_plugin.getString("LNDatabase", &dbv)) { + strncpy_s(settingDatabase, _countof(settingDatabase), dbv.pszVal, _countof(settingDatabase)); + db_free(&dbv); + } + if (!g_plugin.getString("LNServer", &dbv)) { + strncpy_s(settingServer, _countof(settingServer), dbv.pszVal, _countof(settingServer)); + db_free(&dbv); + } + if (!g_plugin.getString("LNServerSec", &dbv)) { + strncpy_s(settingServerSec, _countof(settingServerSec), dbv.pszVal, _countof(settingServerSec)); + db_free(&dbv); + } + if (!g_plugin.getString("LNPassword", &dbv)) { + strncpy_s(settingPassword, _countof(settingPassword), dbv.pszVal, _countof(settingPassword)); + db_free(&dbv); + } + if (!g_plugin.getString("LNCommand", &dbv)) { + strncpy_s(settingCommand, _countof(settingCommand), dbv.pszVal, _countof(settingCommand)); + db_free(&dbv); + } + if (!g_plugin.getString("LNParameters", &dbv)) { + strncpy_s(settingParameters, _countof(settingParameters), dbv.pszVal, _countof(settingParameters)); + db_free(&dbv); + } + + if (!g_plugin.getWString("LNFilterSender", &dbv)) { + wcsncpy_s(settingFilterSender, dbv.pwszVal, _TRUNCATE); + db_free(&dbv); + } + if (!g_plugin.getWString("LNFilterSubject", &dbv)) { + wcsncpy_s(settingFilterSubject, dbv.pwszVal, _TRUNCATE); + db_free(&dbv); + } + if (!g_plugin.getWString("LNFilterTo", &dbv)) { + wcsncpy_s(settingFilterTo, dbv.pwszVal, _TRUNCATE); + db_free(&dbv); + } + + settingOnceOnly = g_plugin.getByte("LNOnceOnly", 0); + + settingNonClickedOnly = g_plugin.getByte("LNNonClickedOnly", 1); + settingShowError = g_plugin.getByte("LNShowError", 1); + settingSetColours = g_plugin.getByte("LNSetColours", 0); + settingBgColor = (COLORREF)g_plugin.getDword("LNBgColor", (uint32_t)0xFFFFFF); + settingFgColor = (COLORREF)g_plugin.getDword("LNFgColor", (uint32_t)0x000000); + settingNewest = g_plugin.getByte("LNNewest", 0); + settingEvenNonClicked = g_plugin.getByte("LNEvenNonClicked", 0); + settingNewestID = (uint32_t)g_plugin.getDword("LNNewestID", 0); + settingIniAnswer = g_plugin.getByte("LNIniAnswer", 0); + settingIniCheck = g_plugin.getByte("LNIniCheck", 0); + + for (int i = 0; i < STATUS_COUNT; i++) { + char buff[128]; + mir_snprintf(buff, "LNStatus%d", i); + settingStatus[i] = (g_plugin.getByte(buff, 0) == 1); + } +} + +static void SaveSettings(HWND hwndDlg) +{ + char buff[128]; + GetDlgItemTextA(hwndDlg, IDC_SERVER, settingServer, _countof(settingServer)); + g_plugin.setString("LNServer", settingServer); + g_plugin.setString("LNServerSec", settingServerSec); + g_plugin.setString("LNPassword", settingPassword); + g_plugin.setString("LNDatabase", settingDatabase); + g_plugin.setDword("LNInterval", settingInterval); + g_plugin.setDword("LNInterval1", settingInterval1); + g_plugin.setByte("LNKeepConnection", settingKeepConnection); + g_plugin.setString("LNCommand", settingCommand); + g_plugin.setString("LNParameters", settingParameters); + g_plugin.setByte("LNOnceOnly", settingOnceOnly); + g_plugin.setByte("LNNonClickedOnly", settingNonClickedOnly); + g_plugin.setByte("LNShowError", settingShowError); + g_plugin.setByte("LNSetColours", settingSetColours); + g_plugin.setDword("LNBgColor", (uint32_t)settingBgColor); + g_plugin.setDword("LNFgColor", (uint32_t)settingFgColor); + g_plugin.setByte("LNNewest", settingNewest); + g_plugin.setByte("LNEvenNonClicked", settingEvenNonClicked); + g_plugin.setByte("LNIniCheck", settingIniCheck); + g_plugin.setByte("LNIniAnswer", settingIniAnswer); + + for (int i = 0; i < STATUS_COUNT; i++) { + mir_snprintf(buff, "LNStatus%d", i); + settingStatus[i] = (ListView_GetCheckState(GetDlgItem(hwndDlg, IDC_STATUS), i) ? TRUE : FALSE); + g_plugin.setByte(buff, settingStatus[i] ? 1 : 0); + } + + settingFilterSender[0] = 0; + for (int i = 0; i < SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER, CB_GETCOUNT, 0, 0); i++) { + wchar_t text[512] = TEXT(""); + SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER, CB_GETLBTEXT, (WPARAM)i, (LPARAM)text); + wcscat_s(settingFilterSender, _countof(settingFilterSender), text); + wcscat_s(settingFilterSender, _countof(settingFilterSender), TEXT(";")); + } + g_plugin.setWString("LNFilterSender", settingFilterSender); + + settingFilterSubject[0] = 0; + for (int i = 0; i < SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT, CB_GETCOUNT, 0, 0); i++) { + wchar_t text[512] = TEXT(""); + SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT, CB_GETLBTEXT, (WPARAM)i, (LPARAM)text); + wcscat_s(settingFilterSubject, _countof(settingFilterSubject), text); + wcscat_s(settingFilterSubject, _countof(settingFilterSubject), TEXT(";")); + } + g_plugin.setWString("LNFilterSubject", settingFilterSubject); + + settingFilterTo[0] = 0; + for (int i = 0; i < SendDlgItemMessage(hwndDlg, IDC_FILTER_TO, CB_GETCOUNT, 0, 0); i++) { + wchar_t text[512] = TEXT(""); + SendDlgItemMessage(hwndDlg, IDC_FILTER_TO, CB_GETLBTEXT, (WPARAM)i, (LPARAM)text); + wcscat_s(settingFilterTo, _countof(settingFilterTo), text); + wcscat_s(settingFilterTo, _countof(settingFilterTo), TEXT(";")); + } + g_plugin.setWString("LNFilterTo", settingFilterTo); +} + +///////////////////////////////////////////////////////////////////////////////////////// +//fill combo in options dlgbox with all known servers + +static void fillServersList(HWND hwndDlg) +{ + HANDLE hServerList = NULLHANDLE; + uint8_t far *pServerList; /* Pointer to start of Server List */ + uint16_t wServerCount; /* Number of servers in list. */ + uint16_t far *pwServerLength; /* Index to array of servername lens */ + uint8_t far *pServerName; + STATUS error = NOERROR; /* Error return from API routines. */ + char ServerString[MAXPATH]; /* String to hold server names. */ + LPSTR szServerString = ServerString; + + if (!hLotusDll) { + return; + } + + error = NSGetServerList1(nullptr, &hServerList); + if (error == NOERROR) { + + pServerList = (uint8_t far *) OSLockObject1(hServerList); + wServerCount = (uint16_t)*pServerList; + + pwServerLength = (uint16_t *)(pServerList + sizeof(uint16_t)); + + pServerName = (uint8_t far *) pServerList + sizeof(wServerCount) + ((wServerCount) * sizeof(uint16_t)); + + for (USHORT i = 0; i < wServerCount; pServerName += pwServerLength[i], i++) { + memmove(szServerString, pServerName, pwServerLength[i]); + szServerString[pwServerLength[i]] = '\0'; + decodeServer(ServerString); + SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, (LPARAM)szServerString); + } + OSUnlockObject1(hServerList); + OSMemFree1(hServerList); + + } + else { + ErMsgByLotusCode(error); + } +} + +//callback function to speak with user interactions in options page +static INT_PTR CALLBACK DlgProcLotusNotifyConnectionOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static bool bInit = false; + + switch (msg) { + case WM_INITDIALOG://initialize dialog, so set properties from db. + bInit = true; + TranslateDialogDefault(hwndDlg);//translate miranda function + LoadSettings(); + CheckDlgButton(hwndDlg, IDC_BUTTON_CHECK, settingIniCheck ? BST_CHECKED : BST_UNCHECKED); + SetDlgItemTextA(hwndDlg, IDC_SERVER, settingServer); + SetDlgItemTextA(hwndDlg, IDC_SERVERSEC, settingServerSec); + SetDlgItemTextA(hwndDlg, IDC_DATABASE, settingDatabase); + SetDlgItemTextA(hwndDlg, IDC_PASSWORD, settingPassword); + SetDlgItemInt(hwndDlg, IDC_INTERVAL, settingInterval, FALSE); + CheckDlgButton(hwndDlg, IDC_KEEP_CONNEXION_ON_ERROR, settingKeepConnection ? BST_CHECKED : BST_UNCHECKED); + bInit = false; + break; + + case WM_COMMAND://user changed something, so get changes to variables + if (!bInit) { + switch (HIWORD(wParam)) { + case EN_CHANGE: // text is modified in an edit ctrl + case BN_CLICKED: // a checkbox is modified + PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + } + switch (LOWORD(wParam)) { + case IDC_BUTTON_DETECT: + lookupLotusDefaultSettings(hwndDlg); + GetDlgItemTextA(hwndDlg, IDC_SERVER, settingServer, _countof(settingServer)); + GetDlgItemTextA(hwndDlg, IDC_DATABASE, settingDatabase, _countof(settingDatabase)); + break; + case IDC_BUTTON_CHECK: + settingIniCheck = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_BUTTON_CHECK); + checkNotesIniFile(TRUE); + break; + case IDC_DATABASE: + GetDlgItemTextA(hwndDlg, IDC_DATABASE, settingDatabase, _countof(settingDatabase)); + break; + case IDC_SERVER: + switch (HIWORD(wParam)) { + case CBN_SELCHANGE: + { + int i = SendDlgItemMessage(hwndDlg, IDC_SERVER, CB_GETCURSEL, 0, 0); + char text[MAXENVVALUE]; + SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_GETLBTEXT, (WPARAM)i, (LPARAM)text); + SetDlgItemTextA(hwndDlg, IDC_SERVER, text); + if (!bInit) { + PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + } + + case CBN_DROPDOWN: + SendDlgItemMessage(hwndDlg, IDC_SERVER, CB_RESETCONTENT, 0, 0); + fillServersList(hwndDlg); + SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, (LPARAM)settingServer); + SendDlgItemMessageA(hwndDlg, IDC_SERVER, CB_SELECTSTRING, -1, (LPARAM)settingServer); + break; + } + break; + case IDC_SERVERSEC: + GetDlgItemTextA(hwndDlg, IDC_SERVERSEC, settingServerSec, _countof(settingServerSec)); + break; + case IDC_PASSWORD: + GetDlgItemTextA(hwndDlg, IDC_PASSWORD, settingPassword, _countof(settingPassword)); + break; + case IDC_INTERVAL: + settingInterval = GetDlgItemInt(hwndDlg, IDC_INTERVAL, nullptr, FALSE); + break; + case IDC_KEEP_CONNEXION_ON_ERROR: + settingKeepConnection = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_KEEP_CONNEXION_ON_ERROR); + break; + } + break; + + case WM_NOTIFY://apply changes so write it to db + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_RESET: + LoadSettings(); + return TRUE; + + case PSN_APPLY: + SaveSettings(hwndDlg); + return TRUE; + } + break; + } //id from + + break; //switch(msg) + + } + return FALSE; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +static INT_PTR CALLBACK DlgProcLotusNotifyPopupOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static bool bInit = false; + + switch (msg) { + case WM_INITDIALOG://initialize dialog, so set properties from db. + bInit = true; + TranslateDialogDefault(hwndDlg);//translate miranda function + LoadSettings(); + + CheckDlgButton(hwndDlg, IDC_SETCOLOURS, settingSetColours ? BST_CHECKED : BST_UNCHECKED); + SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingBgColor); + EnableWindow(GetDlgItem(hwndDlg, IDC_BGCOLOR), settingSetColours != 0); + SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_SETCOLOUR, 0, (LPARAM)settingFgColor); + EnableWindow(GetDlgItem(hwndDlg, IDC_FGCOLOR), settingSetColours != 0); + + SetDlgItemInt(hwndDlg, IDC_INTERVAL1, settingInterval1, TRUE); + CheckDlgButton(hwndDlg, IDC_ONCEONLY, settingOnceOnly ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_NONCLICKEDONLY, settingNonClickedOnly ? BST_CHECKED : BST_UNCHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_NONCLICKEDONLY), settingOnceOnly != 0); + CheckDlgButton(hwndDlg, IDC_SHOWERROR, settingShowError ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_NEWEST, settingNewest ? BST_CHECKED : BST_UNCHECKED); + CheckDlgButton(hwndDlg, IDC_REMEMBEREVENNONCLICKED, settingEvenNonClicked ? BST_CHECKED : BST_UNCHECKED); + EnableWindow(GetDlgItem(hwndDlg, IDC_REMEMBEREVENNONCLICKED), settingNewest != 0); + SetDlgItemTextA(hwndDlg, IDC_COMMAND, settingCommand); + SetDlgItemTextA(hwndDlg, IDC_PARAMETERS, settingParameters); + + bInit = FALSE; + break; + + case WM_COMMAND://user changed something, so get changes to variables + if (!bInit) { + switch (HIWORD(wParam)) { + case EN_CHANGE: // text is modified in an edit ctrl + case BN_CLICKED: // a checkbox is modified + case CPN_COLOURCHANGED: // a color has changed + PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + } + switch (LOWORD(wParam)) { + case IDC_SETCOLOURS: + settingSetColours = IsDlgButtonChecked(hwndDlg, IDC_SETCOLOURS); + EnableWindow(GetDlgItem(hwndDlg, IDC_BGCOLOR), settingSetColours); + EnableWindow(GetDlgItem(hwndDlg, IDC_FGCOLOR), settingSetColours); + break; + case IDC_BGCOLOR: + settingBgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_BGCOLOR, CPM_GETCOLOUR, 0, 0); + break; + case IDC_FGCOLOR: + settingFgColor = (COLORREF)SendDlgItemMessage(hwndDlg, IDC_FGCOLOR, CPM_GETCOLOUR, 0, 0); + break; + case IDC_INTERVAL1: + settingInterval1 = GetDlgItemInt(hwndDlg, IDC_INTERVAL1, nullptr, TRUE); + break; + case IDC_ONCEONLY: + settingOnceOnly = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_ONCEONLY); + EnableWindow(GetDlgItem(hwndDlg, IDC_NONCLICKEDONLY), settingOnceOnly); + break; + case IDC_NONCLICKEDONLY: + settingNonClickedOnly = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_NONCLICKEDONLY); + break; + case IDC_SHOWERROR: + settingShowError = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_SHOWERROR); + break; + case IDC_NEWEST: + settingNewest = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_NEWEST); + EnableWindow(GetDlgItem(hwndDlg, IDC_REMEMBEREVENNONCLICKED), settingNewest); + break; + case IDC_REMEMBEREVENNONCLICKED: + settingEvenNonClicked = (uint8_t)IsDlgButtonChecked(hwndDlg, IDC_REMEMBEREVENNONCLICKED); + break; + case IDC_COMMAND: + GetDlgItemTextA(hwndDlg, IDC_COMMAND, settingCommand, _countof(settingCommand)); + break; + case IDC_PARAMETERS: + GetDlgItemTextA(hwndDlg, IDC_PARAMETERS, settingParameters, _countof(settingParameters)); + break; + case IDC_BUTTON_CLEAR: + deleteElements(); + break; + } + break; + + case WM_NOTIFY://apply changes so write it to db + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + { + switch (((LPNMHDR)lParam)->code) { + case PSN_RESET: + LoadSettings(); + return TRUE; + case PSN_APPLY: + SaveSettings(hwndDlg); + + return TRUE; + break; + } + //KillTimer(hTimerWnd,TID); + //if(settingInterval!=0) + // SetTimer(hTimerWnd, TID, settingInterval*60000, (TIMERPROC)atTime); + + break; + } //case 0 + } //id from + + break; //switch(msg) + + } + return FALSE; +} + +///////////////////////////////////////////////////////////////////////////////////////// + +static INT_PTR CALLBACK DlgProcLotusNotifyMiscOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +{ + static bool bInit = false; + + wchar_t *strptr; + LVITEM lvI = { 0 }; + LVCOLUMN lvc = { 0 }; + switch (msg) { + case WM_INITDIALOG://initialize dialog, so set properties from db. + { + wchar_t buff[512]; + bInit = true; + TranslateDialogDefault(hwndDlg);//translate miranda function + LoadSettings(); + + //fill filter combos + + wcsncpy_s(buff, settingFilterSender, _TRUNCATE); + while (strptr = wcschr(buff, TEXT(';'))) { + wchar_t tmp[512] = TEXT(""); + wcsncpy_s(tmp, buff, (strptr - buff)); + SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER, CB_ADDSTRING, 0, (LPARAM)tmp); + wcsncpy_s(buff, strptr + 1, _TRUNCATE); + } + + wcsncpy_s(buff, settingFilterSubject, _TRUNCATE); + while (strptr = wcschr(buff, TEXT(';'))) { + wchar_t tmp[512] = TEXT(""); + wcsncpy_s(tmp, buff, (strptr - buff)); + SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT, CB_ADDSTRING, 0, (LPARAM)tmp); + wcsncpy_s(buff, strptr + 1, _TRUNCATE); + } + + wcsncpy_s(buff, settingFilterTo, _TRUNCATE); + while (strptr = wcschr(buff, TEXT(';'))) { + wchar_t tmp[512] = TEXT(""); + wcsncpy_s(tmp, buff, (strptr - buff)); + SendDlgItemMessage(hwndDlg, IDC_FILTER_TO, CB_ADDSTRING, 0, (LPARAM)tmp); + wcsncpy_s(buff, strptr + 1, _TRUNCATE); + } + + // initialise and fill listbox + HWND hwndList = GetDlgItem(hwndDlg, IDC_STATUS); + ListView_DeleteAllItems(hwndList); + + SendMessage(hwndList, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, LVS_EX_FULLROWSELECT | LVS_EX_CHECKBOXES); + + // Initialize the LVCOLUMN structure. + // The mask specifies that the format, width, text, and + // subitem members of the structure are valid. + lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; + lvc.fmt = LVCFMT_LEFT; + + lvc.iSubItem = 0; + lvc.pszText = TranslateT("Status"); + lvc.cx = 120; // width of column in pixels + ListView_InsertColumn(hwndList, 0, &lvc); + + // Some code to create the list-view control. + // Initialize LVITEM members that are common to all items. + lvI.mask = LVIF_TEXT; + for (int i = 0; i < STATUS_COUNT; i++) { + lvI.pszText = Clist_GetStatusModeDescription(ID_STATUS_ONLINE + i, 0); + lvI.iItem = i; + ListView_InsertItem(hwndList, &lvI); + ListView_SetCheckState(hwndList, i, settingStatus[i]); + } + + bInit = false; + break; + } + case WM_COMMAND://user changed something, so get changes to variables + { + if (!bInit && (HIWORD(wParam) == EN_CHANGE)) { + PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + char tmp[255]; + int index, size; + switch (LOWORD(wParam)) { + case IDC_BUTTON_ADD_SENDER_FILTER: + GetDlgItemTextA(hwndDlg, IDC_FILTER_SENDER, tmp, _countof(tmp)); + if (strlen(tmp) > 0) { + SendDlgItemMessageA(hwndDlg, IDC_FILTER_SENDER, CB_ADDSTRING, 0, (LPARAM)tmp); + PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + case IDC_BUTTON_REMOVE_SENDER_FILTER: + index = SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER, CB_GETCURSEL, 0, 0); + size = SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER, CB_DELETESTRING, index, 0); + SendDlgItemMessage(hwndDlg, IDC_FILTER_SENDER, CB_SETCURSEL, min(index, size - 1), 0); + PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_BUTTON_ADD_SUBJECT_FILTER: + GetDlgItemTextA(hwndDlg, IDC_FILTER_SUBJECT, tmp, _countof(tmp)); + if (strlen(tmp) > 0) { + SendDlgItemMessageA(hwndDlg, IDC_FILTER_SUBJECT, CB_ADDSTRING, 0, (LPARAM)tmp); + PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + case IDC_BUTTON_REMOVE_SUBJECT_FILTER: + index = SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT, CB_GETCURSEL, 0, 0); + size = SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT, CB_DELETESTRING, index, 0); + SendDlgItemMessage(hwndDlg, IDC_FILTER_SUBJECT, CB_SETCURSEL, min(index, size - 1), 0); + PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + case IDC_BUTTON_ADD_TO_FILTER: + GetDlgItemTextA(hwndDlg, IDC_FILTER_TO, tmp, _countof(tmp)); + if (strlen(tmp) > 0) { + SendDlgItemMessageA(hwndDlg, IDC_FILTER_TO, CB_ADDSTRING, 0, (LPARAM)tmp); + PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + case IDC_BUTTON_REMOVE_TO_FILTER: + index = SendDlgItemMessage(hwndDlg, IDC_FILTER_TO, CB_GETCURSEL, 0, 0); + size = SendDlgItemMessage(hwndDlg, IDC_FILTER_TO, CB_DELETESTRING, index, 0); + SendDlgItemMessage(hwndDlg, IDC_FILTER_TO, CB_SETCURSEL, min(index, size - 1), 0); + PostMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + break; + } + break; + } + case WM_NOTIFY://apply changes so write it to db + if (bInit) { + break; + } + switch (((LPNMHDR)lParam)->idFrom) { + case 0: + switch (((LPNMHDR)lParam)->code) { + case PSN_RESET: + LoadSettings(); + return TRUE; + + case PSN_APPLY: + SaveSettings(hwndDlg); + return TRUE; + } + + break; + } //id from + + if (GetDlgItem(hwndDlg, IDC_STATUS) == ((LPNMHDR)lParam)->hwndFrom) { + switch (((LPNMHDR)lParam)->code) { + case LVN_ITEMCHANGED: + { + NMLISTVIEW *nmlv = (NMLISTVIEW *)lParam; + if ((nmlv->uNewState ^ nmlv->uOldState) & LVIS_STATEIMAGEMASK) { + SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); + } + break; + + } + break; + } + } + break; //switch(msg) + + } + return FALSE; +} + +///////////////////////////////////////////////////////////////////////////////////////// +// options page on miranda called + +int LotusNotifyOptInit(WPARAM wParam, LPARAM) +{ + OPTIONSDIALOGPAGE odp = {}; + odp.szGroup.w = LPGENW("Plugins"); + odp.szTitle.w = _A2W(__PLUGIN_NAME); + odp.flags = ODPF_BOLDGROUPS | ODPF_UNICODE; + + odp.szTab.w = LPGENW("Connection"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_LOTUS_CONECTION); + odp.pfnDlgProc = DlgProcLotusNotifyConnectionOpts; + g_plugin.addOptions(wParam, &odp); + + odp.szTab.w = LPGENW("Popup"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_LOTUS_POPUP); + odp.pfnDlgProc = DlgProcLotusNotifyPopupOpts; + g_plugin.addOptions(wParam, &odp); + + odp.szTab.w = LPGENW("Miscellaneous"); + odp.pszTemplate = MAKEINTRESOURCEA(IDD_OPT_LOTUS_MISC); + odp.pfnDlgProc = DlgProcLotusNotifyMiscOpts; + g_plugin.addOptions(wParam, &odp); + return 0; +} diff --git a/protocols/LotusNotify/src/stdafx.h b/protocols/LotusNotify/src/stdafx.h index 7a6bf951a8..02d1308006 100644 --- a/protocols/LotusNotify/src/stdafx.h +++ b/protocols/LotusNotify/src/stdafx.h @@ -35,3 +35,26 @@ #include "cnotesapi/include/extmgr.h" #include "cnotesapi/include/bsafeerr.h" #include "cnotesapi/include/nsferr.h" + +BOOL checkNotesIniFile(BOOL bInfo); +void decodeServer(char *tmp); +void deleteElements(); +void LoadSettings(); +void ErMsgByLotusCode(STATUS erno); + +#define MAX_SETTING_STR 512 +#define MAX_FIELD 256 +#define STATUS_COUNT 9 + +#define MODULENAME "LotusNotify" + +extern char settingServer[MAX_SETTING_STR], settingServerSec[MAX_SETTING_STR], settingDatabase[MAX_SETTING_STR]; +extern char settingCommand[MAX_SETTING_STR], settingParameters[MAX_SETTING_STR], settingPassword[MAX_SETTING_STR]; +extern wchar_t settingFilterSubject[MAX_SETTING_STR], settingFilterSender[MAX_SETTING_STR], settingFilterTo[MAX_SETTING_STR]; + +extern COLORREF settingBgColor, settingFgColor; +extern int settingInterval, settingInterval1; +extern uint32_t settingNewestID; +extern uint8_t settingSetColours, settingShowError, settingIniAnswer, settingIniCheck; +extern uint8_t settingOnceOnly, settingNonClickedOnly, settingNewest, settingEvenNonClicked, settingKeepConnection; +extern BOOL settingStatus[STATUS_COUNT]; diff --git a/protocols/LotusNotify/src/version.h b/protocols/LotusNotify/src/version.h index 96d7cf4283..44f9d3b95c 100644 --- a/protocols/LotusNotify/src/version.h +++ b/protocols/LotusNotify/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 1 #define __RELEASE_NUM 23 -#define __BUILD_NUM 0 +#define __BUILD_NUM 1 #include <stdver.h> |