Exemplo n.º 1
0
        public void RemoveSignedPreKey(uint signedPreKeyId)
        {
            SignedPreKeysRepository signedPreKeysRepository = new SignedPreKeysRepository();
            List <SignedPreKeys>    signedPreKeys           = signedPreKeysRepository.GetSignedPreKeys(Convert.ToString(signedPreKeyId));

            if (signedPreKeys != null && signedPreKeys.Count > 0)
            {
                SignedPreKeys signedPreKey = signedPreKeys.First();
                signedPreKeysRepository.Delete(signedPreKey);
            }
        }
Exemplo n.º 2
0
        public SignedPreKeyRecord LoadSignedPreKey(uint signedPreKeyId)
        {
            SignedPreKeysRepository preKeysRepository = new SignedPreKeysRepository();
            List <SignedPreKeys>    signedPreKeys     = preKeysRepository.GetSignedPreKeys(Convert.ToString(signedPreKeyId));

            if (signedPreKeys != null && signedPreKeys.Count > 0)
            {
                SignedPreKeyRecord signedPreKeyRecord = new SignedPreKeyRecord(signedPreKeys.First().Record);
                return(signedPreKeyRecord);
            }

            return(null);
        }
Exemplo n.º 3
0
        public List <SignedPreKeyRecord> LoadSignedPreKeys()
        {
            List <SignedPreKeyRecord> retVal = new List <SignedPreKeyRecord>();

            SignedPreKeysRepository preKeysRepository = new SignedPreKeysRepository();
            List <SignedPreKeys>    signedPreKeys     = (List <SignedPreKeys>)preKeysRepository.GetAll();

            foreach (SignedPreKeys signedPreKeyse in signedPreKeys)
            {
                retVal.Add(new SignedPreKeyRecord(signedPreKeyse.Record));
            }

            return(retVal.Count > 0 ? retVal : null);
        }
Exemplo n.º 4
0
        public void StoreSignedPreKey(uint signedPreKeyId, SignedPreKeyRecord record)
        {
            if (ContainsSignedPreKey(signedPreKeyId))
            {
                RemovePreKey(signedPreKeyId);
            }

            SignedPreKeysRepository signedPreKeysRepository = new SignedPreKeysRepository();
            SignedPreKeys           signedPreKey            = new SignedPreKeys()
            {
                PreKeyId = Convert.ToString(signedPreKeyId),
                Record   = record.Serialize()
            };
            bool result = signedPreKeysRepository.Save(signedPreKey);
        }
Exemplo n.º 5
0
        public void Clear()
        {
            IdentityKeysRepository identityKeysRepository = new IdentityKeysRepository();

            identityKeysRepository.DeleteAll();

            PreKeysRepository preKeysRepository = new PreKeysRepository();

            preKeysRepository.DeleteAll();

            SenderKeysRepository senderKeysRepository = new SenderKeysRepository();

            senderKeysRepository.DeleteAll();

            SessionsRepository sessionsRepository = new SessionsRepository();

            sessionsRepository.DeleteAll();

            SignedPreKeysRepository signedPreKeysRepository = new SignedPreKeysRepository();

            signedPreKeysRepository.DeleteAll();
        }
Exemplo n.º 6
0
        public bool ContainsSignedPreKey(uint signedPreKeyId)
        {
            SignedPreKeysRepository signedPreKeysRepository = new SignedPreKeysRepository();

            return(signedPreKeysRepository.Contains(Convert.ToString(signedPreKeyId)));
        }