示例#1
0
        /// <summary>
        /// If the OMEMO device list got changed and does not contain the local device id update it and add it again.
        /// </summary>
        /// <param name="msg">The received OmemoDeviceListEventMessage.</param>
        private async Task onOmemoDeviceListEventMessageAsync(OmemoDeviceListEventMessage msg)
        {
            string senderBareJid = Utils.getBareJidFromFullJid(msg.getFrom());

            if (string.Equals(senderBareJid, CONNECTION.account.getBareJid()))
            {
                if (CONNECTION.account.omemoDeviceId != 0)
                {
                    if (!msg.DEVICES.DEVICES.Any(d => d.ID == CONNECTION.account.omemoDeviceId))
                    {
                        msg.DEVICES.DEVICES.Add(new OmemoXmlDevice(CONNECTION.account.omemoDeviceId, CONNECTION.account.omemoDeviceLabel));
                        OmemoSetDeviceListMessage setMsg = new OmemoSetDeviceListMessage(CONNECTION.account.getFullJid(), msg.DEVICES);
                        await CONNECTION.SendAsync(setMsg, false);
                    }
                    DEVICES = msg.DEVICES;
                }
                else
                {
                    return;
                }
            }

            OMEMO_STORAGE.StoreDevices(msg.DEVICES.toOmemoProtocolAddress(senderBareJid), senderBareJid);
            OMEMO_STORAGE.StoreDeviceListSubscription(senderBareJid, new Tuple <OmemoDeviceListSubscriptionState, DateTime>(OmemoDeviceListSubscriptionState.SUBSCRIBED, DateTime.Now));
        }
示例#2
0
        public void onOmemoDeviceListEventMessage(OmemoDeviceListEventMessage msg)
        {
            string chatJid = Utils.getBareJidFromFullJid(msg.getFrom());

            OmemoDeviceDBManager.INSTANCE.setDevices(msg.DEVICES, chatJid, CONNECTION.account.getIdAndDomain());
            OmemoDeviceDBManager.INSTANCE.setDeviceListSubscription(new OmemoDeviceListSubscriptionTable(chatJid, CONNECTION.account.getIdAndDomain(), OmemoDeviceListSubscriptionState.SUBSCRIBED, DateTime.Now));
        }
示例#3
0
 /// <summary>
 /// If the OMEMO device list got changed and does not contain the local device id update it and add it again.
 /// </summary>
 /// <param name="msg">The received OmemoDeviceListEventMessage.</param>
 private async Task onOmemoDeviceListEventMessageAsync(OmemoDeviceListEventMessage msg)
 {
     if (!msg.DEVICES.DEVICES.Contains(CONNECTION.account.omemoDeviceId))
     {
         msg.DEVICES.DEVICES.Add(CONNECTION.account.omemoDeviceId);
         OmemoSetDeviceListMessage setMsg = new OmemoSetDeviceListMessage(CONNECTION.account.getIdDomainAndResource(), msg.DEVICES);
         await CONNECTION.sendAsync(setMsg, false, false);
     }
 }
示例#4
0
        /// <summary>
        /// If the OMEMO device list got changed and does not contain the local device id update it and add it again.
        /// </summary>
        /// <param name="msg">The received OmemoDeviceListEventMessage.</param>
        private async Task onOmemoDeviceListEventMessageAsync(OmemoDeviceListEventMessage msg)
        {
            string senderBareJid = Utils.getBareJidFromFullJid(msg.getFrom());

            if (string.Equals(senderBareJid, CONNECTION.account.getBareJid()))
            {
                if (!msg.DEVICES.IDS.Contains(CONNECTION.account.omemoDeviceId))
                {
                    msg.DEVICES.IDS.Add(CONNECTION.account.omemoDeviceId);
                    OmemoSetDeviceListMessage setMsg = new OmemoSetDeviceListMessage(CONNECTION.account.getFullJid(), msg.DEVICES);
                    await CONNECTION.SendAsync(setMsg, false);
                }
                DEVICES = msg.DEVICES;
            }

            OMEMO_STORE.StoreDevices(msg.DEVICES.toSignalProtocolAddressList(senderBareJid));
            OMEMO_STORE.StoreDeviceListSubscription(senderBareJid, new Tuple <OmemoDeviceListSubscriptionState, DateTime>(OmemoDeviceListSubscriptionState.SUBSCRIBED, DateTime.Now));
        }