summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlad Mironov <mironych@googlemail.com>2014-03-31 04:00:46 +0000
committerVlad Mironov <mironych@googlemail.com>2014-03-31 04:00:46 +0000
commita918638dd89a73a51023e5bafe7d5a0ee09bf9d2 (patch)
treef648fff1bf199dcd2afd2a2d45b4f386b62eb007
parent8503aa4ab16e26af462917ee72d0902338dec7f1 (diff)
Variables: added ability to get a contact info by handle.
git-svn-id: http://svn.miranda-ng.org/main/trunk@8804 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--plugins/Variables/src/contact.cpp38
1 files changed, 21 insertions, 17 deletions
diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp
index ff139c7e93..64d4dfb308 100644
--- a/plugins/Variables/src/contact.cpp
+++ b/plugins/Variables/src/contact.cpp
@@ -227,29 +227,33 @@ int getContactFromString(CONTACTSINFO *ci)
}
/* contact was not in cache, do a search */
- for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact)) {
+ for (MCONTACT hContact = db_find_first(); hContact; hContact = db_find_next(hContact))
+ {
+ TCHAR *szFind = NULL;
+ BOOL bMatch = FALSE;
+
+ // <_HANDLE_:hContact>
+ size_t size = _tcslen(_T(PROTOID_HANDLE)) + 36;
+ szFind = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
+ if (szFind != NULL)
+ {
+ mir_sntprintf(szFind, size, _T("<%s:%p>"), _T(PROTOID_HANDLE), hContact);
+ if (!_tcsncmp(tszContact, szFind, _tcslen(tszContact)))
+ bMatch = TRUE;
+
+ mir_free(szFind);
+ }
+
char *szProto = GetContactProto(hContact);
if (szProto == NULL)
continue;
// <proto:id> (exact)
- TCHAR *szFind = NULL;
- BOOL bMatch = FALSE;
- if (ci->flags & CI_PROTOID) {
+ if ((ci->flags & CI_PROTOID) && !bMatch)
+ {
TCHAR *cInfo = getContactInfoT(CNF_UNIQUEID, hContact);
- if (cInfo == NULL) {
- // <HANDLE:hContact>
- size_t size = _tcslen(_T(PROTOID_HANDLE)) + 36;
- szFind = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
- if (szFind != NULL) {
- mir_sntprintf(szFind, size, _T("<%s:%p>"), _T(PROTOID_HANDLE), hContact);
- if (!_tcsncmp(tszContact, szFind, _tcslen(tszContact)))
- bMatch = TRUE;
-
- mir_free(szFind);
- }
- }
- else {
+ if (cInfo)
+ {
size_t size = _tcslen(cInfo) + strlen(szProto) + 4;
szFind = (TCHAR *)mir_alloc(size * sizeof(TCHAR));
if (szFind != NULL) {