public void handle(SignalServiceEnvelope envelope, bool sendExplicitReceipt)
        {
            if (!isActiveNumber(envelope.getSource()))
            {
                TextSecureDirectory directory           = DatabaseFactory.getDirectoryDatabase();
                ContactTokenDetails contactTokenDetails = new ContactTokenDetails();
                contactTokenDetails.setNumber(envelope.getSource());

                directory.setNumber(contactTokenDetails, true);

                // TODO: evtl DirectoryRefresh
            }

            if (envelope.isReceipt())
            {
                handleReceipt(envelope);
            }
            else if (envelope.isPreKeySignalMessage() || envelope.isSignalMessage())
            {
                handleMessage(envelope, sendExplicitReceipt);
            }
            else
            {
                Log.Warn($"Received envelope of unknown type: {envelope.GetType()}");
            }
        }
Exemple #2
0
        public void handle(TextSecureEnvelope envelope, bool sendExplicitReceipt)
        {
            if (!isActiveNumber(envelope.getSource()))
            {
                TextSecureDirectory directory           = DatabaseFactory.getDirectoryDatabase();
                ContactTokenDetails contactTokenDetails = new ContactTokenDetails();
                contactTokenDetails.setNumber(envelope.getSource());

                directory.setNumber(contactTokenDetails, true);
            }

            if (envelope.isReceipt())
            {
                handleReceipt(envelope);
            }
            else
            {
                handleMessage(envelope, sendExplicitReceipt);
            }
        }
Exemple #3
0
        public static async Task <bool> refreshDirectory(SignalServiceAccountManager accountManager, String localNumber)
        {
            TextSecureDirectory directory = DatabaseFactory.getDirectoryDatabase();
            List <string>       eligibleContactNumbers = await directory.GetNumbersAsync(localNumber);

            List <ContactTokenDetails> activeTokens = await accountManager.getContacts(eligibleContactNumbers);

            if (activeTokens != null)
            {
                foreach (ContactTokenDetails activeToken in activeTokens)
                {
                    Debug.WriteLine($"Token {activeToken.getNumber()}, {activeToken.getToken()}");
                    eligibleContactNumbers.Remove(activeToken.getNumber());
                    activeToken.setNumber(activeToken.getNumber());
                }

                directory.setNumbers(activeTokens, eligibleContactNumbers);
            }

            return(true);
        }
Exemple #4
0
        private async static Task <bool> isPushDestination(String destination)
        {
            TextSecureDirectory directory = DatabaseFactory.getDirectoryDatabase();

            try
            {
                return(directory.isActiveNumber(destination));
            }
            catch (/*NotInDirectory*/ Exception e)
            {
                try
                {
                    TextSecureAccountManager  accountManager = TextSecureCommunicationFactory.createManager();
                    May <ContactTokenDetails> registeredUser = await App.Current.accountManager.getContact(destination);

                    if (!registeredUser.HasValue)
                    {
                        registeredUser = new May <ContactTokenDetails>(new ContactTokenDetails());
                        registeredUser.ForceGetValue().setNumber(destination);
                        directory.setNumber(registeredUser.ForceGetValue(), false);
                        return(false);
                    }
                    else
                    {
                        registeredUser.ForceGetValue().setNumber(destination);
                        directory.setNumber(registeredUser.ForceGetValue(), true);
                        return(true);
                    }
                }
                catch (Exception e1)
                {
                    //Log.w(TAG, e1);
                    return(false);
                }
            }
        }