summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/JabberG/src')
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.h1
-rw-r--r--protocols/JabberG/src/jabber_search.cpp101
-rw-r--r--protocols/JabberG/src/jabber_search.h54
3 files changed, 78 insertions, 78 deletions
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index 3bea53160a..40227f952c 100755
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -700,7 +700,6 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
//---- jabber_search.cpp -------------------------------------------------------------
- void SearchReturnResults(HANDLE id, void* pvUsersInfo, UNIQUE_MAP *pmAllFields);
void OnIqResultAdvancedSearch(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
void OnIqResultGetSearchFields(const TiXmlElement *iqNode, CJabberIqInfo *pInfo);
int SearchRenewFields(HWND hwndDlg, JabberSearchData * dat);
diff --git a/protocols/JabberG/src/jabber_search.cpp b/protocols/JabberG/src/jabber_search.cpp
index 4cfb616394..24bdfe9ce4 100644
--- a/protocols/JabberG/src/jabber_search.cpp
+++ b/protocols/JabberG/src/jabber_search.cpp
@@ -202,33 +202,32 @@ void CJabberProto::OnIqResultGetSearchFields(const TiXmlElement *iqNode, CJabber
// The pmFields is the pointer to map of <field Name, field Label> Not unical but ordered
// This can help to made result parser routines more simple
-static wchar_t *nickfields[] = { L"nick", L"nickname", L"fullname", L"name", L"given", L"first", L"jid", nullptr };
+static char *nickfields[] = { "nick", "nickname", "fullname", "name", "given", "first", "jid", nullptr };
-static int TCharKeyCmp(const wchar_t *p1, const wchar_t *p2)
+static int TCharKeyCmp(const char *p1, const char *p2)
{
- return mir_wstrcmpi(p1, p2);
+ return mir_strcmpi(p1, p2);
}
-void CJabberProto::SearchReturnResults(HANDLE id, void *pvUsersInfo, UNIQUE_MAP *pmAllFields)
+static void SearchReturnResults(CJabberProto *ppro, HANDLE id, LIST<UNIQUE_MAP> &plUsersInfo, UNIQUE_MAP &pmAllFields)
{
- LIST<wchar_t> ListOfNonEmptyFields(20, TCharKeyCmp);
- LIST<wchar_t> ListOfFields(20);
- LIST<UNIQUE_MAP> *plUsersInfo = (LIST<UNIQUE_MAP>*)pvUsersInfo;
+ LIST<char> ListOfNonEmptyFields(20, TCharKeyCmp);
+ LIST<char> ListOfFields(20);
// lets fill the ListOfNonEmptyFields but in users order
- for (auto &pmUserData : *plUsersInfo) {
+ for (auto &pmUserData : plUsersInfo) {
int nUserFields = pmUserData->getCount();
for (int j = 0; j < nUserFields; j++) {
- wchar_t *var = pmUserData->getKeyName(j);
+ char *var = pmUserData->getKeyName(j);
if (var && ListOfNonEmptyFields.getIndex(var) < 0)
ListOfNonEmptyFields.insert(var);
}
}
// now fill the ListOfFields but order is from pmAllFields
- int nAllCount = pmAllFields->getCount();
+ int nAllCount = pmAllFields.getCount();
for (int i = 0; i < nAllCount; i++) {
- wchar_t *var = pmAllFields->getUnOrderedKeyName(i);
+ char *var = pmAllFields.getUnOrderedKeyName(i);
if (var && ListOfNonEmptyFields.getIndex(var) < 0)
continue;
ListOfFields.insert(var);
@@ -244,46 +243,50 @@ void CJabberProto::SearchReturnResults(HANDLE id, void *pvUsersInfo, UNIQUE_MAP
// Sending Columns Titles
for (int i = 0; i < nFieldCount; i++) {
- wchar_t *var = ListOfFields[i];
+ char *var = ListOfFields[i];
if (var)
- Results.pszFields[i] = pmAllFields->operator [](var);
+ Results.pszFields[i] = mir_utf8decodeW(pmAllFields[var]);
}
Results.psr.cbSize = 0; // sending column names
- ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM)&Results);
+ ppro->ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM)&Results);
+ for (int i = 0; i < nFieldCount; i++)
+ replaceStrW(Results.pszFields[i], nullptr);
// Sending Users Data
Results.psr.cbSize = sizeof(Results.psr);
- for (auto &pmUserData : *plUsersInfo) {
- wchar_t buff[200];
- buff[0] = 0;
+ for (auto &pmUserData : plUsersInfo) {
for (int j = 0; j < nFieldCount; j++) {
- wchar_t *var = ListOfFields[j];
- wchar_t *value = pmUserData->operator [](var);
- Results.pszFields[j] = value ? value : (wchar_t *)L" ";
- if (!mir_wstrcmpi(var, L"jid") && value)
- Results.psr.id.w = value;
+ char *var = ListOfFields[j];
+ char *value = pmUserData->operator [](var);
+ Results.pszFields[j] = value ? mir_utf8decodeW(value) : mir_wstrdup(L" ");
+ if (!mir_strcmpi(var, "jid") && value)
+ Results.psr.id.w = Results.pszFields[j];
}
- wchar_t *nick = nullptr;
+ const char *nick = nullptr;
for (int k = 0; k < _countof(nickfields) && !nick; k++)
nick = pmUserData->operator [](nickfields[k]);
if (nick) {
- if (mir_wstrcmpi(nick, Results.psr.id.w))
- mir_snwprintf(buff, L"%s (%s)", nick, Results.psr.id.w);
+ Utf2T wszNick(nick);
+ wchar_t buff[200];
+ if (mir_wstrcmpi(wszNick, Results.psr.id.w))
+ mir_snwprintf(buff, L"%s (%s)", wszNick, Results.psr.id.w);
else
- wcsncpy_s(buff, nick, _TRUNCATE);
+ wcsncpy_s(buff, wszNick, _TRUNCATE);
- nick = buff;
+ Results.psr.nick.w = buff;
}
- Results.psr.nick.w = nick;
+ else Results.psr.nick.w = L"";
Results.psr.flags = PSR_UNICODE;
- ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM)&Results);
- Results.psr.nick.w = nullptr;
+ ppro->ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SEARCHRESULT, id, (LPARAM)&Results);
+ for (int i = 0; i < nFieldCount; i++)
+ replaceStrW(Results.pszFields[i], nullptr);
}
+
mir_free(Results.pszFields);
}
@@ -296,7 +299,7 @@ void CJabberProto::OnIqResultAdvancedSearch(const TiXmlElement *iqNode, CJabberI
int id;
UNIQUE_MAP mColumnsNames(10);
- LIST<void> SearchResults(2);
+ LIST<UNIQUE_MAP> SearchResults(2);
if (((id = JabberGetPacketID(iqNode)) == -1) || ((type = XmlGetAttr(iqNode, "type")) == nullptr)) {
ProtoBroadcastAck(0, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)id, 0);
@@ -309,22 +312,21 @@ void CJabberProto::OnIqResultAdvancedSearch(const TiXmlElement *iqNode, CJabberI
if (xNode) {
// 1. Form search results info
for (auto *fieldNode : TiXmlFilter(XmlFirstChild(xNode, "reported"), "field")) {
- const char *var = XmlGetAttr(fieldNode, "var");
+ auto *var = XmlGetAttr(fieldNode, "var");
if (var) {
- Utf2T wszVar(var), wszLabel(XmlGetAttr(fieldNode, "label"));
- mColumnsNames.insert(wszVar, (wszLabel != nullptr) ? wszLabel: wszVar);
+ auto *label = XmlGetAttr(fieldNode, "label");
+ mColumnsNames.insert(var, (label != nullptr) ? label : var);
}
}
for (auto *itemNode : TiXmlFilter(xNode, "item")) {
UNIQUE_MAP *pUserColumn = new UNIQUE_MAP(10);
for (auto *fieldNode : TiXmlFilter(itemNode, "field")) {
- if (const char* var = XmlGetAttr(fieldNode, "var")) {
+ if (auto *var = XmlGetAttr(fieldNode, "var")) {
if (auto *textNode = XmlFirstChild(fieldNode, "value")) {
- Utf2T wszVar(var), wszText(textNode->GetText());
- if (!mColumnsNames[wszVar.get()])
- mColumnsNames.insert(wszVar, wszVar);
- pUserColumn->insert(wszVar, wszText);
+ if (!mColumnsNames[var])
+ mColumnsNames.insert(var, var);
+ pUserColumn->insert(var, textNode->GetText());
}
}
}
@@ -337,26 +339,25 @@ void CJabberProto::OnIqResultAdvancedSearch(const TiXmlElement *iqNode, CJabberI
for (auto *itemNode : TiXmlFilter(queryNode, "item")) {
UNIQUE_MAP *pUserColumn = new UNIQUE_MAP(10);
- Utf2T jid(XmlGetAttr(itemNode, "jid"));
- wchar_t *keyReturned;
- mColumnsNames.insertCopyKey(L"jid", L"jid", &keyReturned);
- mColumnsNames.insert(L"jid", keyReturned);
- pUserColumn->insertCopyKey(L"jid", jid, nullptr);
+ auto *jid = XmlGetAttr(itemNode, "jid");
+ char *keyReturned;
+ mColumnsNames.insertCopyKey("jid", "jid", &keyReturned);
+ mColumnsNames.insert("jid", keyReturned);
+ pUserColumn->insertCopyKey("jid", jid, nullptr);
for (auto *child : TiXmlEnum(itemNode)) {
const char *szColumnName = child->Name();
if (szColumnName) {
const char *pszChild = child->GetText();
if (pszChild && *pszChild) {
- Utf2T wszVar(szColumnName), wszText(pszChild);
- mColumnsNames.insertCopyKey(wszVar, L"", &keyReturned);
- mColumnsNames.insert(wszVar, keyReturned);
- pUserColumn->insertCopyKey(wszVar, wszText, nullptr);
+ mColumnsNames.insertCopyKey(szColumnName, "", &keyReturned);
+ mColumnsNames.insert(szColumnName, keyReturned);
+ pUserColumn->insertCopyKey(szColumnName, pszChild, nullptr);
}
}
}
- SearchResults.insert((void*)pUserColumn);
+ SearchResults.insert(pUserColumn);
}
}
}
@@ -380,7 +381,7 @@ void CJabberProto::OnIqResultAdvancedSearch(const TiXmlElement *iqNode, CJabberI
return;
}
- SearchReturnResults((HANDLE)id, (void*)&SearchResults, (UNIQUE_MAP *)&mColumnsNames);
+ SearchReturnResults(this, (HANDLE)id, SearchResults, mColumnsNames);
for (auto &it : SearchResults)
delete ((UNIQUE_MAP*)it);
diff --git a/protocols/JabberG/src/jabber_search.h b/protocols/JabberG/src/jabber_search.h
index 4010cb9bd6..7cdccbba91 100644
--- a/protocols/JabberG/src/jabber_search.h
+++ b/protocols/JabberG/src/jabber_search.h
@@ -66,25 +66,24 @@ static HWND searchHandleDlg = nullptr;
// Implementation of MAP class (the list
class UNIQUE_MAP
{
- typedef struct _tagRECORD
+ struct _RECORD
{
- _tagRECORD(wchar_t *key, wchar_t *value = nullptr) { _key = key; _value = value; _order = 0; }
- ~_tagRECORD()
- {
- mir_free(_key);
- _key = nullptr;
- }
- wchar_t *_key;
- wchar_t *_value;
- int _order;
- } _RECORD;
+ _RECORD(char *key, char *value = nullptr) :
+ _key(key),
+ _value(value)
+ { }
+
+ char *_key;
+ char *_value;
+ int _order = 0;
+ };
int _nextOrder;
LIST<_RECORD> _Records;
static int _KeysEqual(const _RECORD *p1, const _RECORD *p2)
{
- return mir_wstrcmpi(p1->_key, p2->_key);
+ return mir_strcmpi(p1->_key, p2->_key);
}
inline int _remove(_RECORD *p)
@@ -100,6 +99,7 @@ class UNIQUE_MAP
}
return 0;
}
+
inline _RECORD* _getUnorderedRec(int index)
{
for (auto &rec : _Records)
@@ -121,9 +121,9 @@ public:
while (record = _Records[i++]) delete record;
}
- int insert(wchar_t *Key, wchar_t *Value)
+ int insert(const char *Key, const char *Value)
{
- _RECORD *rec = new _RECORD(Key, Value);
+ _RECORD *rec = new _RECORD((char*)Key, (char*)Value);
int index = _Records.getIndex(rec);
if (index < 0) {
if (!_Records.insert(rec)) delete rec;
@@ -133,18 +133,18 @@ public:
}
}
else {
- _Records[index]->_value = Value;
+ _Records[index]->_value = (char*)Value;
delete rec;
}
return index;
}
- int insertCopyKey(wchar_t *Key, wchar_t *Value, wchar_t **_KeyReturn)
+ int insertCopyKey(const char *Key, const char *Value, char **_KeyReturn)
{
- _RECORD *rec = new _RECORD(Key, Value);
+ _RECORD *rec = new _RECORD((char*)Key, (char*)Value);
int index = _Records.getIndex(rec);
if (index < 0) {
- wchar_t *newKey = mir_wstrdup(Key);
+ char *newKey = mir_strdup(Key);
if (!_Records.insert(rec)) {
delete rec;
mir_free(newKey);
@@ -160,7 +160,7 @@ public:
}
}
else {
- _Records[index]->_value = Value;
+ _Records[index]->_value = (char*)Value;
if (_KeyReturn)
*_KeyReturn = _Records[index]->_key;
delete rec;
@@ -168,39 +168,39 @@ public:
return index;
}
- inline wchar_t* operator[](wchar_t* _KEY) const
+ inline char* operator[](const char* _KEY) const
{
- _RECORD rec(_KEY);
+ _RECORD rec((char*)_KEY);
int index = _Records.getIndex(&rec);
_RECORD *rv = _Records[index];
if (rv) {
if (rv->_value)
return rv->_value;
else
- return L"";
+ return "";
}
else
return nullptr;
}
- inline wchar_t* operator[](int index) const
+ inline char* operator[](int index) const
{
_RECORD *rv = _Records[index];
if (rv) return rv->_value;
else return nullptr;
}
- inline wchar_t* getKeyName(int index)
+ inline char* getKeyName(int index)
{
_RECORD *rv = _Records[index];
if (rv) return rv->_key;
else return nullptr;
}
- inline wchar_t* getUnOrdered(int index)
+ inline char* getUnOrdered(int index)
{
_RECORD *rec = _getUnorderedRec(index);
if (rec) return rec->_value;
else return nullptr;
}
- inline wchar_t* getUnOrderedKeyName(int index)
+ inline char* getUnOrderedKeyName(int index)
{
_RECORD *rec = _getUnorderedRec(index);
if (rec) return rec->_key;
@@ -222,7 +222,7 @@ public:
if (p) return _remove(p);
else return 0;
}
- inline int getIndex(wchar_t * key)
+ inline int getIndex(char *key)
{
_RECORD temp(key);
return _Records.getIndex(&temp);