blob: b4de756ec1d63b85f171f9f2178e833b690ce7fd [file] [log] [blame]
atraczykb724d332016-08-30 15:25:59 -04001/***************************************************************************
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
22using namespace Platform::Collections;
23using namespace Concurrency;
24
25namespace RingClientUWP
26{
27
Nicolas Jager0788e962016-08-26 15:41:06 -040028/* delegates */
atraczykb724d332016-08-30 15:25:59 -040029delegate void NewContactSelected();
30delegate void NoContactSelected();
Nicolas Jager0788e962016-08-26 15:41:06 -040031delegate void ScreenConversationMessage(String^ accountId, String^ from, String^ payload);
32delegate void NotifyNewConversationMessage();
atraczykb724d332016-08-30 15:25:59 -040033
34namespace ViewModel {
35public ref class ContactsViewModel sealed
36{
37internal:
38 /* singleton */
39 static property ContactsViewModel^ instance
40 {
41 ContactsViewModel^ get()
42 {
43 static ContactsViewModel^ instance_ = ref new ContactsViewModel();
44 return instance_;
45 }
46 }
47
48 /* functions */
49 Contact^ findContactByName(String^ name);
50 Contact^ addNewContact(String^ name, String^ ringId);
51 void saveContactsToFile();
52 void openContactsFromFile();
53 String^ Stringify();
54 void Destringify(String^ data);
55
56 /* properties */
57 property Contact^ selectedContact
58 {
59 Contact^ get()
60 {
61 return currentItem_;
62 }
63 void set(Contact^ value)
64 {
65 oldItem_ = currentItem_;
66 currentItem_ = value;
67 if (value)
68 newContactSelected();
69 else
70 noContactSelected();
71 }
72 }
73
74 property Vector<Contact^>^ contactsList
75 {
76 Vector<Contact^>^ get()
77 {
78 return contactsList_;
79 }
80 }
81
82 /* events */
83 event NewContactSelected^ newContactSelected;
84 event NoContactSelected^ noContactSelected;
Nicolas Jager0788e962016-08-26 15:41:06 -040085 event ScreenConversationMessage^ screenConversationMessage;
86 event NotifyNewConversationMessage^ notifyNewConversationMessage;
atraczykb724d332016-08-30 15:25:59 -040087
88private:
89 ContactsViewModel(); // singleton
90 Vector<Contact^>^ contactsList_;
91 Contact^ currentItem_;
92 Contact^ oldItem_;
93
94};
95}
96}