diff options
author | George Hazan <ghazan@miranda.im> | 2019-02-12 18:29:58 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2019-02-12 18:29:58 +0300 |
commit | 0333d7006f7c1e415819c0521d01b58f80313fbe (patch) | |
tree | 7db5b73c9b39adefa7a38ea742b22f022a7f0119 /plugins/UserInfoEx | |
parent | 837be8df532198e24b6672eb9e0bd14a5c0fed3c (diff) |
code cleaning
Diffstat (limited to 'plugins/UserInfoEx')
-rw-r--r-- | plugins/UserInfoEx/src/commonheaders.cpp | 158 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/ctrl_contact.cpp | 6 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/dlg_anniversarylist.cpp | 14 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp | 6 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/ex_import/classExImContactBase.h | 4 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp | 2 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp | 317 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/init.cpp | 3 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/stdafx.h | 6 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/svc_refreshci.cpp | 365 |
10 files changed, 292 insertions, 589 deletions
diff --git a/plugins/UserInfoEx/src/commonheaders.cpp b/plugins/UserInfoEx/src/commonheaders.cpp deleted file mode 100644 index 21c680affe..0000000000 --- a/plugins/UserInfoEx/src/commonheaders.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/*
-UserinfoEx plugin for Miranda IM
-
-Copyright:
-© 2006-2010 DeathAxe, Yasnovidyashii, Merlin, K. Romanov, Kreol
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-*/
-
-#include "stdafx.h"
-
-// global:
-
-MGLOBAL myGlobals;
-pfnDwmIsCompositionEnabled dwmIsCompositionEnabled;
-
-/**
- * Calculates an unique DWORD number from a string.
- * It's the same as used in langpack.
- *
- * @param szStr - string to calculate the hash value for
- * @return the unique id for the szStr
- **/
-
-#if __GNUC__
-#define NOINLINEASM
-#endif
-
-DWORD hashSetting(LPCSTR szStr)
-{
-#if defined _M_IX86 && !defined _NUMEGA_BC_FINALCHECK && !defined NOINLINEASM
- __asm
- {
- xor edx,edx
- xor eax,eax
- mov esi,szStr
- mov al,[esi]
- dec esi
- xor cl,cl
- lph_top: //only 4 of 9 instructions in here don't use AL, so optimal pipe use is impossible
- xor edx,eax
- inc esi
- and cl,31
- movzx eax,byte ptr [esi]
- add cl,5
- test al,al
- rol eax,cl //rol is u-pipe only, but pairable
- //rol doesn't touch z-flag
- jnz lph_top //5 clock tick loop. not bad.
-
- xor eax,edx
- }
-#else
- DWORD hash = 0;
- int i;
- int shift = 0;
- for (i = 0; szStr[i]; i++)
- {
- hash ^= szStr[i] << shift;
- if (shift > 24)
- {
- hash ^= (szStr[i] >> (32 - shift)) & 0x7F;
- }
- shift = (shift + 5) & 0x1F;
- }
- return hash;
-#endif
-}
-
-// MurmurHash2
-#ifdef _DEBUG
-#pragma optimize( "gt", on )
-#endif
-unsigned int __fastcall hash_M2(const void * key, unsigned int len)
-{
- // 'm' and 'r' are mixing constants generated offline.
- // They're not really 'magic', they just happen to work well.
- const unsigned int m = 0x5bd1e995;
- const int r = 24;
-
- // Initialize the hash to a 'random' value
- unsigned int h = len;
-
- // Mix 4 bytes at a time into the hash
- const unsigned char * data = (const unsigned char *)key;
-
- while(len >= 4)
- {
- unsigned int k = *(unsigned int *)data;
-
- k *= m;
- k ^= k >> r;
- k *= m;
-
- h *= m;
- h ^= k;
-
- data += 4;
- len -= 4;
- }
-
- // Handle the last few bytes of the input array
- switch(len)
- {
- case 3: h ^= data[2] << 16;
- case 2: h ^= data[1] << 8;
- case 1: h ^= data[0];
- h *= m;
- };
-
- // Do a few final mixes of the hash to ensure the last few
- // bytes are well-incorporated.
- h ^= h >> 13;
- h *= m;
- h ^= h >> 15;
-
- return h;
-}
-
-unsigned int hashSettingW_M2(const char * key)
-{
- if (key == nullptr) return 0;
- const unsigned int len = (unsigned int)mir_wstrlen((const wchar_t*)key);
- char* buf = (char*)alloca(len + 1);
- for (unsigned i = 0; i <= len ; ++i)
- buf[i] = key[i << 1];
- return hash_M2(buf, len);
-}
-
-unsigned int hashSetting_M2(const char * key)
-{
- if (key == nullptr) return 0;
- const unsigned int len = (unsigned int)mir_strlen((const char*)key);
- return hash_M2(key, len);
-}
-
-unsigned int hashSetting_M2(const wchar_t * key)
-{
- if (key == nullptr) return 0;
- const unsigned int len = (unsigned int)mir_wstrlen((const wchar_t*)key);
- return hash_M2(key, len * sizeof(wchar_t));
-}
-
-#ifdef _DEBUG
-#pragma optimize( "", on )
-#endif
diff --git a/plugins/UserInfoEx/src/ctrl_contact.cpp b/plugins/UserInfoEx/src/ctrl_contact.cpp index c0ad33eb9c..d8084daaed 100644 --- a/plugins/UserInfoEx/src/ctrl_contact.cpp +++ b/plugins/UserInfoEx/src/ctrl_contact.cpp @@ -1290,7 +1290,7 @@ int CtrlContactAddItemFromDB( CBEXITEM cbi;
cbi.pszVal = nullptr;
- cbi.dwID = hashSetting(szSettingVal);
+ cbi.dwID = mir_hashstr(szSettingVal);
cbi.wFlags = CBEXIF_CATREADONLY|DB::Setting::GetTStringCtrl(hContact, pszModule, pszModule, pszProto, szSettingVal, &dbv);
if (dbv.type >= DBVT_WCHAR) {
// no value read from database
@@ -1355,7 +1355,7 @@ int CtrlContactAddMyItemsFromDB( i++)
{
// read value
- cbi.dwID = hashSetting(pszSetting);
+ cbi.dwID = mir_hashstr(pszSetting);
cbi.pszVal = dbv.pwszVal;
dbv.type = DBVT_DELETED;
dbv.pwszVal = nullptr;
@@ -1421,7 +1421,7 @@ int CtrlContactWriteItemToDB( cbi.pszVal = szVal;
cbi.ccVal = MAXDATASIZE - 4;
cbi.iItem = 0;
- cbi.dwID = hashSetting(pszSetting);
+ cbi.dwID = mir_hashstr(pszSetting);
if (!CtrlContactWndProc(hCtrl, CBEXM_GETITEM, NULL, (LPARAM)&cbi)) return 1;
if (!(cbi.wFlags & CTRLF_CHANGED)) return 0;
if (!hContact && !(pszModule = pszProto)) return 1;
diff --git a/plugins/UserInfoEx/src/dlg_anniversarylist.cpp b/plugins/UserInfoEx/src/dlg_anniversarylist.cpp index 69dc4dce35..0f8c68c09f 100644 --- a/plugins/UserInfoEx/src/dlg_anniversarylist.cpp +++ b/plugins/UserInfoEx/src/dlg_anniversarylist.cpp @@ -927,17 +927,11 @@ public: INT_PTR DlgAnniversaryListShow(WPARAM, LPARAM)
{
if (!gpDlg) {
- try {
- myGlobals.WantAeroAdaption = g_plugin.getByte(SET_PROPSHEET_AEROADAPTION, TRUE);
- gpDlg = new CAnnivList();
- }
- catch(...) {
- delete gpDlg;
- gpDlg = nullptr;
- }
+ myGlobals.WantAeroAdaption = g_plugin.getByte(SET_PROPSHEET_AEROADAPTION, TRUE);
+ gpDlg = new CAnnivList();
}
- else
- gpDlg->BringToFront();
+ else gpDlg->BringToFront();
+
return 0;
}
diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp index bd1829e228..717203bab7 100644 --- a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp +++ b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp @@ -334,13 +334,13 @@ BYTE CExImContactBase::compareUID(DBVARIANT *dbv) } break; case DBVT_ASCIIZ: - hash = hashSetting_M2(dbv->pszVal); + hash = mir_hashstr(dbv->pszVal); case DBVT_WCHAR: - if (!hash) hash = hashSettingW_M2((const char *)dbv->pwszVal); + if (!hash) hash = mir_hashstrW(dbv->pwszVal); case DBVT_UTF8: if (!hash) { LPWSTR tmp = mir_utf8decodeW(dbv->pszVal); - hash = hashSettingW_M2((const char *)tmp); + hash = mir_hashstrW(tmp); mir_free(tmp); } if (hash == _dbvUIDHash) diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactBase.h b/plugins/UserInfoEx/src/ex_import/classExImContactBase.h index 4894d09bae..122b35c6ef 100644 --- a/plugins/UserInfoEx/src/ex_import/classExImContactBase.h +++ b/plugins/UserInfoEx/src/ex_import/classExImContactBase.h @@ -60,13 +60,13 @@ public: __inline void uida(LPCSTR val)
{
_dbvUID.type = (_dbvUID.pszVal = mir_utf8decodeA(val))? DBVT_ASCIIZ : DBVT_DELETED;
- _dbvUIDHash = hashSetting_M2(_dbvUID.pszVal);
+ _dbvUIDHash = mir_hashstr(_dbvUID.pszVal);
}
__inline void uidu(LPCSTR val)
{
_dbvUID.type = (_dbvUID.pszVal = mir_strdup(val))? DBVT_UTF8 : DBVT_DELETED;
LPWSTR temp = mir_utf8decodeW(val);
- _dbvUIDHash = hashSettingW_M2((const char *)temp);
+ _dbvUIDHash = mir_hashstrW(temp);
mir_free(temp);
}
diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp index d30973d337..c1d0d624cd 100644 --- a/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/classExImContactXML.cpp @@ -83,7 +83,7 @@ BYTE CExImContactXML::IsContactInfo(LPCSTR pszKey) if (pszKey && *pszKey) {
char buf[MAXSETTING];
// convert to hash and make bsearch as it is much faster then working with strings
- const DWORD dwHash = hashSetting(_strlwr(mir_strncpy(buf, pszKey, _countof(buf))));
+ const DWORD dwHash = mir_hashstr(_strlwr(mir_strncpy(buf, pszKey, _countof(buf))));
return bsearch(&dwHash, dwCiHash, _countof(dwCiHash), sizeof(dwCiHash[0]), (int (*)(const void*, const void*))SortProc) != nullptr;
}
return FALSE;
diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp index 390af4034f..196daf6230 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImXML.cpp @@ -79,43 +79,40 @@ INT_PTR CALLBACK DlgProc_DataHistory(HWND hDlg, UINT msg, WPARAM wParam, LPARAM * exporting stuff
***********************************************************************************************************/
-/**
- * name: Export
- * desc: globally accessible function which does the whole export stuff.
- * params: hContact - handle to the contact who is to export
- * pszFileName - full qualified path to the xml file which is destination for the export process
- * return: 0 on success, 1 otherwise
- **/
+ /**
+ * name: Export
+ * desc: globally accessible function which does the whole export stuff.
+ * params: hContact - handle to the contact who is to export
+ * pszFileName - full qualified path to the xml file which is destination for the export process
+ * return: 0 on success, 1 otherwise
+ **/
int CFileXml::Export(lpExImParam ExImContact, LPCSTR pszFileName)
{
DB::CEnumList Modules;
- DWORD result = (DWORD) DialogBox(g_plugin.getInst(),
- MAKEINTRESOURCE(IDD_EXPORT_DATAHISTORY),
- nullptr, DlgProc_DataHistory);
- if (LOWORD(result) != IDOK)
- {
+ DWORD result = (DWORD)DialogBox(g_plugin.getInst(),
+ MAKEINTRESOURCE(IDD_EXPORT_DATAHISTORY),
+ nullptr, DlgProc_DataHistory);
+ if (LOWORD(result) != IDOK) {
return 0;
}
_wExport = HIWORD(result);
// show dialog to enable user to select modules for export
if (!(_wExport & EXPORT_DATA) ||
- !DlgExImModules_SelectModulesToExport(ExImContact, &Modules, nullptr))
- {
+ !DlgExImModules_SelectModulesToExport(ExImContact, &Modules, nullptr)) {
FILE *xmlfile = fopen(pszFileName, "wt");
- if (!xmlfile)
- {
+ if (!xmlfile) {
MsgErr(nullptr, LPGENW("Can't create xml file!\n%S"), pszFileName);
return 1;
}
-
+
SYSTEMTIME now;
GetLocalTime(&now);
// write xml header raw as it is without using the tinyxml api
- fprintf(xmlfile,
+ fprintf(xmlfile,
"%c%c%c<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
"<XMLCard ver=\"" XMLCARD_VERSION "\" ref=\"%04d-%02d-%02d %02d:%02d:%02d\">\n",
0xefU, 0xbbU, 0xbfU, now.wYear, now.wMonth, now.wDay, now.wHour, now.wMinute, now.wSecond
@@ -126,7 +123,7 @@ int CFileXml::Export(lpExImParam ExImContact, LPCSTR pszFileName) CExImContactXML vContact(this);
// write data
- if ( ExImContact->Typ == EXIM_CONTACT) {
+ if (ExImContact->Typ == EXIM_CONTACT) {
// export single contact
_hContactToWorkOn = ExImContact->hContact;
if (vContact.fromDB(ExImContact->hContact)) {
@@ -136,57 +133,45 @@ int CFileXml::Export(lpExImParam ExImContact, LPCSTR pszFileName) else {
// other export mode
_hContactToWorkOn = INVALID_CONTACT_ID;
-#ifdef _DEBUG
- LARGE_INTEGER freq, t1, t2;
- QueryPerformanceFrequency(&freq);
- QueryPerformanceCounter(&t1);
-#endif
// export owner contact
if (ExImContact->Typ == EXIM_ALL && vContact.fromDB(NULL)) {
vContact.Export(xmlfile, &Modules);
}
// loop for all other contact
- for (MCONTACT hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact))
- {
- switch (ExImContact->Typ)
- {
- case EXIM_ALL:
- case EXIM_GROUP:
- // dont export meta subcontacts by default
- if (!db_mc_isSub(hContact)) {
- if (vContact.fromDB(hContact)) {
- vContact.Export(xmlfile, &Modules);
- }
+ for (MCONTACT hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) {
+ switch (ExImContact->Typ) {
+ case EXIM_ALL:
+ case EXIM_GROUP:
+ // dont export meta subcontacts by default
+ if (!db_mc_isSub(hContact)) {
+ if (vContact.fromDB(hContact)) {
+ vContact.Export(xmlfile, &Modules);
}
- break;
- case EXIM_SUBGROUP:
- // dont export meta subcontacts by default and
- // export only contact with selectet group name
- if (!db_mc_isSub(hContact) &&
- mir_wstrncmp(ExImContact->ptszName, DB::Setting::GetTString(hContact, "CList", "Group"), mir_wstrlen(ExImContact->ptszName))== 0)
- {
- if (vContact.fromDB(hContact)) {
- vContact.Export(xmlfile, &Modules);
- }
+ }
+ break;
+ case EXIM_SUBGROUP:
+ // dont export meta subcontacts by default and
+ // export only contact with selectet group name
+ if (!db_mc_isSub(hContact) &&
+ mir_wstrncmp(ExImContact->ptszName, DB::Setting::GetTString(hContact, "CList", "Group"), mir_wstrlen(ExImContact->ptszName)) == 0) {
+ if (vContact.fromDB(hContact)) {
+ vContact.Export(xmlfile, &Modules);
}
- break;
- case EXIM_ACCOUNT:
- // export only contact with selectet account name
- if (!mir_strncmp(ExImContact->pszName, Proto_GetBaseAccountName(hContact), mir_strlen(ExImContact->pszName))) {
- if (vContact.fromDB(hContact)) {
- vContact.Export(xmlfile, &Modules);
- }
+ }
+ break;
+ case EXIM_ACCOUNT:
+ // export only contact with selectet account name
+ if (!mir_strncmp(ExImContact->pszName, Proto_GetBaseAccountName(hContact), mir_strlen(ExImContact->pszName))) {
+ if (vContact.fromDB(hContact)) {
+ vContact.Export(xmlfile, &Modules);
}
- break;
+ }
+ break;
}
} // *end for
-#ifdef _DEBUG
- QueryPerformanceCounter(&t2);
- MsgErr(nullptr, LPGENW("Export took %f ms"),
- (long double)(t2.QuadPart - t1.QuadPart) / freq.QuadPart * 1000.);
-#endif
- }// *end other export mode
+ }
+ // *end other export mode
// nothing exported?
if (cbHeader == ftell(xmlfile)) {
@@ -207,15 +192,15 @@ int CFileXml::Export(lpExImParam ExImContact, LPCSTR pszFileName) CFileXml::CFileXml()
{
- _numContactsTodo = 0;
- _numContactsDone = 0;
- _numSettingsTodo = 0;
- _numSettingsDone = 0;
- _numEventsTodo = 0;
- _numEventsDone = 0;
- _numEventsDuplicated = 0;
- _hContactToWorkOn = INVALID_CONTACT_ID;
- _wExport = 0;
+ _numContactsTodo = 0;
+ _numContactsDone = 0;
+ _numSettingsTodo = 0;
+ _numSettingsDone = 0;
+ _numEventsTodo = 0;
+ _numEventsDone = 0;
+ _numEventsDuplicated = 0;
+ _hContactToWorkOn = INVALID_CONTACT_ID;
+ _wExport = 0;
}
/**
@@ -258,33 +243,23 @@ int CFileXml::ImportContacts(TiXmlElement* xmlParent) if (_progress.UpdateContact(LPGENW("Contact: %s (%S)"), pszNick, xContact->Attribute("proto"))) {
int result = vContact.LoadXmlElemnt(xContact);
switch (result) {
- case ERROR_OK:
- // init contact class and import if matches the user desires
- if (_hContactToWorkOn == INVALID_CONTACT_ID || vContact.handle() == _hContactToWorkOn) {
- result = vContact.Import(_hContactToWorkOn != INVALID_CONTACT_ID);
- switch (result) {
- case ERROR_OK:
- _numContactsDone++;
- break;
- case ERROR_ABORTED:
- if (pszNick) mir_free(pszNick);
- return ERROR_ABORTED;
-#ifdef _DEBUG
- default:
- MsgErr(nullptr, LPGENW("Importing %s caused error %d"), pszNick, result);
- break;
-#endif
- }
+ case ERROR_OK:
+ // init contact class and import if matches the user desires
+ if (_hContactToWorkOn == INVALID_CONTACT_ID || vContact.handle() == _hContactToWorkOn) {
+ result = vContact.Import(_hContactToWorkOn != INVALID_CONTACT_ID);
+ switch (result) {
+ case ERROR_OK:
+ _numContactsDone++;
+ break;
+ case ERROR_ABORTED:
+ if (pszNick) mir_free(pszNick);
+ return ERROR_ABORTED;
}
- break;
- case ERROR_ABORTED:
- if (pszNick) mir_free(pszNick);
- return ERROR_ABORTED;
-#ifdef _DEBUG
- default:
- MsgErr(nullptr, LPGENW("Loading contact %s from xml failed with error %d"), pszNick, result);
- break;
-#endif
+ }
+ break;
+ case ERROR_ABORTED:
+ if (pszNick) mir_free(pszNick);
+ return ERROR_ABORTED;
}
}
if (pszNick) mir_free(pszNick);
@@ -293,15 +268,11 @@ int CFileXml::ImportContacts(TiXmlElement* xmlParent) else if (_hContactToWorkOn == INVALID_CONTACT_ID && !mir_strcmpi(xContact->Value(), XKEY_OWNER) && (vContact = xContact)) {
int result = vContact.Import();
switch (result) {
- case ERROR_OK:
- _numContactsDone++;
- break;
- case ERROR_ABORTED:
- return ERROR_ABORTED;
-#ifdef _DEBUG
- default:
- MsgErr(nullptr, LPGENW("Importing Owner caused error %d"), result);
-#endif
+ case ERROR_OK:
+ _numContactsDone++;
+ break;
+ case ERROR_ABORTED:
+ return ERROR_ABORTED;
}
}
}
@@ -316,18 +287,13 @@ int CFileXml::ImportContacts(TiXmlElement* xmlParent) **/
DWORD CFileXml::CountContacts(TiXmlElement* xmlParent)
{
- try {
- DWORD dwCount = 0;
- // count contacts in file for progress bar
- for (TiXmlNode *xContact = xmlParent->FirstChild(); xContact != nullptr; xContact = xContact->NextSibling())
- if (!mir_strcmpi(xContact->Value(), XKEY_CONTACT) || !mir_strcmpi(xContact->Value(), XKEY_OWNER))
- dwCount += CountContacts(xContact->ToElement()) + 1;
+ DWORD dwCount = 0;
+ // count contacts in file for progress bar
+ for (TiXmlNode *xContact = xmlParent->FirstChild(); xContact != nullptr; xContact = xContact->NextSibling())
+ if (!mir_strcmpi(xContact->Value(), XKEY_CONTACT) || !mir_strcmpi(xContact->Value(), XKEY_OWNER))
+ dwCount += CountContacts(xContact->ToElement()) + 1;
- return dwCount;
- }
- catch(...) {
- return 0;
- }
+ return dwCount;
}
/**
@@ -340,77 +306,72 @@ DWORD CFileXml::CountContacts(TiXmlElement* xmlParent) **/
int CFileXml::Import(MCONTACT hContact, LPCSTR pszFileName)
{
- try {
- _hContactToWorkOn = hContact;
- // load xml file
- TiXmlDocument doc;
- if (!doc.LoadFile(pszFileName)) {
- MsgErr(nullptr, LPGENW("Parser is unable to load XMLCard \"%s\"\nError: %d\nDescription: %s"),
- pszFileName, doc.ErrorID(), doc.Error());
- return 1;
- }
- // is xmlfile a XMLCard ?
- TiXmlElement *xmlCard = doc.FirstChildElement("XMLCard");
- if (xmlCard == nullptr) {
- MsgErr(nullptr, LPGENW("The selected file is no valid XMLCard"));
- return 1;
+ _hContactToWorkOn = hContact;
+ // load xml file
+ TiXmlDocument doc;
+ if (!doc.LoadFile(pszFileName)) {
+ MsgErr(nullptr, LPGENW("Parser is unable to load XMLCard \"%s\"\nError: %d\nDescription: %s"),
+ pszFileName, doc.ErrorID(), doc.Error());
+ return 1;
+ }
+ // is xmlfile a XMLCard ?
+ TiXmlElement *xmlCard = doc.FirstChildElement("XMLCard");
+ if (xmlCard == nullptr) {
+ MsgErr(nullptr, LPGENW("The selected file is no valid XMLCard"));
+ return 1;
+ }
+ // check version
+ if (mir_strcmp(xmlCard->Attribute("ver"), XMLCARD_VERSION)) {
+ MsgErr(nullptr, LPGENW("The version of the XMLCard is not supported by UserInfoEx"));
+ return 1;
+ }
+
+ // is owner contact to import ?
+ if (_hContactToWorkOn == NULL) {
+ int ret;
+
+ // disable database safty mode to speed up the operation
+ db_set_safety_mode(0);
+ // import owner contact
+ ret = ImportOwner(xmlCard->FirstChildElement(XKEY_OWNER));
+ // as soon as possible enable safty mode again!
+ db_set_safety_mode(1);
+
+ if (!ret) {
+ MsgBox(nullptr, MB_ICONINFORMATION,
+ LPGENW("Complete"),
+ LPGENW("Import complete"),
+ LPGENW("Owner contact successfully imported."));
+ return 0;
}
- // check version
- if (mir_strcmp(xmlCard->Attribute("ver"), XMLCARD_VERSION)) {
- MsgErr(nullptr, LPGENW("The version of the XMLCard is not supported by UserInfoEx"));
+ else {
+ MsgErr(nullptr, LPGENW("Selected XMLCard does not contain an owner contact!"));
return 1;
}
-
- // is owner contact to import ?
- if (_hContactToWorkOn == NULL) {
- int ret;
-
+ }
+ else {
+ // count contacts in file for progress bar
+ _numContactsTodo = CountContacts(xmlCard);
+ if (_numContactsTodo > 0) {
+ _progress.SetContactCount(_numContactsTodo);
// disable database safty mode to speed up the operation
db_set_safety_mode(0);
- // import owner contact
- ret = ImportOwner(xmlCard->FirstChildElement(XKEY_OWNER));
+ // import the contacts
+ ImportContacts(xmlCard);
// as soon as possible enable safty mode again!
db_set_safety_mode(1);
-
- if (!ret) {
- MsgBox(nullptr, MB_ICONINFORMATION,
- LPGENW("Complete"),
- LPGENW("Import complete"),
- LPGENW("Owner contact successfully imported."));
- return 0;
- } else {
- MsgErr(nullptr, LPGENW("Selected XMLCard does not contain an owner contact!"));
- return 1;
- }
- }
- else {
- // count contacts in file for progress bar
- _numContactsTodo = CountContacts(xmlCard);
- if (_numContactsTodo > 0) {
- _progress.SetContactCount(_numContactsTodo);
- // disable database safty mode to speed up the operation
- db_set_safety_mode(0);
- // import the contacts
- ImportContacts(xmlCard);
- // as soon as possible enable safty mode again!
- db_set_safety_mode(1);
- }
- // finally hide the progress dialog
- _progress.Hide();
-
- // show results
- MsgBox(nullptr, MB_ICONINFORMATION, LPGENW("Import complete"), LPGENW("Some basic statistics"),
- LPGENW("added contacts: %u / %u\nadded settings: %u / %u\nadded events %u / %u\nduplicated events: %u"),
- _numContactsDone, _numContactsTodo,
- _numSettingsDone, _numSettingsTodo,
- _numEventsDone, _numEventsTodo,
- _numEventsDuplicated);
-
}
- return 0;
- }
- catch(...) {
- MsgErr(nullptr, LPGENW("FATAL: An exception was thrown while importing contacts from xmlCard!"));
- return 1;
+ // finally hide the progress dialog
+ _progress.Hide();
+
+ // show results
+ MsgBox(nullptr, MB_ICONINFORMATION, LPGENW("Import complete"), LPGENW("Some basic statistics"),
+ LPGENW("added contacts: %u / %u\nadded settings: %u / %u\nadded events %u / %u\nduplicated events: %u"),
+ _numContactsDone, _numContactsTodo,
+ _numSettingsDone, _numSettingsTodo,
+ _numEventsDone, _numEventsTodo,
+ _numEventsDuplicated);
+
}
+ return 0;
}
diff --git a/plugins/UserInfoEx/src/init.cpp b/plugins/UserInfoEx/src/init.cpp index c71c1c64e8..2259a892b0 100644 --- a/plugins/UserInfoEx/src/init.cpp +++ b/plugins/UserInfoEx/src/init.cpp @@ -24,6 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. CMPlugin g_plugin;
HMODULE hDwmApi;
+MGLOBAL myGlobals;
+pfnDwmIsCompositionEnabled dwmIsCompositionEnabled;
+
/////////////////////////////////////////////////////////////////////////////////////////
static PLUGININFOEX pluginInfoEx =
diff --git a/plugins/UserInfoEx/src/stdafx.h b/plugins/UserInfoEx/src/stdafx.h index 095017dd57..c15c141fe9 100644 --- a/plugins/UserInfoEx/src/stdafx.h +++ b/plugins/UserInfoEx/src/stdafx.h @@ -104,10 +104,6 @@ using namespace std; #define GetUserData(p) GetWindowLongPtr((p), GWLP_USERDATA)
#define SetUserData(p, l) SetWindowLongPtr((p), GWLP_USERDATA, (LONG_PTR) (l))
-unsigned int hashSetting_M2(const wchar_t * key); //new Murma2 hash
-unsigned int hashSetting_M2(const char * key); //new Murma2 hash
-unsigned int hashSettingW_M2(const char * key); //new Murma2 hash
-
#include "resource.h"
#include "version.h"
#include "../IconPacks/default/src/icons.h"
@@ -209,8 +205,6 @@ extern struct CountryListEntry *countries; * UserInfoEx common used functions
***********************************************************************************************************/
-DWORD hashSetting(LPCSTR szStr); //old miranda hash
-
static FORCEINLINE BOOL IsProtoOnline(LPSTR pszProto)
{
return pszProto && pszProto[0] && Proto_GetStatus(pszProto) >= ID_STATUS_ONLINE;
diff --git a/plugins/UserInfoEx/src/svc_refreshci.cpp b/plugins/UserInfoEx/src/svc_refreshci.cpp index 6f3d9473ea..6f07273138 100644 --- a/plugins/UserInfoEx/src/svc_refreshci.cpp +++ b/plugins/UserInfoEx/src/svc_refreshci.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define HM_PROTOACK (WM_USER+100)
-typedef INT_PTR (*PUpdCallback) (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, void *UserData);
+typedef INT_PTR(*PUpdCallback) (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, void *UserData);
/***********************************************************************************************************
* class CUpdProgress
@@ -51,36 +51,30 @@ protected: *
* @return This method returns 0.
**/
- static INT_PTR CALLBACK DefWndProc(CUpdProgress *pProgress, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+ static INT_PTR CALLBACK DefWndProc(CUpdProgress *pProgress, HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
- __try
- {
- if (PtrIsValid(pProgress))
- {
- switch (uMsg)
- {
+ __try {
+ if (PtrIsValid(pProgress)) {
+ switch (uMsg) {
case UM_POPUPACTION:
case WM_COMMAND:
{
- if (wParam == MAKEWORD(IDSKIP, BN_CLICKED))
- {
+ if (wParam == MAKEWORD(IDSKIP, BN_CLICKED)) {
pProgress->Destroy();
}
- else
- if (wParam == MAKEWORD(IDCANCEL, BN_CLICKED))
- {
- pProgress->_bIsCanceled = TRUE;
- }
+ else
+ if (wParam == MAKEWORD(IDCANCEL, BN_CLICKED)) {
+ pProgress->_bIsCanceled = TRUE;
+ }
}
}
- if (PtrIsValid(pProgress->_pFnCallBack))
- {
+ if (PtrIsValid(pProgress->_pFnCallBack)) {
pProgress->_pFnCallBack(hWnd, uMsg, wParam, lParam, pProgress->_pData);
}
}
}
- __except(GetExceptionCode()==EXCEPTION_ACCESS_VIOLATION ?
- EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
+ __except (GetExceptionCode() == EXCEPTION_ACCESS_VIOLATION ?
+ EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH)
{ // code to handle exception
puts("Exception Occurred");
}
@@ -89,10 +83,10 @@ protected: public:
- virtual HWND Create (LPCTSTR szTitle, PUpdCallback pFnCallBack) = 0;
- virtual void Destroy (void) {};
- virtual void SetTitle (LPCTSTR szText) = 0;
- virtual void SetText (LPCTSTR szText) = 0;
+ virtual HWND Create(LPCTSTR szTitle, PUpdCallback pFnCallBack) = 0;
+ virtual void Destroy(void) {};
+ virtual void SetTitle(LPCTSTR szText) = 0;
+ virtual void SetText(LPCTSTR szText) = 0;
BYTE IsVisible() const
{
@@ -113,15 +107,13 @@ public: **/
void SetTitleParam(LPCTSTR szText, ...)
{
- if (szText)
- {
+ if (szText) {
wchar_t buf[MAXDATASIZE];
va_list vl;
-
+
va_start(vl, szText);
- if (mir_vsnwprintf(buf, _countof(buf), szText, vl) != -1)
- {
- SetTitle(buf);
+ if (mir_vsnwprintf(buf, _countof(buf), szText, vl) != -1) {
+ SetTitle(buf);
}
va_end(vl);
}
@@ -130,7 +122,7 @@ public: /**
* This method is used to set the popups or dialogs message text.
* It takes text with parameters as sprintf does. If bbcodes are
- * disabled this method automatically deletes them from the text.
+ * disabled this method automatically deletes them from the text.
*
* @param szText - the text to display. Can contain formats like
* sprintf does.
@@ -141,47 +133,39 @@ public: **/
void SetTextParam(LPCTSTR szText, ...)
{
- if (szText)
- {
+ if (szText) {
INT_PTR cch = mir_wstrlen(szText);
- LPTSTR fmt = (LPTSTR) mir_alloc((cch + 1) * sizeof(wchar_t));
-
- if (fmt)
- {
+ LPTSTR fmt = (LPTSTR)mir_alloc((cch + 1) * sizeof(wchar_t));
+
+ if (fmt) {
wchar_t buf[MAXDATASIZE];
va_list vl;
mir_wstrcpy(fmt, szText);
// delete bbcodes
- if (!_bBBCode)
- {
+ if (!_bBBCode) {
LPTSTR s, e;
- for (s = fmt, e = fmt + cch; s[0] != 0; s++)
- {
- if (s[0] == '[')
- {
+ for (s = fmt, e = fmt + cch; s[0] != 0; s++) {
+ if (s[0] == '[') {
// leading bbcode tag (e.g.: [b], [u], [i])
- if ((s[1] == 'b' || s[1] == 'u' || s[1] == 'i') && s[2] == ']')
- {
+ if ((s[1] == 'b' || s[1] == 'u' || s[1] == 'i') && s[2] == ']') {
memmove(s, s + 3, (e - s - 2) * sizeof(wchar_t));
e -= 3;
}
// ending bbcode tag (e.g.: [/b], [/u], [/i])
- else if (s[1] == '/' && (s[2] == 'b' || s[2] == 'u' || s[2] == 'i') && s[3] == ']')
- {
+ else if (s[1] == '/' && (s[2] == 'b' || s[2] == 'u' || s[2] == 'i') && s[3] == ']') {
memmove(s, s + 4, (e - s - 3) * sizeof(wchar_t));
e -= 4;
}
}
}
}
-
+
va_start(vl, szText);
- if (mir_vsnwprintf(buf, _countof(buf), fmt, vl) != -1)
- {
- SetText(buf);
+ if (mir_vsnwprintf(buf, _countof(buf), fmt, vl) != -1) {
+ SetText(buf);
}
va_end(vl);
mir_free(fmt);
@@ -231,7 +215,7 @@ class CDlgUpdProgress : public CUpdProgress *
*
**/
- static INT_PTR CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+ static INT_PTR CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch (uMsg) {
case WM_INITDIALOG:
@@ -242,11 +226,11 @@ class CDlgUpdProgress : public CUpdProgress { ICO_BTN_CANCEL, BM_SETIMAGE, IDCANCEL }
};
IcoLib_SetCtrlIcons(hWnd, idIcon, g_plugin.getByte(SET_ICONS_BUTTONS, 1) ? 2 : 1);
-
- SendDlgItemMessage(hWnd, IDCANCEL, BUTTONTRANSLATE, NULL, NULL);
- SendDlgItemMessage(hWnd, IDSKIP, BUTTONTRANSLATE, NULL, NULL);
+
+ SendDlgItemMessage(hWnd, IDCANCEL, BUTTONTRANSLATE, NULL, NULL);
+ SendDlgItemMessage(hWnd, IDSKIP, BUTTONTRANSLATE, NULL, NULL);
SetUserData(hWnd, lParam);
-
+
TranslateDialogDefault(hWnd);
}
return TRUE;
@@ -260,7 +244,7 @@ class CDlgUpdProgress : public CUpdProgress }
return FALSE;
}
- return CUpdProgress::DefWndProc((CUpdProgress *) GetUserData(hWnd), hWnd, uMsg, wParam, lParam);
+ return CUpdProgress::DefWndProc((CUpdProgress *)GetUserData(hWnd), hWnd, uMsg, wParam, lParam);
}
public:
@@ -281,13 +265,12 @@ public: virtual HWND Create(LPCTSTR szTitle, PUpdCallback pFnCallBack)
{
_pFnCallBack = pFnCallBack;
- _hWnd = CreateDialogParam(g_plugin.getInst(),
- MAKEINTRESOURCE(IDD_REFRESHDETAILS),
- nullptr,
- CDlgUpdProgress::WndProc,
- (LPARAM) this);
- if (_hWnd)
- {
+ _hWnd = CreateDialogParam(g_plugin.getInst(),
+ MAKEINTRESOURCE(IDD_REFRESHDETAILS),
+ nullptr,
+ CDlgUpdProgress::WndProc,
+ (LPARAM)this);
+ if (_hWnd) {
SetTitle(szTitle);
ShowWindow(_hWnd, SW_SHOW);
}
@@ -300,8 +283,7 @@ public: **/
virtual void Destroy()
{
- if (_hWnd)
- {
+ if (_hWnd) {
SetUserData(_hWnd, NULL);
EndDialog(_hWnd, IDOK);
_hWnd = nullptr;
@@ -343,16 +325,14 @@ class CPopupUpdProgress : public CUpdProgress **/
void UpdateText()
{
- if (_szText)
- {
+ if (_szText) {
INT_PTR cb = mir_wstrlen(_szText) + 8;
- LPTSTR pb = (LPTSTR) mir_alloc(cb * sizeof(wchar_t));
+ LPTSTR pb = (LPTSTR)mir_alloc(cb * sizeof(wchar_t));
- if (pb)
- {
+ if (pb) {
mir_wstrcpy(pb, _szText);
- SendMessage(_hWnd, UM_CHANGEPOPUP, CPT_TITLET, (LPARAM) pb);
+ SendMessage(_hWnd, UM_CHANGEPOPUP, CPT_TITLET, (LPARAM)pb);
}
}
}
@@ -364,18 +344,17 @@ class CPopupUpdProgress : public CUpdProgress * if passed to the default windows procedure.
*
**/
- static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
+ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
// Filter out messages, which must not be passed to default windows procedure or even
// to the callback function!
- switch (uMsg)
- {
+ switch (uMsg) {
case UM_INITPOPUP:
case UM_CHANGEPOPUP:
case UM_FREEPLUGINDATA:
break;
default:
- CUpdProgress::DefWndProc((CUpdProgress *) PUGetPluginData(hWnd), hWnd, uMsg, wParam, lParam);
+ CUpdProgress::DefWndProc((CUpdProgress *)PUGetPluginData(hWnd), hWnd, uMsg, wParam, lParam);
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
@@ -426,11 +405,11 @@ public: // dummy text
_szText = mir_wstrdup(szTitle);
mir_wstrcpy(pd.lptzContactName, _szText);
-
+
mir_wstrcpy(pd.lptzText, L" ");
-
+
_pFnCallBack = pFnCallBack;
- _hWnd = (HWND) CallService(MS_POPUP_ADDPOPUPT, (WPARAM) &pd, APF_RETURN_HWND|APF_NEWDATA);
+ _hWnd = (HWND)CallService(MS_POPUP_ADDPOPUPT, (WPARAM)&pd, APF_RETURN_HWND | APF_NEWDATA);
return _hWnd;
}
@@ -440,8 +419,7 @@ public: **/
virtual void Destroy()
{
- if (_hWnd)
- {
+ if (_hWnd) {
PUDeletePopup(_hWnd);
_hWnd = nullptr;
}
@@ -465,7 +443,7 @@ public: **/
virtual void SetText(LPCTSTR szText)
{
- SendMessage(_hWnd, UM_CHANGEPOPUP, CPT_TEXTT, (LPARAM) mir_wstrdup(szText));
+ SendMessage(_hWnd, UM_CHANGEPOPUP, CPT_TEXTT, (LPARAM)mir_wstrdup(szText));
}
};
@@ -497,25 +475,21 @@ class CContactUpdater : public CContactQueue *
* @return This method returns 0.
**/
- static int DlgProc(HWND, UINT uMsg, WPARAM wParam, LPARAM, CContactUpdater* u)
+ static int DlgProc(HWND, UINT uMsg, WPARAM wParam, LPARAM, CContactUpdater* u)
{
- switch (uMsg)
- {
+ switch (uMsg) {
- /**
- * User has clicked on the skip or cancel button.
- **/
+ /**
+ * User has clicked on the skip or cancel button.
+ **/
case UM_POPUPACTION:
- case WM_COMMAND:
+ case WM_COMMAND:
{
- if (PtrIsValid(u))
- {
- switch (LOWORD(wParam))
- {
+ if (PtrIsValid(u)) {
+ switch (LOWORD(wParam)) {
case IDCANCEL:
{
- if (HIWORD(wParam) == BN_CLICKED)
- {
+ if (HIWORD(wParam) == BN_CLICKED) {
u->Cancel();
}
}
@@ -534,7 +508,7 @@ class CContactUpdater : public CContactQueue * the time is shortend to 4s.
*
* @param wParam - not used
- * @param ack - pointer to an ACKDATA structure containing all
+ * @param ack - pointer to an ACKDATA structure containing all
* data for the acknoledgement.
*
* @return nothing
@@ -547,7 +521,7 @@ class CContactUpdater : public CContactQueue _nContactAcks = (INT_PTR)ack->hProcess;
_hContactAcks = (PBYTE)mir_calloc(sizeof(BYTE) * (INT_PTR)ack->hProcess);
}
-
+
if (ack->result == ACKRESULT_SUCCESS || ack->result == ACKRESULT_FAILED)
_hContactAcks[ack->lParam] = 1;
@@ -569,11 +543,10 @@ class CContactUpdater : public CContactQueue *
* @return nothing
**/
- virtual void OnEmpty()
+ virtual void OnEmpty()
{
// This was the last contact, so destroy the progress window.
- if (_hProtoAckEvent)
- {
+ if (_hProtoAckEvent) {
UnhookEvent(_hProtoAckEvent);
_hProtoAckEvent = nullptr;
}
@@ -584,8 +557,7 @@ class CContactUpdater : public CContactQueue _hContact = NULL;
// close progress bar
- if (_pProgress)
- {
+ if (_pProgress) {
_pProgress->Destroy();
delete _pProgress;
@@ -606,66 +578,44 @@ class CContactUpdater : public CContactQueue *
* @return nothing
**/
+
virtual void Callback(MCONTACT hContact, PVOID)
{
- LPSTR pszProto = Proto_GetBaseAccountName(hContact);
+ LPSTR pszProto = Proto_GetBaseAccountName(hContact);
- if (pszProto && pszProto[0])
- {
+ if (pszProto && pszProto[0]) {
MIR_FREE(_hContactAcks);
_nContactAcks = 0;
_hContact = hContact;
if (!_hProtoAckEvent)
- {
- _hProtoAckEvent = (HANDLE) ThisHookEvent(ME_PROTO_ACK, (EVENTHOOK) &CContactUpdater::OnProtoAck);
- }
+ _hProtoAckEvent = (HANDLE)ThisHookEvent(ME_PROTO_ACK, (EVENTHOOK)&CContactUpdater::OnProtoAck);
if (_pProgress)
- {
- _pProgress->SetTextParam(TranslateT("[b]%s (%S)...[/b]\n%d Contacts remaining"),
- Clist_GetContactDisplayName(_hContact), pszProto, Size());
- }
+ _pProgress->SetTextParam(TranslateT("[b]%s (%S)...[/b]\n%d Contacts remaining"), Clist_GetContactDisplayName(_hContact), pszProto, Size());
+
if (IsProtoOnline(pszProto))
- {
- int i;
- for (i = 0; i < 3 && ProtoChainSend(hContact, PSS_GETINFO, 0, 0); i++)
- {
+ for (int i = 0; i < 3 && ProtoChainSend(hContact, PSS_GETINFO, 0, 0); i++)
Sleep(3000);
- }
- }
}
}
public:
-
- /**
- * This is the default constructor
- *
- **/
CContactUpdater() : CContactQueue()
{
- _hContactAcks = nullptr;
- _nContactAcks = 0;
- _hContact = NULL;
- _pProgress = nullptr;
- _hProtoAckEvent = nullptr;
+ _hContactAcks = nullptr;
+ _nContactAcks = 0;
+ _hContact = NULL;
+ _pProgress = nullptr;
+ _hProtoAckEvent = nullptr;
}
- /**
- *
- *
- **/
~CContactUpdater()
{
RemoveAll();
OnEmpty();
}
- /**
- *
- *
- **/
BOOL QueueAddRefreshContact(MCONTACT hContact, int iWait)
{
LPSTR pszProto = Proto_GetBaseAccountName(hContact);
@@ -676,10 +626,6 @@ public: return 0;
}
- /**
- *
- *
- **/
void RefreshAll()
{
int iWait = 100;
@@ -688,18 +634,15 @@ public: if (QueueAddRefreshContact(hContact, iWait))
iWait += 5000;
- if (Size() && !_pProgress)
- {
- if (ServiceExists(MS_POPUP_CHANGETEXTT) && g_plugin.getByte("PopupProgress", FALSE))
- {
+ if (Size() && !_pProgress) {
+ if (ServiceExists(MS_POPUP_CHANGETEXTT) && g_plugin.getByte("PopupProgress", FALSE)) {
_pProgress = new CPopupUpdProgress(this);
}
- else
- {
+ else {
_pProgress = new CDlgUpdProgress(this);
}
- _pProgress->Create(TranslateT("Refresh contact details"), (PUpdCallback) CContactUpdater::DlgProc);
+ _pProgress->Create(TranslateT("Refresh contact details"), (PUpdCallback)CContactUpdater::DlgProc);
_pProgress->SetText(TranslateT("Preparing..."));
}
@@ -708,10 +651,6 @@ public: Menu_ModifyItem(hMenuItemRefresh, LPGENW("Abort Refreshing Contact Details"), IcoLib_GetIcon(ICO_BTN_CANCEL));
}
- /**
- *
- *
- **/
void Cancel()
{
RemoveAll();
@@ -725,14 +664,15 @@ static CContactUpdater *ContactUpdater = nullptr; * common helper functions
***********************************************************************************************************/
-/**
- * This function checks, whether at least one protocol is online!
- *
- * @param none
- *
- * @retval TRUE - At least one protocol is online.
- * @retval FALSE - All protocols are offline.
- **/
+ /**
+ * This function checks, whether at least one protocol is online!
+ *
+ * @param none
+ *
+ * @retval TRUE - At least one protocol is online.
+ * @retval FALSE - All protocols are offline.
+ **/
+
static BOOL IsMirandaOnline()
{
for (auto &pa : Accounts())
@@ -746,47 +686,35 @@ static BOOL IsMirandaOnline() * services
***********************************************************************************************************/
-/**
- * This is the service function being called by MS_USERINFO_REFRESH.
- * It adds each contact, whose protocol is online, to the queue of contacts to refresh.
- * The queue is running a separate thread, which is responsible for requesting the contact information
- * one after another with a certain time to wait in between.
- *
- * @param wParam - not used
- * @param lParam - not used
- *
- * @return This service function always returns 0.
- **/
+ /**
+ * This is the service function being called by MS_USERINFO_REFRESH.
+ * It adds each contact, whose protocol is online, to the queue of contacts to refresh.
+ * The queue is running a separate thread, which is responsible for requesting the contact information
+ * one after another with a certain time to wait in between.
+ *
+ * @param wParam - not used
+ * @param lParam - not used
+ *
+ * @return This service function always returns 0.
+ **/
+
static INT_PTR RefreshService(WPARAM, LPARAM)
{
- try
- {
- if (IsMirandaOnline())
- {
- if (!ContactUpdater)
- {
- ContactUpdater = new CContactUpdater();
- }
-
- if (ContactUpdater->Size() == 0)
- {
- ContactUpdater->RefreshAll();
- }
- else if (IDYES == MsgBox(nullptr, MB_YESNO|MB_ICON_QUESTION, LPGENW("Refresh contact details"), nullptr,
- LPGENW("Do you want to cancel the current refresh procedure?")))
- {
- ContactUpdater->Cancel();
- }
- }
- else
- {
- MsgErr(nullptr, LPGENW("Miranda must be online for refreshing contact information!"));
- }
+ if (!IsMirandaOnline()) {
+ MsgErr(nullptr, LPGENW("Miranda must be online for refreshing contact information!"));
+ return 0;
}
- catch(...)
- {
- MsgErr(nullptr, LPGENW("The function caused an exception!"));
+
+ if (!ContactUpdater)
+ ContactUpdater = new CContactUpdater();
+
+ if (ContactUpdater->Size() == 0)
+ ContactUpdater->RefreshAll();
+ else if (IDYES == MsgBox(nullptr, MB_YESNO | MB_ICON_QUESTION, LPGENW("Refresh contact details"), nullptr,
+ LPGENW("Do you want to cancel the current refresh procedure?"))) {
+ ContactUpdater->Cancel();
}
+
return 0;
}
@@ -794,39 +722,22 @@ static INT_PTR RefreshService(WPARAM, LPARAM) * events
***********************************************************************************************************/
-/**
- *
- *
- **/
static int OnContactAdded(WPARAM hContact, LPARAM)
{
- try
- {
- DWORD dwStmp = db_get_dw(hContact, USERINFO, SET_CONTACT_ADDEDTIME, 0);
- if (!dwStmp)
- {
- MTime mt;
-
- mt.GetLocalTime();
- mt.DBWriteStamp(hContact, USERINFO, SET_CONTACT_ADDEDTIME);
-
- // create updater, if not yet exists
- if (!ContactUpdater)
- {
- ContactUpdater = new CContactUpdater();
- }
-
- // add to the end of the queue
- ContactUpdater->AddIfDontHave(
- (ContactUpdater->Size() > 0)
- ? max(ContactUpdater->Get(ContactUpdater->Size() - 1)->check_time + 15000, 4000)
- : 4000, hContact);
- }
- }
- catch(...)
- {
- MsgErr(nullptr, LPGENW("The function caused an exception!"));
+ DWORD dwStmp = db_get_dw(hContact, USERINFO, SET_CONTACT_ADDEDTIME, 0);
+ if (!dwStmp) {
+ MTime mt;
+ mt.GetLocalTime();
+ mt.DBWriteStamp(hContact, USERINFO, SET_CONTACT_ADDEDTIME);
+
+ // create updater, if not yet exists
+ if (!ContactUpdater)
+ ContactUpdater = new CContactUpdater();
+
+ // add to the end of the queue
+ ContactUpdater->AddIfDontHave((ContactUpdater->Size() > 0) ? max(ContactUpdater->Get(ContactUpdater->Size() - 1)->check_time + 15000, 4000) : 4000, hContact);
}
+
return 0;
}
@@ -839,6 +750,7 @@ static int OnContactAdded(WPARAM hContact, LPARAM) *
* @return This function always returns 0.
**/
+
static int OnPreShutdown(WPARAM, LPARAM)
{
if (ContactUpdater) {
@@ -853,9 +765,6 @@ static int OnPreShutdown(WPARAM, LPARAM) * initialization
***********************************************************************************************************/
-/**
- * This function initially loads the module upon startup.
- **/
void SvcRefreshContactInfoLoadModule(void)
{
CreateServiceFunction(MS_USERINFO_REFRESH, RefreshService);
|