summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--protocols/JabberG/src/jabber_agent.cpp4
-rw-r--r--protocols/JabberG/src/jabber_bookmarks.cpp12
-rw-r--r--protocols/JabberG/src/jabber_captcha.cpp4
-rw-r--r--protocols/JabberG/src/jabber_ibb.cpp4
-rwxr-xr-xprotocols/JabberG/src/jabber_iqid.cpp4
-rwxr-xr-xprotocols/JabberG/src/jabber_omemo.cpp122
-rw-r--r--protocols/JabberG/src/jabber_privacy.cpp2
-rw-r--r--protocols/JabberG/src/jabber_svc.cpp4
8 files changed, 65 insertions, 91 deletions
diff --git a/protocols/JabberG/src/jabber_agent.cpp b/protocols/JabberG/src/jabber_agent.cpp
index 89320ee344..ba31f2c28d 100644
--- a/protocols/JabberG/src/jabber_agent.cpp
+++ b/protocols/JabberG/src/jabber_agent.cpp
@@ -105,7 +105,7 @@ public:
SetDlgItemText(m_hwnd, IDC_FRAME_TEXT, TranslateT("Please wait..."));
m_proto->m_ThreadInfo->send(
- XmlNodeIq( m_proto->AddIQ(&CJabberProto::OnIqResultGetRegister, JABBER_IQ_TYPE_GET, m_jid))
+ XmlNodeIq(m_proto->AddIQ(&CJabberProto::OnIqResultGetRegister, JABBER_IQ_TYPE_GET, m_jid))
<< XQUERY(JABBER_FEAT_REGISTER));
// Enable WS_EX_CONTROLPARENT on IDC_FRAME (so tab stop goes through all its children)
@@ -236,7 +236,7 @@ public:
wchar_t *str2 = (wchar_t*)alloca(sizeof(wchar_t) * 128);
int id = 0;
- XmlNodeIq iq( m_proto->AddIQ(&CJabberProto::OnIqResultSetRegister, JABBER_IQ_TYPE_SET, from));
+ XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultSetRegister, JABBER_IQ_TYPE_SET, from));
HXML query = iq << XQUERY(JABBER_FEAT_REGISTER);
if ((xNode = XmlGetChild(queryNode , "x")) != NULL) {
diff --git a/protocols/JabberG/src/jabber_bookmarks.cpp b/protocols/JabberG/src/jabber_bookmarks.cpp
index 17cff33d7c..d6cfad7b7b 100644
--- a/protocols/JabberG/src/jabber_bookmarks.cpp
+++ b/protocols/JabberG/src/jabber_bookmarks.cpp
@@ -133,7 +133,7 @@ static INT_PTR CALLBACK JabberAddBookmarkDlgProc(HWND hwndDlg, UINT msg, WPARAM
item->bAutoJoin = IsDlgButtonChecked(hwndDlg, IDC_CHECK_BM_AUTOJOIN) == BST_CHECKED;
- XmlNodeIq iq( param->ppro->AddIQ(&CJabberProto::OnIqResultSetBookmarks, JABBER_IQ_TYPE_SET));
+ XmlNodeIq iq(param->ppro->AddIQ(&CJabberProto::OnIqResultSetBookmarks, JABBER_IQ_TYPE_SET));
param->ppro->SetBookmarkRequest(iq);
param->ppro->m_ThreadInfo->send(iq);
}
@@ -240,7 +240,7 @@ private:
m_lvBookmarks.SetItemState(iItem, 0, LVIS_SELECTED); // Unselect the item
- XmlNodeIq iq( m_proto->AddIQ(&CJabberProto::OnIqResultSetBookmarks, JABBER_IQ_TYPE_SET));
+ XmlNodeIq iq(m_proto->AddIQ(&CJabberProto::OnIqResultSetBookmarks, JABBER_IQ_TYPE_SET));
m_proto->SetBookmarkRequest(iq);
m_proto->m_ThreadInfo->send(iq);
}
@@ -248,9 +248,9 @@ private:
CJabberDlgBookmarks::CJabberDlgBookmarks(CJabberProto *proto) :
CSuper(proto, IDD_BOOKMARKS, NULL),
- m_btnAdd(this, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add")),
- m_btnEdit(this, IDC_EDIT, SKINICON_OTHER_RENAME, LPGEN("Edit")),
- m_btnRemove(this, IDC_REMOVE, SKINICON_OTHER_DELETE, LPGEN("Remove")),
+ m_btnAdd(this, IDC_ADD, SKINICON_OTHER_ADDCONTACT, LPGEN("Add")),
+ m_btnEdit(this, IDC_EDIT, SKINICON_OTHER_RENAME, LPGEN("Edit")),
+ m_btnRemove(this, IDC_REMOVE, SKINICON_OTHER_DELETE, LPGEN("Remove")),
m_lvBookmarks(this, IDC_BM_LIST, true, true)
{
m_lvBookmarks.OnItemActivate = Callback(this, &CJabberDlgBookmarks::lvBookmarks_OnDoubleClick);
@@ -264,7 +264,7 @@ void CJabberDlgBookmarks::UpdateData()
if (!m_proto->m_bJabberOnline) return;
m_proto->m_ThreadInfo->send(
- XmlNodeIq( m_proto->AddIQ(&CJabberProto::OnIqResultDiscoBookmarks, JABBER_IQ_TYPE_GET))
+ XmlNodeIq(m_proto->AddIQ(&CJabberProto::OnIqResultDiscoBookmarks, JABBER_IQ_TYPE_GET))
<< XQUERY(JABBER_FEAT_PRIVATE_STORAGE) << XCHILDNS(L"storage", L"storage:bookmarks"));
}
diff --git a/protocols/JabberG/src/jabber_captcha.cpp b/protocols/JabberG/src/jabber_captcha.cpp
index 73f944de41..c44879fc96 100644
--- a/protocols/JabberG/src/jabber_captcha.cpp
+++ b/protocols/JabberG/src/jabber_captcha.cpp
@@ -168,7 +168,7 @@ bool CJabberProto::ProcessCaptcha(HXML node, HXML parentNode, ThreadData *info)
void CJabberProto::sendCaptchaResult(wchar_t* buf, ThreadData *info, LPCTSTR from, LPCTSTR challenge, LPCTSTR fromjid, LPCTSTR sid)
{
XmlNodeIq iq(L"set", SerialNext());
- HXML query= iq <<XATTR(L"to", from) << XCHILD(L"captcha") << XATTR(L"xmlns", L"urn:xmpp:captcha") << XCHILD (L"x") << XATTR(L"xmlns", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"submit");
+ HXML query= iq <<XATTR(L"to", from) << XCHILDNS(L"captcha", L"urn:xmpp:captcha") << XCHILDNS(L"x", JABBER_FEAT_DATA_FORMS) << XATTR(L"type", L"submit");
query << XCHILD(L"field") << XATTR (L"var", L"FORM_TYPE") << XCHILD(L"value", L"urn:xmpp:captcha");
query << XCHILD(L"field") << XATTR (L"var", L"from") << XCHILD(L"value", fromjid);
query << XCHILD(L"field") << XATTR (L"var", L"challenge") << XCHILD(L"value", challenge);
@@ -182,6 +182,6 @@ void CJabberProto::sendCaptchaError(ThreadData *info, LPCTSTR from, LPCTSTR to,
XmlNode message(L"message");
message << XATTR(L"type", L"error") << XATTR(L"to", from) << XATTR(L"id", challenge) << XATTR(L"from", to)
<< XCHILD(L"error") << XATTR(L"type", L"modify")
- << XCHILD(L"not-acceptable") << XATTR(L"xmlns", L"urn:ietf:params:xml:ns:xmpp-stanzas");
+ << XCHILDNS(L"not-acceptable", L"urn:ietf:params:xml:ns:xmpp-stanzas");
info->send(message);
}
diff --git a/protocols/JabberG/src/jabber_ibb.cpp b/protocols/JabberG/src/jabber_ibb.cpp
index be359f8b48..7f0ad3baa4 100644
--- a/protocols/JabberG/src/jabber_ibb.cpp
+++ b/protocols/JabberG/src/jabber_ibb.cpp
@@ -97,7 +97,7 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb)
jibb->state = JIBB_SENDING;
m_ThreadInfo->send(
- XmlNodeIq( AddIQ(&CJabberProto::OnIbbInitiateResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
+ XmlNodeIq(AddIQ(&CJabberProto::OnIbbInitiateResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
<< XCHILDNS(L"open", JABBER_FEAT_IBB) << XATTR(L"sid", jibb->sid) << XATTRI(L"block-size", JABBER_IBB_BLOCK_SIZE)
<< XATTR(L"stanza", L"message"));
@@ -114,7 +114,7 @@ void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb)
jibb->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
m_ThreadInfo->send(
- XmlNodeIq( AddIQ(&CJabberProto::OnIbbCloseResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
+ XmlNodeIq(AddIQ(&CJabberProto::OnIbbCloseResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
<< XCHILDNS(L"close", JABBER_FEAT_IBB) << XATTR(L"sid", jibb->sid));
WaitForSingleObject(jibb->hEvent, INFINITE);
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index 087ce675a4..0ca4045c29 100755
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -104,7 +104,7 @@ void CJabberProto::OnIqResultNestedRosterGroups(HXML iqNode, CJabberIqInfo *pInf
// roster request
wchar_t *szUserData = mir_wstrdup(szGroupDelimeter ? szGroupDelimeter : L"\\");
m_ThreadInfo->send(
- XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetRoster, JABBER_IQ_TYPE_GET, NULL, 0, -1, (void*)szUserData))
+ XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetRoster, JABBER_IQ_TYPE_GET, NULL, 0, -1, (void*)szUserData))
<< XCHILDNS(L"query", JABBER_FEAT_IQ_ROSTER));
}
@@ -305,7 +305,7 @@ void CJabberProto::OnIqResultBind(HXML iqNode, CJabberIqInfo *pInfo)
}
if (m_ThreadInfo->bIsSessionAvailable)
m_ThreadInfo->send(
- XmlNodeIq( AddIQ(&CJabberProto::OnIqResultSession, JABBER_IQ_TYPE_SET))
+ XmlNodeIq(AddIQ(&CJabberProto::OnIqResultSession, JABBER_IQ_TYPE_SET))
<< XCHILDNS(L"session", L"urn:ietf:params:xml:ns:xmpp-session"));
else
OnLoggedIn();
diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp
index f3a5e8da07..4c54bf96a2 100755
--- a/protocols/JabberG/src/jabber_omemo.cpp
+++ b/protocols/JabberG/src/jabber_omemo.cpp
@@ -598,103 +598,77 @@ wchar_t* StripResourceFromJid(const wchar_t *source)
void CJabberProto::OmemoAnnounceDevice()
{
- //check "OmemoDeviceId%d" for own id and send updated list if not exist
+ // check "OmemoDeviceId%d" for own id and send updated list if not exist
DWORD own_id = omemo::GetOwnDeviceId(this);
- int i = 0;
+
char setting_name[64];
- mir_snprintf(setting_name, "OmemoDeviceId%d", i);
- for (DWORD val = getDword(setting_name, 0); val != 0; ++i, mir_snprintf(setting_name, "OmemoDeviceId%d", i), val = getDword(setting_name, 0))
- {
+ for (int i = 0;; ++i) {
+ mir_snprintf(setting_name, "OmemoDeviceId%d", i);
+ DWORD val = getDword(setting_name);
+ if (val == 0)
+ break;
if (val == own_id)
- return; //nothing to do, list is fresh enough
+ return; // nothing to do, list is fresh enough
}
- //add own device id
- //construct node
- XmlNodeIq iq(L"set", SerialNext());
- iq << XATTR(L"from", ptrW(StripResourceFromJid(m_ThreadInfo->fullJID)));
- HXML pubsub_node = XmlAddChild(iq, L"pubsub");
- xmlAddAttr(pubsub_node, L"xmlns", L"http://jabber.org/protocol/pubsub");
- HXML publish_node = XmlAddChild(pubsub_node, L"publish");
- xmlAddAttr(publish_node, L"node", JABBER_FEAT_OMEMO L":devicelist");
- HXML item_node = XmlAddChild(publish_node, L"item");
- HXML list_node = XmlAddChild(item_node, L"list");
- xmlAddAttr(list_node, L"xmlns", JABBER_FEAT_OMEMO);
- i = 0;
- mir_snprintf(setting_name, "OmemoDeviceId%d", i);
- for (DWORD val = getDword(setting_name, 0); val != 0; ++i, mir_snprintf(setting_name, "OmemoDeviceId%d", i), val = getDword(setting_name, 0))
- {
- HXML device_node = XmlAddChild(list_node, L"device");
- xmlAddAttrInt(device_node, L"id", val);
+ // add own device id
+ // construct node
+ XmlNodeIq iq(L"set", SerialNext()); iq << XATTR(L"from", ptrW(StripResourceFromJid(m_ThreadInfo->fullJID)));
+ HXML publish_node = iq << XCHILDNS(L"pubsub", L"http://jabber.org/protocol/pubsub") << XCHILD(L"publish") << XATTR(L"node", JABBER_FEAT_OMEMO L":devicelist");
+ HXML list_node = publish_node << XCHILDNS(L"list", JABBER_FEAT_OMEMO);
+
+ for (int i = 0; ; ++i) {
+ mir_snprintf(setting_name, "OmemoDeviceId%d", i);
+ DWORD val = getDword(setting_name);
+ if (val == 0)
+ break;
+
+ list_node << XCHILD(L"device") << XATTRI(L"id", val);
}
- HXML device_node = XmlAddChild(list_node, L"device");
- xmlAddAttrInt(device_node, L"id", own_id);
-
- //send device list back
- m_ThreadInfo->send(iq);
+ list_node << XCHILD(L"device") << XATTRI(L"id", own_id);
+ // send device list back
+ m_ThreadInfo->send(iq);
}
void CJabberProto::OmemoSendBundle()
{
- //get own device id
+ // get own device id
DWORD own_id = omemo::GetOwnDeviceId(this);
- //construct bundle node
- XmlNodeIq iq(L"set", SerialNext());
- iq << XATTR(L"from", ptrW(StripResourceFromJid(m_ThreadInfo->fullJID)));
- //TODO: add "from"
- HXML pubsub_node = XmlAddChild(iq, L"pubsub");
- xmlAddAttr(pubsub_node, L"xmlns", L"http://jabber.org/protocol/pubsub");
- HXML publish_node = XmlAddChild(pubsub_node, L"publish");
+ // construct bundle node
+ XmlNodeIq iq(L"set", SerialNext()); iq << XATTR(L"from", ptrW(StripResourceFromJid(m_ThreadInfo->fullJID)));
+ // TODO: add "from"
+ HXML publish_node = iq << XCHILDNS(L"pubsub", L"http://jabber.org/protocol/pubsub") << XCHILD(L"publish");
{
wchar_t attr_val[128];
mir_snwprintf(attr_val, L"%s:bundles:%d", JABBER_FEAT_OMEMO, own_id);
- xmlAddAttr(publish_node, L"node", attr_val);
- }
- HXML item_node = XmlAddChild(publish_node, L"item");
- HXML bundle_node = XmlAddChild(item_node, L"bundle");
- xmlAddAttr(bundle_node, L"xmlns", JABBER_FEAT_OMEMO);
- //add signed pre key public
- {
- HXML signedPreKeyPublic_node = XmlAddChild(bundle_node, L"signedPreKeyPublic");
- xmlAddAttr(signedPreKeyPublic_node, L"signedPreKeyId", L"1");
- ptrW buf(getWStringA("OmemoSignedPreKeyPublic"));
- xmlSetText(signedPreKeyPublic_node, buf);
+ publish_node << XATTR(L"node", attr_val);
}
+ HXML bundle_node = publish_node << XCHILD(L"item") << XCHILDNS(L"bundle", JABBER_FEAT_OMEMO);
+
+ // add signed pre key public
+ bundle_node << XCHILD(L"signedPreKeyPublic", ptrW(getWStringA("OmemoSignedPreKeyPublic"))) << XATTR(L"signedPreKeyId", L"1");
+
//add pre key signature
- {
- HXML signedPreKeySignature_node = XmlAddChild(bundle_node, L"signedPreKeySignature");
- ptrW buf(getWStringA("OmemoSignedPreKeySignature"));
- xmlSetText(signedPreKeySignature_node, buf);
- }
+ bundle_node << XCHILD(L"signedPreKeySignature", ptrW(getWStringA("OmemoSignedPreKeySignature")));
+
//add identity key
//it is must be a public key right ?, standart is a bit confusing...
- {
- HXML identityKey_node = XmlAddChild(bundle_node, L"identityKey");
- ptrW buf(getWStringA("OmemoDevicePublicKey"));
- xmlSetText(identityKey_node, buf);
- }
+ bundle_node << XCHILD(L"identityKey", ptrW(getWStringA("OmemoDevicePublicKey")));
+
//add prekeys
HXML prekeys_node = XmlAddChild(bundle_node, L"prekeys");
- {
- int i = 0;
- char setting_name[64];
+
+ char setting_name[64];
+ for (int i = 0;; i++) {
mir_snprintf(setting_name, "OmemoPreKey%dPublic", i);
- wchar_t *val;
- for (val = getWStringA(setting_name); val && val[0]; ++i, mir_snprintf(setting_name, "OmemoPreKey%dPublic", i), val = getWStringA(setting_name))
- {
- HXML preKeyPublic_node = XmlAddChild(prekeys_node, L"preKeyPublic");
- xmlAddAttrInt(preKeyPublic_node, L"preKeyId", i + 1);
- xmlSetText(preKeyPublic_node, val);
- mir_free(val);
- val = nullptr;
- }
- mir_free(val);
- val = nullptr;
+ ptrW val(getWStringA(setting_name));
+ if (val == nullptr)
+ break;
+
+ prekeys_node << XCHILD(L"preKeyPublic", val) << XATTRI(L"preKeyId", i + 1);
}
- //send bundle
+ // send bundle
m_ThreadInfo->send(iq);
-
}
-
diff --git a/protocols/JabberG/src/jabber_privacy.cpp b/protocols/JabberG/src/jabber_privacy.cpp
index eabe7f3570..9cbc1ab4d5 100644
--- a/protocols/JabberG/src/jabber_privacy.cpp
+++ b/protocols/JabberG/src/jabber_privacy.cpp
@@ -269,7 +269,7 @@ void CJabberProto::OnIqResultPrivacyLists(HXML iqNode, CJabberIqInfo *pInfo)
// Query contents only if list editior is visible!
if (m_pDlgPrivacyLists)
m_ThreadInfo->send(
- XmlNodeIq( AddIQ(&CJabberProto::OnIqResultPrivacyList, JABBER_IQ_TYPE_GET))
+ XmlNodeIq(AddIQ(&CJabberProto::OnIqResultPrivacyList, JABBER_IQ_TYPE_GET))
<< XQUERY(JABBER_FEAT_PRIVACY_LISTS) << XCHILD(L"list") << XATTR(L"name", listName));
}
}
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp
index d7004342c8..6efd57a802 100644
--- a/protocols/JabberG/src/jabber_svc.cpp
+++ b/protocols/JabberG/src/jabber_svc.cpp
@@ -161,8 +161,8 @@ INT_PTR __cdecl CJabberProto::JabberGetAvatarInfo(WPARAM wParam, LPARAM lParam)
debugLogW(L"Rereading %s for %s", isXVcard ? JABBER_FEAT_VCARD_TEMP : JABBER_FEAT_AVATAR, szJid);
m_ThreadInfo->send((isXVcard) ?
- XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetVCardAvatar, JABBER_IQ_TYPE_GET, szJid)) << XCHILDNS(L"vCard", JABBER_FEAT_VCARD_TEMP) :
- XmlNodeIq( AddIQ(&CJabberProto::OnIqResultGetClientAvatar, JABBER_IQ_TYPE_GET, szJid)) << XQUERY(JABBER_FEAT_AVATAR));
+ XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetVCardAvatar, JABBER_IQ_TYPE_GET, szJid)) << XCHILDNS(L"vCard", JABBER_FEAT_VCARD_TEMP) :
+ XmlNodeIq(AddIQ(&CJabberProto::OnIqResultGetClientAvatar, JABBER_IQ_TYPE_GET, szJid)) << XQUERY(JABBER_FEAT_AVATAR));
return GAIR_WAITFOR;
}
}