Example #1
0
 public void StoreSignedPreKey(uint signedPreKeyId, SignedPreKeyRecord record)
 {
     conn.Insert(new SignedPreKeyRecordI()
     {
         SignedPreyKeyId = signedPreKeyId, Record = record.serialize()
     });
 }
Example #2
0
 public void StoreSignedPreKey(UInt32 signedPreKeyId, SignedPreKeyRecord record)
 {
     if (this.OnstoreSignedPreKey != null)
     {
         this.OnstoreSignedPreKey(signedPreKeyId, record.serialize());
     }
 }
Example #3
0
 public void storeSignedPreKey(uint signedPreKeyId, SignedPreKeyRecord record)
 {
     if (store.ContainsKey(signedPreKeyId)) // mimic Java HashMap
     {
         store.Remove(signedPreKeyId);
     }
     store.Add(signedPreKeyId, record.serialize());
 }
 public void storeSignedPreKey(uint signedPreKeyId, SignedPreKeyRecord record)
 {
     if (store.ContainsKey(signedPreKeyId)) // mimic Java HashMap
     {
         store.Remove(signedPreKeyId);
     }
     store.Add(signedPreKeyId, record.serialize());
 }
Example #5
0
 public void setSignedPreKey(uint signedPreKeyId, SignedPreKeyRecord signedPreKey, string accountId)
 {
     dB.InsertOrReplace(new SignedPreKeyTable()
     {
         id             = SignedPreKeyTable.generateId(signedPreKeyId, accountId),
         signedPreKeyId = signedPreKeyId,
         accountId      = accountId,
         signedPreKey   = signedPreKey.serialize()
     });
 }
Example #6
0
 public static void StoreSignedPreKey(uint signedPreKeyId, SignedPreKeyRecord record)
 {
     lock (DBLock)
     {
         using (var ctx = new LibsignalDBContext())
         {
             ctx.SignedPreKeys.Add(new SignalSignedPreKey()
             {
                 Id  = signedPreKeyId,
                 Key = Base64.encodeBytes(record.serialize())
             });
             ctx.SaveChanges();
         }
     }
 }
Example #7
0
 public override bool Equals(object obj)
 {
     if (obj is XMPPAccount)
     {
         XMPPAccount o = obj as XMPPAccount;
         return(o.disabled == disabled &&
                o.port == port &&
                o.presencePriorety == presencePriorety &&
                string.Equals(o.serverAddress, serverAddress) &&
                Equals(o.user, user) &&
                string.Equals(o.color, color) &&
                o.presence == presence &&
                string.Equals(o.status, status) &&
                connectionConfiguration.Equals(o.connectionConfiguration) &&
                o.omemoDeviceId == omemoDeviceId &&
                Equals(o.omemoIdentityKeyPair.serialize(), omemoIdentityKeyPair.serialize()) &&
                Equals(o.omemoSignedPreKeyPair.serialize(), omemoSignedPreKeyPair.serialize()) &&
                Equals(o.omemoPreKeys, omemoPreKeys) &&
                o.omemoBundleInfoAnnounced == omemoBundleInfoAnnounced);
     }
     return(false);
 }
		public void StoreSignedPreKey(uint signedPreKeyId, SignedPreKeyRecord record)
		{
			store[signedPreKeyId] = record.serialize();
		}
 public void StoreSignedPreKey(uint signedPreKeyId, SignedPreKeyRecord record)
 {
     store[signedPreKeyId] = record.serialize();
 }
        private void RequestRegister(uint registrationId, IdentityKeyPair identityKeyPair, SignedPreKeyRecord signedPreKey, List <PreKeyRecord> preKeys)
        {
            //Send the login username and password to the server and get response
            string apiUrl    = "https://ycandgap.me/api_server2.php";
            string apiMethod = "registerUser";

            // Login_Request has two properties: username and password
            Login_Request myLogin_Request = new Login_Request();

            myLogin_Request.Username                    = username.Text;
            myLogin_Request.Password                    = password.Text.GetHashCode();
            myLogin_Request.RegistrationID              = registrationId;
            myLogin_Request.PublicIdentityKey           = JsonConvert.SerializeObject(identityKeyPair.getPublicKey().serialize());
            myLogin_Request.PublicSignedPreKeyID        = signedPreKey.getId();
            myLogin_Request.PublicSignedPreKeySignature = JsonConvert.SerializeObject(signedPreKey.getSignature());
            myLogin_Request.PublicSignedPreKey          = JsonConvert.SerializeObject(signedPreKey.getKeyPair().getPublicKey().serialize());

            // Save in local Database
            ISharedPreferences       sharedprefs = PreferenceManager.GetDefaultSharedPreferences(this);
            ISharedPreferencesEditor editor      = sharedprefs.Edit();

            // Store identityKeyPair somewhere durable and safe.
            editor.PutString("IdentityKeyPair", JsonConvert.SerializeObject(identityKeyPair.serialize()));
            editor.PutString("SignedPreKey", JsonConvert.SerializeObject(signedPreKey.serialize()));
            editor.PutString("Username", username.Text);
            editor.PutInt("Password", password.Text.GetHashCode());

            // Store registrationId somewhere durable and safe.
            editor.PutString("RegistrationId", registrationId.ToString());
            editor.Apply();

            // make http post request
            string response = Http.Post(apiUrl, new NameValueCollection()
            {
                { "api_method", apiMethod },
                { "api_data", JsonConvert.SerializeObject(myLogin_Request) }
            });

            // decode json string to dto object
            API_Response r = JsonConvert.DeserializeObject <API_Response>(response);

            if (r != null)
            {
                if (!r.IsError)
                {
                    foreach (PreKeyRecord preKey in preKeys)
                    {
                        Prekey_Request preKey_Request = new Prekey_Request();
                        preKey_Request.PublicSignedPreKeyID = signedPreKey.getId();
                        preKey_Request.PublicPreKeyID       = preKey.getId();
                        preKey_Request.PublicPreKey         = JsonConvert.SerializeObject(preKey.getKeyPair().getPublicKey().serialize());
                        apiMethod = "storePreKeys";

                        // make http post request
                        string preKeyResponse = Http.Post(apiUrl, new NameValueCollection()
                        {
                            { "api_method", apiMethod },
                            { "api_data", JsonConvert.SerializeObject(preKey_Request) }
                        });

                        // decode json string to dto object
                        API_Response preKeyR = JsonConvert.DeserializeObject <API_Response>(preKeyResponse);
                        if (preKeyR == null)
                        {
                            break;
                        }
                    }
                }
            }
        }