Exemplo n.º 1
0
        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()}");
            }
        }
        /// <summary>
        /// Checks whether a contact is currently registered with the server.
        /// </summary>
        /// <param name="e164number">The contact to check.</param>
        /// <returns>An optional ContactTokenDetails, present if registered, absent if not.</returns>
        public async Task <May <ContactTokenDetails> > getContact(string e164number)// throws IOException
        {
            string contactToken = createDirectoryServerToken(e164number, true);
            ContactTokenDetails contactTokenDetails = await this.pushServiceSocket.getContactTokenDetails(contactToken);

            if (contactTokenDetails != null)
            {
                contactTokenDetails.setNumber(e164number);
            }

            return(new May <ContactTokenDetails>(contactTokenDetails));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Checks whether a contact is currently registered with the server
        /// </summary>
        /// <param name="token">The cancellaion token</param>
        /// <param name="e164number">The contact to check.</param>
        /// <returns>An optional ContactTokenDetails, present if registered, absent if not.</returns>
        public async Task <May <ContactTokenDetails> > GetContact(CancellationToken token, string e164number)// throws IOException
        {
            string contactToken = CreateDirectoryServerToken(e164number, true);
            ContactTokenDetails contactTokenDetails = await PushServiceSocket.GetContactTokenDetails(token, contactToken);

            if (contactTokenDetails != null)
            {
                contactTokenDetails.Number = e164number;
            }

            return(new May <ContactTokenDetails>(contactTokenDetails));
        }
Exemplo n.º 4
0
        public void setNumber(ContactTokenDetails token, bool active)
        {
            Directory dir = new Directory()
            {
                Number     = token.getNumber(),
                Relay      = token.getRelay(),
                Registered = active ? (uint)1 : 0,
                //supports_sms = token.isSupportsSms() ? (uint)1 : 0,
                Time = TimeUtil.GetDateTimeMillis()
            };

            conn.InsertOrReplace(dir);
        }
Exemplo n.º 5
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);
            }
        }