Esempio n. 1
0
        private void TryLogin(object sender, RoutedEventArgs e)
        {
            if (loading)
            {
                return;
            }
            loading = true;
            SquawkInterface sharedInterface = SquawkInterface.getSharedInterface();

            sharedInterface.tryUserLoginWithSecret(generatedPassword);

            sharedInterface.messageDelegate = this;
            sharedInterface.isUserLoggedInCallback();

            loading = false;
        }
Esempio n. 2
0
        public static async Task <IEnumerable <Squawker> > reload()
        {
            System.Diagnostics.Debug.WriteLine("Reloading squawks... ");
            IEnumerable <Contact> contacts = await getContacts();

            IEnumerable <SquawkMessage> recentSquawks = await SquawkInterface.getSharedInterface().loadRecentSquawks();

            var squawkersForPhoneNumbers = new Dictionary <string, Squawker>();

            foreach (Contact contact in contacts)
            {
                Squawker squawker = new Squawker();
                squawker.contact = contact;
                foreach (ContactPhoneNumber number in contact.PhoneNumbers)
                {
                    squawkersForPhoneNumbers[Squawker.normalizePhoneNumber(number)] = squawker;
                }
            }
            foreach (SquawkMessage squawk in recentSquawks)
            {
                String   sender   = squawk.sender;
                Squawker squawker = null;
                if (squawkersForPhoneNumbers.ContainsKey(sender))
                {
                    squawker = squawkersForPhoneNumbers[sender];
                }
                else
                {
                    squawker = new Squawker();
                    squawkersForPhoneNumbers[sender] = squawker;
                }
                squawker.squawks.Add(squawk);
            }
            HashSet <Squawker> allSquawkers    = new HashSet <Squawker>(squawkersForPhoneNumbers.Values);
            List <Squawker>    sortedSquawkers = new List <Squawker>(allSquawkers);

            sortedSquawkers.Sort();
            return(sortedSquawkers);
        }
Esempio n. 3
0
        public override Uri MapUri(Uri uri)
        {
            Uri initial = new Uri("/Initial.xaml", UriKind.Relative);

            if (uri == initial)
            {
                Task <bool> isLoggedInTask = SquawkInterface.getSharedInterface().isUserLoggedInAsync();

                isLoggedInTask.Wait();
                bool isLoggedIn = isLoggedInTask.Result;
                if (isLoggedIn)
                {
                    return(new Uri("/MainPage.xaml", UriKind.Relative));
                }
                else
                {
                    return(new Uri("/Welcome.xaml", UriKind.Relative));
                }
            }

            return(uri);
        }