diff options
author | George Hazan <george.hazan@gmail.com> | 2015-05-31 11:46:05 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-05-31 11:46:05 +0000 |
commit | 1ce3da1cca093143d9629bc46e221dd8be962e12 (patch) | |
tree | b99d12d635a65f8c78499137137df2bd591b50be /protocols/JabberG | |
parent | 03512ff2ed0f3d1ed6857ee85b0eb7268931ec3f (diff) |
- MAllStrings: a handy union to hold an incoming string parameter of any type;
- FNAMECHAR: atavism extincted;
- PROTOSEARCHRESULT: structure prepared to use results of any type, including utf
git-svn-id: http://svn.miranda-ng.org/main/trunk@13932 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG')
-rw-r--r-- | protocols/JabberG/src/jabber_chat.cpp | 14 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iqid.cpp | 66 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_proto.cpp | 20 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_search.cpp | 22 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_search.h | 9 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_svc.cpp | 12 |
6 files changed, 67 insertions, 76 deletions
diff --git a/protocols/JabberG/src/jabber_chat.cpp b/protocols/JabberG/src/jabber_chat.cpp index 349853f05a..4ac3010bea 100644 --- a/protocols/JabberG/src/jabber_chat.cpp +++ b/protocols/JabberG/src/jabber_chat.cpp @@ -1208,18 +1208,18 @@ static void sttNickListHook(CJabberProto *ppro, JABBER_LIST_ITEM *item, GCHOOK* case IDM_RJID_ADD:
if (him->m_tszRealJid && *him->m_tszRealJid) {
- PROTOSEARCHRESULT jsr = { 0 };
- jsr.cbSize = sizeof(jsr);
- jsr.flags = PSR_TCHAR;
- jsr.id = NEWTSTR_ALLOCA(him->m_tszRealJid);
- if (TCHAR *tmp = _tcschr(jsr.id, _T('/')))
+ PROTOSEARCHRESULT psr = { 0 };
+ psr.cbSize = sizeof(psr);
+ psr.flags = PSR_TCHAR;
+ psr.id.t = NEWTSTR_ALLOCA(him->m_tszRealJid);
+ if (TCHAR *tmp = _tcschr(psr.id.t, _T('/')))
*tmp = 0;
- jsr.nick = jsr.id;
+ psr.nick.t = psr.id.t;
ADDCONTACTSTRUCT acs = { 0 };
acs.handleType = HANDLE_SEARCHRESULT;
acs.szProto = ppro->m_szModuleName;
- acs.psr = &jsr;
+ acs.psr = &psr;
CallService(MS_ADDCONTACT_SHOW, (WPARAM)CallService(MS_CLUI_GETHWND, 0, 0), (LPARAM)&acs);
}
break;
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index 53b84ba56e..dfe3246216 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -661,15 +661,15 @@ void CJabberProto::OnIqResultGetVcard(HXML iqNode, CJabberIqInfo*) if ((vCardNode = xmlGetChild(iqNode , "vCard")) != NULL) {
if (!mir_tstrcmp(type, _T("result"))) {
- PROTOSEARCHRESULT jsr = { 0 };
- jsr.cbSize = sizeof(jsr);
- jsr.flags = PSR_TCHAR;
- jsr.nick = sttGetText(vCardNode, "NICKNAME");
- jsr.firstName = sttGetText(vCardNode, "FN");
- jsr.lastName = _T("");
- jsr.email = sttGetText(vCardNode, "EMAIL");
- jsr.id = NEWTSTR_ALLOCA(jid);
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&jsr);
+ PROTOSEARCHRESULT psr = { 0 };
+ psr.cbSize = sizeof(psr);
+ psr.flags = PSR_TCHAR;
+ psr.nick.t = sttGetText(vCardNode, "NICKNAME");
+ psr.firstName.t = sttGetText(vCardNode, "FN");
+ psr.lastName.t = _T("");
+ psr.email.t = sttGetText(vCardNode, "EMAIL");
+ psr.id.t = NEWTSTR_ALLOCA(jid);
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&psr);
ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
}
else if (!mir_tstrcmp(type, _T("error")))
@@ -1136,8 +1136,8 @@ void CJabberProto::OnIqResultSetSearch(HXML iqNode, CJabberIqInfo*) if ((queryNode = xmlGetChild(iqNode, "query")) == NULL)
return;
- PROTOSEARCHRESULT jsr = { 0 };
- jsr.cbSize = sizeof(jsr);
+ PROTOSEARCHRESULT psr = { 0 };
+ psr.cbSize = sizeof(psr);
for (int i = 0;; i++) {
HXML itemNode = xmlGetChild(queryNode, i);
if (!itemNode)
@@ -1145,26 +1145,26 @@ void CJabberProto::OnIqResultSetSearch(HXML iqNode, CJabberIqInfo*) if (!mir_tstrcmp(xmlGetName(itemNode), _T("item"))) {
if ((jid = xmlGetAttrValue(itemNode, _T("jid"))) != NULL) {
- jsr.id = (TCHAR*)jid;
+ psr.id.t = (TCHAR*)jid;
debugLog(_T("Result jid = %s"), jid);
if ((n = xmlGetChild(itemNode, "nick")) != NULL && xmlGetText(n) != NULL)
- jsr.nick = (TCHAR*)xmlGetText(n);
+ psr.nick.t = (TCHAR*)xmlGetText(n);
else
- jsr.nick = _T("");
+ psr.nick.t = _T("");
if ((n = xmlGetChild(itemNode, "first")) != NULL && xmlGetText(n) != NULL)
- jsr.firstName = (TCHAR*)xmlGetText(n);
+ psr.firstName.t = (TCHAR*)xmlGetText(n);
else
- jsr.firstName = _T("");
+ psr.firstName.t = _T("");
if ((n = xmlGetChild(itemNode, "last")) != NULL && xmlGetText(n) != NULL)
- jsr.lastName = (TCHAR*)xmlGetText(n);
+ psr.lastName.t = (TCHAR*)xmlGetText(n);
else
- jsr.lastName = _T("");
+ psr.lastName.t = _T("");
if ((n = xmlGetChild(itemNode, "email")) != NULL && xmlGetText(n) != NULL)
- jsr.email = (TCHAR*)xmlGetText(n);
+ psr.email.t = (TCHAR*)xmlGetText(n);
else
- jsr.email = _T("");
- jsr.flags = PSR_TCHAR;
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&jsr);
+ psr.email.t = _T("");
+ psr.flags = PSR_TCHAR;
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&psr);
}
}
}
@@ -1198,9 +1198,9 @@ void CJabberProto::OnIqResultExtSearch(HXML iqNode, CJabberIqInfo*) if (mir_tstrcmp(xmlGetName(itemNode), _T("item")))
continue;
- PROTOSEARCHRESULT jsr = { 0 };
- jsr.cbSize = sizeof(jsr);
- jsr.flags = PSR_TCHAR;
+ PROTOSEARCHRESULT psr = { 0 };
+ psr.cbSize = sizeof(psr);
+ psr.flags = PSR_TCHAR;
for (int j=0; ; j++) {
HXML fieldNode = xmlGetChild(itemNode ,j);
@@ -1219,22 +1219,22 @@ void CJabberProto::OnIqResultExtSearch(HXML iqNode, CJabberIqInfo*) continue;
if (!mir_tstrcmp(fieldName, _T("jid"))) {
- jsr.id = (TCHAR*)xmlGetText(n);
- debugLog(_T("Result jid = %s"), jsr.id);
+ psr.id.t = (TCHAR*)xmlGetText(n);
+ debugLog(_T("Result jid = %s"), psr.id.t);
}
else if (!mir_tstrcmp(fieldName, _T("nickname")))
- jsr.nick = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
+ psr.nick.t = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
else if (!mir_tstrcmp(fieldName, _T("fn")))
- jsr.firstName = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
+ psr.firstName.t = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
else if (!mir_tstrcmp(fieldName, _T("given")))
- jsr.firstName = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
+ psr.firstName.t = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
else if (!mir_tstrcmp(fieldName, _T("family")))
- jsr.lastName = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
+ psr.lastName.t = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
else if (!mir_tstrcmp(fieldName, _T("email")))
- jsr.email = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
+ psr.email.t = (xmlGetText(n) != NULL) ? (TCHAR*)xmlGetText(n) : _T("");
}
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&jsr);
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)id, (LPARAM)&psr);
}
ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 6fcc49e023..ee87d26b89 100644 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -332,10 +332,10 @@ MCONTACT CJabberProto::AddToListByJID(const TCHAR *newJid, DWORD flags) MCONTACT CJabberProto::AddToList(int flags, PROTOSEARCHRESULT* psr)
{
- if (psr->cbSize != sizeof(PROTOSEARCHRESULT) && psr->id == NULL)
+ if (psr->cbSize != sizeof(PROTOSEARCHRESULT) && psr->id.t == NULL)
return NULL;
- return AddToListByJID(psr->id, flags);
+ return AddToListByJID(psr->id.t, flags);
}
MCONTACT __cdecl CJabberProto::AddToListByEvent(int flags, int /*iContact*/, MEVENT hDbEvent)
@@ -681,15 +681,15 @@ void __cdecl CJabberProto::BasicSearchThread(JABBER_SEARCH_BASIC *jsb) {
Sleep(100);
- PROTOSEARCHRESULT jsr = { 0 };
- jsr.cbSize = sizeof(jsr);
- jsr.flags = PSR_TCHAR;
- jsr.nick = jsb->jid;
- jsr.firstName = _T("");
- jsr.lastName = _T("");
- jsr.id = jsb->jid;
+ PROTOSEARCHRESULT psr = { 0 };
+ psr.cbSize = sizeof(psr);
+ psr.flags = PSR_TCHAR;
+ psr.nick.t = jsb->jid;
+ psr.firstName.t = _T("");
+ psr.lastName.t = _T("");
+ psr.id.t = jsb->jid;
- ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)jsb->hSearch, (LPARAM)&jsr);
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)jsb->hSearch, (LPARAM)&psr);
ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)jsb->hSearch, 0);
mir_free(jsb);
}
diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp index 292ecaeb97..8cca0b3109 100644 --- a/protocols/JabberG/src/jabber_search.cpp +++ b/protocols/JabberG/src/jabber_search.cpp @@ -33,7 +33,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /////////////////////////////////////////////////////////////////////////////// // Subclassing of IDC_FRAME to implement more user-friendly fields scrolling -// + static int JabberSearchFrameProc(HWND hwnd, int msg, WPARAM wParam, LPARAM lParam) { if (msg == WM_COMMAND && lParam != 0) { @@ -84,7 +84,7 @@ static int JabberSearchFrameProc(HWND hwnd, int msg, WPARAM wParam, LPARAM lPara /////////////////////////////////////////////////////////////////////////////// // Add Search field to form -// + static int JabberSearchAddField(HWND hwndDlg, Data* FieldDat) { if (!FieldDat || !FieldDat->Label || !FieldDat->Var) @@ -234,7 +234,7 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M // now lets transfer field names int nFieldCount = ListOfFields.getCount(); - JABBER_CUSTOMSEARCHRESULTS Results = { 0 }; + CUSTOMSEARCHRESULTS Results = { 0 }; Results.nSize = sizeof(Results); Results.pszFields = (TCHAR**)mir_alloc(sizeof(TCHAR*)*nFieldCount); Results.nFieldCount = nFieldCount; @@ -246,11 +246,11 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M Results.pszFields[i] = pmAllFields->operator [](var); } - Results.jsr.cbSize = 0; // sending column names + Results.psr.cbSize = 0; // sending column names ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM) &Results); /* Sending Users Data */ - Results.jsr.cbSize = sizeof(Results.jsr); // sending user data + Results.psr.cbSize = sizeof(Results.psr); // sending user data for (i=0; i < nUsersFound; i++) { TCHAR buff[200]; @@ -261,7 +261,7 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M TCHAR *value = pmUserData->operator [](var); Results.pszFields[j] = value ? value : (TCHAR *)_T(" "); if (!mir_tstrcmpi(var,_T("jid")) && value) - Results.jsr.id = value; + Results.psr.id.t = value; } TCHAR *nick = NULL; @@ -269,18 +269,18 @@ void CJabberProto::SearchReturnResults(HANDLE id, void * pvUsersInfo, U_TCHAR_M nick = pmUserData->operator [](nickfields[k]); if (nick) { - if (mir_tstrcmpi(nick, Results.jsr.id)) - mir_sntprintf(buff, SIZEOF(buff), _T("%s (%s)"), nick, Results.jsr.id); + if (mir_tstrcmpi(nick, Results.psr.id.t)) + mir_sntprintf(buff, SIZEOF(buff), _T("%s (%s)"), nick, Results.psr.id.t); else _tcsncpy_s(buff, nick, _TRUNCATE); nick = buff; } - Results.jsr.nick = nick; - Results.jsr.flags = PSR_TCHAR; + Results.psr.nick.t = nick; + Results.psr.flags = PSR_TCHAR; ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM) &Results); - Results.jsr.nick=NULL; + Results.psr.nick.t = NULL; } mir_free(Results.pszFields); } diff --git a/protocols/JabberG/src/jabber_search.h b/protocols/JabberG/src/jabber_search.h index dc7a442aca..3af25191e4 100644 --- a/protocols/JabberG/src/jabber_search.h +++ b/protocols/JabberG/src/jabber_search.h @@ -60,15 +60,6 @@ typedef struct tag_Data } Data;
-
-typedef struct tagJABBER_CUSTOMSEARCHRESULTS
-{
- size_t nSize;
- int nFieldCount;
- TCHAR ** pszFields;
- PROTOSEARCHRESULT jsr;
-}JABBER_CUSTOMSEARCHRESULTS;
-
static HWND searchHandleDlg=NULL;
//local functions declarations
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index 669871a203..b175f9c426 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -464,16 +464,16 @@ INT_PTR __cdecl CJabberProto::JabberServiceParseXmppURI(WPARAM, LPARAM lParam) if (!mir_tstrcmpi(szCommand, _T("roster"))) {
if (!HContactFromJID(szJid)) {
- PROTOSEARCHRESULT jsr = { 0 };
- jsr.cbSize = sizeof(jsr);
- jsr.flags = PSR_TCHAR;
- jsr.nick = szJid;
- jsr.id = szJid;
+ PROTOSEARCHRESULT psr = { 0 };
+ psr.cbSize = sizeof(psr);
+ psr.flags = PSR_TCHAR;
+ psr.nick.t = szJid;
+ psr.id.t = szJid;
ADDCONTACTSTRUCT acs;
acs.handleType = HANDLE_SEARCHRESULT;
acs.szProto = m_szModuleName;
- acs.psr = &jsr;
+ acs.psr = &psr;
CallService(MS_ADDCONTACT_SHOW, 0, (LPARAM)&acs);
}
return 0;
|