Beispiel #1
0
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        /// <summary>
        /// Loads all OMEMO keys from the given store.
        /// </summary>
        /// <param name="omemoStore">A persistent store for all the OMEMO related data (e.g. device ids and keys).</param>
        /// <returns>Returns true on success.</returns>
        public bool loadOmemoKeys(IOmemoStore omemoStore)
        {
            if (!omemoKeysGenerated)
            {
                Logger.Error("Failed to load OMEMO keys for: " + getBareJid() + " - run generateOmemoKeys() first!");
                return(false);
            }

            OMEMO_PRE_KEYS.Clear();
            OMEMO_PRE_KEYS.AddRange(omemoStore.LoadPreKeys());
            if (OMEMO_PRE_KEYS.Count <= 0)
            {
                Logger.Error("Failed to load OMEMO prekeys for: " + getBareJid());
                return(false);
            }

            omemoSignedPreKeyPair = omemoStore.LoadSignedPreKey(omemoSignedPreKeyId);
            if (omemoSignedPreKeyPair is null)
            {
                Logger.Error("Failed to load OMEMO signed prekey pair for: " + getBareJid());
                return(false);
            }

            Logger.Info("Successfully loaded OMEMO keys for: " + getBareJid());
            return(true);
        }
        /*
         * Loads items from the DB and appends them to the bottom of the list. Infinity Scroll™
         */
        private async Task LoadItems()
        {
            IsLoading = true;

            // This is where users will be populated from
            UserList.AddRange(await getUsers(currentIndex, 20));
            currentIndex += 20;

            IsLoading = false;
        }
        /*
         * Loads items from the DB and appends them to the bottom of the list. Infinity Scroll™
         */
        private async Task LoadItems()
        {
            IsLoading = true;

            // This is where users will be populated from
            List <User> fetchedUsers = await getUsers(currentIndex, 20);

            fetchedUsers.RemoveAll(user => activeConversations.Contains(user.id));

            UserList.AddRange(fetchedUsers);
            currentIndex += 20;

            IsLoading = false;
        }
Beispiel #4
0
 //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
 #region --Constructors--
 public LecturesDataTemplate(List <Lecture> lecturesList)
 {
     // There always has to be one grade:
     HEADER         = lecturesList[0].SemesterId;
     LECTURES_GROUP = new CustomObservableCollection <Lecture>(true);
     LECTURES_GROUP.AddRange(lecturesList);
 }
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        public void LoadAccounts()
        {
            Task.Run(async() =>
            {
                if (!(loadingAccountsTask is null))
                {
                    await loadingAccountsTask;
                }

                loadingAccountsTask = Task.Run(() =>
                {
                    IsLoading = true;
                    ConnectionHandler.INSTANCE.ClientsCollectionChanged -= INSTANCE_ClientsCollectionChanged;
                    ConnectionHandler.INSTANCE.ClientsCollectionChanged += INSTANCE_ClientsCollectionChanged;

                    ACCOUNTS.Clear();

                    CustomObservableCollection <XMPPClient> clients = ConnectionHandler.INSTANCE.getClients();
                    IEnumerable <AccountDataTemplate> accounts      = clients.Select((client) =>
                    {
                        return(new AccountDataTemplate
                        {
                            Client = client
                        });
                    });

                    ACCOUNTS.AddRange(accounts);
                });

                await loadingAccountsTask;
                IsLoading = false;
            });
        }
 //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
 #region --Constructors--
 public GradesDataTemplate(List <Grade> gradesList)
 {
     // There always has to be one grade:
     HEADER       = gradesList[0].LectureSemester;
     GRADES_GROUP = new CustomObservableCollection <Grade>(true);
     GRADES_GROUP.AddRange(gradesList);
     AVERAGE_GRADE = CalcAvgGrade(gradesList);
 }
Beispiel #7
0
        /*
         * Performs the medication search
         */
        async void Handle_SearchButtonPressed(object sender, EventArgs e)
        {
            // Update the current search param
            IsLoading = true;
            observableMedicationList.Clear();
            string searchQuery = InputValidation.Trim(MedicationSearchBar.Text);
            MedicationResponseObject medicationsReturned = await drugAutoFillActiveIngredientsAPI.autocomplete(searchQuery);

            observableMedicationList.AddRange(medicationsReturned.suggestions);

            IsLoading = false;
            DateTime dateTime = DateTime.Now;
        }
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--
        public void setDevices(IList <uint> devices)
        {
            DEVICES.Clear();
            List <UintTemplate> dev = new List <UintTemplate>();

            foreach (uint d in devices)
            {
                dev.Add(new UintTemplate()
                {
                    value = d
                });
            }
            DEVICES.AddRange(dev);
            updateDeviceInfo();
        }
Beispiel #9
0
        //--------------------------------------------------------Constructor:----------------------------------------------------------------\\
        #region --Constructors--


        #endregion
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        public void UpdateView(AccountDataTemplate account)
        {
            DEVICES.Clear();
            if (account is null)
            {
                return;
            }

            IEnumerable <uint> devices = account.Client.getOmemoHelper()?.DEVICES?.IDS;

            if (!(devices is null))
            {
                DEVICES.AddRange(devices.Select(x => new UintDataTemplate {
                    Value = x
                }));
            }
        }
Beispiel #10
0
        private void showChatMessages(ChatTable newChat, ChatTable oldChat)
        {
            if (newChat != null)
            {
                // Only show chat messages if the chat changed:
                if (oldChat != null && Equals(newChat.id, oldChat.id))
                {
                    return;
                }

                // Show loading:
                loading_ldng.IsLoading           = true;
                invertedListView_lstv.Visibility = Visibility.Collapsed;

                // Create a copy to prevent multi threading issues:
                ChatTable chatCpy = newChat;

                Task.Run(async() =>
                {
                    // Mark all unread messages as read for this chat:
                    ChatDBManager.INSTANCE.markAllMessagesAsRead(chatCpy.id);
                    // Remove notification group:
                    ToastHelper.removeToastGroup(chatCpy.id);

                    // Show all chat messages:
                    List <ChatMessageDataTemplate> msgs = new List <ChatMessageDataTemplate>();
                    foreach (ChatMessageTable msg in ChatDBManager.INSTANCE.getAllChatMessagesForChat(chatCpy.id))
                    {
                        msgs.Add(new ChatMessageDataTemplate()
                        {
                            message = msg,
                            chat    = chatCpy
                        });
                    }
                    await Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
                    {
                        chatMessages.Clear();
                        chatMessages.AddRange(msgs);
                        invertedListView_lstv.Visibility = Visibility.Visible;
                        loading_ldng.IsLoading           = false;
                    });
                });
            }
        }
 private bool onMessage(AbstractMessage msg)
 {
     if (msg is IQErrorMessage errorMsg)
     {
         Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             bookmarks.Clear();
             if (errorMsg.ERROR_OBJ.ERROR_NAME == ErrorName.ITEM_NOT_FOUND)
             {
                 noneFound_notification.Show("Found 0 bookmarks.", 2000);
             }
             else
             {
                 noneFound_notification.Show("Request failed with:\n" + errorMsg.ERROR_OBJ.ERROR_NAME + " and " + errorMsg.ERROR_OBJ.ERROR_MESSAGE);
             }
             reload_abb.IsEnabled    = true;
             loading_grid.Visibility = Visibility.Collapsed;
             main_grid.Visibility    = Visibility.Visible;
         }).AsTask();
         return(true);
     }
     else if (msg is BookmarksResultMessage result)
     {
         Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () =>
         {
             bookmarks.Clear();
             bookmarks.AddRange(result.STORAGE.CONFERENCES);
             if (result.STORAGE.CONFERENCES.Count > 1)
             {
                 noneFound_notification.Show("Found " + result.STORAGE.CONFERENCES.Count + " bookmarks.", 2000);
             }
             else
             {
                 noneFound_notification.Show("Found " + result.STORAGE.CONFERENCES.Count + " bookmark.", 2000);
             }
             reload_abb.IsEnabled    = true;
             loading_grid.Visibility = Visibility.Collapsed;
             main_grid.Visibility    = Visibility.Visible;
         }).AsTask();
         return(true);
     }
     return(false);
 }
        /*
         * Used when viewing -> editing an existing procedure
         * Constructor which initialises the entries of the procedures listview.
         */
        public SingleProcedurePage(Procedure procedure, ProceduresPage proceduresPageController)
        {
            InitializeComponent();
            currentProcedure = procedure;
            this.proceduresPageController = proceduresPageController;
            Title = "View Procedure";

            affectedOrganStack.IsVisible = false;

            organsAffected = new CustomObservableCollection <string>();
            organsAffectedList.ItemsSource = organsAffected;

            SummaryEntry.Text     = procedure.summary;
            DescriptionEntry.Text = procedure.description;
            DateDueEntry.Date     = procedure.date.ToDateTime();

            organsAffected.AddRange(procedure.organsAffected.ConvertAll(OrganExtensions.ToString));

            if (this.proceduresPageController.isClinicianAccessing)
            {
                EditProcedureButton.IsVisible = true;
            }
        }
        /*
         * Constructor which sets the detail strings for each medication and also sets
         * the visibility of the no data label and compare medications button.
         */
        public MedicationsPage()
        {
            InitializeComponent();
            observableMedicationList    = new CustomObservableCollection <Medication>();
            MedicationsList.ItemsSource = observableMedicationList;
            CheckIfClinicianAccessing();

            //FOR SOME REASON IT DOESNT WORK IF I HAVE THESE IN THE CONSTRUCTORS??

            foreach (Medication item in UserController.Instance.LoggedInUser.currentMedications)
            {
                item.DetailString = item.history[0];
            }
            foreach (Medication item in UserController.Instance.LoggedInUser.historicMedications)
            {
                item.DetailString = item.history[item.history.Count - 1];
            }

            if (UserController.Instance.LoggedInUser.currentMedications.Count == 0)
            {
                NoDataLabel.IsVisible     = true;
                MedicationsList.IsVisible = false;
            }

            if (UserController.Instance.LoggedInUser.currentMedications.Count + UserController.Instance.LoggedInUser.historicMedications.Count < 2)
            {
                CompareButton.IsVisible = false;
            }

            observableMedicationList.AddRange(UserController.Instance.LoggedInUser.currentMedications);

            if (isClinicianAccessing)
            {
                AddMedicationButton.IsVisible = true;
            }
        }
        /*
         * Event handler to handle when a user switches between current and historic medications
         * resetting the sorting and changing the listview items.
         */
        void Handle_MedicationChanged(object sender, SegmentedControl.FormsPlugin.Abstractions.ValueChangedEventArgs e)
        {
            switch (e.NewValue)
            {
            case 0:
                if (UserController.Instance.LoggedInUser.currentMedications.Count == 0)
                {
                    NoDataLabel.IsVisible     = true;
                    MedicationsList.IsVisible = false;
                }
                else
                {
                    NoDataLabel.IsVisible     = false;
                    MedicationsList.IsVisible = true;
                }
                observableMedicationList.Clear();
                observableMedicationList.AddRange(UserController.Instance.LoggedInUser.currentMedications);
                break;

            case 1:
                if (UserController.Instance.LoggedInUser.historicMedications.Count == 0)
                {
                    NoDataLabel.IsVisible     = true;
                    MedicationsList.IsVisible = false;
                }
                else
                {
                    NoDataLabel.IsVisible     = false;
                    MedicationsList.IsVisible = true;
                }

                observableMedicationList.Clear();
                observableMedicationList.AddRange(UserController.Instance.LoggedInUser.historicMedications);
                break;
            }
        }
Beispiel #15
0
        //--------------------------------------------------------Set-, Get- Methods:---------------------------------------------------------\\
        #region --Set-, Get- Methods--


        #endregion
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--
        public void LoadProvider()
        {
            PROVIDER.Clear();
            PROVIDER.AddRange(XMPPProviders.INSTANCE.providersB);
        }
Beispiel #16
0
        //--------------------------------------------------------Misc Methods:---------------------------------------------------------------\\
        #region --Misc Methods (Public)--


        #endregion

        #region --Misc Methods (Private)--
        private void LoadClients()
        {
            CLIENTS.Clear();
            CLIENTS.AddRange(ConnectionHandler.INSTANCE.getClients().Select((x) => new XMPPClientDataTemplate(x)));
        }