diff options
Diffstat (limited to 'protocols/JabberG/src/jabber_misc.cpp')
-rwxr-xr-x | protocols/JabberG/src/jabber_misc.cpp | 162 |
1 files changed, 81 insertions, 81 deletions
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index 4fccb9d3d1..490fbd7c35 100755 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -30,25 +30,25 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ///////////////////////////////////////////////////////////////////////////////
// JabberAddContactToRoster() - adds a contact to the roster
-void CJabberProto::AddContactToRoster(const wchar_t *jid, const wchar_t *nick, const wchar_t *grpName)
+void CJabberProto::AddContactToRoster(const char *jid, const char *nick, const char *grpName)
{
- XmlNodeIq iq(L"set", SerialNext());
- HXML query = iq << XQUERY(JABBER_FEAT_IQ_ROSTER)
- << XCHILD(L"item") << XATTR(L"jid", jid) << XATTR(L"name", nick);
+ XmlNodeIq iq("set", SerialNext());
+ TiXmlElement *query = iq << XQUERY(JABBER_FEAT_IQ_ROSTER)
+ << XCHILD("item") << XATTR("jid", jid) << XATTR("name", nick);
if (grpName)
- query << XCHILD(L"group", grpName);
+ query << XCHILD("group", grpName);
m_ThreadInfo->send(iq);
}
///////////////////////////////////////////////////////////////////////////////
// JabberDBAddAuthRequest()
-void CJabberProto::DBAddAuthRequest(const wchar_t *jid, const wchar_t *nick)
+void CJabberProto::DBAddAuthRequest(const char *jid, const char *nick)
{
MCONTACT hContact = DBCreateContact(jid, nick, true, true);
delSetting(hContact, "Hidden");
- DB_AUTH_BLOB blob(hContact, T2Utf(nick), nullptr, nullptr, T2Utf(jid), nullptr);
+ DB_AUTH_BLOB blob(hContact, nick, nullptr, nullptr, jid, nullptr);
DBEVENTINFO dbei = {};
dbei.szModule = m_szModuleName;
@@ -64,7 +64,7 @@ void CJabberProto::DBAddAuthRequest(const wchar_t *jid, const wchar_t *nick) ///////////////////////////////////////////////////////////////////////////////
// JabberDBCreateContact()
-MCONTACT CJabberProto::DBCreateContact(const wchar_t *jid, const wchar_t *nick, bool temporary, bool stripResource)
+MCONTACT CJabberProto::DBCreateContact(const char *jid, const char *nick, bool temporary, bool stripResource)
{
if (jid == nullptr || jid[0] == '\0')
return 0;
@@ -74,24 +74,24 @@ MCONTACT CJabberProto::DBCreateContact(const wchar_t *jid, const wchar_t *nick, return hContact;
// strip resource if present
- wchar_t szJid[JABBER_MAX_JID_LEN];
+ char szJid[JABBER_MAX_JID_LEN];
if (stripResource)
JabberStripJid(jid, szJid, _countof(szJid));
else
- wcsncpy_s(szJid, jid, _TRUNCATE);
+ strncpy_s(szJid, jid, _TRUNCATE);
MCONTACT hNewContact = db_add_contact();
Proto_AddToContact(hNewContact, m_szModuleName);
- setWString(hNewContact, "jid", szJid);
+ setUString(hNewContact, "jid", szJid);
if (nick != nullptr && *nick != '\0')
- setWString(hNewContact, "Nick", nick);
+ setUString(hNewContact, "Nick", nick);
if (temporary)
db_set_b(hNewContact, "CList", "NotOnList", 1);
else
SendGetVcard(szJid);
if (JABBER_LIST_ITEM *pItem = ListAdd(LIST_ROSTER, jid, hNewContact))
- pItem->bUseResource = wcschr(szJid, '/') != nullptr;
+ pItem->bUseResource = strchr(szJid, '/') != nullptr;
debugLogW(L"Create Jabber contact jid=%s, nick=%s", szJid, nick);
DBCheckIsTransportedContact(szJid, hNewContact);
@@ -171,7 +171,7 @@ void CJabberProto::GetAvatarFileName(MCONTACT hContact, wchar_t* pszDest, size_t ///////////////////////////////////////////////////////////////////////////////
// JabberResolveTransportNicks - massive vcard update
-void CJabberProto::ResolveTransportNicks(const wchar_t *jid)
+void CJabberProto::ResolveTransportNicks(const char *jid)
{
// Set all contacts to offline
MCONTACT hContact = m_ThreadInfo->resolveContact;
@@ -182,15 +182,15 @@ void CJabberProto::ResolveTransportNicks(const wchar_t *jid) if (!getByte(hContact, "IsTransported", 0))
continue;
- ptrW dbJid(getWStringA(hContact, "jid")); if (dbJid == nullptr) continue;
- ptrW dbNick(getWStringA(hContact, "Nick")); if (dbNick == nullptr) continue;
+ ptrA dbJid(getUStringA(hContact, "jid")); if (dbJid == nullptr) continue;
+ ptrA dbNick(getUStringA(hContact, "Nick")); if (dbNick == nullptr) continue;
- wchar_t *p = wcschr(dbJid, '@');
+ char *p = strchr(dbJid, '@');
if (p == nullptr)
continue;
*p = 0;
- if (!mir_wstrcmp(jid, p + 1) && !mir_wstrcmp(dbJid, dbNick)) {
+ if (!mir_strcmp(jid, p + 1) && !mir_strcmp(dbJid, dbNick)) {
*p = '@';
m_ThreadInfo->resolveID = SendGetVcard(dbJid);
m_ThreadInfo->resolveContact = hContact;
@@ -245,26 +245,26 @@ void CJabberProto::SetServerStatus(int iNewStatus) struct
{
- wchar_t *node;
- wchar_t *name;
+ char *node;
+ char *name;
}
static sttCapsNodeToName_Map[] =
{
- { L"http://miranda-im.org", L"Miranda IM Jabber" },
- { L"http://miranda-ng.org", L"Miranda NG Jabber" },
- { L"http://www.google.com", L"GTalk" },
- { L"http://mail.google.com", L"GMail" },
- { L"http://www.android.com", L"Android" },
- { L"http://qip.ru", L"QIP 2012" },
- { L"http://2010.qip.ru", L"QIP 2010"},
- { L"http://conversations.im", L"Conversations IM" }
+ { "http://miranda-im.org", "Miranda IM Jabber" },
+ { "http://miranda-ng.org", "Miranda NG Jabber" },
+ { "http://www.google.com", "GTalk" },
+ { "http://mail.google.com", "GMail" },
+ { "http://www.android.com", "Android" },
+ { "http://qip.ru", "QIP 2012" },
+ { "http://2010.qip.ru", "QIP 2010"},
+ { "http://conversations.im", "Conversations IM" }
};
-const wchar_t* CJabberProto::GetSoftName(const wchar_t *wszName)
+const char* CJabberProto::GetSoftName(const char *szName)
{
// search through known software list
for (auto &it : sttCapsNodeToName_Map)
- if (wcsstr(wszName, it.node))
+ if (strstr(szName, it.node))
return it.name;
return nullptr;
@@ -284,7 +284,7 @@ void CJabberProto::UpdateMirVer(JABBER_LIST_ITEM *item) UpdateMirVer(hContact, pResourceStatus(item->m_pManualResource));
}
-void CJabberProto::FormatMirVer(const pResourceStatus &resource, CMStringW &res)
+void CJabberProto::FormatMirVer(const pResourceStatus &resource, CMStringA &res)
{
res.Empty();
if (resource == nullptr)
@@ -292,48 +292,48 @@ void CJabberProto::FormatMirVer(const pResourceStatus &resource, CMStringW &res) // no caps info? set MirVer = resource name
if (resource->m_pCaps == nullptr) {
- debugLogW(L"JabberUpdateMirVer: for rc %s: %s", resource->m_tszResourceName, resource->m_tszResourceName);
- if (resource->m_tszResourceName)
- res = resource->m_tszResourceName;
+ debugLogA("JabberUpdateMirVer: for rc %s: %s", resource->m_szResourceName, resource->m_szResourceName);
+ if (resource->m_szResourceName)
+ res = resource->m_szResourceName;
}
// XEP-0115 caps mode
else {
CJabberClientPartialCaps *pCaps = resource->m_pCaps;
- debugLogW(L"JabberUpdateMirVer: for rc %s: %s#%s", resource->m_tszResourceName, pCaps->GetNode(), pCaps->GetHash());
+ debugLogA("JabberUpdateMirVer: for rc %s: %s#%s", resource->m_szResourceName, pCaps->GetNode(), pCaps->GetHash());
// unknown software
- const wchar_t *szDefaultName = GetSoftName(pCaps->GetNode());
+ const char *szDefaultName = GetSoftName(pCaps->GetNode());
res = (szDefaultName == nullptr) ? pCaps->GetSoft() : szDefaultName;
if (pCaps->GetSoftVer())
- res.AppendFormat(L" %s", pCaps->GetSoftVer());
+ res.AppendFormat(" %s", pCaps->GetSoftVer());
if (pCaps->GetSoftMir())
- res.AppendFormat(L" %s", pCaps->GetSoftMir());
+ res.AppendFormat(" %s", pCaps->GetSoftMir());
}
// attach additional info for fingerprint plguin
if (resource->m_tszCapsExt) {
- if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX86) && !wcsstr(res, L"x86"))
- res.Append(L" x86");
+ if (strstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX86) && !strstr(res, "x86"))
+ res.Append(" x86");
- if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX64) && !wcsstr(res, L"x64"))
- res.Append(L" x64");
+ if (strstr(resource->m_tszCapsExt, JABBER_EXT_PLATFORMX64) && !strstr(res, "x64"))
+ res.Append(" x64");
- if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_SECUREIM) && !wcsstr(res, L"(SecureIM)"))
- res.Append(L" (SecureIM)");
+ if (strstr(resource->m_tszCapsExt, JABBER_EXT_SECUREIM) && !strstr(res, "(SecureIM)"))
+ res.Append(" (SecureIM)");
- if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_MIROTR) && !wcsstr(res, L"(MirOTR)"))
- res.Append(L" (MirOTR)");
+ if (strstr(resource->m_tszCapsExt, JABBER_EXT_MIROTR) && !strstr(res, "(MirOTR)"))
+ res.Append(" (MirOTR)");
- if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_NEWGPG) && !wcsstr(res, L"(New_GPG)"))
- res.Append(L" (New_GPG)");
+ if (strstr(resource->m_tszCapsExt, JABBER_EXT_NEWGPG) && !strstr(res, "(New_GPG)"))
+ res.Append(" (New_GPG)");
- if (wcsstr(resource->m_tszCapsExt, JABBER_EXT_OMEMO) && !wcsstr(res, L"(omemo)"))
- res.Append(L" (omemo)");
+ if (strstr(resource->m_tszCapsExt, JABBER_EXT_OMEMO) && !strstr(res, "(omemo)"))
+ res.Append(" (omemo)");
}
- if (resource->m_tszResourceName && !wcsstr(res, resource->m_tszResourceName))
- if (wcsstr(res, L"Miranda IM") || wcsstr(res, L"Miranda NG") || m_bShowForeignResourceInMirVer)
- res.AppendFormat(L" [%s]", resource->m_tszResourceName);
+ if (resource->m_szResourceName && !strstr(res, resource->m_szResourceName))
+ if (strstr(res, "Miranda IM") || strstr(res, "Miranda NG") || m_bShowForeignResourceInMirVer)
+ res.AppendFormat(" [%s]", resource->m_szResourceName);
}
void CJabberProto::UpdateMirVer(MCONTACT hContact, const pResourceStatus &r)
@@ -341,21 +341,21 @@ void CJabberProto::UpdateMirVer(MCONTACT hContact, const pResourceStatus &r) if (r == nullptr)
return;
- CMStringW tszMirVer;
+ CMStringA tszMirVer;
FormatMirVer(r, tszMirVer);
if (!tszMirVer.IsEmpty())
- setWString(hContact, "MirVer", tszMirVer);
+ setUString(hContact, "MirVer", tszMirVer);
- ptrW jid(getWStringA(hContact, "jid"));
+ ptrA jid(getUStringA(hContact, "jid"));
if (jid == nullptr)
return;
- wchar_t szFullJid[JABBER_MAX_JID_LEN];
- if (r->m_tszResourceName && !wcschr(jid, '/'))
- mir_snwprintf(szFullJid, L"%s/%s", jid, r->m_tszResourceName);
+ char szFullJid[JABBER_MAX_JID_LEN];
+ if (r->m_szResourceName && !strchr(jid, '/'))
+ mir_snprintf(szFullJid, "%s/%s", jid, r->m_szResourceName);
else
- mir_wstrncpy(szFullJid, jid, _countof(szFullJid));
- setWString(hContact, DBSETTING_DISPLAY_UID, szFullJid);
+ mir_strncpy(szFullJid, jid, _countof(szFullJid));
+ setUString(hContact, DBSETTING_DISPLAY_UID, szFullJid);
}
void CJabberProto::UpdateSubscriptionInfo(MCONTACT hContact, JABBER_LIST_ITEM *item)
@@ -443,28 +443,28 @@ void CJabberProto::MsgPopup(MCONTACT hContact, const wchar_t *szMsg, const wchar }
}
-CMStringW CJabberProto::ExtractImage(HXML node)
+CMStringA CJabberProto::ExtractImage(const TiXmlElement *node)
{
- HXML nHtml, nBody, nImg;
- const wchar_t *src;
- CMStringW link;
-
- if ((nHtml = XmlGetChild(node, "html")) != nullptr &&
- (nBody = XmlGetChild(nHtml, "body")) != nullptr &&
- (nImg = XmlGetChild(nBody, "img")) != nullptr &&
- (src = XmlGetAttrValue(nImg, L"src")) != nullptr) {
-
- CMStringW strSrc(src);
- if (strSrc.Left(11).Compare(L"data:image/") == 0) {
- int end = strSrc.Find(L';');
+ const TiXmlElement *nHtml, *nBody, *nImg;
+ const char *src;
+ CMStringA link;
+
+ if ((nHtml = node->FirstChildElement("html")) != nullptr &&
+ (nBody = nHtml->FirstChildElement("body")) != nullptr &&
+ (nImg = nBody->FirstChildElement("img")) != nullptr &&
+ (src = nImg->Attribute("src")) != nullptr) {
+
+ CMStringA strSrc(src);
+ if (strSrc.Left(11).Compare("data:image/") == 0) {
+ int end = strSrc.Find(';');
if (end != -1) {
CMStringW ext(strSrc.c_str() + 11, end - 11);
int comma = strSrc.Find(L',', end);
if (comma != -1) {
- CMStringW image(strSrc.c_str() + comma + 1, strSrc.GetLength() - comma - 1);
- image.Replace(L"%2B", L"+");
- image.Replace(L"%2F", L"/");
- image.Replace(L"%3D", L"=");
+ CMStringA image(strSrc.c_str() + comma + 1, strSrc.GetLength() - comma - 1);
+ image.Replace("%2B", "+");
+ image.Replace("%2F", "/");
+ image.Replace("%3D", "=");
wchar_t tszTempPath[MAX_PATH], tszTempFile[MAX_PATH];
GetTempPath(_countof(tszTempPath), tszTempPath);
@@ -479,12 +479,12 @@ CMStringW CJabberProto::ExtractImage(HXML node) if (h != INVALID_HANDLE_VALUE) {
DWORD n;
size_t bufferLen;
- ptrA buffer((char*)mir_base64_decode(_T2A(image), &bufferLen));
+ ptrA buffer((char*)mir_base64_decode(image, &bufferLen));
WriteFile(h, buffer, (DWORD)bufferLen, &n, nullptr);
CloseHandle(h);
- link = L" file:///";
- link += tszTempFile;
+ link = " file:///";
+ link += T2Utf(tszTempFile);
}
}
}
|