atraczyk | b724d33 | 2016-08-30 15:25:59 -0400 | [diff] [blame] | 1 | /***************************************************************************
|
| 2 | * Copyright (C) 2016 by Savoir-faire Linux *
|
| 3 | * Author: Jäger Nicolas <nicolas.jager@savoirfairelinux.com> *
|
| 4 | * Author: Traczyk Andreas <andreas.traczyk@savoirfairelinux.com> *
|
| 5 | * *
|
| 6 | * This program is free software; you can redistribute it and/or modify *
|
| 7 | * it under the terms of the GNU General Public License as published by *
|
| 8 | * the Free Software Foundation; either version 3 of the License, or *
|
| 9 | * (at your option) any later version. *
|
| 10 | * *
|
| 11 | * This program is distributed in the hope that it will be useful, *
|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
| 14 | * GNU General Public License for more details. *
|
| 15 | * *
|
| 16 | * You should have received a copy of the GNU General Public License *
|
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
| 18 | **************************************************************************/
|
| 19 |
|
| 20 | #pragma once
|
| 21 |
|
| 22 | using namespace Platform::Collections;
|
| 23 | using namespace Concurrency;
|
| 24 |
|
| 25 | namespace RingClientUWP
|
| 26 | {
|
| 27 |
|
Nicolas Jager | 0788e96 | 2016-08-26 15:41:06 -0400 | [diff] [blame] | 28 | /* delegates */
|
Nicolas Jager | 7c409f3 | 2016-09-08 09:35:16 -0400 | [diff] [blame] | 29 | delegate void ContactAdded(Contact^);
|
atraczyk | b724d33 | 2016-08-30 15:25:59 -0400 | [diff] [blame] | 30 |
|
| 31 | namespace ViewModel {
|
| 32 | public ref class ContactsViewModel sealed
|
| 33 | {
|
| 34 | internal:
|
| 35 | /* singleton */
|
| 36 | static property ContactsViewModel^ instance
|
| 37 | {
|
| 38 | ContactsViewModel^ get()
|
| 39 | {
|
| 40 | static ContactsViewModel^ instance_ = ref new ContactsViewModel();
|
| 41 | return instance_;
|
| 42 | }
|
| 43 | }
|
| 44 |
|
| 45 | /* functions */
|
| 46 | Contact^ findContactByName(String^ name);
|
| 47 | Contact^ addNewContact(String^ name, String^ ringId);
|
| 48 | void saveContactsToFile();
|
| 49 | void openContactsFromFile();
|
| 50 | String^ Stringify();
|
| 51 | void Destringify(String^ data);
|
| 52 |
|
| 53 | /* properties */
|
atraczyk | b724d33 | 2016-08-30 15:25:59 -0400 | [diff] [blame] | 54 | property Vector<Contact^>^ contactsList
|
| 55 | {
|
| 56 | Vector<Contact^>^ get()
|
| 57 | {
|
| 58 | return contactsList_;
|
| 59 | }
|
| 60 | }
|
| 61 |
|
| 62 | /* events */
|
Nicolas Jager | 7c409f3 | 2016-09-08 09:35:16 -0400 | [diff] [blame] | 63 | event ContactAdded^ contactAdded;
|
atraczyk | b724d33 | 2016-08-30 15:25:59 -0400 | [diff] [blame] | 64 |
|
| 65 | private:
|
| 66 | ContactsViewModel(); // singleton
|
| 67 | Vector<Contact^>^ contactsList_;
|
| 68 | Contact^ currentItem_;
|
| 69 | Contact^ oldItem_;
|
| 70 |
|
Nicolas Jager | d57809f | 2016-10-06 11:31:55 -0400 | [diff] [blame] | 71 | void OnincomingMessage(Platform::String ^callId, Platform::String ^payload);
|
atraczyk | b724d33 | 2016-08-30 15:25:59 -0400 | [diff] [blame] | 72 | };
|
| 73 | }
|
| 74 | }
|