From 9263c0341134cc0079cf78b64319cc81d035317b Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 22 Dec 2013 17:31:01 +0000 Subject: =?UTF-8?q?more=20cleaning=20for=20=D0=B3=D1=88=D1=82=D0=B0=D1=89?= =?UTF-8?q?=D1=83=D1=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: http://svn.miranda-ng.org/main/trunk@7341 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/UserInfoEx/src/Flags/svc_flags.cpp | 32 +- plugins/UserInfoEx/src/Flags/svc_flagsicons.h | 1 - plugins/UserInfoEx/src/svc_constants.cpp | 91 ++- plugins/UserInfoEx/src/svc_contactinfo.cpp | 830 +++++++++++++------------- plugins/UserInfoEx/src/svc_email.cpp | 176 +++--- plugins/UserInfoEx/src/svc_gender.cpp | 87 ++- plugins/UserInfoEx/src/svc_homepage.cpp | 167 +++--- plugins/UserInfoEx/src/svc_phone.cpp | 127 ++-- plugins/UserInfoEx/src/svc_refreshci.cpp | 4 +- plugins/UserInfoEx/src/svc_reminder.cpp | 771 +++++++++++------------- plugins/UserInfoEx/src/svc_timezone.cpp | 41 +- plugins/UserInfoEx/src/svc_timezone_old.cpp | 388 ++++++------ 12 files changed, 1268 insertions(+), 1447 deletions(-) (limited to 'plugins/UserInfoEx') diff --git a/plugins/UserInfoEx/src/Flags/svc_flags.cpp b/plugins/UserInfoEx/src/Flags/svc_flags.cpp index 46907cc5ec..9ee871bd61 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flags.cpp +++ b/plugins/UserInfoEx/src/Flags/svc_flags.cpp @@ -34,7 +34,6 @@ struct CountryListEntry *countries; static HANDLE hExtraIconSvc = INVALID_HANDLE_VALUE; /* hook */ static HANDLE hApplyIconHook = NULL; -static HANDLE hMsgWndEventHook = NULL; static HANDLE hSettingChangedHook = NULL; static int OnContactSettingChanged(WPARAM wParam,LPARAM lParam); @@ -211,7 +210,8 @@ void SvcFlagsEnableExtraIcons(BYTE bColumn, BYTE bUpdateDB) * message winsow status icon functions ***********************************************************************************************************/ -MsgWndData::MsgWndData(HWND hwnd, HANDLE hContact) { +MsgWndData::MsgWndData(HWND hwnd, HANDLE hContact) +{ m_hwnd = hwnd; m_hContact = hContact; m_countryID = (int)ServiceDetectContactOriginCountry((WPARAM)m_hContact, 0); @@ -224,7 +224,8 @@ MsgWndData::MsgWndData(HWND hwnd, HANDLE hContact) { FlagsIconUpdate(); } -MsgWndData::~MsgWndData() { +MsgWndData::~MsgWndData() +{ FlagsIconUnset(); //check if realy need } @@ -360,23 +361,23 @@ static int OnStatusIconsChanged(WPARAM wParam, LPARAM lParam) static int OnContactSettingChanged(WPARAM wParam, LPARAM lParam) { - if ((HANDLE)wParam == NULL) return 0; - DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING*)lParam; + if ((HANDLE)wParam == NULL) + return 0; /* user details update */ + DBCONTACTWRITESETTING *dbcws = (DBCONTACTWRITESETTING*)lParam; if (!lstrcmpA(dbcws->szSetting, SET_CONTACT_COUNTRY) || - !lstrcmpA(dbcws->szSetting, SET_CONTACT_ORIGIN_COUNTRY) || - !lstrcmpA(dbcws->szSetting, SET_CONTACT_COMPANY_COUNTRY)) + !lstrcmpA(dbcws->szSetting, SET_CONTACT_ORIGIN_COUNTRY) || + !lstrcmpA(dbcws->szSetting, SET_CONTACT_COMPANY_COUNTRY)) { /* Extra Image */ - CallFunctionBuffered(SetExtraImage, wParam, TRUE, EXTRAIMAGE_REFRESHDELAY); + SetExtraImage(wParam); + /* Status Icon */ - if (hMsgWndEventHook) { - int i = gMsgWndList.getIndex((MsgWndData*)&wParam); - if (i != -1) { - gMsgWndList[i]->ContryIDchange((int)ServiceDetectContactOriginCountry(wParam, 0)); - gMsgWndList[i]->FlagsIconUpdate(); - } + int i = gMsgWndList.getIndex((MsgWndData*)&wParam); + if (i != -1) { + gMsgWndList[i]->ContryIDchange((int)ServiceDetectContactOriginCountry(wParam, 0)); + gMsgWndList[i]->FlagsIconUpdate(); } } return 0; @@ -423,7 +424,7 @@ void SvcFlagsOnModulesLoaded() SvcFlagsEnableExtraIcons(db_get_b(NULL, MODNAME, SET_CLIST_EXTRAICON_FLAGS2, 0), FALSE); /* Status Icon */ - hMsgWndEventHook = HookEvent(ME_MSG_WINDOWEVENT, OnMsgWndEvent); + HookEvent(ME_MSG_WINDOWEVENT, OnMsgWndEvent); } /** @@ -439,7 +440,6 @@ void SvcFlagsUnloadModule() //Uninit ExtraImg UnhookEvent(hApplyIconHook); //Uninit message winsow - UnhookEvent(hMsgWndEventHook); for (int i = 0; i < gMsgWndList.getCount(); i++) { //this should not happen delete gMsgWndList[i]; diff --git a/plugins/UserInfoEx/src/Flags/svc_flagsicons.h b/plugins/UserInfoEx/src/Flags/svc_flagsicons.h index 362e2d9c68..ee9c6641df 100644 --- a/plugins/UserInfoEx/src/Flags/svc_flagsicons.h +++ b/plugins/UserInfoEx/src/Flags/svc_flagsicons.h @@ -30,7 +30,6 @@ HICON LoadFlag(int countryNumber); HANDLE LoadFlagHandle(int countryNumber); void InitIcons(); -//void SvcFlagsOnModulesLoaded(); void UninitIcons(); #endif /* _UINFOEX_FLAGSICONS_H_INCLUDED_ */ diff --git a/plugins/UserInfoEx/src/svc_constants.cpp b/plugins/UserInfoEx/src/svc_constants.cpp index 4b2828b247..8e97677eb6 100644 --- a/plugins/UserInfoEx/src/svc_constants.cpp +++ b/plugins/UserInfoEx/src/svc_constants.cpp @@ -241,31 +241,33 @@ static IDSTRLIST *MyCountries = NULL; static UINT MyCountriesCount = 0; /** - * This is a sort procedure, which compares two items of an IDSTRLIST array. - * It is used by qsort in SvcConstantsTranslateList and cares about the - * locale, which was set up in OS. This prevents e.g. Ä,Ö to be put onto - * the end of the list., but being sorted to the right position. - * - * @param p1 - (LPIDSTRLIST) first item to compare - * @param p2 - (LPIDSTRLIST) second item to compare - * - * returns -1, 0, 1 according to the comparison result of _tcscmp. - **/ +* This is a sort procedure, which compares two items of an IDSTRLIST array. +* It is used by qsort in SvcConstantsTranslateList and cares about the +* locale, which was set up in OS. This prevents e.g. Ä,Ö to be put onto +* the end of the list., but being sorted to the right position. +* +* @param p1 - (LPIDSTRLIST) first item to compare +* @param p2 - (LPIDSTRLIST) second item to compare +* +* returns -1, 0, 1 according to the comparison result of _tcscmp. +**/ + static int __cdecl ListSortProc(const LPIDSTRLIST p1, const LPIDSTRLIST p2) { return lstrcmpi(p1->ptszTranslated, p2->ptszTranslated); } /** - * Translates the text of each item of an IDStrinList to users locale - * language and saves result in szTranslated member for later use and - * faster access to translated strings later. - * - * @param pList - pointer to list to translate - * @param nListCount - number of list items - * - * @return nothing - **/ +* Translates the text of each item of an IDStrinList to users locale +* language and saves result in szTranslated member for later use and +* faster access to translated strings later. +* +* @param pList - pointer to list to translate +* @param nListCount - number of list items +* +* @return nothing +**/ + static void SvcConstantsTranslateList(LPIDSTRLIST pList, UINT nListCount/*, SortedList *pSorted*/) { if (!pList[0].ptszTranslated) @@ -284,30 +286,27 @@ static void SvcConstantsTranslateList(LPIDSTRLIST pList, UINT nListCount/*, Sort } /** - * This function uses the country list provided by the core to create ower own one. - * The core's list is extended by a translated value. The cached translation is meant - * to improve speed uppon adding items to a combobox. - * - * @param pList - LPIDSTRLIST pointer, which retrieves the list pointer. - * @param pnListSize - pointer to an unsigned integer, which retrieves the number of items. - * - * @retval MIR_OK - indicates success - * @retval MIR_FAIL - indicates error - **/ +* This function uses the country list provided by the core to create ower own one. +* The core's list is extended by a translated value. The cached translation is meant +* to improve speed upon adding items to a combobox. +* +* @param pList - LPIDSTRLIST pointer, which retrieves the list pointer. +* @param pnListSize - pointer to an unsigned integer, which retrieves the number of items. +* +* @retval MIR_OK - indicates success +* @retval MIR_FAIL - indicates error +**/ + INT_PTR GetCountryList(LPUINT pnListSize, LPIDSTRLIST *pList) { INT_PTR rc = MIR_OK; - if (!MyCountries) - { - struct CountryListEntry *country; + if (!MyCountries) { - if (!CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&MyCountriesCount, (LPARAM)&country)) - { + CountryListEntry *country; + if (!CallService(MS_UTILS_GETCOUNTRYLIST, (WPARAM)&MyCountriesCount, (LPARAM)&country)) { MyCountries = (IDSTRLIST*)mir_alloc(MyCountriesCount * sizeof(IDSTRLIST)); - if (MyCountries) - { - for (UINT i = 0; i < MyCountriesCount; i++) - { + if (MyCountries) { + for (UINT i = 0; i < MyCountriesCount; i++) { MyCountries[i].nID = country[i].id; MyCountries[i].pszText = country[i].szName; MyCountries[i].ptszTranslated = (LPTSTR)CallService(MS_LANGPACK_PCHARTOTCHAR, 0, (LPARAM)country[i].szName); @@ -316,15 +315,9 @@ INT_PTR GetCountryList(LPUINT pnListSize, LPIDSTRLIST *pList) qsort(MyCountries+1, MyCountriesCount-1, sizeof(MyCountries[0]), (int (*)(const void*, const void*))ListSortProc); } - else - { - rc = MIR_FAIL; - } - } - else - { - rc = MIR_FAIL; + else rc = MIR_FAIL; } + else rc = MIR_FAIL; } *pnListSize = MyCountriesCount; *pList = MyCountries; @@ -406,12 +399,8 @@ void SvcConstantsLoadModule(void) static void FORCEINLINE SvcConstantsClearList(UINT pnListSize, LPIDSTRLIST pList) { if (pList) - { for (UINT i = 0; i < pnListSize; i++) - { MIR_FREE(pList[i].ptszTranslated); - } - } } void SvcConstantsUnloadModule(void) @@ -425,4 +414,4 @@ void SvcConstantsUnloadModule(void) SvcConstantsClearList(SIZEOF(TmplPrefixes), TmplPrefixes); SvcConstantsClearList(MyCountriesCount, MyCountries); MIR_FREE(MyCountries); -} \ No newline at end of file +} diff --git a/plugins/UserInfoEx/src/svc_contactinfo.cpp b/plugins/UserInfoEx/src/svc_contactinfo.cpp index 43f1522e8e..0c39d10aec 100644 --- a/plugins/UserInfoEx/src/svc_contactinfo.cpp +++ b/plugins/UserInfoEx/src/svc_contactinfo.cpp @@ -31,60 +31,61 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static BYTE gNameOrder[NAMEORDERCOUNT]; // name order as set up for contact list /** - * This function translates the DBVARIANT structure to an CONTACTINFO structure - * and keeps the original data type. - * - * @warning ci MUST NOT be NULL and dbv must be freed by caller on failure! - * - * @param dbv - DBVARIANT to take the data for translation from - * @param ci - CONTACTINFO structure to translate to - * - * @retval 0 - success - * @retval 1 - failure - **/ +* This function translates the DBVARIANT structure to an CONTACTINFO structure +* and keeps the original data type. +* +* @warning ci MUST NOT be NULL and dbv must be freed by caller on failure! +* +* @param dbv - DBVARIANT to take the data for translation from +* @param ci - CONTACTINFO structure to translate to +* +* @retval 0 - success +* @retval 1 - failure +**/ + static FORCEINLINE INT_PTR VarToVarCI(const DBVARIANT *dbv, CONTACTINFO *ci) { switch (dbv->type) { case DBVT_ASCIIZ: - case DBVT_WCHAR: { - // string translation is to be done by caller!!! - ci->pszVal = dbv->ptszVal; - ci->type = (ci->pszVal != NULL) ? CNFT_ASCIIZ : 0; - } break; - - case DBVT_BYTE: { - ci->type = CNFT_BYTE; - ci->bVal = dbv->bVal; - } break; - - case DBVT_WORD: { - ci->type = CNFT_WORD; - ci->wVal = dbv->wVal; - } break; - - case DBVT_DWORD: { - ci->type = CNFT_DWORD; - ci->dVal = dbv->dVal; - } break; - - default: { - ci->type = 0; - } + case DBVT_WCHAR: + // string translation is to be done by caller!!! + ci->pszVal = dbv->ptszVal; + ci->type = (ci->pszVal != NULL) ? CNFT_ASCIIZ : 0; + break; + + case DBVT_BYTE: + ci->type = CNFT_BYTE; + ci->bVal = dbv->bVal; + break; + + case DBVT_WORD: + ci->type = CNFT_WORD; + ci->wVal = dbv->wVal; + break; + + case DBVT_DWORD: + ci->type = CNFT_DWORD; + ci->dVal = dbv->dVal; + break; + + default: + ci->type = 0; } return ci->type == 0; } /** - * This function tries to read a setting from the contact's protocol module. - * - * @warning ci MUST NOT be NULL! - * - * @param ci - pointer to a CONTACTINFO structure holding information about the contact - * @param pszSetting - the desired setting to read - * - * @retval 0 - if setting was found and read correctly - * @retval 1 - if any error occured or setting was not found - **/ +* This function tries to read a setting from the contact's protocol module. +* +* @warning ci MUST NOT be NULL! +* +* @param ci - pointer to a CONTACTINFO structure holding information about the contact +* @param pszSetting - the desired setting to read +* +* @retval 0 - if setting was found and read correctly +* @retval 1 - if any error occured or setting was not found +**/ + static FORCEINLINE INT_PTR GCIVar(CONTACTINFO *ci, LPCSTR pszSetting) { DBVARIANT dbv; @@ -95,26 +96,26 @@ static FORCEINLINE INT_PTR GCIVar(CONTACTINFO *ci, LPCSTR pszSetting) db_free(&dbv); } } - else { - ci->type = 0; - } + else ci->type = 0; + return ci->type == 0; } /** - * This function tries to read a setting from a certain module (e.g. USERINFO) and if failed it - * tries once again with the baseprotocol of the contact (e.g. ICQ). If nothing was found anyway - * and this is an metacontact it can have a look into subcontacts to retrieve the information. - * This depends on the settings the user did. - * - * @warning ci MUST NOT be NULL! - * - * @param ci - pointer to a CONTACTINFO structure holding information about the contact - * @param pszSetting - the desired setting to read - * - * @retval 0 - if setting was found and read correctly - * @retval 1 - if any error occured or setting was not found - **/ +* This function tries to read a setting from a certain module (e.g. USERINFO) and if failed it +* tries once again with the baseprotocol of the contact (e.g. ICQ). If nothing was found anyway +* and this is an metacontact it can have a look into subcontacts to retrieve the information. +* This depends on the settings the user did. +* +* @warning ci MUST NOT be NULL! +* +* @param ci - pointer to a CONTACTINFO structure holding information about the contact +* @param pszSetting - the desired setting to read +* +* @retval 0 - if setting was found and read correctly +* @retval 1 - if any error occured or setting was not found +**/ + static FORCEINLINE INT_PTR GCIVarEx(CONTACTINFO *ci, LPCSTR pszSetting) { DBVARIANT dbv; @@ -125,26 +126,26 @@ static FORCEINLINE INT_PTR GCIVarEx(CONTACTINFO *ci, LPCSTR pszSetting) db_free(&dbv); } } - else { - ci->type = 0; - } + else ci->type = 0; + return ci->type == 0; } /** - * This function tries to read a Language from a certain module (e.g. USERINFO) and if failed it - * tries once again with the baseprotocol of the contact (e.g. ICQ). If nothing was found anyway - * and this is an metacontact it can have a look into subcontacts to retrieve the information. - * This depends on the settings the user did. - * - * @warning ci MUST NOT be NULL! - * - * @param ci - pointer to a CONTACTINFO structure holding information about the contact - * @param pszSetting - the desired setting to read - * - * @retval 0 - if setting was found and read correctly - * @retval 1 - if any error occured or setting was not found - **/ +* This function tries to read a Language from a certain module (e.g. USERINFO) and if failed it +* tries once again with the baseprotocol of the contact (e.g. ICQ). If nothing was found anyway +* and this is an metacontact it can have a look into subcontacts to retrieve the information. +* This depends on the settings the user did. +* +* @warning ci MUST NOT be NULL! +* +* @param ci - pointer to a CONTACTINFO structure holding information about the contact +* @param pszSetting - the desired setting to read +* +* @retval 0 - if setting was found and read correctly +* @retval 1 - if any error occured or setting was not found +**/ + static FORCEINLINE INT_PTR GCILangEx(CONTACTINFO *ci, LPCSTR pszSetting) { if (0 == GCIVarEx(ci, pszSetting)) { @@ -153,18 +154,16 @@ static FORCEINLINE INT_PTR GCILangEx(CONTACTINFO *ci, LPCSTR pszSetting) LPIDSTRLIST pList; UINT nList, i, res = 0; switch (ci->type) { - case CNFT_BYTE: res = ci->bVal; break; - case CNFT_WORD: res = ci->wVal; break; - case CNFT_DWORD: res = ci->dVal; break; - default: return 1; + case CNFT_BYTE: res = ci->bVal; break; + case CNFT_WORD: res = ci->wVal; break; + case CNFT_DWORD: res = ci->dVal; break; + default: return 1; } GetLanguageList(&nList, &pList); for(i = 0; ipszVal = (ci->dwFlag & CNF_UNICODE) - ? (LPTSTR) mir_a2u(pList[i].pszText) - : (LPTSTR) mir_strdup(pList[i].pszText); + ci->pszVal = (ci->dwFlag & CNF_UNICODE) ? (LPTSTR) mir_a2u(pList[i].pszText) : (LPTSTR) mir_strdup(pList[i].pszText); ci->type = (ci->pszVal != NULL) ? CNFT_ASCIIZ : 0; return 0; } @@ -173,52 +172,51 @@ static FORCEINLINE INT_PTR GCILangEx(CONTACTINFO *ci, LPCSTR pszSetting) ci->pszVal = NULL; } } - else { - ci->type = 0; - } + else ci->type = 0; + return ci->type == 0; } /** - * This function read a setting from the baseprotocol of the contact (e.g. ICQ). - * - * @warning ci MUST NOT be NULL! - * - * @param ci - pointer to a CONTACTINFO structure holding information about the contact - * @param pszSetting - the desired setting to read - * - * @retval 0 - if setting was found and read correctly - * @retval 1 - if any error occured or setting was not found - **/ +* This function read a setting from the baseprotocol of the contact (e.g. ICQ). +* +* @warning ci MUST NOT be NULL! +* +* @param ci - pointer to a CONTACTINFO structure holding information about the contact +* @param pszSetting - the desired setting to read +* +* @retval 0 - if setting was found and read correctly +* @retval 1 - if any error occured or setting was not found +**/ + static FORCEINLINE INT_PTR GCIStr(CONTACTINFO *ci, LPCSTR pszSetting) { const BYTE type = CI_TCHAR(ci); DBVARIANT dbv; if (DB::Setting::Get(ci->hContact, ci->szProto, pszSetting, &dbv, type) == 0) { - if (DB::Variant::dbv2String(&dbv, type) == 0) { + if (DB::Variant::dbv2String(&dbv, type) == 0) ci->pszVal = dbv.ptszVal; - } else { db_free(&dbv); ci->pszVal = NULL; } } - else { - ci->pszVal = NULL; - } + else ci->pszVal = NULL; + ci->type = (ci->pszVal) ? CNFT_ASCIIZ : 0; return ci->type == 0; } /** - * Format the full name for the contact. - * - * @params ci - CONTACTINFO structure - * - * @retval 0 - if setting was found and read correctly - * @retval 1 - if any error occured or setting was not found - **/ +* Format the full name for the contact. +* +* @params ci - CONTACTINFO structure +* +* @retval 0 - if setting was found and read correctly +* @retval 1 - if any error occured or setting was not found +**/ + static FORCEINLINE INT_PTR GCIFirstLast(CONTACTINFO *ci) { DBVARIANT dbvf, dbvl; @@ -227,79 +225,64 @@ static FORCEINLINE INT_PTR GCIFirstLast(CONTACTINFO *ci) BYTE type = CI_TCHAR(ci); if (DB::Setting::GetEx(ci->hContact, USERINFO, ci->szProto, SET_CONTACT_FIRSTNAME, &dbvf, type)) - { dbvf.type = DBVT_DELETED; - } + if (DB::Setting::GetEx(ci->hContact, USERINFO, ci->szProto, SET_CONTACT_LASTNAME, &dbvl, type)) - { dbvl.type = DBVT_DELETED; - } - if (type == DBVT_WCHAR) - { + if (type == DBVT_WCHAR) { // both firstname and lastname are valid - if (dbvf.type == DBVT_WCHAR && dbvl.type == DBVT_WCHAR) - { + if (dbvf.type == DBVT_WCHAR && dbvl.type == DBVT_WCHAR) { cbf = mir_wcslen(dbvf.pwszVal); cbl = mir_wcslen(dbvl.pwszVal); ci->pszVal = (LPTSTR) mir_alloc((cbf + cbl + 2) * sizeof(WCHAR)); if (ci->pszVal) - { mir_snwprintf((LPWSTR) ci->pszVal, cbf + cbl + 2, L"%s %s", dbvf.pwszVal, dbvl.pwszVal); - } + db_free(&dbvf); db_free(&dbvl); } // set firstname as result - else if (dbvf.type == DBVT_WCHAR) - { + else if (dbvf.type == DBVT_WCHAR) { ci->pszVal = (LPTSTR) dbvf.pwszVal; db_free(&dbvl); } // set lastname as result - else if (dbvl.type == DBVT_WCHAR) - { + else if (dbvl.type == DBVT_WCHAR) { ci->pszVal = (LPTSTR) dbvl.pwszVal; db_free(&dbvf); } - else - { + else { ci->pszVal = NULL; db_free(&dbvf); db_free(&dbvl); } } - else - { + else { // both firstname and lastname are valid - if (dbvf.type == DBVT_ASCIIZ && dbvl.type == DBVT_ASCIIZ) - { + if (dbvf.type == DBVT_ASCIIZ && dbvl.type == DBVT_ASCIIZ) { cbf = mir_strlen(dbvf.pszVal); cbl = mir_strlen(dbvl.pszVal); ci->pszVal = (LPTSTR) mir_alloc((cbf + cbl + 2) * sizeof(CHAR)); if (ci->pszVal) - { mir_snprintf((LPSTR) ci->pszVal, cbf + cbl + 2, "%s %s", dbvf.pszVal, dbvl.pszVal); - } + db_free(&dbvf); db_free(&dbvl); } // set firstname as result - else if (dbvf.type == DBVT_ASCIIZ) - { + else if (dbvf.type == DBVT_ASCIIZ) { ci->pszVal = (LPTSTR) dbvf.pszVal; db_free(&dbvl); } // set lastname as result - else if (dbvl.type == DBVT_ASCIIZ) - { + else if (dbvl.type == DBVT_ASCIIZ) { ci->pszVal = (LPTSTR) dbvl.pszVal; db_free(&dbvf); } - else - { + else { ci->pszVal = NULL; db_free(&dbvf); db_free(&dbvl); @@ -310,14 +293,15 @@ static FORCEINLINE INT_PTR GCIFirstLast(CONTACTINFO *ci) } /** - * return the country name - * - * @param ci - pointer to a CONTACTINFO structure holding information about the contact - * @param pszSetting - the desired setting to read the countrys id from - * - * @retval 0 - if setting was found and read correctly - * @retval 1 - if any error occured or setting was not found - **/ +* return the country name +* +* @param ci - pointer to a CONTACTINFO structure holding information about the contact +* @param pszSetting - the desired setting to read the countrys id from +* +* @retval 0 - if setting was found and read correctly +* @retval 1 - if any error occured or setting was not found +**/ + static FORCEINLINE INT_PTR GCICountry(CONTACTINFO *ci, LPCSTR pszSetting) { if (0 == GCIVarEx(ci, pszSetting)) { @@ -331,14 +315,11 @@ static FORCEINLINE INT_PTR GCICountry(CONTACTINFO *ci, LPCSTR pszSetting) } LPSTR szCountry = res ? (LPSTR)CallService(MS_UTILS_GETCOUNTRYBYNUMBER, res, 0) : NULL; - if (szCountry) { - ci->pszVal = (ci->dwFlag & CNF_UNICODE) - ? (LPTSTR) mir_a2u(szCountry) - : (LPTSTR) mir_strdup(szCountry); - } - else { + if (szCountry) + ci->pszVal = (ci->dwFlag & CNF_UNICODE) ? (LPTSTR) mir_a2u(szCountry) : (LPTSTR) mir_strdup(szCountry); + else ci->pszVal = NULL; - } + ci->type = (ci->pszVal != NULL) ? CNFT_ASCIIZ : 0; } } @@ -362,196 +343,204 @@ INT_PTR GetContactInfo(WPARAM wParam, LPARAM lParam) CONTACTINFO *ci = (CONTACTINFO*) lParam; INT_PTR result; - if (ci && ci->cbSize == sizeof(CONTACTINFO) && (ci->szProto != NULL || (ci->szProto = DB::Contact::Proto(ci->hContact)) != NULL)) - { + if (ci && ci->cbSize == sizeof(CONTACTINFO) && (ci->szProto != NULL || (ci->szProto = DB::Contact::Proto(ci->hContact)) != NULL)) { switch (ci->dwFlag & 0x7F) { // // contact name // - case CNF_FIRSTNAME: { - result = GCIVarEx(ci, SET_CONTACT_FIRSTNAME); - } break; + case CNF_FIRSTNAME: + result = GCIVarEx(ci, SET_CONTACT_FIRSTNAME); + break; - case CNF_LASTNAME: { - result = GCIVarEx(ci, SET_CONTACT_LASTNAME); - } break; + case CNF_LASTNAME: + result = GCIVarEx(ci, SET_CONTACT_LASTNAME); + break; - case CNF_FIRSTLAST: { - result = GCIVarEx(ci, SET_CONTACT_FIRSTLASTNAME); //first try to read "FullName" - if (result) result = GCIFirstLast(ci); //fallback to "FirstName" + "LastName" - } break; + case CNF_FIRSTLAST: + result = GCIVarEx(ci, SET_CONTACT_FIRSTLASTNAME); //first try to read "FullName" + if (result) result = GCIFirstLast(ci); //fallback to "FirstName" + "LastName" + break; - case CNF_NICK: { - result = GCIVarEx(ci, SET_CONTACT_NICK); - } break; + case CNF_NICK: + result = GCIVarEx(ci, SET_CONTACT_NICK); + break; - case CNF_CUSTOMNICK: { + case CNF_CUSTOMNICK: + { LPSTR s = ci->szProto; ci->szProto = MOD_CLIST; result = GCIVar(ci, SET_CONTACT_MYHANDLE); ci->szProto = s; - } break; + } + break; - case CNF_LANGUAGE1: { - result = GCILangEx(ci, SET_CONTACT_LANG1); - } break; + case CNF_LANGUAGE1: + result = GCILangEx(ci, SET_CONTACT_LANG1); + break; - case CNF_LANGUAGE2: { - result = GCILangEx(ci, SET_CONTACT_LANG2); - } break; + case CNF_LANGUAGE2: + result = GCILangEx(ci, SET_CONTACT_LANG2); + break; - case CNF_LANGUAGE3: { - result = GCILangEx(ci, SET_CONTACT_LANG3); - } break; + case CNF_LANGUAGE3: + result = GCILangEx(ci, SET_CONTACT_LANG3); + break; // // private contact // - case CNF_STREET: { - result = GCIVarEx(ci, SET_CONTACT_STREET); - } break; + case CNF_STREET: + result = GCIVarEx(ci, SET_CONTACT_STREET); + break; - case CNF_ZIP: { - result = GCIVarEx(ci, SET_CONTACT_ZIP); - } break; + case CNF_ZIP: + result = GCIVarEx(ci, SET_CONTACT_ZIP); + break; - case CNF_CITY: { - result = GCIVarEx(ci, SET_CONTACT_CITY); - } break; + case CNF_CITY: + result = GCIVarEx(ci, SET_CONTACT_CITY); + break; - case CNF_STATE: { - result = GCIVarEx(ci, SET_CONTACT_STATE); - } break; + case CNF_STATE: + result = GCIVarEx(ci, SET_CONTACT_STATE); + break; - case CNF_COUNTRY: { - result = GCICountry(ci, SET_CONTACT_COUNTRY); - } break; + case CNF_COUNTRY: + result = GCICountry(ci, SET_CONTACT_COUNTRY); + break; - case CNF_PHONE: { - result = GCIVarEx(ci, SET_CONTACT_PHONE); - } break; + case CNF_PHONE: + result = GCIVarEx(ci, SET_CONTACT_PHONE); + break; - case CNF_FAX: { - result = GCIVarEx(ci, SET_CONTACT_FAX); - } break; + case CNF_FAX: + result = GCIVarEx(ci, SET_CONTACT_FAX); + break; - case CNF_CELLULAR: { - result = GCIVarEx(ci, SET_CONTACT_CELLULAR); - } break; + case CNF_CELLULAR: + result = GCIVarEx(ci, SET_CONTACT_CELLULAR); + break; - case CNF_EMAIL: { - result = GCIVarEx(ci, SET_CONTACT_EMAIL); - } break; + case CNF_EMAIL: + result = GCIVarEx(ci, SET_CONTACT_EMAIL); + break; - case CNF_HOMEPAGE: { - result = GCIVarEx(ci, SET_CONTACT_HOMEPAGE); - } break; + case CNF_HOMEPAGE: + result = GCIVarEx(ci, SET_CONTACT_HOMEPAGE); + break; // // company information // - case CNF_CONAME: { - result = GCIVarEx(ci, SET_CONTACT_COMPANY); - } break; + case CNF_CONAME: + result = GCIVarEx(ci, SET_CONTACT_COMPANY); + break; - case CNF_CODEPT: { - result = GCIVarEx(ci, SET_CONTACT_COMPANY_DEPARTMENT); - } break; + case CNF_CODEPT: + result = GCIVarEx(ci, SET_CONTACT_COMPANY_DEPARTMENT); + break; - case CNF_COPOSITION: { - result = GCIVarEx(ci, SET_CONTACT_COMPANY_POSITION); - } break; + case CNF_COPOSITION: + result = GCIVarEx(ci, SET_CONTACT_COMPANY_POSITION); + break; - case CNF_COSTREET: { - result = GCIVarEx(ci, SET_CONTACT_COMPANY_STREET); - } break; + case CNF_COSTREET: + result = GCIVarEx(ci, SET_CONTACT_COMPANY_STREET); + break; - case CNF_COZIP: { - result = GCIVarEx(ci, SET_CONTACT_COMPANY_ZIP); - } break; + case CNF_COZIP: + result = GCIVarEx(ci, SET_CONTACT_COMPANY_ZIP); + break; - case CNF_COCITY: { - result = GCIVarEx(ci, SET_CONTACT_COMPANY_CITY); - } break; + case CNF_COCITY: + result = GCIVarEx(ci, SET_CONTACT_COMPANY_CITY); + break; - case CNF_COSTATE: { - result = GCIVarEx(ci, SET_CONTACT_COMPANY_STATE); - } break; + case CNF_COSTATE: + result = GCIVarEx(ci, SET_CONTACT_COMPANY_STATE); + break; - case CNF_COCOUNTRY: { - result = GCICountry(ci, SET_CONTACT_COMPANY_COUNTRY); - } break; + case CNF_COCOUNTRY: + result = GCICountry(ci, SET_CONTACT_COMPANY_COUNTRY); + break; - case CNF_COPHONE: { - result = GCIVarEx(ci, SET_CONTACT_COMPANY_PHONE); - } break; + case CNF_COPHONE: + result = GCIVarEx(ci, SET_CONTACT_COMPANY_PHONE); + break; - case CNF_COFAX: { - result = GCIVarEx(ci, SET_CONTACT_COMPANY_FAX); - } break; + case CNF_COFAX: + result = GCIVarEx(ci, SET_CONTACT_COMPANY_FAX); + break; - case CNF_COCELLULAR: { - result = GCIVarEx(ci, SET_CONTACT_COMPANY_CELLULAR); - } break; + case CNF_COCELLULAR: + result = GCIVarEx(ci, SET_CONTACT_COMPANY_CELLULAR); + break; - case CNF_COEMAIL: { - result = GCIVarEx(ci, SET_CONTACT_COMPANY_EMAIL); - } break; + case CNF_COEMAIL: + result = GCIVarEx(ci, SET_CONTACT_COMPANY_EMAIL); + break; - case CNF_COHOMEPAGE: { - result = GCIVarEx(ci, SET_CONTACT_COMPANY_HOMEPAGE); - } break; + case CNF_COHOMEPAGE: + result = GCIVarEx(ci, SET_CONTACT_COMPANY_HOMEPAGE); + break; // // personal information // - case CNF_ABOUT: { - result = GCIVarEx(ci, SET_CONTACT_ABOUT); - } break; + case CNF_ABOUT: + result = GCIVarEx(ci, SET_CONTACT_ABOUT); + break; - case CNF_MYNOTES: { - result = GCIVarEx(ci, SET_CONTACT_MYNOTES); - } break; + case CNF_MYNOTES: + result = GCIVarEx(ci, SET_CONTACT_MYNOTES); + break; - case CNF_AGE: { - result = GCIVarEx(ci, SET_CONTACT_AGE); - } break; // returns age (byte, 0==unspecified) ?? + case CNF_AGE: + result = GCIVarEx(ci, SET_CONTACT_AGE); + break; // returns age (byte, 0==unspecified) ?? - case CNF_GENDER: { - ci->bVal = GenderOf(ci->hContact, ci->szProto); - ci->type = (ci->bVal != 0) ? CNFT_BYTE : 0; - result = ci->type == 0; - } break; + case CNF_GENDER: + ci->bVal = GenderOf(ci->hContact, ci->szProto); + ci->type = (ci->bVal != 0) ? CNFT_BYTE : 0; + result = ci->type == 0; + break; - case CNF_BIRTHDAY: { + case CNF_BIRTHDAY: + { MAnnivDate mda; result = mda.DBGetBirthDate(ci->hContact, ci->szProto); if (result == 0) { - ci->bVal = (BYTE) mda.Day(); + ci->bVal = (BYTE)mda.Day(); ci->type = CNFT_BYTE; } - } break; + } + break; - case CNF_BIRTHMONTH: { + case CNF_BIRTHMONTH: + { MAnnivDate mda; result = mda.DBGetBirthDate(ci->hContact, ci->szProto); if (result == 0) { - ci->bVal = (BYTE) mda.Month(); + ci->bVal = (BYTE)mda.Month(); ci->type = CNFT_BYTE; } - } break; + } + break; - case CNF_BIRTHYEAR: { + case CNF_BIRTHYEAR: + { MAnnivDate mda; result = mda.DBGetBirthDate(ci->hContact, ci->szProto); if (result == 0) { - ci->wVal = (WORD) mda.Year(); + ci->wVal = (WORD)mda.Year(); ci->type = CNFT_WORD; } - } break; + } + break; - case CNF_BIRTHDATE: { + case CNF_BIRTHDATE: + { MAnnivDate mda; result = mda.DBGetBirthDate(ci->hContact, ci->szProto); if (result == 0) { @@ -559,176 +548,160 @@ INT_PTR GetContactInfo(WPARAM wParam, LPARAM lParam) ci->pszVal = NULL; if (ci->dwFlag & CNF_UNICODE) { WCHAR wszDate[80]; - if (GetDateFormatW(LOCALE_USER_DEFAULT, wParam == 1 ? DATE_LONGDATE : DATE_SHORTDATE, &st, NULL, wszDate, SIZEOF(wszDate))) { + if (GetDateFormatW(LOCALE_USER_DEFAULT, wParam == 1 ? DATE_LONGDATE : DATE_SHORTDATE, &st, NULL, wszDate, SIZEOF(wszDate))) ci->pszVal = (LPTSTR)mir_wcsdup(wszDate); - } } else { CHAR szDate[80]; - if (GetDateFormatA(LOCALE_USER_DEFAULT, wParam == 1 ? DATE_LONGDATE : DATE_SHORTDATE, &st, NULL, szDate, SIZEOF(szDate))) { + if (GetDateFormatA(LOCALE_USER_DEFAULT, wParam == 1 ? DATE_LONGDATE : DATE_SHORTDATE, &st, NULL, szDate, SIZEOF(szDate))) ci->pszVal = (LPTSTR)mir_strdup(szDate); - } } ci->type = (ci->pszVal != NULL) ? CNFT_ASCIIZ : 0; result = ci->type == 0; } - } break; - - case CNF_TIMEZONE: { - //use new core tz interface - if (tmi.prepareList) { - HANDLE hTz = tmi.createByContact(ci->hContact, TZF_KNOWNONLY); - if (hTz) { - LPTIME_ZONE_INFORMATION tzi = tmi.getTzi(hTz); - int offset = tzi->Bias + tzi->StandardBias; - - char str[80]; - mir_snprintf(str, SIZEOF(str), offset ? "UTC%+d:%02d" : "UTC", offset / -60, abs(offset % 60)); - ci->pszVal = ci->dwFlag & CNF_UNICODE - ? (TCHAR*)mir_a2u(str) - : (TCHAR*)mir_strdup(str); - ci->type = CNFT_ASCIIZ; - return 0; - } - else { - ci->pszVal = NULL; - } + } + break; + + case CNF_TIMEZONE: + //use new core tz interface + if (tmi.prepareList) { + HANDLE hTz = tmi.createByContact(ci->hContact, TZF_KNOWNONLY); + if (hTz) { + LPTIME_ZONE_INFORMATION tzi = tmi.getTzi(hTz); + int offset = tzi->Bias + tzi->StandardBias; + + char str[80]; + mir_snprintf(str, SIZEOF(str), offset ? "UTC%+d:%02d" : "UTC", offset / -60, abs(offset % 60)); + ci->pszVal = ci->dwFlag & CNF_UNICODE ? (TCHAR*)mir_a2u(str) : (TCHAR*)mir_strdup(str); + ci->type = CNFT_ASCIIZ; + return 0; + } + ci->pszVal = NULL; + } + //fallback use old UIEX method + else { + CTimeZone* ptz = GetContactTimeZone(ci->hContact, ci->szProto); + if (ptz) { + if (ci->dwFlag & CNF_UNICODE) + ci->pszVal = (LPTSTR)mir_t2u(ptz->ptszDisplay); + else + ci->pszVal = (LPTSTR)mir_t2a(ptz->ptszDisplay); } - //fallback use old UIEX method else { - CTimeZone* ptz = GetContactTimeZone(ci->hContact, ci->szProto); - if (ptz) { - if (ci->dwFlag & CNF_UNICODE) { - ci->pszVal = (LPTSTR) mir_t2u(ptz->ptszDisplay); - } - else { - ci->pszVal = (LPTSTR) mir_t2a(ptz->ptszDisplay); - } - } - else { - /* If a timezone does not exist in CTzMgr, it is a invalid timezone, - because Windows and CTzMgr know all existing timezones and it - would not be shown anywhere anyway as UserInfoEx displays only - known windows timezones in the details dialog! - */ - ci->pszVal = NULL; - } + /* If a timezone does not exist in CTzMgr, it is a invalid timezone, + because Windows and CTzMgr know all existing timezones and it + would not be shown anywhere anyway as UserInfoEx displays only + known windows timezones in the details dialog! + */ + ci->pszVal = NULL; } - ci->type = (ci->pszVal != NULL) ? CNFT_ASCIIZ : 0; - result = ci->type == 0; - } break; + } + ci->type = (ci->pszVal != NULL) ? CNFT_ASCIIZ : 0; + result = ci->type == 0; + break; // // information about IM specific stuff // - case CNF_UNIQUEID: { - // protocol must define a PFLAG_UNIQUEIDSETTING + case CNF_UNIQUEID: + // protocol must define a PFLAG_UNIQUEIDSETTING + result = CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if (result != CALLSERVICE_NOTFOUND && result != NULL) + result = GCIVar(ci, (LPCSTR)result); + break; + + case CNF_DISPLAYUID: + if (!GCIVar(ci, "display_uid")) + result = 0; + else { result = CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if (result != CALLSERVICE_NOTFOUND && result != NULL) { - result = GCIVar(ci, (LPCSTR) result); - } - } break; - - case CNF_DISPLAYUID: { - if (!GCIVar(ci, "display_uid")) - result=0; - else { - result = CallProtoService(ci->szProto,PS_GETCAPS,PFLAG_UNIQUEIDSETTING,0); - if (result != CALLSERVICE_NOTFOUND && result != NULL) { - result = GCIVar(ci, (LPCSTR) result); - } - } - } break; + if (result != CALLSERVICE_NOTFOUND && result != NULL) + result = GCIVar(ci, (LPCSTR)result); + } + break; case CNF_DISPLAYNC: - case CNF_DISPLAY: { - int i; - for (i = 0; i < NAMEORDERCOUNT; i++) { - switch (gNameOrder[i]) { - case 0: // custom name - { - // make sure we aren't in CNF_DISPLAYNC mode - // don't get custom name for NULL contact - if (ci->hContact != NULL && (ci->dwFlag & 0x7F) == CNF_DISPLAY) { - BYTE dwFlag = ci->dwFlag; - ci->dwFlag = (ci->dwFlag & CNF_UNICODE) | CNF_CUSTOMNICK; - if (!GetContactInfo(NULL, (LPARAM)ci)) { - ci->dwFlag = dwFlag; - return 0; - } - ci->dwFlag = dwFlag; - } - } break; - case 1: // nick - { - if (!GCIVarEx(ci, SET_CONTACT_NICK)) - return 0; - } break; - case 2: // First Name - { - if (!GCIVarEx(ci, SET_CONTACT_FIRSTNAME)) - return 0; - } break; - case 3: // E-mail - { - if (!GCIVarEx(ci, SET_CONTACT_EMAIL)) - return 0; - } break; - case 4: // Last Name - { - if (!GCIVarEx(ci, SET_CONTACT_LASTNAME)) - return 0; - } break; - case 5: // Unique id - { - // protocol must define a PFLAG_UNIQUEIDSETTING - result = CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); - if (result != CALLSERVICE_NOTFOUND && result != NULL) { - if (!GCIStr(ci, (LPCSTR) result)) - return 0; - } - } break; - case 6: // first + last name - { - if (!GCIFirstLast(ci)) - return 0; - } break; - default: // unknown contact - { - if (ci->dwFlag & CNF_UNICODE) { - ci->pszVal = (LPTSTR) mir_wcsdup(TranslateW(L"'(Unknown Contact)'")); - } - else { - ci->pszVal = (LPTSTR) mir_strdup(Translate("'(Unknown Contact)'")); - } - ci->type = (ci->pszVal != NULL) ? CNFT_ASCIIZ : 0; - return ci->type == 0; + case CNF_DISPLAY: + for (int i = 0; i < NAMEORDERCOUNT; i++) { + switch (gNameOrder[i]) { + case 0: // custom name + // make sure we aren't in CNF_DISPLAYNC mode + // don't get custom name for NULL contact + if (ci->hContact != NULL && (ci->dwFlag & 0x7F) == CNF_DISPLAY) { + BYTE dwFlag = ci->dwFlag; + ci->dwFlag = (ci->dwFlag & CNF_UNICODE) | CNF_CUSTOMNICK; + if (!GetContactInfo(NULL, (LPARAM)ci)) { + ci->dwFlag = dwFlag; + return 0; } + ci->dwFlag = dwFlag; } + break; + + case 1: // nick + if (!GCIVarEx(ci, SET_CONTACT_NICK)) + return 0; + break; + + case 2: // First Name + if (!GCIVarEx(ci, SET_CONTACT_FIRSTNAME)) + return 0; + break; + + case 3: // E-mail + if (!GCIVarEx(ci, SET_CONTACT_EMAIL)) + return 0; + break; + + case 4: // Last Name + if (!GCIVarEx(ci, SET_CONTACT_LASTNAME)) + return 0; + break; + + case 5: // Unique id + // protocol must define a PFLAG_UNIQUEIDSETTING + result = CallProtoService(ci->szProto, PS_GETCAPS, PFLAG_UNIQUEIDSETTING, 0); + if (result != CALLSERVICE_NOTFOUND && result != NULL) { + if (!GCIStr(ci, (LPCSTR)result)) + return 0; + } + break; + + case 6: // first + last name + if (!GCIFirstLast(ci)) + return 0; + break; + + default: // unknown contact + if (ci->dwFlag & CNF_UNICODE) + ci->pszVal = (LPTSTR)mir_wcsdup(TranslateW(L"'(Unknown Contact)'")); + else + ci->pszVal = (LPTSTR)mir_strdup(Translate("'(Unknown Contact)'")); + + ci->type = (ci->pszVal != NULL) ? CNFT_ASCIIZ : 0; + return ci->type == 0; } } - default: { - result = 1; - } + default: + result = 1; } } - else - { - result = 1; - } + else result = 1; + return result; } /** - * This is the implementation of the MS_DB_CONTACT_GETSETTING_STR_EX service. - * - * @param wParam - handle of the contact a setting was written for (must be NULL in this case) - * @param lParam - DBCONTACTGETSETTING structure holding information about the setting to read - * - * @retval 0 - success - * @retval 1 - error - **/ +* This is the implementation of the MS_DB_CONTACT_GETSETTING_STR_EX service. +* +* @param wParam - handle of the contact a setting was written for (must be NULL in this case) +* @param lParam - DBCONTACTGETSETTING structure holding information about the setting to read +* +* @retval 0 - success +* @retval 1 - error +**/ + static INT_PTR GetContactSettingStrExService(WPARAM wParam, LPARAM lParam) { DBCONTACTGETSETTING *cgs = (DBCONTACTGETSETTING*)lParam; @@ -737,31 +710,30 @@ static INT_PTR GetContactSettingStrExService(WPARAM wParam, LPARAM lParam) } /** - * If the user changes the name order update the global value. - * - * @param wParam - handle of the contact a setting was written for (must be NULL in this case) - * @param lParam - DBCONTACTWRITESETTING structure holding information about the written data - * @return 0 - **/ +* If the user changes the name order update the global value. +* +* @param wParam - handle of the contact a setting was written for (must be NULL in this case) +* @param lParam - DBCONTACTWRITESETTING structure holding information about the written data +* @return 0 +**/ + static int OnSettingChanged(WPARAM wParam, LPARAM lParam) { if ((HANDLE)wParam == NULL) { DBCONTACTWRITESETTING *pdbcws = (DBCONTACTWRITESETTING*) lParam; - if (!mir_strcmp(pdbcws->szModule, "Contact") && - !mir_strcmp(pdbcws->szSetting, "NameOrder")) - { - memcpy(gNameOrder, pdbcws->value.pbVal,pdbcws->value.cpbVal); - } + if (!mir_strcmp(pdbcws->szModule, "Contact") && !mir_strcmp(pdbcws->szSetting, "NameOrder")) + memcpy(gNameOrder, pdbcws->value.pbVal, pdbcws->value.cpbVal); } return 0; } /** - * Loads the module at startup and replaces the service. - * - * @param none - * @return nothing - **/ +* Loads the module at startup and replaces the service. +* +* @param none +* @return nothing +**/ + void SvcContactInfoLoadModule() { CreateServiceFunction(MS_DB_CONTACT_GETSETTING_STR_EX, GetContactSettingStrExService); @@ -769,10 +741,8 @@ void SvcContactInfoLoadModule() DBVARIANT dbv; if (DB::Setting::GetAString(NULL, "Contact", "NameOrder", &dbv)) { - BYTE i; - for (i = 0; i < NAMEORDERCOUNT; i++) { + for (int i = 0; i < NAMEORDERCOUNT; i++) gNameOrder[i] = i; - } } else { memcpy(gNameOrder, dbv.pbVal, dbv.cpbVal); diff --git a/plugins/UserInfoEx/src/svc_email.cpp b/plugins/UserInfoEx/src/svc_email.cpp index 55aacd17b5..bf337d5788 100644 --- a/plugins/UserInfoEx/src/svc_email.cpp +++ b/plugins/UserInfoEx/src/svc_email.cpp @@ -21,50 +21,41 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h" -static HGENMENU ghMenuItem = NULL; -static HANDLE ghExtraIconDef = INVALID_HANDLE_VALUE; -static HANDLE ghExtraIconSvc = INVALID_HANDLE_VALUE; +static HGENMENU ghMenuItem = NULL; +static HANDLE ghExtraIconDef = INVALID_HANDLE_VALUE; +static HANDLE ghExtraIconSvc = INVALID_HANDLE_VALUE; -static HANDLE hChangedHook = NULL; -static HANDLE hApplyIconHook = NULL; -static HANDLE hRebuildIconsHook = NULL; +static HANDLE hChangedHook = NULL; +static HANDLE hApplyIconHook = NULL; /** - * This function reads the email address of the contact. - * - * @param hContact - handle to contact to read email from - * - * @retval email address - * @retval NULL, if contact does not provide any email address - **/ +* This function reads the email address of the contact. +* +* @param hContact - handle to contact to read email from +* +* @retval email address +* @retval NULL, if contact does not provide any email address +**/ + static LPSTR Get(HANDLE hContact) { // ignore owner - if (hContact != NULL) - { + if (hContact != NULL) { LPCSTR pszProto = DB::Contact::Proto(hContact); - if (pszProto != NULL) - { - LPCSTR e[2][4] = { + if (pszProto != NULL) { + LPCSTR e[2][4] = { { SET_CONTACT_EMAIL, SET_CONTACT_EMAIL0, SET_CONTACT_EMAIL1, "Mye-mail0"}, { SET_CONTACT_COMPANY_EMAIL, SET_CONTACT_COMPANY_EMAIL0, SET_CONTACT_COMPANY_EMAIL1, "MyCompanye-mail0"} }; - int i, j; - LPSTR pszEMail; - - for (i = 0; i < 2; i++) - { - for (j = 0; j < 4; j++) - { - pszEMail = DB::Setting::GetAStringEx(hContact, USERINFO, pszProto, e[i][j]); - if (pszEMail) - { + for (int i = 0; i < 2; i++) { + for (int j = 0; j < 4; j++) { + LPSTR pszEMail = DB::Setting::GetAStringEx(hContact, USERINFO, pszProto, e[i][j]); + if (pszEMail) { if (strchr(pszEMail, '@')) - { return pszEMail; - } + mir_free(pszEMail); } } @@ -75,14 +66,15 @@ static LPSTR Get(HANDLE hContact) } /** - * Service function that sends emails - * - * @param wParam - handle to contact to send an email to - * @param lParam - not used - * - * @retval 0 if email was sent - * @retval 1 if no email can be sent - **/ +* Service function that sends emails +* +* @param wParam - handle to contact to send an email to +* @param lParam - not used +* +* @retval 0 if email was sent +* @retval 1 if no email can be sent +**/ + static INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam) { int result; @@ -91,8 +83,7 @@ static INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam) __try { val = Get((HANDLE) wParam); - if (val) - { + if (val) { LPSTR szUrl; INT_PTR len; @@ -105,8 +96,7 @@ static INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam) result = CallService(MS_UTILS_OPENURL, 1, (LPARAM)szUrl); } - else - { + else { result = 1; MsgBox((HWND)lParam, MB_OK, LPGENT("Send e-mail"), NULL, LPGENT("Memory allocation error!")); } @@ -114,11 +104,7 @@ static INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam) __except(GetExceptionCode()==EXCEPTION_ACCESS_VIOLATION ? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH) { - if (val) - { - mir_free(val); - } - + mir_free(val); result = 1; MsgErr((HWND)lParam, LPGENT("Memory allocation error!")); } @@ -130,11 +116,12 @@ static INT_PTR MenuCommand(WPARAM wParam,LPARAM lParam) ***********************************************************************************************************/ /** - * Notification handler for clist extra icons to be applied for a contact. - * - * @param wParam - handle to the contact whose extra icon is to apply - * @param lParam - not used - **/ +* Notification handler for clist extra icons to be applied for a contact. +* +* @param wParam - handle to the contact whose extra icon is to apply +* @param lParam - not used +**/ + static int OnCListApplyIcons(WPARAM wParam, LPARAM lParam) { LPSTR val = Get((HANDLE)wParam); @@ -144,11 +131,12 @@ static int OnCListApplyIcons(WPARAM wParam, LPARAM lParam) } /** - * Notification handler for changed contact settings - * - * @param wParam - (HANDLE)hContact - * @param lParam - (DBCONTACTWRITESETTING*)pdbcws - **/ +* Notification handler for changed contact settings +* +* @param wParam - (HANDLE)hContact +* @param lParam - (DBCONTACTWRITESETTING*)pdbcws +**/ + static int OnContactSettingChanged(HANDLE hContact, DBCONTACTWRITESETTING* pdbcws) { if (hContact && pdbcws && pdbcws->szSetting && @@ -163,13 +151,14 @@ static int OnContactSettingChanged(HANDLE hContact, DBCONTACTWRITESETTING* pdbcw } /** - * This function decides whether to show menuitem for sending emails or not. - * - * @param wParam - handle to contact to send an email to - * @param lParam - not used - * - * @return always 0 - **/ +* This function decides whether to show menuitem for sending emails or not. +* +* @param wParam - handle to contact to send an email to +* @param lParam - not used +* +* @return always 0 +**/ + static int OnPreBuildMenu(WPARAM wParam, LPARAM lParam) { LPSTR val = Get((HANDLE)wParam); @@ -182,9 +171,6 @@ static int OnPreBuildMenu(WPARAM wParam, LPARAM lParam) * public Module Interface functions ***********************************************************************************************************/ -/** - * This function enables or disables menuitems. - **/ void SvcEMailRebuildMenu() { static HANDLE hPrebuildMenuHook = NULL; @@ -215,11 +201,12 @@ void SvcEMailRebuildMenu() } /** - * Force all icons to be reloaded. - * - * @param wParam - handle to the contact whose extra icon is to apply - * @param lParam - not used - **/ +* Force all icons to be reloaded. +* +* @param wParam - handle to the contact whose extra icon is to apply +* @param lParam - not used +**/ + void SvcEMailApplyCListIcons() { // walk through all the contacts stored in the DB @@ -228,17 +215,18 @@ void SvcEMailApplyCListIcons() } /** - * Enable or disable the replacement of clist extra icons. - * - * @param bEnable - determines whether icons are enabled or not - * @param bUpdateDB - if true the database setting is updated, too. - **/ +* Enable or disable the replacement of clist extra icons. +* +* @param bEnable - determines whether icons are enabled or not +* @param bUpdateDB - if true the database setting is updated, too. +**/ + void SvcEMailEnableExtraIcons(BYTE bEnable, BYTE bUpdateDB) { if (bUpdateDB) db_set_b(NULL, MODNAME, SET_CLIST_EXTRAICON_EMAIL, bEnable); - if (bEnable) { // E-mail checkt + if (bEnable) { // E-mail checked // hook events if (hChangedHook == NULL) hChangedHook = HookEvent(ME_DB_CONTACT_SETTINGCHANGED, (MIRANDAHOOK)OnContactSettingChanged); @@ -258,27 +246,23 @@ void SvcEMailEnableExtraIcons(BYTE bEnable, BYTE bUpdateDB) UnhookEvent(hApplyIconHook); hApplyIconHook = NULL; } - if (hRebuildIconsHook) { - UnhookEvent(hRebuildIconsHook); - hRebuildIconsHook = NULL; - } } SvcEMailApplyCListIcons(); } /** - * This function initially loads the module uppon startup. - **/ +* This function initially loads the module upon startup. +**/ + void SvcEMailOnModulesLoaded() { - SvcEMailEnableExtraIcons( - db_get_b(NULL, MODNAME, SET_CLIST_EXTRAICON_EMAIL, - DEFVAL_CLIST_EXTRAICON_EMAIL), FALSE); + SvcEMailEnableExtraIcons(db_get_b(NULL, MODNAME, SET_CLIST_EXTRAICON_EMAIL, DEFVAL_CLIST_EXTRAICON_EMAIL), FALSE); } /** - * This function initially loads the module uppon startup. - **/ +* This function initially loads the module upon startup. +**/ + void SvcEMailLoadModule() { if (db_get_b(NULL, MODNAME, SET_EXTENDED_EMAILSERVICE, TRUE)) { @@ -289,16 +273,16 @@ void SvcEMailLoadModule() } /** - * This function unloads the Email module. - * - * @param none - * - * @return nothing - **/ +* This function unloads the Email module. +* +* @param none +* +* @return nothing +**/ + void SvcEMailUnloadModule() { // unhook event handlers UnhookEvent(hChangedHook); hChangedHook = NULL; UnhookEvent(hApplyIconHook); hApplyIconHook = NULL; - UnhookEvent(hRebuildIconsHook); hRebuildIconsHook = NULL; } diff --git a/plugins/UserInfoEx/src/svc_gender.cpp b/plugins/UserInfoEx/src/svc_gender.cpp index a8bcf8d5bf..ebee43c044 100644 --- a/plugins/UserInfoEx/src/svc_gender.cpp +++ b/plugins/UserInfoEx/src/svc_gender.cpp @@ -21,39 +21,36 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h" -static HANDLE ghExtraIconF = INVALID_HANDLE_VALUE; -static HANDLE ghExtraIconM = INVALID_HANDLE_VALUE; -static HANDLE ghExtraIconSvc = INVALID_HANDLE_VALUE; +static HANDLE ghExtraIconF = INVALID_HANDLE_VALUE; +static HANDLE ghExtraIconM = INVALID_HANDLE_VALUE; +static HANDLE ghExtraIconSvc = INVALID_HANDLE_VALUE; -static HANDLE hChangedHook = NULL; -static HANDLE hApplyIconHook = NULL; -static HANDLE hRebuildIconsHook = NULL; +static HANDLE hChangedHook = NULL; +static HANDLE hApplyIconHook = NULL; BYTE GenderOf(HANDLE hContact, LPCSTR pszProto) { DBVARIANT dbv; - - if (DB::Setting::GetAsIsEx(hContact, USERINFO, pszProto, SET_CONTACT_GENDER, &dbv) == 0) - { + if (DB::Setting::GetAsIsEx(hContact, USERINFO, pszProto, SET_CONTACT_GENDER, &dbv) == 0) { // gender must be byte and either M or F if (dbv.type == DBVT_BYTE && (dbv.bVal == 'M' || dbv.bVal == 'F')) - { return dbv.bVal; - } + db_free(&dbv); } return 0; } /** - * This function gets the gender of the contact from the database. - * - * @param hContact - handle to contact to read email from - * - * @retval F - contact is female - * @retval M - contact is male - * @retval 0 - contact does not provide its gender - **/ +* This function gets the gender of the contact from the database. +* +* @param hContact - handle to contact to read email from +* +* @retval F - contact is female +* @retval M - contact is male +* @retval 0 - contact does not provide its gender +**/ + BYTE GenderOf(HANDLE hContact) { return GenderOf(hContact, DB::Contact::Proto(hContact)); @@ -64,11 +61,11 @@ BYTE GenderOf(HANDLE hContact) ***********************************************************************************************************/ /** - * Notification handler for clist extra icons to be applied for a contact. - * - * @param wParam - handle to the contact whose extra icon is to apply - * @param lParam - not used - **/ +* Notification handler for clist extra icons to be applied for a contact. +* +* @param wParam - handle to the contact whose extra icon is to apply +* @param lParam - not used +**/ static int OnCListApplyIcons(HANDLE hContact, LPARAM) { @@ -90,6 +87,7 @@ static int OnCListApplyIcons(HANDLE hContact, LPARAM) * @param wParam - (HANDLE)hContact * @param lParam - (DBCONTACTWRITESETTING*)pdbcws **/ + static int OnContactSettingChanged(HANDLE hContact, DBCONTACTWRITESETTING* pdbcws) { if (hContact && pdbcws && (pdbcws->value.type <= DBVT_BYTE) && !lstrcmpA(pdbcws->szSetting, SET_CONTACT_GENDER)) @@ -108,6 +106,7 @@ static int OnContactSettingChanged(HANDLE hContact, DBCONTACTWRITESETTING* pdbcw * @param wParam - handle to the contact whose extra icon is to apply * @param lParam - not used **/ + void SvcGenderApplyCListIcons() { //walk through all the contacts stored in the DB @@ -116,11 +115,12 @@ void SvcGenderApplyCListIcons() } /** - * Enable or disable the replacement of clist extra icons. - * - * @param bEnable - determines whether icons are enabled or not - * @param bUpdateDB - if true the database setting is updated, too. - **/ +* Enable or disable the replacement of clist extra icons. +* +* @param bEnable - determines whether icons are enabled or not +* @param bUpdateDB - if true the database setting is updated, too. +**/ + void SvcGenderEnableExtraIcons(BYTE bColumn, BYTE bUpdateDB) { bool bEnable = (bColumn!=((BYTE)-1)); @@ -128,7 +128,7 @@ void SvcGenderEnableExtraIcons(BYTE bColumn, BYTE bUpdateDB) if (bUpdateDB) db_set_b(NULL, MODNAME, SET_CLIST_EXTRAICON_GENDER2, bColumn); - if (bEnable) { // Gender checkt or dropdown select + if (bEnable) { // Gender checked or dropdown select if (ghExtraIconSvc == INVALID_HANDLE_VALUE) ghExtraIconSvc = ExtraIcon_Register("gender", LPGEN("Gender (uinfoex)"), ICO_COMMON_MALE); @@ -148,33 +148,30 @@ void SvcGenderEnableExtraIcons(BYTE bColumn, BYTE bUpdateDB) UnhookEvent(hApplyIconHook); hApplyIconHook = NULL; } - if (hRebuildIconsHook) { - UnhookEvent(hRebuildIconsHook); - hRebuildIconsHook = NULL; - } } SvcGenderApplyCListIcons(); } /** - * This function initially loads the module uppon startup. - **/ +* This function initially loads the module upon startup. +**/ + void SvcGenderLoadModule() { SvcGenderEnableExtraIcons(db_get_b(NULL, MODNAME, SET_CLIST_EXTRAICON_GENDER2, 0), FALSE); } /** - * This function unloads the module. - * - * @param none - * - * @return nothing - **/ +* This function unloads the module. +* +* @param none +* +* @return nothing +**/ + void SvcGenderUnloadModule() { // unhook event handlers - UnhookEvent(hChangedHook); hChangedHook = NULL; - UnhookEvent(hApplyIconHook); hApplyIconHook = NULL; - UnhookEvent(hRebuildIconsHook); hRebuildIconsHook = NULL; + UnhookEvent(hChangedHook); hChangedHook = NULL; + UnhookEvent(hApplyIconHook); hApplyIconHook = NULL; } diff --git a/plugins/UserInfoEx/src/svc_homepage.cpp b/plugins/UserInfoEx/src/svc_homepage.cpp index 45e0b8330c..801855c699 100644 --- a/plugins/UserInfoEx/src/svc_homepage.cpp +++ b/plugins/UserInfoEx/src/svc_homepage.cpp @@ -27,32 +27,25 @@ static HANDLE ghExtraIconSvc = INVALID_HANDLE_VALUE; static HANDLE hChangedHook = NULL; static HANDLE hApplyIconHook = NULL; -static HANDLE hRebuildIconsHook = NULL; + /** - * This function reads the homepage address of the contact. - * - * @param hContact - handle to contact to read email from - * - * @retval URL to contacts homepage - * @retval NULL if contact provides no homepage - **/ +* This function reads the homepage address of the contact. +* +* @param hContact - handle to contact to read email from +* +* @retval URL to contacts homepage +* @retval NULL if contact provides no homepage +**/ + static LPSTR Get(HANDLE hContact) { // ignore owner - if (hContact != NULL) - { + if (hContact != NULL) { LPCSTR pszProto = DB::Contact::Proto(hContact); - - if (pszProto != NULL) - { - LPCSTR e[2] = { SET_CONTACT_HOMEPAGE, SET_CONTACT_COMPANY_HOMEPAGE }; - LPSTR pszHomepage; - - int i; - - for (i = 0; i < 2; i++) - { - pszHomepage = DB::Setting::GetAStringEx(hContact, USERINFO, pszProto, e[i]); + if (pszProto != NULL) { + LPCSTR e[2] = { SET_CONTACT_HOMEPAGE, SET_CONTACT_COMPANY_HOMEPAGE }; + for (int i = 0; i < 2; i++) { + LPSTR pszHomepage = DB::Setting::GetAStringEx(hContact, USERINFO, pszProto, e[i]); if (pszHomepage) return pszHomepage; } @@ -62,29 +55,24 @@ static LPSTR Get(HANDLE hContact) } /** - * Service function that opens the default browser and displays the homepage. - * - * @param wParam - handle to contact to send an email to - * @param lParam - not used - * - * @retval 0 if email was sent - * @retval 1 if no email can be sent - **/ +* Service function that opens the default browser and displays the homepage. +* +* @param wParam - handle to contact to send an email to +* @param lParam - not used +* +* @retval 0 if email was sent +* @retval 1 if no email can be sent +**/ + static INT_PTR MenuCommand(WPARAM wParam, LPARAM lParam) { LPSTR szUrl = Get((HANDLE)wParam); - - if (szUrl) - { + if (szUrl) { CallService(MS_UTILS_OPENURL, 1, (LPARAM)szUrl); mir_free(szUrl); } - else - { - MessageBox((HWND)lParam, - TranslateT("User has no valid homepage"), - TranslateT("View Homepage"), MB_OK); - } + else MessageBox((HWND)lParam, TranslateT("User has no valid homepage"), TranslateT("View Homepage"), MB_OK); + return 0; } @@ -93,11 +81,12 @@ static INT_PTR MenuCommand(WPARAM wParam, LPARAM lParam) ***********************************************************************************************************/ /** - * Notification handler for clist extra icons to be applied for a contact. - * - * @param wParam - handle to the contact whose extra icon is to apply - * @param lParam - not used - **/ +* Notification handler for clist extra icons to be applied for a contact. +* +* @param wParam - handle to the contact whose extra icon is to apply +* @param lParam - not used +**/ + static int OnCListApplyIcons(HANDLE hContact, LPARAM) { LPSTR val = Get(hContact); @@ -108,11 +97,12 @@ static int OnCListApplyIcons(HANDLE hContact, LPARAM) } /** - * Notification handler for changed contact settings - * - * @param wParam - (HANDLE)hContact - * @param lParam - (DBCONTACTWRITESETTING*)pdbcws - **/ +* Notification handler for changed contact settings +* +* @param wParam - (HANDLE)hContact +* @param lParam - (DBCONTACTWRITESETTING*)pdbcws +**/ + static int OnContactSettingChanged(HANDLE hContact, DBCONTACTWRITESETTING* pdbcws) { if (hContact && pdbcws && pdbcws->szSetting && @@ -125,13 +115,14 @@ static int OnContactSettingChanged(HANDLE hContact, DBCONTACTWRITESETTING* pdbcw } /** - * This function decides whether to show menuitem for sending emails or not. - * - * @param wParam - handle to contact to send an email to - * @param lParam - not used - * - * @return always 0 - **/ +* This function decides whether to show menuitem for sending emails or not. +* +* @param wParam - handle to contact to send an email to +* @param lParam - not used +* +* @return always 0 +**/ + static int OnPreBuildMenu(WPARAM wParam, LPARAM lParam) { LPSTR val = Get((HANDLE)wParam); @@ -145,11 +136,12 @@ static int OnPreBuildMenu(WPARAM wParam, LPARAM lParam) ***********************************************************************************************************/ /** - * enable or disable menuitem - * - * @param not used - * @return nothing - **/ +* enable or disable menuitem +* +* @param not used +* @return nothing +**/ + void SvcHomepageRebuildMenu() { static HANDLE hPrebuildMenuHook = NULL; @@ -169,11 +161,12 @@ void SvcHomepageRebuildMenu() } /** - * Force all icons to be reloaded. - * - * @param wParam - handle to the contact whose extra icon is to apply - * @param lParam - not used - **/ +* Force all icons to be reloaded. +* +* @param wParam - handle to the contact whose extra icon is to apply +* @param lParam - not used +**/ + void SvcHomepageApplyCListIcons() { //walk through all the contacts stored in the DB @@ -182,11 +175,12 @@ void SvcHomepageApplyCListIcons() } /** - * Enable or disable the replacement of clist extra icons. - * - * @param bEnable - determines whether icons are enabled or not - * @param bUpdateDB - if true the database setting is updated, too. - **/ +* Enable or disable the replacement of clist extra icons. +* +* @param bEnable - determines whether icons are enabled or not +* @param bUpdateDB - if true the database setting is updated, too. +**/ + void SvcHomepageEnableExtraIcons(BYTE bEnable, BYTE bUpdateDB) { if (bUpdateDB) @@ -212,20 +206,17 @@ void SvcHomepageEnableExtraIcons(BYTE bEnable, BYTE bUpdateDB) UnhookEvent(hApplyIconHook); hApplyIconHook = NULL; } - if (hRebuildIconsHook) { - UnhookEvent(hRebuildIconsHook); - hRebuildIconsHook = NULL; - } } SvcHomepageApplyCListIcons(); } /** - * This function initially loads the module uppon startup. - * - * @param not used - * @return nothing - **/ +* This function initially loads the module upon startup. +* +* @param not used +* @return nothing +**/ + void SvcHomepageLoadModule() { CreateServiceFunction(MS_USERINFO_HOMEPAGE_OPENURL, MenuCommand); @@ -234,16 +225,16 @@ void SvcHomepageLoadModule() } /** - * This function unloads the Email module. - * - * @param none - * - * @return nothing - **/ +* This function unloads the Email module. +* +* @param none +* +* @return nothing +**/ + void SvcHomepageUnloadModule() { // unhook event handlers - UnhookEvent(hChangedHook); hChangedHook = NULL; - UnhookEvent(hApplyIconHook); hApplyIconHook = NULL; - UnhookEvent(hRebuildIconsHook); hRebuildIconsHook = NULL; + UnhookEvent(hChangedHook); hChangedHook = NULL; + UnhookEvent(hApplyIconHook); hApplyIconHook = NULL; } diff --git a/plugins/UserInfoEx/src/svc_phone.cpp b/plugins/UserInfoEx/src/svc_phone.cpp index a5d0aefb13..e8b0e8cace 100644 --- a/plugins/UserInfoEx/src/svc_phone.cpp +++ b/plugins/UserInfoEx/src/svc_phone.cpp @@ -28,48 +28,40 @@ enum EPhoneType PHONE_SMS }; -static HANDLE ghMenuItem = NULL; -static HANDLE ghExtraIconDef[2] = { INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE }; -static HANDLE ghExtraIconSvc = INVALID_HANDLE_VALUE; +static HANDLE ghMenuItem = NULL; +static HANDLE ghExtraIconDef[2] = { INVALID_HANDLE_VALUE, INVALID_HANDLE_VALUE }; +static HANDLE ghExtraIconSvc = INVALID_HANDLE_VALUE; -static HANDLE hChangedHook = NULL; -static HANDLE hApplyIconHook = NULL; -static HANDLE hRebuildIconsHook = NULL; +static HANDLE hChangedHook = NULL; +static HANDLE hApplyIconHook = NULL; /** - * This function reads the contact's phone number from database and returns its type. - * - * @param hContact - handle to contact to read email from - * - * @retval PHONE_SMS: The phone supports sms, so is a cellular - * @retval PHONE_NORMAL: The phone is a normal phone - * @retval PHONE_NONE: The contact does not provide any phone number - **/ +* This function reads the contact's phone number from database and returns its type. +* +* @param hContact - handle to contact to read email from +* +* @retval PHONE_SMS: The phone supports sms, so is a cellular +* @retval PHONE_NORMAL: The phone is a normal phone +* @retval PHONE_NONE: The contact does not provide any phone number +**/ + static INT_PTR Get(HANDLE hContact) { INT_PTR nType = PHONE_NONE; // ignore owner - if (hContact != NULL) - { + if (hContact != NULL) { LPCSTR pszProto = DB::Contact::Proto(hContact); - if (pszProto != NULL) - { - LPCSTR e[2][4] = { - { SET_CONTACT_CELLULAR, SET_CONTACT_PHONE, "MyPhone0" }, - { SET_CONTACT_COMPANY_CELLULAR, SET_CONTACT_COMPANY_PHONE, "MyCompanyPhone0" } + if (pszProto != NULL) { + LPCSTR e[2][4] = { + { SET_CONTACT_CELLULAR, SET_CONTACT_PHONE, "MyPhone0" }, + { SET_CONTACT_COMPANY_CELLULAR, SET_CONTACT_COMPANY_PHONE, "MyCompanyPhone0" } }; - int i, j; - LPSTR pszPhone; - - for (i = 0; (i < 2) && (nType == PHONE_NONE); i++) - { - for (j = 0; (j < 3) && (nType == PHONE_NONE); j++) - { - pszPhone = DB::Setting::GetAStringEx(hContact, USERINFO, pszProto, e[i][j]); - if (pszPhone) - { + for (int i = 0; (i < 2) && (nType == PHONE_NONE); i++) { + for (int j = 0; (j < 3) && (nType == PHONE_NONE); j++) { + LPSTR pszPhone = DB::Setting::GetAStringEx(hContact, USERINFO, pszProto, e[i][j]); + if (pszPhone) { nType = (strstr(pszPhone, " SMS")) ? PHONE_SMS : PHONE_NORMAL; MIR_FREE(pszPhone); break; @@ -86,11 +78,11 @@ static INT_PTR Get(HANDLE hContact) ***********************************************************************************************************/ /** - * Notification handler for clist extra icons to be applied for a contact. - * - * @param wParam - handle to the contact whose extra icon is to apply - * @param lParam - not used - **/ +* Notification handler for clist extra icons to be applied for a contact. +* +* @param wParam - handle to the contact whose extra icon is to apply +* @param lParam - not used +**/ static int OnCListApplyIcons(HANDLE hContact, LPARAM) { @@ -105,11 +97,12 @@ static int OnCListApplyIcons(HANDLE hContact, LPARAM) } /** - * Notification handler for changed contact settings - * - * @param wParam - (HANDLE)hContact - * @param lParam - (DBCONTACTWRITESETTING*)pdbcws - **/ +* Notification handler for changed contact settings +* +* @param wParam - (HANDLE)hContact +* @param lParam - (DBCONTACTWRITESETTING*)pdbcws +**/ + static int OnContactSettingChanged(HANDLE hContact, DBCONTACTWRITESETTING* pdbcws) { if (hContact && pdbcws && pdbcws->szSetting && @@ -129,11 +122,12 @@ static int OnContactSettingChanged(HANDLE hContact, DBCONTACTWRITESETTING* pdbcw ***********************************************************************************************************/ /** - * Force all icons to be reloaded. - * - * @param wParam - handle to the contact whose extra icon is to apply - * @param lParam - not used - **/ +* Force all icons to be reloaded. +* +* @param wParam - handle to the contact whose extra icon is to apply +* @param lParam - not used +**/ + void SvcPhoneApplyCListIcons() { //walk through all the contacts stored in the DB @@ -142,11 +136,12 @@ void SvcPhoneApplyCListIcons() } /** - * Enable or disable the replacement of clist extra icons. - * - * @param bEnable - determines whether icons are enabled or not - * @param bUpdateDB - if true the database setting is updated, too. - **/ +* Enable or disable the replacement of clist extra icons. +* +* @param bEnable - determines whether icons are enabled or not +* @param bUpdateDB - if true the database setting is updated, too. +**/ + void SvcPhoneEnableExtraIcons(BYTE bEnable, BYTE bUpdateDB) { if (bUpdateDB) @@ -173,34 +168,30 @@ void SvcPhoneEnableExtraIcons(BYTE bEnable, BYTE bUpdateDB) UnhookEvent(hApplyIconHook); hApplyIconHook = NULL; } - if (hRebuildIconsHook) { - UnhookEvent(hRebuildIconsHook); - hRebuildIconsHook = NULL; - } } SvcPhoneApplyCListIcons(); } /** - * This function initially loads the module uppon startup. - **/ +* This function initially loads the module upon startup. +**/ + void SvcPhoneLoadModule() { - SvcPhoneEnableExtraIcons( - db_get_b(NULL, MODNAME, SET_CLIST_EXTRAICON_PHONE, DEFVAL_CLIST_EXTRAICON_PHONE), FALSE); + SvcPhoneEnableExtraIcons(db_get_b(NULL, MODNAME, SET_CLIST_EXTRAICON_PHONE, DEFVAL_CLIST_EXTRAICON_PHONE), FALSE); } /** - * This function unloads the Email module. - * - * @param none - * - * @return nothing - **/ +* This function unloads the Email module. +* +* @param none +* +* @return nothing +**/ + void SvcPhoneUnloadModule() { // unhook event handlers - UnhookEvent(hChangedHook); hChangedHook = NULL; - UnhookEvent(hApplyIconHook); hApplyIconHook = NULL; - UnhookEvent(hRebuildIconsHook); hRebuildIconsHook = NULL; + UnhookEvent(hChangedHook); hChangedHook = NULL; + UnhookEvent(hApplyIconHook); hApplyIconHook = NULL; } diff --git a/plugins/UserInfoEx/src/svc_refreshci.cpp b/plugins/UserInfoEx/src/svc_refreshci.cpp index ac9cf0d28f..905594a589 100644 --- a/plugins/UserInfoEx/src/svc_refreshci.cpp +++ b/plugins/UserInfoEx/src/svc_refreshci.cpp @@ -33,7 +33,7 @@ class CUpdProgress { protected: BYTE _bBBCode; // TRUE if text renderer can handle BBCodes - BYTE _bIsCanceled; // is set to TRUE uppon click on the CANCEL button + BYTE _bIsCanceled; // is set to TRUE upon click on the CANCEL button PUpdCallback _pFnCallBack; // a pointer to a callback function, which can be used // to catch several messages by the caller. PVOID _pData; // application defined data @@ -893,7 +893,7 @@ static int OnPreShutdown(WPARAM, LPARAM) ***********************************************************************************************************/ /** - * This function initially loads the module uppon startup. + * This function initially loads the module upon startup. **/ void SvcRefreshContactInfoLoadModule(void) { diff --git a/plugins/UserInfoEx/src/svc_reminder.cpp b/plugins/UserInfoEx/src/svc_reminder.cpp index 269af4ada0..ee03c1a221 100644 --- a/plugins/UserInfoEx/src/svc_reminder.cpp +++ b/plugins/UserInfoEx/src/svc_reminder.cpp @@ -26,8 +26,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "commonheaders.h" /** - * The CEvent structure describes the next anniversary to remind of. - **/ +* The CEvent structure describes the next anniversary to remind of. +**/ + struct CEvent { enum EType { NONE, BIRTHDAY, ANNIVERSARY }; @@ -70,18 +71,18 @@ static REMINDEROPTIONS gRemindOpts; static void UpdateTimer(BYTE bStartup); - /*********************************************************************************************************** * struct CEvent ***********************************************************************************************************/ /** - * This is the default constructor. - * - * @param none - * - * @return nothing - **/ +* This is the default constructor. +* +* @param none +* +* @return nothing +**/ + CEvent::CEvent() { _wDaysLeft = 0xFFFF; @@ -89,13 +90,14 @@ CEvent::CEvent() } /** - * This is the default constructor. - * - * @param eType - initial type - * @param wDaysLeft - initial days to event - * - * @return nothing - **/ +* This is the default constructor. +* +* @param eType - initial type +* @param wDaysLeft - initial days to event +* +* @return nothing +**/ + CEvent::CEvent(EType eType, WORD wDaysLeft) { _wDaysLeft = wDaysLeft; @@ -103,18 +105,18 @@ CEvent::CEvent(EType eType, WORD wDaysLeft) } /** - * This operator dups the attributes of the given CEvent object if - * the event comes up earlier then the one of the object. - * - * @param evt - the reference to the event object whose attributes to assign. - * - * @retval TRUE - The values of @e evt have been assigned. - * @retval FALSE - The values are not assigned. - **/ +* This operator dups the attributes of the given CEvent object if +* the event comes up earlier then the one of the object. +* +* @param evt - the reference to the event object whose attributes to assign. +* +* @retval TRUE - The values of @e evt have been assigned. +* @retval FALSE - The values are not assigned. +**/ + BYTE CEvent::operator << (const CEvent& evt) { - if (_wDaysLeft > evt._wDaysLeft) - { + if (_wDaysLeft > evt._wDaysLeft) { _wDaysLeft = evt._wDaysLeft; _eType = evt._eType; return TRUE; @@ -127,13 +129,13 @@ BYTE CEvent::operator << (const CEvent& evt) ***********************************************************************************************************/ /** - * This function returns the icon for the given anniversary, - * which is the given number of days in advance. - * - * @param evt - structure specifying the next anniversary - * - * @return The function returns icolib's icon if found or NULL otherwise. - **/ +* This function returns the icon for the given anniversary, +* which is the given number of days in advance. +* +* @param evt - structure specifying the next anniversary +* +* @return The function returns icolib's icon if found or NULL otherwise. +**/ static HICON GetAnnivIcon(const CEvent &evt) { @@ -163,13 +165,14 @@ static HICON GetAnnivIcon(const CEvent &evt) } /** - * Displays an clist extra icon according to the kind of anniversary - * and the days in advance. - * - * @param evt - structure specifying the next anniversary - * - * @return nothing - **/ +* Displays an clist extra icon according to the kind of anniversary +* and the days in advance. +* +* @param evt - structure specifying the next anniversary +* +* @return nothing +**/ + static void NotifyWithExtraIcon(HANDLE hContact, const CEvent &evt) { if (gRemindOpts.bCListExtraIcon) { @@ -202,177 +205,161 @@ static void NotifyWithExtraIcon(HANDLE hContact, const CEvent &evt) } /** - * Message procedure for popup messages - * - * @param hWnd - handle to the popupwindow - * @param uMsg - message to handle - * @param wParam - message specific parameter - * @param lParam - message specific parameter - * - * @return message specific - **/ +* Message procedure for popup messages +* +* @param hWnd - handle to the popupwindow +* @param uMsg - message to handle +* @param wParam - message specific parameter +* @param lParam - message specific parameter +* +* @return message specific +**/ + static LRESULT CALLBACK PopupWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - switch (uMsg) - { + switch (uMsg) { case WM_COMMAND: - { - if (HIWORD(wParam) == STN_CLICKED) - { - PUDeletePopup(hWnd); - return TRUE; - } - break; - } - - case WM_CONTEXTMENU: - { + if (HIWORD(wParam) == STN_CLICKED) { PUDeletePopup(hWnd); return TRUE; } + break; + + case WM_CONTEXTMENU: + PUDeletePopup(hWnd); + return TRUE; } return DefWindowProc(hWnd, uMsg, wParam, lParam); } /** - * Displays a popup - * - * @param hContact - contact to display popup for - * @param eventType - indicates which popup settings to apply - * @param DaysToAnniv - days left until anniversary occures - * @param pszDesc - this is the headline - * @param szMsg - message to display - * - * @return return value of the popup service - **/ +* Displays a popup +* +* @param hContact - contact to display popup for +* @param eventType - indicates which popup settings to apply +* @param DaysToAnniv - days left until anniversary occures +* @param pszDesc - this is the headline +* @param szMsg - message to display +* +* @return return value of the popup service +**/ + static int NotifyWithPopup(HANDLE hContact, CEvent::EType eventType, int DaysToAnniv, LPCTSTR pszDesc, LPCTSTR pszMsg) { - if (gRemindOpts.bPopups) - { - POPUPDATAT ppd = { 0 }; - ppd.PluginWindowProc = PopupWindowProc; - ppd.iSeconds = (int)db_get_b(NULL, MODNAME, SET_POPUP_DELAY, 0); - - if (hContact) { - ppd.lchContact = hContact; - mir_sntprintf(ppd.lptzContactName, SIZEOF(ppd.lptzContactName), - _T("%s - %s"), TranslateTS(pszDesc), DB::Contact::DisplayName(hContact)); - } - else mir_tcsncpy(ppd.lptzContactName, TranslateT("Reminder"), SIZEOF(ppd.lptzContactName)); + if (!gRemindOpts.bPopups) + return 1; - mir_tcsncpy(ppd.lptzText, pszMsg, MAX_SECONDLINE); + POPUPDATAT ppd = { 0 }; + ppd.PluginWindowProc = PopupWindowProc; + ppd.iSeconds = (int)db_get_b(NULL, MODNAME, SET_POPUP_DELAY, 0); - ppd.lchIcon = GetAnnivIcon(CEvent(eventType, DaysToAnniv)); + if (hContact) { + ppd.lchContact = hContact; + mir_sntprintf(ppd.lptzContactName, SIZEOF(ppd.lptzContactName), + _T("%s - %s"), TranslateTS(pszDesc), DB::Contact::DisplayName(hContact)); + } + else mir_tcsncpy(ppd.lptzContactName, TranslateT("Reminder"), SIZEOF(ppd.lptzContactName)); - switch (eventType) { - case CEvent::BIRTHDAY: - switch (db_get_b(NULL, MODNAME, SET_POPUP_BIRTHDAY_COLORTYPE, POPUP_COLOR_CUSTOM)) { - case POPUP_COLOR_WINDOWS: - ppd.colorBack = GetSysColor(COLOR_BTNFACE); - ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); - break; - - case POPUP_COLOR_CUSTOM: - ppd.colorBack = db_get_dw(NULL, MODNAME, SET_POPUP_BIRTHDAY_COLOR_BACK, RGB(192,180,30)); - ppd.colorText = db_get_dw(NULL, MODNAME, SET_POPUP_BIRTHDAY_COLOR_TEXT, 0); - break; - } + mir_tcsncpy(ppd.lptzText, pszMsg, MAX_SECONDLINE); + + ppd.lchIcon = GetAnnivIcon(CEvent(eventType, DaysToAnniv)); + + switch (eventType) { + case CEvent::BIRTHDAY: + switch (db_get_b(NULL, MODNAME, SET_POPUP_BIRTHDAY_COLORTYPE, POPUP_COLOR_CUSTOM)) { + case POPUP_COLOR_WINDOWS: + ppd.colorBack = GetSysColor(COLOR_BTNFACE); + ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); break; - case CEvent::ANNIVERSARY: - switch (db_get_b(NULL, MODNAME, SET_POPUP_ANNIVERSARY_COLORTYPE, POPUP_COLOR_CUSTOM)) { - case POPUP_COLOR_WINDOWS: - ppd.colorBack = GetSysColor(COLOR_BTNFACE); - ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); - break; - - case POPUP_COLOR_CUSTOM: - ppd.colorBack = db_get_dw(NULL, MODNAME, SET_POPUP_ANNIVERSARY_COLOR_BACK, RGB(90, 190, 130)); - ppd.colorText = db_get_dw(NULL, MODNAME, SET_POPUP_ANNIVERSARY_COLOR_TEXT, 0); - break; - } + case POPUP_COLOR_CUSTOM: + ppd.colorBack = db_get_dw(NULL, MODNAME, SET_POPUP_BIRTHDAY_COLOR_BACK, RGB(192, 180, 30)); + ppd.colorText = db_get_dw(NULL, MODNAME, SET_POPUP_BIRTHDAY_COLOR_TEXT, 0); + break; + } + break; + + case CEvent::ANNIVERSARY: + switch (db_get_b(NULL, MODNAME, SET_POPUP_ANNIVERSARY_COLORTYPE, POPUP_COLOR_CUSTOM)) { + case POPUP_COLOR_WINDOWS: + ppd.colorBack = GetSysColor(COLOR_BTNFACE); + ppd.colorText = GetSysColor(COLOR_WINDOWTEXT); + break; + + case POPUP_COLOR_CUSTOM: + ppd.colorBack = db_get_dw(NULL, MODNAME, SET_POPUP_ANNIVERSARY_COLOR_BACK, RGB(90, 190, 130)); + ppd.colorText = db_get_dw(NULL, MODNAME, SET_POPUP_ANNIVERSARY_COLOR_TEXT, 0); + break; } - return PUAddPopupT(&ppd); } - return 1; + return PUAddPopupT(&ppd); } /** - * Flash contact list's contact icon. - * - * @param hContact - contact whose icon to flash - * @param evt - structure specifying the next anniversary - * - * @return nothing - **/ +* Flash contact list's contact icon. +* +* @param hContact - contact whose icon to flash +* @param evt - structure specifying the next anniversary +* +* @return nothing +**/ + static void NotifyFlashCListIcon(HANDLE hContact, const CEvent &evt) { - if (gRemindOpts.bFlashCList && evt._wDaysLeft == 0) - { - CLISTEVENT cle ={0}; - TCHAR szMsg[MAX_PATH]; + if (!gRemindOpts.bFlashCList || evt._wDaysLeft != 0) + return; - cle.cbSize = sizeof(CLISTEVENT); - cle.hContact = hContact; - cle.flags = CLEF_URGENT|CLEF_TCHAR; - cle.hDbEvent = NULL; + TCHAR szMsg[MAX_PATH]; - switch (evt._eType) { - case CEvent::BIRTHDAY: - { - mir_sntprintf(szMsg, SIZEOF(szMsg), - TranslateT("%s has %s today."), - DB::Contact::DisplayName(hContact), - TranslateT("Birthday")); - cle.hIcon = IcoLib_GetIcon(ICO_COMMON_BIRTHDAY); - } - break; - - case CEvent::ANNIVERSARY: - { - mir_sntprintf(szMsg, SIZEOF(szMsg), - TranslateT("%s has %s today."), - DB::Contact::DisplayName(hContact), - TranslateT("an anniversary")); - cle.hIcon = IcoLib_GetIcon(ICO_COMMON_ANNIVERSARY); - } - break; + CLISTEVENT cle = { sizeof(cle) }; + cle.hContact = hContact; + cle.flags = CLEF_URGENT|CLEF_TCHAR; + cle.hDbEvent = NULL; - default: - szMsg[0] = NULL; - } - cle.ptszTooltip = szMsg; + switch (evt._eType) { + case CEvent::BIRTHDAY: + mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%s has %s today."), DB::Contact::DisplayName(hContact), TranslateT("Birthday")); + cle.hIcon = IcoLib_GetIcon(ICO_COMMON_BIRTHDAY); + break; - // pszService = NULL get error (crash), - // pszService = "dummy" get 'service not fount' and continue; - cle.pszService = "dummy"; - cle.lParam = NULL; + case CEvent::ANNIVERSARY: + mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%s has %s today."), DB::Contact::DisplayName(hContact), TranslateT("an anniversary")); + cle.hIcon = IcoLib_GetIcon(ICO_COMMON_ANNIVERSARY); + break; - CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); + default: + return; } + cle.ptszTooltip = szMsg; + + // pszService = NULL get error (crash), + // pszService = "dummy" get 'service not fount' and continue; + cle.pszService = "dummy"; + cle.lParam = NULL; + + CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); } /** - * Play a sound for the nearest upcoming anniversary - * - * @param evt - structure specifying the next anniversary - * - * @retval 0 if sound was played - * @retval 1 otherwise - **/ +* Play a sound for the nearest upcoming anniversary +* +* @param evt - structure specifying the next anniversary +* +* @retval 0 if sound was played +* @retval 1 otherwise +**/ + static BYTE NotifyWithSound(const CEvent &evt) { - if (evt._wDaysLeft <= min(db_get_b(NULL, MODNAME, SET_REMIND_SOUNDOFFSET, DEFVAL_REMIND_SOUNDOFFSET), gRemindOpts.wDaysEarlier)) - { - switch (evt._eType) - { - case CEvent::BIRTHDAY: - SkinPlaySound(evt._wDaysLeft == 0 ? SOUND_BIRTHDAY_TODAY : SOUND_BIRTHDAY_SOON); - return 0; - - case CEvent::ANNIVERSARY: - SkinPlaySound(SOUND_ANNIVERSARY); - return 0; + if (evt._wDaysLeft <= min(db_get_b(NULL, MODNAME, SET_REMIND_SOUNDOFFSET, DEFVAL_REMIND_SOUNDOFFSET), gRemindOpts.wDaysEarlier)) { + switch (evt._eType) { + case CEvent::BIRTHDAY: + SkinPlaySound(evt._wDaysLeft == 0 ? SOUND_BIRTHDAY_TODAY : SOUND_BIRTHDAY_SOON); + return 0; + + case CEvent::ANNIVERSARY: + SkinPlaySound(SOUND_ANNIVERSARY); + return 0; } } return 1; @@ -384,8 +371,7 @@ static BYTE NotifyWithSound(const CEvent &evt) static LPCTSTR ContactGender(HANDLE hContact) { - switch (GenderOf(hContact)) - { + switch (GenderOf(hContact)) { case 'M': return TranslateT("He"); case 'F': return TranslateT("She"); } @@ -397,82 +383,57 @@ static BYTE CheckAnniversaries(HANDLE hContact, MTime &Now, CEvent &evt, BYTE bN int numAnniversaries = 0; int Diff; MAnnivDate mta; - int i; TCHAR szAnniv[MAX_PATH]; TCHAR strMsg[MAX_SECONDLINE]; BYTE bOverflow = FALSE; WORD wDaysEarlier; - if ((gRemindOpts.RemindState == REMIND_ANNIV) || (gRemindOpts.RemindState == REMIND_ALL)) - { - for (i = 0; i < ANID_LAST && !mta.DBGetAnniversaryDate(hContact, i); i++) - { + if ((gRemindOpts.RemindState == REMIND_ANNIV) || (gRemindOpts.RemindState == REMIND_ALL)) { + for (int i = 0; i < ANID_LAST && !mta.DBGetAnniversaryDate(hContact, i); i++) { mta.DBGetReminderOpts(hContact); - if (mta.RemindOption() != BST_UNCHECKED) - { + if (mta.RemindOption() != BST_UNCHECKED) { wDaysEarlier = (mta.RemindOption() == BST_CHECKED) ? mta.RemindOffset() : -1; if (wDaysEarlier == (WORD)-1) - { wDaysEarlier = gRemindOpts.wDaysEarlier; - } Diff = mta.CompareDays(Now); - if ((Diff >= 0) && (Diff <= wDaysEarlier)) - { - if (evt._wDaysLeft > Diff) - { + if ((Diff >= 0) && (Diff <= wDaysEarlier)) { + if (evt._wDaysLeft > Diff) { evt._wDaysLeft = Diff; evt._eType = CEvent::ANNIVERSARY; } numAnniversaries++; // create displayed text for popup - if (bNotify && !bOverflow) - { + if (bNotify && !bOverflow) { // first anniversary found - if (numAnniversaries == 1) - { + if (numAnniversaries == 1) { mir_sntprintf(szAnniv, MAX_PATH, TranslateT("%s has the following anniversaries:\0"), ContactGender(hContact)); mir_tcsncpy(strMsg, szAnniv, mir_tcslen(szAnniv)); } - switch (Diff) - { - case 0: - { - mir_sntprintf(szAnniv, MAX_PATH, - TranslateT("%d. %s today\0"), - mta.Age(), mta.Description()); - } - break; - - case 1: - { - mir_sntprintf(szAnniv, MAX_PATH, - TranslateT("%d. %s tomorrow\0"), - mta.Age() + 1, mta.Description()); - } - break; - - default: - { - mir_sntprintf(szAnniv, MAX_PATH, - TranslateT("%d. %s in %d days\0"), - mta.Age() + 1, mta.Description(), Diff); - } + + switch (Diff) { + case 0: + mir_sntprintf(szAnniv, MAX_PATH, TranslateT("%d. %s today\0"), mta.Age(), mta.Description()); + break; + case 1: + mir_sntprintf(szAnniv, MAX_PATH, TranslateT("%d. %s tomorrow\0"), mta.Age() + 1, mta.Description()); + break; + default: + mir_sntprintf(szAnniv, MAX_PATH, TranslateT("%d. %s in %d days\0"), mta.Age() + 1, mta.Description(), Diff); } - if (mir_tcslen(szAnniv) >= MAX_SECONDLINE - mir_tcslen(strMsg)) - { + + if (mir_tcslen(szAnniv) >= MAX_SECONDLINE - mir_tcslen(strMsg)) { if (strMsg) mir_tcsncat(strMsg, _T("\n...\0"), SIZEOF(strMsg)); else mir_tcsncpy(strMsg, _T("\n...\0"), mir_tcslen(_T("\n...\0"))); bOverflow = TRUE; } - else - { + else { if (strMsg) mir_tcsncat(strMsg, _T("\n- \0"), SIZEOF(strMsg)); else @@ -484,36 +445,34 @@ static BYTE CheckAnniversaries(HANDLE hContact, MTime &Now, CEvent &evt, BYTE bN } } } + // show one popup for all anniversaries if (numAnniversaries != 0 && bNotify) - { NotifyWithPopup(hContact, CEvent::ANNIVERSARY, Diff, LPGENT("Anniversaries"), strMsg); - } + return numAnniversaries != 0; } /** - * This function checks, whether a contact has a birthday and it is within the period of time to remind of or not. - * - * @param hContact - the contact to check - * @param Now - current time - * @param evt - the reference to a structure, which retrieves the resulting DTB - * @param bNotify - if TRUE, a popup will be displayed for a contact having birthday within the next few days. - * @param LastAnswer - this parameter is used for the automatic backup function - * - * @retval TRUE - contact has a birthday to remind of - * @retval FALSE - contact has no birthday or it is not within the desired period of time. - **/ +* This function checks, whether a contact has a birthday and it is within the period of time to remind of or not. +* +* @param hContact - the contact to check +* @param Now - current time +* @param evt - the reference to a structure, which retrieves the resulting DTB +* @param bNotify - if TRUE, a popup will be displayed for a contact having birthday within the next few days. +* @param LastAnswer - this parameter is used for the automatic backup function +* +* @retval TRUE - contact has a birthday to remind of +* @retval FALSE - contact has no birthday or it is not within the desired period of time. +**/ + static BYTE CheckBirthday(HANDLE hContact, MTime &Now, CEvent &evt, BYTE bNotify, PWORD LastAnwer) { BYTE result = FALSE; - if (gRemindOpts.RemindState == REMIND_BIRTH || gRemindOpts.RemindState == REMIND_ALL) - { + if (gRemindOpts.RemindState == REMIND_BIRTH || gRemindOpts.RemindState == REMIND_ALL) { MAnnivDate mtb; - - if (!mtb.DBGetBirthDate(hContact)) - { + if (!mtb.DBGetBirthDate(hContact)) { int Diff; WORD wDaysEarlier; @@ -521,56 +480,33 @@ static BYTE CheckBirthday(HANDLE hContact, MTime &Now, CEvent &evt, BYTE bNotify // make backup of each protocol based birthday if (db_get_b(NULL, MODNAME, SET_REMIND_SECUREBIRTHDAY, TRUE)) - { mtb.BackupBirthday(hContact, NULL, 0, LastAnwer); - } - if (mtb.RemindOption() != BST_UNCHECKED) - { + if (mtb.RemindOption() != BST_UNCHECKED) { wDaysEarlier = (mtb.RemindOption() == BST_CHECKED) ? mtb.RemindOffset() : -1; if (wDaysEarlier == (WORD)-1) - { wDaysEarlier = gRemindOpts.wDaysEarlier; - } Diff = mtb.CompareDays(Now); - if ((Diff >= 0) && (Diff <= wDaysEarlier)) - { - if (evt._wDaysLeft > Diff) - { + if ((Diff >= 0) && (Diff <= wDaysEarlier)) { + if (evt._wDaysLeft > Diff) { evt._wDaysLeft = Diff; evt._eType = CEvent::BIRTHDAY; } - if (bNotify) - { + if (bNotify) { TCHAR szMsg[MAXDATASIZE]; WORD cchMsg = 0; - switch (Diff) - { - case 0: - { - cchMsg = mir_sntprintf(szMsg, SIZEOF(szMsg), - TranslateT("%s has birthday today."), - DB::Contact::DisplayName(hContact)); - } - break; - - case 1: - { - cchMsg = mir_sntprintf(szMsg, SIZEOF(szMsg), - TranslateT("%s has birthday tomorrow."), - DB::Contact::DisplayName(hContact)); - } - break; - - default: - { - cchMsg = mir_sntprintf(szMsg, SIZEOF(szMsg), - TranslateT("%s has birthday in %d days."), - DB::Contact::DisplayName(hContact), Diff); - } + switch (Diff) { + case 0: + cchMsg = mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%s has birthday today."), DB::Contact::DisplayName(hContact)); + break; + case 1: + cchMsg = mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%s has birthday tomorrow."), DB::Contact::DisplayName(hContact)); + break; + default: + cchMsg = mir_sntprintf(szMsg, SIZEOF(szMsg), TranslateT("%s has birthday in %d days."), DB::Contact::DisplayName(hContact), Diff); } mir_sntprintf(szMsg + cchMsg, SIZEOF(szMsg) - cchMsg, TranslateT("\n%s becomes %d years old."), @@ -587,16 +523,17 @@ static BYTE CheckBirthday(HANDLE hContact, MTime &Now, CEvent &evt, BYTE bNotify } /** - * This function checks one contact. It is mainly used for clist extra icon rebuild notification handler. - * - * @param hContact - the contact to check - * @param Now - current time - * @param evt - the reference to a structure, which retrieves the resulting DTB - * @param bNotify - if TRUE, a popup will be displayed for a contact having birthday within the next few days. - * @param LastAnswer - this parameter is used for the automatic backup function - * - * @return nothing - **/ +* This function checks one contact. It is mainly used for clist extra icon rebuild notification handler. +* +* @param hContact - the contact to check +* @param Now - current time +* @param evt - the reference to a structure, which retrieves the resulting DTB +* @param bNotify - if TRUE, a popup will be displayed for a contact having birthday within the next few days. +* @param LastAnswer - this parameter is used for the automatic backup function +* +* @return nothing +**/ + static void CheckContact(HANDLE hContact, MTime &Now, CEvent &evt, BYTE bNotify, PWORD LastAnwer = 0) { // ignore meta subcontacts here as their birthday information are collected explicitly @@ -606,31 +543,26 @@ static void CheckContact(HANDLE hContact, MTime &Now, CEvent &evt, BYTE bNotify, { CEvent ca; - if (CheckBirthday(hContact, Now, ca, bNotify, LastAnwer) || - CheckAnniversaries(hContact, Now, ca, bNotify)) - { + if (CheckBirthday(hContact, Now, ca, bNotify, LastAnwer) || CheckAnniversaries(hContact, Now, ca, bNotify)) { evt << ca; - if (bNotify) - { NotifyFlashCListIcon(hContact, ca); - } } NotifyWithExtraIcon(hContact, ca); } } /** - * This function checks all contacts. - * - * @param notify - notification type - * - * @return nothing - **/ +* This function checks all contacts. +* +* @param notify - notification type +* +* @return nothing +**/ + void SvcReminderCheckAll(const ENotify notify) { - if (gRemindOpts.RemindState != REMIND_OFF) - { + if (gRemindOpts.RemindState != REMIND_OFF) { CEvent evt; MTime now; WORD a1 = 0; @@ -641,8 +573,7 @@ void SvcReminderCheckAll(const ENotify notify) for (HANDLE hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) CheckContact(hContact, now, evt, notify != NOTIFY_CLIST, &a1); - if (notify != NOTIFY_CLIST) - { + if (notify != NOTIFY_CLIST) { // play sound for the next anniversary NotifyWithSound(evt); @@ -662,45 +593,41 @@ void SvcReminderCheckAll(const ENotify notify) ***********************************************************************************************************/ /** - * This is the notification handler to tell reminder to reload required icons. - * The reminder only loads icons to clist, which are really required at the moment. - * This should help to save a bit memory. - * - * @param: wParam - not used - * @param: lParam - not used - * - * @return This function must return 0 in order to continue in the notification chain. - **/ +* This is the notification handler to tell reminder to reload required icons. +* The reminder only loads icons to clist, which are really required at the moment. +* This should help to save a bit memory. +* +* @param: wParam - not used +* @param: lParam - not used +* +* @return This function must return 0 in order to continue in the notification chain. +**/ + static int OnCListRebuildIcons(WPARAM, LPARAM) { - UINT i; - - for (i = 0; i < SIZEOF(ghCListAnnivIcons); i++) - { + for (int i = 0; i < SIZEOF(ghCListAnnivIcons); i++) ghCListAnnivIcons[i] = INVALID_HANDLE_VALUE; - } - for (i = 0; i < SIZEOF(ghCListBirthdayIcons); i++) - { - ghCListBirthdayIcons[i] = INVALID_HANDLE_VALUE; - } + + for (int k = 0; k < SIZEOF(ghCListBirthdayIcons); k++) + ghCListBirthdayIcons[k] = INVALID_HANDLE_VALUE; + return 0; } /** - * This function is the notification handler for clist extra icons to be applied for a contact. - * - * @param hContact - handle to the contact whose extra icon is to apply - * @param lParam - not used - * - * @return This function must return 0 in order to continue in the notification chain. - **/ +* This function is the notification handler for clist extra icons to be applied for a contact. +* +* @param hContact - handle to the contact whose extra icon is to apply +* @param lParam - not used +* +* @return This function must return 0 in order to continue in the notification chain. +**/ + int OnCListApplyIcon(HANDLE hContact, LPARAM) { - if (gRemindOpts.RemindState != REMIND_OFF) - { + if (gRemindOpts.RemindState != REMIND_OFF) { CEvent evt; MTime now; - now.GetLocalTime(); CheckContact(hContact, now, evt, FALSE); } @@ -708,15 +635,16 @@ int OnCListApplyIcon(HANDLE hContact, LPARAM) } /** - * This is a notification handler for changed contact settings. - * If any anniversary setting has changed for a meta sub contact, - * the parental meta contact is rescanned. - * - * @param hContact - handle of the contect the notification was fired for - * @param pdbcws - pointer to a DBCONTACTWRITESETTING structure - * - * @return This function must return 0 in order to continue in the notification chain. - **/ +* This is a notification handler for changed contact settings. +* If any anniversary setting has changed for a meta sub contact, +* the parental meta contact is rescanned. +* +* @param hContact - handle of the contect the notification was fired for +* @param pdbcws - pointer to a DBCONTACTWRITESETTING structure +* +* @return This function must return 0 in order to continue in the notification chain. +**/ + static int OnContactSettingChanged(HANDLE hContact, DBCONTACTWRITESETTING* pdbcws) { if (hContact && // valid contact not owner! @@ -750,13 +678,13 @@ static int OnContactSettingChanged(HANDLE hContact, DBCONTACTWRITESETTING* pdbcw #define TBB_ICONAME TOOLBARBUTTON_ICONIDPREFIX TBB_IDBTN TOOLBARBUTTON_ICONIDPRIMARYSUFFIX /** - * This function is called by the ME_TTB_MODULELOADED event. - * It adds a set of buttons to the TopToolbar plugin. - * - * @param none - * - * @return nothing - **/ +* This function is called by the ME_TTB_MODULELOADED event. +* It adds a set of buttons to the TopToolbar plugin. +* +* @param none +* +* @return nothing +**/ void SvcReminderOnTopToolBarLoaded() { @@ -768,48 +696,45 @@ void SvcReminderOnTopToolBarLoaded() TopToolbar_AddButton(&ttb); } - /*********************************************************************************************************** * services ***********************************************************************************************************/ /** - * This is the service function for MS_USERINFO_REMINDER_CHECK. - * - * @param: wParam - not used - * @param: lParam - not used - * - * @return 0 - **/ +* This is the service function for MS_USERINFO_REMINDER_CHECK. +* +* @param: wParam - not used +* @param: lParam - not used +* +* @return 0 +**/ + static INT_PTR CheckService(WPARAM, LPARAM) { if (gRemindOpts.RemindState != REMIND_OFF) - { SvcReminderCheckAll(NOTIFY_NOANNIV); - } return 0; } /** - * This is the service function for MS_USERINFO_REMINDER_AGGRASIVEBACKUP. - * - * @param hContact - handle to single contact or NULL to backup all - * @param lParam - if 1, the messagebox will not be displayed - * - * return: 0 - **/ +* This is the service function for MS_USERINFO_REMINDER_AGGRASIVEBACKUP. +* +* @param hContact - handle to single contact or NULL to backup all +* @param lParam - if 1, the messagebox will not be displayed +* +* return: 0 +**/ + static INT_PTR BackupBirthdayService(WPARAM wParam, LPARAM lParam) { HANDLE hContact = (HANDLE)wParam; MAnnivDate mdb; - if (hContact) - { + if (hContact) { if (!mdb.DBGetBirthDate(hContact)) mdb.BackupBirthday(hContact, NULL, TRUE); } - else - { + else { WORD a1 = 0; //walk through all the contacts stored in the DB @@ -818,10 +743,8 @@ static INT_PTR BackupBirthdayService(WPARAM wParam, LPARAM lParam) mdb.BackupBirthday(hContact, NULL, TRUE, &a1); } - if (lParam != TRUE) - { + if (lParam != TRUE) { MSGBOX mBox; - mBox.cbSize = sizeof(MSGBOX); mBox.hParent = NULL; mBox.hiLogo = IcoLib_GetIcon(ICO_COMMON_BIRTHDAY); @@ -834,36 +757,36 @@ static INT_PTR BackupBirthdayService(WPARAM wParam, LPARAM lParam) } /** - * This function returns a constant pointer to the module the date should be saved to - * - * @param none - * - * @return module to write birthday information to, MOD_MBIRTHDAY by default - **/ +* This function returns a constant pointer to the module the date should be saved to +* +* @param none +* +* @return module to write birthday information to, MOD_MBIRTHDAY by default +**/ + LPCSTR SvcReminderGetMyBirthdayModule() { return ((db_get_b(NULL, MODNAME, SET_REMIND_BIRTHMODULE, DEFVAL_REMIND_BIRTHMODULE) == 1) ? USERINFO : MOD_MBIRTHDAY); } - /*********************************************************************************************************** * timer stuff ***********************************************************************************************************/ /** - * Timer procedure, called if date changed. This updates clist icons. - * - * @param hwnd - not used - * @param uMsg - not used - * @param idEvent - not used - * @param dwTime - not used - * @return nothing - **/ +* Timer procedure, called if date changed. This updates clist icons. +* +* @param hwnd - not used +* @param uMsg - not used +* @param idEvent - not used +* @param dwTime - not used +* @return nothing +**/ + static void CALLBACK TimerProc_DateChanged(HWND, UINT, UINT_PTR, DWORD) { static MTime last; MTime now; - now.GetLocalTime(); if (now.Day() > last.Day() || now.Month() > last.Month() || now.Year() > last.Year()) { SvcReminderCheckAll(NOTIFY_CLIST); @@ -872,27 +795,29 @@ static void CALLBACK TimerProc_DateChanged(HWND, UINT, UINT_PTR, DWORD) } /** - * Timer procedure, called again and again if the notification interval ellapsed - * - * @param hwnd - not used - * @param uMsg - not used - * @param idEvent - not used - * @param dwTime - not used - * - * @return nothing - **/ +* Timer procedure, called again and again if the notification interval ellapsed +* +* @param hwnd - not used +* @param uMsg - not used +* @param idEvent - not used +* @param dwTime - not used +* +* @return nothing +**/ + static void CALLBACK TimerProc_Check(HWND, UINT, UINT_PTR, DWORD) { SvcReminderCheckAll(NOTIFY_POPUP); } /** - * Load timers or update them. - * - * @param bStartup - is only TRUE if module is loaded to indicate startup process - * - * @return nothing - **/ +* Load timers or update them. +* +* @param bStartup - is only TRUE if module is loaded to indicate startup process +* +* @return nothing +**/ + static void UpdateTimer(BYTE bStartup) { LONG wNotifyInterval = 60 * 60 * (LONG)db_get_w(NULL, MODNAME, SET_REMIND_NOTIFYINTERVAL, DEFVAL_REMIND_NOTIFYINTERVAL); @@ -911,9 +836,8 @@ static void UpdateTimer(BYTE bStartup) ghRemindDateChangeTimer = SetTimer(0, 0, 1000 * 60 * 5, (TIMERPROC)TimerProc_DateChanged); } - else { - now.DBWriteStamp(NULL, MODNAME, SET_REMIND_LASTCHECK); - } + else now.DBWriteStamp(NULL, MODNAME, SET_REMIND_LASTCHECK); + // wait at least 5 seconds before checking at startup, to give miranda a better chance to load faster KillTimer(0, ghRemindTimer); ghRemindTimer = SetTimer(0, 0, 1000 * wNotifyInterval, TimerProc_Check); @@ -957,12 +881,13 @@ void SvcReminderEnable(BYTE bEnable) } /** - * This function is called by Miranda just after loading all system modules. - * - * @param none - * - * @return nothing - **/ +* This function is called by Miranda just after loading all system modules. +* +* @param none +* +* @return nothing +**/ + void SvcReminderOnModulesLoaded(void) { // init clist extra icon structure @@ -972,12 +897,13 @@ void SvcReminderOnModulesLoaded(void) } /** - * This function initially loads all required stuff for reminder. - * - * @param none - * - * @return nothing - **/ +* This function initially loads all required stuff for reminder. +* +* @param none +* +* @return nothing +**/ + void SvcReminderLoadModule(void) { // init sounds @@ -1015,12 +941,13 @@ void SvcReminderLoadModule(void) } /** - * This function unloads the reminder module. - * - * @param none - * - * @return nothing - **/ +* This function unloads the reminder module. +* +* @param none +* +* @return nothing +**/ + void SvcReminderUnloadModule(void) { // kill timers diff --git a/plugins/UserInfoEx/src/svc_timezone.cpp b/plugins/UserInfoEx/src/svc_timezone.cpp index fc8bc336e2..37f0a89d11 100644 --- a/plugins/UserInfoEx/src/svc_timezone.cpp +++ b/plugins/UserInfoEx/src/svc_timezone.cpp @@ -26,16 +26,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ***********************************************************************************************************/ /** - * This service function provides a TIME_ZONE_INFORMATION structure - * for the desired contact, in case the contact's timezone can be determined. -.* parsed to new core tzi interface if present. - * - * @param wParam - HANDLE of the contact, to retrieve timezone information from. - * @param lParam - pointer to a TIME_ZONE_INFORMATION to fill. - * - * @retval 0 - success - * @retval 1 - failure - **/ +* This service function provides a TIME_ZONE_INFORMATION structure +* for the desired contact, in case the contact's timezone can be determined. +* parsed to new core tzi interface if present. +* +* @param wParam - HANDLE of the contact, to retrieve timezone information from. +* @param lParam - pointer to a TIME_ZONE_INFORMATION to fill. +* +* @retval 0 - success +* @retval 1 - failure +**/ + INT_PTR GetContactTimeZoneInformation(WPARAM wParam,LPARAM lParam) { //use new core tz interface @@ -45,13 +46,14 @@ INT_PTR GetContactTimeZoneInformation(WPARAM wParam,LPARAM lParam) } /** - * This function returns the contact's local time. - * - * @param wParam - HANDLE of the contact, to retrieve timezone information from. - * @param lParam - pointer to a systemtime structure - * - * @return TRUE or FALSE - **/ +* This function returns the contact's local time. +* +* @param wParam - HANDLE of the contact, to retrieve timezone information from. +* @param lParam - pointer to a systemtime structure +* +* @return TRUE or FALSE +**/ + INT_PTR GetContactLocalTime(WPARAM wParam, LPARAM lParam) { //use new core tz interface @@ -64,8 +66,9 @@ INT_PTR GetContactLocalTime(WPARAM wParam, LPARAM lParam) ***********************************************************************************************************/ /** - * This function initially loads the module uppon startup. - **/ +* This function initially loads the module upon startup. +**/ + void SvcTimezoneLoadModule() { CreateServiceFunction(MS_USERINFO_TIMEZONEINFO, GetContactTimeZoneInformation); diff --git a/plugins/UserInfoEx/src/svc_timezone_old.cpp b/plugins/UserInfoEx/src/svc_timezone_old.cpp index e38ec717cd..683af3c65b 100644 --- a/plugins/UserInfoEx/src/svc_timezone_old.cpp +++ b/plugins/UserInfoEx/src/svc_timezone_old.cpp @@ -29,18 +29,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. **************************************************************************************************/ /** - * This is the default constructure, which resets - * all attributes to NULL. - **/ +* This is the default constructure, which resets +* all attributes to NULL. +**/ + CTimeZone::CTimeZone() { ZeroMemory(this, sizeof(*this)); } /** - * The default construcor's task ist to clear out - * all pieces of the used memory. - **/ +* The default construcor's task ist to clear out +* all pieces of the used memory. +**/ + CTimeZone::~CTimeZone() { MIR_FREE(ptszName); @@ -48,27 +50,28 @@ CTimeZone::~CTimeZone() } /** - * This method can be used to basically convert a Windows - * timezone to the format, known by miranda. - * - * @warning This operation does not work vice versa in - * all cases, as there are sometimes more then - * one Windows timezones with the same Bias. - **/ +* This method can be used to basically convert a Windows +* timezone to the format, known by miranda. +* +* @warning This operation does not work vice versa in +* all cases, as there are sometimes more then +* one Windows timezones with the same Bias. +**/ + BYTE CTimeZone::ToMirandaTimezone() const { return (BYTE) (Bias / 30); } /** - * This operator translates the content of this object to - * a TIME_ZONE_INFORMATION structure as it is required by - * several windows functions. - **/ +* This operator translates the content of this object to +* a TIME_ZONE_INFORMATION structure as it is required by +* several windows functions. +**/ + CTimeZone::operator TIME_ZONE_INFORMATION() const { TIME_ZONE_INFORMATION tzi; - tzi.Bias = Bias; tzi.DaylightBias = DaylightBias; tzi.StandardBias = StandardBias; @@ -107,12 +110,13 @@ public: ***********************************************************************************************************/ /** - * This class is a deriviant of miranda's SortedList and holds all timezones - * known by Windows. By default there is no API to list timezones, so we - * need to get the information directly from the registry. In order to avoid - * heavy reading operations from registry, this class has the task to cache - * all required information for much faster access. - **/ +* This class is a deriviant of miranda's SortedList and holds all timezones +* known by Windows. By default there is no API to list timezones, so we +* need to get the information directly from the registry. In order to avoid +* heavy reading operations from registry, this class has the task to cache +* all required information for much faster access. +**/ + class CTzMgr : public LIST { CTzBias _bias; @@ -128,18 +132,12 @@ class CTzMgr : public LIST **/ void destroy() { - int i; - // delete data - for (i = 0 ; i < count; i++) - { + for (int i = 0 ; i < count; i++) delete (*this)[i]; - } + // delete the list LIST::destroy(); - // delete the _bias list ???? - //_bias.destroy(); - } public: @@ -153,20 +151,22 @@ public: } /** - * This is the default destructor of the class. - * - * @param none - * - * @return nothing - **/ + * This is the default destructor of the class. + * + * @param none + * + * @return nothing + **/ + ~CTzMgr() { destroy(); } /** - * This method loads all information about timezones from windows' registry. - **/ + * This method loads all information about timezones from windows' registry. + **/ + int Init() { int result; @@ -180,21 +180,16 @@ public: result = RegOpenKey(HKEY_LOCAL_MACHINE, _T(TZREG), &hKeyRoot); if (result != ERROR_SUCCESS) - { result = RegOpenKey(HKEY_LOCAL_MACHINE, _T(TZREG_9X), &hKeyRoot); - } - if (result == ERROR_SUCCESS) - { + + if (result == ERROR_SUCCESS) { // clear out old list this->destroy(); _bias.destroy(); - for (i = 0; ERROR_SUCCESS == RegEnumKey(hKeyRoot, i, szName, SIZEOF(szName)); i++) - { + for (i = 0; ERROR_SUCCESS == RegEnumKey(hKeyRoot, i, szName, SIZEOF(szName)); i++) { result = RegOpenKey(hKeyRoot, szName, &hKeyTz); - if (result == ERROR_SUCCESS) - { + if (result == ERROR_SUCCESS) { pTimeZone = new CTimeZone(); - if (pTimeZone) - { + if (pTimeZone) { cbData = sizeof(szDisplay); result |= RegQueryValueEx(hKeyTz, _T("Display"), 0, 0, (LPBYTE)szDisplay, &cbData); @@ -203,23 +198,18 @@ public: cbData = sizeof(DWORD); if (RegQueryValueEx(hKeyTz, _T("Index"), 0, 0, (LPBYTE)(UINT_PTR)pTimeZone->dwIndex, &cbData) != ERROR_SUCCESS) - { pTimeZone->dwIndex = TZINDEX_UNSPECIFIED; - } - if (result == ERROR_SUCCESS) - { + + if (result == ERROR_SUCCESS) { pTimeZone->ptszName = mir_tcsdup(szName); pTimeZone->ptszDisplay = mir_tcsdup(szDisplay); result = (insert(pTimeZone) == ERROR_SUCCESS); } + if (result != ERROR_SUCCESS) - { delete pTimeZone; - } else - { _bias.insert(pTimeZone); - } } RegCloseKey(hKeyTz); } @@ -230,29 +220,27 @@ public: } /** - * This method is used to find a certain list entry according to - * a key, providing information about the entry to look for. - * - * @param result - Pointer to a pointer, retrieving the CTimeZone - * object, matching the criteria provided by key - * @param key - Pointer to a CTimeZone structure, providing - * information about the item to look for. - * The Bias member and/or pszDisplay member must - * be valid. - * @retval -1 : item not found - * @retval 0...count : index of the found item - **/ + * This method is used to find a certain list entry according to + * a key, providing information about the entry to look for. + * + * @param result - Pointer to a pointer, retrieving the CTimeZone + * object, matching the criteria provided by key + * @param key - Pointer to a CTimeZone structure, providing + * information about the item to look for. + * The Bias member and/or pszDisplay member must + * be valid. + * @retval -1 : item not found + * @retval 0...count : index of the found item + **/ + int find(CTimeZone** pTimezone, CTimeZone* pKey) const { int nItemIndex = -1; - if (pKey && pKey->ptszName) - { + if (pKey && pKey->ptszName) { nItemIndex = getIndex(pKey); if (pTimezone) - { *pTimezone = (nItemIndex == -1) ? NULL : items[nItemIndex]; - } } return nItemIndex; } @@ -269,37 +257,35 @@ public: } /** - * This method is used to find a certain list entry according to - * a given dwTzIndex, providing information about the entry to look for. - * - * @param result - Pointer to a pointer, retrieving the CTimeZone - * object, matching the criteria provided by key - * @param dwTzIndex - Timezone index as read from Windows Registry - * @retval -1 : item not found - * @retval 0...count : index of the found item - **/ + * This method is used to find a certain list entry according to + * a given dwTzIndex, providing information about the entry to look for. + * + * @param result - Pointer to a pointer, retrieving the CTimeZone + * object, matching the criteria provided by key + * @param dwTzIndex - Timezone index as read from Windows Registry + * @retval -1 : item not found + * @retval 0...count : index of the found item + **/ + int find(CTimeZone** result, DWORD dwTzIndex) const { int nItemIndex = -1; CTimeZone *ptz = NULL; - if (dwTzIndex != TZINDEX_UNSPECIFIED) - { - for (nItemIndex = 0; nItemIndex < count; nItemIndex++) - { + if (dwTzIndex != TZINDEX_UNSPECIFIED) { + for (nItemIndex = 0; nItemIndex < count; nItemIndex++) { ptz = items[nItemIndex]; if (ptz && (ptz->dwIndex == dwTzIndex)) break; } } + if (result) - { *result = ptz; - } return ((nItemIndex == count) ? -1 : nItemIndex); } - }; + // global timezone TzMgr object static CTzMgr TzMgr; @@ -308,21 +294,22 @@ static CTzMgr TzMgr; ***********************************************************************************************************/ /** - * This method trys to find some default windows timezone idices for a given - * miranda timezone. - * - * @param MirTz - this is a miranda timezone with values between -24 and 24. - * - * @return This method returns a @TZ_MAP struct of a windows timezone, which is maps - * the @MirTz value,name or {-1,NULL} if no windows timezone index exists. - **/ +* This method trys to find some default windows timezone idices for a given +* miranda timezone. +* +* @param MirTz - this is a miranda timezone with values between -24 and 24. +* +* @return This method returns a @TZ_MAP struct of a windows timezone, which is maps +* the @MirTz value,name or {-1,NULL} if no windows timezone index exists. +**/ + static TZ_MAP MirTZ2WinTZ(const CHAR MirTz) { /** - * This is an item of an array of timezones, which are known by both Miranda-IM - * and Windows. It is used to map an ICQ timezone against a Windows timezone - * for retrieving information about daylight saving time and more. - **/ + * This is an item of an array of timezones, which are known by both Miranda-IM + * and Windows. It is used to map an ICQ timezone against a Windows timezone + * for retrieving information about daylight saving time and more. + **/ static const TZ_MAP TzMap[] = { { 0, _T("Dateline Standard Time")}, // GMT-12:00 Eniwetok; Kwajalein {-1, _T("")}, // GMT-11:30 @@ -379,14 +366,15 @@ static TZ_MAP MirTZ2WinTZ(const CHAR MirTz) } /** - * This function reads out the Timezone, associated with the given contact - * - * @param hContact - HANDLE of the contact to retrieve the timezone for. - * @param pszProto - contact's protocol - * - * @retval NULL - No timezone exists. - * @retval CTimeZone* - Pointer to the timezone. - **/ +* This function reads out the Timezone, associated with the given contact +* +* @param hContact - HANDLE of the contact to retrieve the timezone for. +* @param pszProto - contact's protocol +* +* @retval NULL - No timezone exists. +* @retval CTimeZone* - Pointer to the timezone. +**/ + CTimeZone* GetContactTimeZone(HANDLE hContact, LPCSTR pszProto) { LPTSTR ptszName; @@ -394,30 +382,22 @@ CTimeZone* GetContactTimeZone(HANDLE hContact, LPCSTR pszProto) // read windows timezone from database (include meta subcontacts) ptszName = DB::Setting::GetTStringEx(hContact, USERINFO, pszProto, SET_CONTACT_TIMEZONENAME); - if (!ptszName || FAILED(TzMgr.find(&pTimeZone, ptszName))) - { + if (!ptszName || FAILED(TzMgr.find(&pTimeZone, ptszName))) { DBVARIANT dbv; TZ_MAP MirTZ; // try to get miranda's timezone index value - if (!myGlobals.TzIndexExist || DB::Setting::GetAsIsEx(hContact, USERINFO, pszProto, SET_CONTACT_TIMEZONEINDEX, &dbv) || FAILED(TzMgr.find(&pTimeZone,dbv.dVal))) - { + if (!myGlobals.TzIndexExist || DB::Setting::GetAsIsEx(hContact, USERINFO, pszProto, SET_CONTACT_TIMEZONEINDEX, &dbv) || FAILED(TzMgr.find(&pTimeZone,dbv.dVal))) { // maybe a failure lets us read a string, so clear it out db_free(&dbv); // try to get miranda's timezone value if (DB::Setting::GetAsIsEx(hContact, USERINFO, pszProto, SET_CONTACT_TIMEZONE, &dbv) || (dbv.type != DBVT_BYTE)) - { - // maybe a failure lets us read a string, so clear it out - db_free(&dbv); - } - else - { + db_free(&dbv); // maybe a failure lets us read a string, so clear it out + else { MirTZ = MirTZ2WinTZ(dbv.cVal); if (*MirTZ.Name != 0) - { TzMgr.find(&pTimeZone, MirTZ.Name); - } } } } @@ -426,29 +406,31 @@ CTimeZone* GetContactTimeZone(HANDLE hContact, LPCSTR pszProto) } /** - * - * - **/ +* +* +**/ + CTimeZone* GetContactTimeZone(HANDLE hContact) { return GetContactTimeZone(hContact, DB::Contact::Proto(hContact)); } /** - * This method trys to find the contact's windows timezone. - * - * @warning Make sure you convert @e dwIndex to CHAR if the function returns 1 in order to get - * the correct miranda timezone! - * - * @param hContact - the HANDLE of the contact to read timezone information for - * @param szProto - contact's protocol - * @param pTimeZone - Pointer to the pointer of a CTimeZone structure, - * which retrieves information about contact's timezone. - * - * @retval CTRLF_... flag - The index for a windows timezone was found for the contact. - * @retval 0 - There is no index, but if the contact's 'timezone' setting is valid, - * @e dwIndex retrieved its value. If not, dwIndex is -100 (unspecified). - **/ +* This method trys to find the contact's windows timezone. +* +* @warning Make sure you convert @e dwIndex to CHAR if the function returns 1 in order to get +* the correct miranda timezone! +* +* @param hContact - the HANDLE of the contact to read timezone information for +* @param szProto - contact's protocol +* @param pTimeZone - Pointer to the pointer of a CTimeZone structure, +* which retrieves information about contact's timezone. +* +* @retval CTRLF_... flag - The index for a windows timezone was found for the contact. +* @retval 0 - There is no index, but if the contact's 'timezone' setting is valid, +* @e dwIndex retrieved its value. If not, dwIndex is -100 (unspecified). +**/ + WORD GetContactTimeZoneCtrl(HANDLE hContact, LPCSTR pszProto, CTimeZone** pTimeZone) { WORD flags; @@ -457,49 +439,43 @@ WORD GetContactTimeZoneCtrl(HANDLE hContact, LPCSTR pszProto, CTimeZone** pTimeZ // try to read windows' timezone name from database flags = DB::Setting::GetCtrl(hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_TIMEZONENAME, &dbv, DBVT_TCHAR); - if (flags == 0 || FAILED(TzMgr.find(&pTz, dbv.ptszVal))) - { + if (flags == 0 || FAILED(TzMgr.find(&pTz, dbv.ptszVal))) { db_free(&dbv); // try to get miranda's timezone index value - if (myGlobals.TzIndexExist) - { + if (myGlobals.TzIndexExist) { flags = DB::Setting::GetAsIsCtrl(hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_TIMEZONEINDEX, &dbv); if (flags && FAILED(TzMgr.find(&pTz, dbv.dVal))) - { flags = 0; - } } - if (flags == 0) - { + + if (flags == 0) { // try to get miranda's timezone value flags = DB::Setting::GetAsIsCtrl(hContact, USERINFO, USERINFO, pszProto, SET_CONTACT_TIMEZONE, &dbv); - if (flags != 0) - { + if (flags != 0) { TZ_MAP MirTZ; MirTZ = MirTZ2WinTZ(dbv.cVal); if ((*MirTZ.Name == 0) || FAILED(TzMgr.find(&pTz, MirTZ.Name))) - { flags = 0; - } } } } + if (pTimeZone && flags != 0) - { *pTimeZone = pTz; - } + db_free(&dbv); return flags; } /** - * This function returns the display name for the contact's timezone - * - * @param hContact - handle of the contact - * - * @return String containing display name. - **/ +* This function returns the display name for the contact's timezone +* +* @param hContact - handle of the contact +* +* @return String containing display name. +**/ + LPCTSTR GetContactTimeZoneDisplayName(HANDLE hContact) { CTimeZone *pTimeZone; @@ -509,19 +485,18 @@ LPCTSTR GetContactTimeZoneDisplayName(HANDLE hContact) } /** - * - * - **/ +* +* +**/ + INT_PTR EnumTimeZones(PEnumNamesProc enumProc, LPARAM lParam) { INT_PTR i, c, r = 0; CTimeZone *pTz; - for (i = 0, c = TzMgr.Bias.getCount(); i < c; i++) - { + for (i = 0, c = TzMgr.Bias.getCount(); i < c; i++) { pTz = TzMgr.Bias[i]; - if (pTz) - { + if (pTz) { r = enumProc(pTz, i, lParam); if (r) break; } @@ -530,14 +505,14 @@ INT_PTR EnumTimeZones(PEnumNamesProc enumProc, LPARAM lParam) } /** - * - * - **/ +* +* +**/ + static BOOL SvcTimezoneSyncWithWindowsProc(LPCSTR pszProto, int bias) { int tz = (int) ((CHAR)db_get_b(NULL, pszProto, SET_CONTACT_TIMEZONE, (BYTE)-100)); - if (tz * 30 != bias) - { + if (tz * 30 != bias) { db_set_b(NULL, pszProto, SET_CONTACT_TIMEZONE, (BYTE)(bias / 30)); return TRUE; } @@ -545,28 +520,23 @@ static BOOL SvcTimezoneSyncWithWindowsProc(LPCSTR pszProto, int bias) } /** - * - * - **/ +* +* +**/ + void SvcTimezoneSyncWithWindows() { - PROTOACCOUNT **pAcc; - int i, nAccCount; - TIME_ZONE_INFORMATION tzi; - - ZeroMemory(&tzi, sizeof(tzi)); + TIME_ZONE_INFORMATION tzi = { 0 }; GetTimeZoneInformation(&tzi); - if (MIRSUCCEEDED(ProtoEnumAccounts(&nAccCount, &pAcc))) - { - for (i = 0; i < nAccCount; i++) - { + PROTOACCOUNT **pAcc; + int nAccCount; + if (MIRSUCCEEDED(ProtoEnumAccounts(&nAccCount, &pAcc))) { + for (int i = 0; i < nAccCount; i++) { // update local timezone as database setting if (IsProtoAccountEnabled(pAcc[i]) && SvcTimezoneSyncWithWindowsProc(pAcc[i]->szModuleName, tzi.Bias)) - { // update my contact information on icq server CallProtoService(pAcc[i]->szModuleName, PS_CHANGEINFOEX, CIXT_LOCATION, NULL); - } } } } @@ -576,15 +546,16 @@ void SvcTimezoneSyncWithWindows() ***********************************************************************************************************/ /** - * This service function provides a TIME_ZONE_INFORMATION structure - * for the desired contact, in case the contact's timezone can be determined. - * - * @param wParam - HANDLE of the contact, to retrieve timezone information from. - * @param lParam - pointer to a TIME_ZONE_INFORMATION to fill. - * - * @retval 0 - success - * @retval 1 - failure - **/ +* This service function provides a TIME_ZONE_INFORMATION structure +* for the desired contact, in case the contact's timezone can be determined. +* +* @param wParam - HANDLE of the contact, to retrieve timezone information from. +* @param lParam - pointer to a TIME_ZONE_INFORMATION to fill. +* +* @retval 0 - success +* @retval 1 - failure +**/ + INT_PTR GetContactTimeZoneInformation_old(WPARAM wParam,LPARAM lParam) { CTimeZone *pTimeZone; @@ -592,26 +563,26 @@ INT_PTR GetContactTimeZoneInformation_old(WPARAM wParam,LPARAM lParam) pTimeZone = GetContactTimeZone((HANDLE)wParam); if (pTimeZone && pTimeZoneInformation) - { (*pTimeZoneInformation) = *pTimeZone; - } + return (pTimeZone == NULL) || (pTimeZoneInformation == NULL); } /** - * This function returns the contact's local time. - * - * @param wParam - HANDLE of the contact, to retrieve timezone information from. - * @param lParam - pointer to a systemtime structure - * - * @return TRUE or FALSE - **/ +* This function returns the contact's local time. +* +* @param wParam - HANDLE of the contact, to retrieve timezone information from. +* @param lParam - pointer to a systemtime structure +* +* @return TRUE or FALSE +**/ + INT_PTR GetContactLocalTime_old(WPARAM wParam, LPARAM lParam) { MTime now; - LPSYSTEMTIME pSystemTime = (LPSYSTEMTIME)lParam; - now.GetLocalTime((HANDLE)wParam); + + LPSYSTEMTIME pSystemTime = (LPSYSTEMTIME)lParam; *pSystemTime = now.SystemTime(); return 0; } @@ -621,15 +592,14 @@ INT_PTR GetContactLocalTime_old(WPARAM wParam, LPARAM lParam) ***********************************************************************************************************/ /** - * This function initially loads the module uppon startup. - **/ +* This function initially loads the module upon startup. +**/ + void SvcTimezoneLoadModule_old() { TzMgr.Init(); CreateServiceFunction(MS_USERINFO_TIMEZONEINFO, GetContactTimeZoneInformation); CreateServiceFunction(MS_USERINFO_LOCALTIME, GetContactLocalTime); if (db_get_b(NULL, MODNAME, SET_OPT_AUTOTIMEZONE, TRUE)) - { SvcTimezoneSyncWithWindows(); - } } -- cgit v1.2.3