diff options
author | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2017-03-27 20:08:55 +0300 |
---|---|---|
committer | Gluzskiy Alexandr <sss@sss.chaoslab.ru> | 2017-03-27 20:17:27 +0300 |
commit | b60c918dbcb16f4da7c35c15b190ee9def957a49 (patch) | |
tree | 2284abfc14457bf42d1c6d5ab9e36a3ef871f68b | |
parent | 780b307ddff495b0a4394d3880b5a3ae7a83f26e (diff) |
omemo: working on 4.3
removed xep-0060 8.1.1 implementation because xep-0163 requires node auto-create support
reverted to "instand publish" logic instead of node precreation
//looks like we have some problems with pubsub events receiving mechanism or client features publishing which
is blocker problem for continuing to work on omemo implementation.
-rwxr-xr-x | protocols/JabberG/src/jabber_iqid.cpp | 15 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_omemo.cpp | 138 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.cpp | 4 | ||||
-rwxr-xr-x | protocols/JabberG/src/jabber_proto.h | 6 |
4 files changed, 11 insertions, 152 deletions
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index d9cd46f0c3..715c6344d3 100755 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -52,6 +52,12 @@ void CJabberProto::OnIqResultServerDiscoInfo(HXML iqNode, CJabberIqInfo*) if (!mir_wstrcmp(tmp.category, L"pubsub") && !mir_wstrcmp(tmp.type, L"pep")) {
m_bPepSupported = true;
+ if (m_options.UseOMEMO)
+ {
+ //publish ndes, precreation is not required
+ OmemoPublishNodes();
+ }
+
EnableMenuItems(true);
RebuildInfoFrame();
continue;
@@ -207,15 +213,6 @@ void CJabberProto::OnLoggedIn() setString("LastLoggedServer", m_ThreadInfo->conn.server);
m_pepServices.ResetPublishAll();
- if (m_options.UseOMEMO)
- {
- if (m_PubsubServiceName) // this is required if login server is changed only
- {
- mir_free(m_PubsubServiceName);
- m_PubsubServiceName = nullptr;
- }
- OmemoCreateNodes();
- }
}
void CJabberProto::OnIqResultGetAuth(HXML iqNode, CJabberIqInfo*)
diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp index 2b80addf46..a86e8e0805 100755 --- a/protocols/JabberG/src/jabber_omemo.cpp +++ b/protocols/JabberG/src/jabber_omemo.cpp @@ -539,141 +539,8 @@ namespace omemo { wchar_t* node_name;
};
- void pubsub_createnode_impl(wchar_t *node_name, CJabberProto *proto)
- {
- //xep-0060 8.1.1 required by xep-0163 3
- IqHandlerUserData *data = (IqHandlerUserData*)mir_alloc(sizeof(IqHandlerUserData)); //this may cause memory leak
- data->node_name = mir_wstrdup(node_name);
- XmlNodeIq iq(proto->AddIQ(&CJabberProto::OmemoOnIqResultPubsubCreateNode, JABBER_IQ_TYPE_SET, proto->m_PubsubServiceName, 0UL, -1, data)); //TODO: check is it correct
- iq << XATTR(L"from", proto->m_ThreadInfo->fullJID); //full unstripped jid used here
- HXML create_node = iq << XCHILDNS(L"pubsub", L"http://jabber.org/protocol/pubsub") << XCHILD(L"create");
- create_node << XATTR(L"node", node_name);
- if(!mir_wstrcmp(node_name, JABBER_FEAT_OMEMO L".devicelist"))
- {
- DWORD own_id = omemo::GetOwnDeviceId(proto);
- wchar_t attr_val[128];
- mir_snwprintf(attr_val, L"%s.bundles:%d", JABBER_FEAT_OMEMO, own_id);
- pubsub_createnode_impl(attr_val, proto);
- }
- proto->m_ThreadInfo->send(iq);
- }
-
- void pubsub_createnode(wchar_t *node_name, CJabberProto *proto)
- {
- if (!proto->m_PubsubServiceName)
- {
- IqHandlerUserData *data = (IqHandlerUserData*)mir_alloc(sizeof(IqHandlerUserData)); //this may cause memory leak
- data->node_name = mir_wstrdup(node_name);
- proto->m_ThreadInfo->send(
- XmlNodeIq(proto->AddIQ(&CJabberProto::OmemoOnIqResultServerDiscoItems, JABBER_IQ_TYPE_GET, _A2T(proto->m_ThreadInfo->conn.server), 0UL, -1, data))
- << XQUERY(JABBER_FEAT_DISCO_ITEMS));
- }
- else
- pubsub_createnode_impl(node_name, proto);
- }
-
};
-void CJabberProto::OmemoOnIqResultServerDiscoInfoJid(HXML iqNode, CJabberIqInfo *pInfo)
-{
- if (m_PubsubServiceName) //one pubsub address is enough
- return;
- if (iqNode == NULL)
- return;
-
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
- if (mir_wstrcmp(type, L"result"))
- return;
-
- LPCTSTR jid = XmlGetAttrValue(iqNode, L"from");
-
- HXML query = XmlGetChildByTag(iqNode, "query", "xmlns", JABBER_FEAT_DISCO_INFO);
- if (query == NULL)
- return;
-
- HXML identity;
- for (int i = 1; (identity = XmlGetNthChild(query, L"identity", i)) != NULL; i++)
- {
- JABBER_DISCO_FIELD tmp = {
- XmlGetAttrValue(identity, L"category"),
- XmlGetAttrValue(identity, L"type")
- };
-
- if (!mir_wstrcmp(tmp.category, L"pubsub") && !mir_wstrcmp(tmp.type, L"service"))
- {
- omemo::IqHandlerUserData *data = (omemo::IqHandlerUserData*)pInfo->GetUserData();
- m_PubsubServiceName = mir_wstrdup(jid);
- omemo::pubsub_createnode(data->node_name, this);
- mir_free(data->node_name);
- mir_free(data);
- break;
- }
- }
-
-}
-
-void CJabberProto::OmemoOnIqResultServerDiscoItems(HXML iqNode, CJabberIqInfo* pInfo)
-{
- if (iqNode == NULL)
- return;
-
- const wchar_t *type = XmlGetAttrValue(iqNode, L"type");
- if (mir_wstrcmp(type, L"result"))
- return;
-
- HXML query = XmlGetChildByTag(iqNode, "query", "xmlns", JABBER_FEAT_DISCO_ITEMS);
- if (query == NULL)
- return;
-
- HXML item;
- for (int i = 1; (item = XmlGetNthChild(query, L"item", i)) != NULL; i++)
- {
- LPCTSTR jid = XmlGetAttrValue(item, L"jid");
- if(jid)
- m_ThreadInfo->send(
- XmlNodeIq(AddIQ(&CJabberProto::OmemoOnIqResultServerDiscoInfoJid, JABBER_IQ_TYPE_GET, jid, 0UL, -1, pInfo->GetUserData()))
- << XQUERY(JABBER_FEAT_DISCO_INFO));
- }
-}
-
-void CJabberProto::OmemoOnIqResultPubsubCreateNode(HXML iqNode, CJabberIqInfo *pInfo)
-{
-
- if (iqNode == NULL)
- return;
-
- LPCTSTR type = XmlGetAttrValue(iqNode, L"type");
- if (mir_wstrcmp(type, L"result"))
- {
- HXML error_node = XmlGetChild(iqNode, L"error");
- if (!error_node) //not error and not success...
- return;
- HXML error_type_node = XmlGetChild(error_node, L"conflict"); //conflict is ok
- if (!error_type_node)
- return;
- }
-
-
- omemo::IqHandlerUserData *data = (omemo::IqHandlerUserData*)pInfo->GetUserData();
- if (!mir_wstrcmp(data->node_name, JABBER_FEAT_OMEMO L".devicelist"))
- { //device list node created
- OmemoAnnounceDevice();
- }
- else
- {
- DWORD own_id = omemo::GetOwnDeviceId(this);
- wchar_t attr_val[128];
- mir_snwprintf(attr_val, L"%s.bundles:%d", JABBER_FEAT_OMEMO, own_id);
- if (!mir_wstrcmp(data->node_name, attr_val))
- { //device bundle node created
- OmemoSendBundle();
- }
- }
-
- mir_free(data->node_name);
- mir_free(data);
-}
-
void CJabberProto::OmemoInitDevice()
{
@@ -827,7 +694,8 @@ void CJabberProto::OmemoSendBundle() m_ThreadInfo->send(iq);
}
-void CJabberProto::OmemoCreateNodes()
+void CJabberProto::OmemoPublishNodes()
{
- omemo::pubsub_createnode(JABBER_FEAT_OMEMO L".devicelist", this);
+ OmemoAnnounceDevice();
+ OmemoSendBundle();
}
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp index 8131541853..19813ac138 100755 --- a/protocols/JabberG/src/jabber_proto.cpp +++ b/protocols/JabberG/src/jabber_proto.cpp @@ -70,8 +70,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) : m_hPrivacyMenuRoot(0),
m_hPrivacyMenuItems(10),
m_lstJabberFeatCapPairsDynamic(2),
- m_uEnabledFeatCapsDynamic(0),
- m_PubsubServiceName(nullptr)
+ m_uEnabledFeatCapsDynamic(0)
{
m_szXmlStreamToBeInitialized = NULL;
@@ -191,7 +190,6 @@ CJabberProto::~CJabberProto() mir_free(m_lstJabberFeatCapPairsDynamic[i]->szDescription);
delete m_lstJabberFeatCapPairsDynamic[i];
}
- mir_free(m_PubsubServiceName);
}
////////////////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index d6e80a1c81..bbcc472262 100755 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -342,11 +342,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface void OmemoInitDevice();
void OmemoAnnounceDevice();
void OmemoSendBundle();
- void OmemoOnIqResultServerDiscoItems(HXML iqNode, CJabberIqInfo*);
- void OmemoOnIqResultServerDiscoInfoJid(HXML iqNode, CJabberIqInfo*);
- void OmemoOnIqResultPubsubCreateNode(HXML iqNode, CJabberIqInfo*);
- void OmemoCreateNodes();
- wchar_t *m_PubsubServiceName;
+ void OmemoPublishNodes();
//---- jabber_console.cpp ------------------------------------------------------------
|