blob: 3a905b96f3f3e9a3cd9b2cd83bf416115c144bcc [file] [log] [blame]
atraczyk8ce1dee2016-08-25 18:15:07 -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 **************************************************************************/
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040019#pragma once
atraczyk8ce1dee2016-08-25 18:15:07 -040020
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040021using namespace Platform;
22using namespace Windows::UI::Xaml::Data;
Nicolas Jager813cf4d2016-10-06 10:54:46 -040023using namespace Platform::Collections;
atraczyk46910032017-03-08 17:57:01 -050024using namespace Windows::Foundation::Collections;
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040025
26namespace RingClientUWP
27{
atraczyk46910032017-03-08 17:57:01 -050028ref class Contact;
29
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040030public ref class Account sealed : public INotifyPropertyChanged
31{
32public:
atraczyk746f3762017-02-28 14:12:51 -050033 Account(String^ name,
34 String^ ringID,
35 String^ accountType,
36 String^ accountID,
37 String^ deviceId,
38 String^ deviceName,
39 bool active,
40 bool upnpState,
41 bool autoAnswer,
42 bool dhtPublicInCalls,
43 bool turnEnabled,
44 String^ turnAddress,
45 String^ sipHostname,
46 String^ sipUsername,
47 String^ sipPassword);
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040048
atraczyk746f3762017-02-28 14:12:51 -050049 void raiseNotifyPropertyChanged(String^ propertyName);
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -040050 virtual event PropertyChangedEventHandler^ PropertyChanged;
51
Nicolas Jager6abfc0d2016-10-21 14:57:47 -040052 property String^ name_
53 {
54 String^ get() {
Nicolas Jager0a7b77d2016-10-26 12:26:43 -040055 return alias_;
Nicolas Jager6abfc0d2016-10-21 14:57:47 -040056 }
57 void set(String^ value) {
Nicolas Jager0a7b77d2016-10-26 12:26:43 -040058 alias_ = value;
Nicolas Jagerd8e49592016-10-25 08:00:11 -040059 NotifyPropertyChanged("name_");
atraczyk746f3762017-02-28 14:12:51 -050060 NotifyPropertyChanged("_bestName");
Nicolas Jager6abfc0d2016-10-21 14:57:47 -040061 }
62 }
atraczyk746f3762017-02-28 14:12:51 -050063
64 property String^ _username
65 {
66 String^ get() {
67 return username_;
68 }
69 void set(String^ value) {
70 username_ = value;
71 NotifyPropertyChanged("_username");
72 NotifyPropertyChanged("_bestName");
73 }
74 }
75
76 property String^ _bestName {
77 String^ get() {
78 String^ bestName;
79 if (alias_)
80 bestName = alias_;
81 return bestName;
82 }
83 }
84
85 property String^ _bestName2 {
86 String^ get() {
87 String^ bestName;
88 if (accountType_ == "RING" && username_)
89 bestName += username_;
90 return bestName;
91 }
92 }
93
94 property String^ _bestName3 {
95 String^ get() {
96 String^ bestName;
97 if (alias_)
98 bestName += alias_;
99 if (accountType_ == "RING" && username_)
100 bestName += " (" + username_ + ")";
101 return bestName;
102 }
103 }
104
Nicolas Jager7168df92016-10-25 13:23:03 -0400105 property String^ ringID_ {
106 String^ get() {
107 return ringID__;
108 }
109 void set(String^ value) {
110 ringID__ = value;
111 NotifyPropertyChanged("ringID_");
112 }
113 }
Nicolas Jagerd0830772016-10-07 08:45:33 -0400114 property String^ accountType_; // refacto : create a enum accountType
atraczyk797fa1a2016-08-31 09:55:53 -0400115 property String^ accountID_;
Nicolas Jager813cf4d2016-10-06 10:54:46 -0400116 property String^ _deviceId;
atraczyk746f3762017-02-28 14:12:51 -0500117 property String^ _deviceName;
118
119 property RegistrationState _registrationState;
120
121 property bool _active;
Nicolas Jager6abfc0d2016-10-21 14:57:47 -0400122 property bool _upnpState;
atraczyk746f3762017-02-28 14:12:51 -0500123 property bool _autoAnswer;
124 property bool _dhtPublicInCalls;
125 property bool _turnEnabled;
126 property String^ _turnAddress;
Nicolas Jager0a7b77d2016-10-26 12:26:43 -0400127 property String^ _sipHostname;
128 property String^ _sipUsername
129 {
130 String^ get() {
131 return sipUsername_;
132 }
133 void set(String^ value) {
134 sipUsername_ = value;
135 NotifyPropertyChanged("_sipUsername");
atraczyk746f3762017-02-28 14:12:51 -0500136 NotifyPropertyChanged("_bestName");
Nicolas Jager0a7b77d2016-10-26 12:26:43 -0400137 }
138 }
atraczyk46910032017-03-08 17:57:01 -0500139
atraczyk746f3762017-02-28 14:12:51 -0500140 property unsigned _unreadMessages {
atraczyk46910032017-03-08 17:57:01 -0500141 unsigned get() {
142 return unreadMessages_;
143 }
144 void set(unsigned value) {
145 unreadMessages_ = value;
146 NotifyPropertyChanged("_unreadMessages");
atraczyk746f3762017-02-28 14:12:51 -0500147 NotifyPropertyChanged("_allUnread");
148 }
149 }
150
151 property unsigned _unreadContactRequests {
152 unsigned get() {
153 return unreadContactRequests_;
154 }
155 void set(unsigned value) {
156 unreadContactRequests_ = value;
157 NotifyPropertyChanged("_unreadContactRequests");
158 NotifyPropertyChanged("_allUnread");
159 }
160 }
161
162 property unsigned _allUnread {
163 unsigned get() {
164 return unreadContactRequests_ + unreadMessages_;
atraczyk46910032017-03-08 17:57:01 -0500165 }
166 }
167
Nicolas Jager0a7b77d2016-10-26 12:26:43 -0400168 property String^ _sipPassword; // refacto : think to encrypt password in memory
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -0400169
atraczyk46910032017-03-08 17:57:01 -0500170 property IVector<Contact^>^ _contactsList {
171 IVector<Contact^>^ get() {
172 return contactsList_;
173 }
174 void set(IVector<Contact^>^ value) {
175 contactsList_ = value;
176 }
177 };
178
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -0400179protected:
180 void NotifyPropertyChanged(String^ propertyName);
181
Nicolas Jager813cf4d2016-10-06 10:54:46 -0400182private:
atraczyk46910032017-03-08 17:57:01 -0500183 IVector<Contact^>^ contactsList_;
184
Nicolas Jager0a7b77d2016-10-26 12:26:43 -0400185 String^ alias_;
atraczyk746f3762017-02-28 14:12:51 -0500186 String^ username_;
Nicolas Jager7168df92016-10-25 13:23:03 -0400187 String^ ringID__;
Nicolas Jager0a7b77d2016-10-26 12:26:43 -0400188 String^ sipUsername_;
atraczyk46910032017-03-08 17:57:01 -0500189 unsigned unreadMessages_;
atraczyk746f3762017-02-28 14:12:51 -0500190 unsigned unreadContactRequests_;
Nicolas Jagerbff5fbb2016-08-18 08:58:56 -0400191};
192}
193