summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src
diff options
context:
space:
mode:
authorGluzskiy Alexandr <sss@sss.chaoslab.ru>2017-02-28 16:10:20 +0300
committerGluzskiy Alexandr <sss@sss.chaoslab.ru>2017-02-28 16:13:54 +0300
commitc91f19085e70f9e7fb2e8a445c87043f860f1f02 (patch)
tree814034e1df805ecb256be34d12ccfcc5c3235b8a /protocols/JabberG/src
parent8736afe83f8c5aadf130542b2bbf14b2bcf57105 (diff)
jabber: fix caps ui bug introduced in early omemo implementation stage
omemo: basic device list event handler, added +notify cap to permanent caps, currenlty jabber have problems with dynamic caps...
Diffstat (limited to 'protocols/JabberG/src')
-rwxr-xr-xprotocols/JabberG/src/jabber_caps.h3
-rwxr-xr-x[-rw-r--r--]protocols/JabberG/src/jabber_iqid.cpp0
-rwxr-xr-xprotocols/JabberG/src/jabber_omemo.cpp80
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.cpp15
-rwxr-xr-xprotocols/JabberG/src/jabber_proto.h1
-rwxr-xr-x[-rw-r--r--]protocols/JabberG/src/jabber_util.cpp0
6 files changed, 68 insertions, 31 deletions
diff --git a/protocols/JabberG/src/jabber_caps.h b/protocols/JabberG/src/jabber_caps.h
index 1afece97bb..4e69e7c1bf 100755
--- a/protocols/JabberG/src/jabber_caps.h
+++ b/protocols/JabberG/src/jabber_caps.h
@@ -167,7 +167,8 @@ typedef unsigned __int64 JabberCapsBits;
JABBER_CAPS_ROSTER_EXCHANGE | JABBER_CAPS_DIRECT_MUC_INVITE)
#define JABBER_CAPS_MIRANDA_ALL (JABBER_CAPS_MIRANDA_PARTIAL | JABBER_CAPS_COMMANDS | \
- JABBER_CAPS_USER_MOOD_NOTIFY | JABBER_CAPS_USER_TUNE_NOTIFY | JABBER_CAPS_USER_ACTIVITY_NOTIFY | JABBER_CAPS_PLATFORMX86 | JABBER_CAPS_PLATFORMX64)
+ JABBER_CAPS_USER_MOOD_NOTIFY | JABBER_CAPS_USER_TUNE_NOTIFY | JABBER_CAPS_USER_ACTIVITY_NOTIFY | JABBER_CAPS_OMEMO_NOTIFY \
+ | JABBER_CAPS_PLATFORMX86 | JABBER_CAPS_PLATFORMX64)
#define JABBER_EXT_SECUREIM L"secureim"
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index df2fd4cf42..df2fd4cf42 100644..100755
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
diff --git a/protocols/JabberG/src/jabber_omemo.cpp b/protocols/JabberG/src/jabber_omemo.cpp
index 47e70401b9..354648c1b8 100755
--- a/protocols/JabberG/src/jabber_omemo.cpp
+++ b/protocols/JabberG/src/jabber_omemo.cpp
@@ -420,19 +420,12 @@ namespace omemo {
int id = proto->getDword("OmemoDeviceId", 0);
if (id == 0)
return true;
- DBVARIANT dbv = { 0 };
- proto->getString("OmemoDevicePublicKey", &dbv);
- if (!dbv.pszVal[0])
- {
- //does it need to free something in DBVARIANT?
+ ptrA buf(proto->getStringA("OmemoDevicePublicKey"));
+ if (!buf[0])
return true;
- }
- proto->getString("OmemoDevicePrivateKey", &dbv);
- if (!dbv.pszVal[0])
- {
- //does it need to free something in DBVARIANT?
+ buf = ptrA(proto->getStringA("OmemoDevicePrivateKey"));
+ if (!buf[0])
return true;
- }
return false;
}
@@ -458,6 +451,8 @@ namespace omemo {
SIGNAL_UNREF(new_dev->device_key);
+ //TODO: publish device info to pubsub
+
}
};
@@ -466,7 +461,7 @@ void CJabberProto::OmemoInitDevice()
{
if (omemo::IsFirstRun(this))
omemo::RefreshDevice(this);
-
+ OmemoAnnounceDevice();
}
@@ -475,7 +470,62 @@ void CJabberProto::OmemoHandleMessage(HXML /*node*/)
//TODO: handle "encrypted" node here
}
-void CJabberProto::OmemoHandleDeviceList(HXML /*node*/)
+void CJabberProto::OmemoHandleDeviceList(HXML node)
{
- //TODO: handle omemo device list event node here
-} \ No newline at end of file
+ if (!node)
+ return;
+ HXML message = xmlGetParent(node);
+ message = xmlGetParent(node);
+ LPCTSTR jid = XmlGetAttrValue(message, L"from");
+ MCONTACT hContact = HContactFromJID(jid);
+ node = XmlGetChild(node, "item"); //get <item> node
+ if (!node)
+ return;
+ node = XmlGetChildByTag(node, L"list", L"xmlns", JABBER_FEAT_OMEMO); //<list xmlns = 'urn:xmpp:omemo:0'>
+ if (!node)
+ return;
+ bool own_jid = false; //TODO: detect own jid (not work dues to jabber_thread.cpp:947+)
+ DWORD current_id;
+ LPCTSTR current_id_str;
+ if (own_jid)
+ {
+ //check if our device exist
+ bool own_device_listed = false;
+ DWORD own_id = getDword("OmemoDeviceId", 0);
+ if (own_id = 0)
+ OmemoInitDevice();
+
+ for (HXML list_item = xmlGetFirstChild(node); list_item; xmlGetNextNode(list_item))
+ {
+ current_id_str = xmlGetAttrValue(list_item, L"id");
+ current_id = _wtoi(current_id_str);
+ if (current_id == own_id)
+ own_device_listed = true;
+ }
+ if (!own_device_listed)
+ OmemoAnnounceDevice();
+ }
+ else
+ {
+ //store device id's
+ int i = 0;
+ char setting_name[64];
+ for (HXML list_item = xmlGetFirstChild(node); list_item; xmlGetNextNode(list_item), i++)
+ {
+ current_id_str = xmlGetAttrValue(list_item, L"id");
+ current_id = _wtoi(current_id_str);
+ mir_snprintf(setting_name, "OmemoDeviceId%d", i);
+ setDword(setting_name, current_id);
+ }
+ }
+}
+
+void CJabberProto::OmemoAnnounceDevice()
+{
+ //TODO: get device list
+ //TODO: check for own device id
+ //TODO: add own device id
+ //TODO: send device list back
+
+}
+
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index 8c220e2a63..19813ac138 100755
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -138,22 +138,7 @@ CJabberProto::CJabberProto(const char *aProtoName, const wchar_t *aUserName) :
m_pepServices.insert(new CPepActivity(this));
if (m_options.UseOMEMO)
- {
- JabberCapsBits jcb = 0;
- // set all bits occupied by g_JabberFeatCapPairs
- for (int i = 0; g_JabberFeatCapPairs[i].szFeature; i++)
- jcb |= g_JabberFeatCapPairs[i].jcbCap;
-
- // set all bits already occupied by external plugins
- for (int i = 0; i < m_lstJabberFeatCapPairsDynamic.getCount(); i++)
- jcb |= m_lstJabberFeatCapPairsDynamic[i]->jcbCap;
-
- jcb |= JABBER_CAPS_OMEMO_NOTIFY;
-
- m_clientCapsManager.SetClientCaps(JABBER_CAPS_MIRANDA_NODE, szCoreVersion, jcb);
-
OmemoInitDevice();
- }
db_set_resident(m_szModuleName, DBSETTING_XSTATUSID);
db_set_resident(m_szModuleName, DBSETTING_XSTATUSNAME);
diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h
index 48c7778461..ed63eff36c 100755
--- a/protocols/JabberG/src/jabber_proto.h
+++ b/protocols/JabberG/src/jabber_proto.h
@@ -340,6 +340,7 @@ struct CJabberProto : public PROTO<CJabberProto>, public IJabberInterface
void OmemoHandleMessage(HXML node);
void OmemoHandleDeviceList(HXML node);
void OmemoInitDevice();
+ void OmemoAnnounceDevice();
//---- jabber_console.cpp ------------------------------------------------------------
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp
index 19de86f090..19de86f090 100644..100755
--- a/protocols/JabberG/src/jabber_util.cpp
+++ b/protocols/JabberG/src/jabber_util.cpp