atraczyk | 8ce1dee | 2016-08-25 18:15:07 -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 | **************************************************************************/
|
Nicolas Jager | bff5fbb | 2016-08-18 08:58:56 -0400 | [diff] [blame] | 19 | #pragma once
|
atraczyk | 8ce1dee | 2016-08-25 18:15:07 -0400 | [diff] [blame] | 20 |
|
Nicolas Jager | bff5fbb | 2016-08-18 08:58:56 -0400 | [diff] [blame] | 21 | using namespace Platform;
|
| 22 | using namespace Windows::UI::Xaml::Data;
|
Nicolas Jager | 813cf4d | 2016-10-06 10:54:46 -0400 | [diff] [blame] | 23 | using namespace Platform::Collections;
|
atraczyk | 4691003 | 2017-03-08 17:57:01 -0500 | [diff] [blame] | 24 | using namespace Windows::Foundation::Collections;
|
Nicolas Jager | bff5fbb | 2016-08-18 08:58:56 -0400 | [diff] [blame] | 25 |
|
| 26 | namespace RingClientUWP
|
| 27 | {
|
atraczyk | 4691003 | 2017-03-08 17:57:01 -0500 | [diff] [blame] | 28 | ref class Contact;
|
| 29 |
|
Nicolas Jager | bff5fbb | 2016-08-18 08:58:56 -0400 | [diff] [blame] | 30 | public ref class Account sealed : public INotifyPropertyChanged
|
| 31 | {
|
| 32 | public:
|
atraczyk | 746f376 | 2017-02-28 14:12:51 -0500 | [diff] [blame^] | 33 | 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 Jager | bff5fbb | 2016-08-18 08:58:56 -0400 | [diff] [blame] | 48 |
|
atraczyk | 746f376 | 2017-02-28 14:12:51 -0500 | [diff] [blame^] | 49 | void raiseNotifyPropertyChanged(String^ propertyName);
|
Nicolas Jager | bff5fbb | 2016-08-18 08:58:56 -0400 | [diff] [blame] | 50 | virtual event PropertyChangedEventHandler^ PropertyChanged;
|
| 51 |
|
Nicolas Jager | 6abfc0d | 2016-10-21 14:57:47 -0400 | [diff] [blame] | 52 | property String^ name_
|
| 53 | {
|
| 54 | String^ get() {
|
Nicolas Jager | 0a7b77d | 2016-10-26 12:26:43 -0400 | [diff] [blame] | 55 | return alias_;
|
Nicolas Jager | 6abfc0d | 2016-10-21 14:57:47 -0400 | [diff] [blame] | 56 | }
|
| 57 | void set(String^ value) {
|
Nicolas Jager | 0a7b77d | 2016-10-26 12:26:43 -0400 | [diff] [blame] | 58 | alias_ = value;
|
Nicolas Jager | d8e4959 | 2016-10-25 08:00:11 -0400 | [diff] [blame] | 59 | NotifyPropertyChanged("name_");
|
atraczyk | 746f376 | 2017-02-28 14:12:51 -0500 | [diff] [blame^] | 60 | NotifyPropertyChanged("_bestName");
|
Nicolas Jager | 6abfc0d | 2016-10-21 14:57:47 -0400 | [diff] [blame] | 61 | }
|
| 62 | }
|
atraczyk | 746f376 | 2017-02-28 14:12:51 -0500 | [diff] [blame^] | 63 |
|
| 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 Jager | 7168df9 | 2016-10-25 13:23:03 -0400 | [diff] [blame] | 105 | property String^ ringID_ {
|
| 106 | String^ get() {
|
| 107 | return ringID__;
|
| 108 | }
|
| 109 | void set(String^ value) {
|
| 110 | ringID__ = value;
|
| 111 | NotifyPropertyChanged("ringID_");
|
| 112 | }
|
| 113 | }
|
Nicolas Jager | d083077 | 2016-10-07 08:45:33 -0400 | [diff] [blame] | 114 | property String^ accountType_; // refacto : create a enum accountType
|
atraczyk | 797fa1a | 2016-08-31 09:55:53 -0400 | [diff] [blame] | 115 | property String^ accountID_;
|
Nicolas Jager | 813cf4d | 2016-10-06 10:54:46 -0400 | [diff] [blame] | 116 | property String^ _deviceId;
|
atraczyk | 746f376 | 2017-02-28 14:12:51 -0500 | [diff] [blame^] | 117 | property String^ _deviceName;
|
| 118 |
|
| 119 | property RegistrationState _registrationState;
|
| 120 |
|
| 121 | property bool _active;
|
Nicolas Jager | 6abfc0d | 2016-10-21 14:57:47 -0400 | [diff] [blame] | 122 | property bool _upnpState;
|
atraczyk | 746f376 | 2017-02-28 14:12:51 -0500 | [diff] [blame^] | 123 | property bool _autoAnswer;
|
| 124 | property bool _dhtPublicInCalls;
|
| 125 | property bool _turnEnabled;
|
| 126 | property String^ _turnAddress;
|
Nicolas Jager | 0a7b77d | 2016-10-26 12:26:43 -0400 | [diff] [blame] | 127 | 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");
|
atraczyk | 746f376 | 2017-02-28 14:12:51 -0500 | [diff] [blame^] | 136 | NotifyPropertyChanged("_bestName");
|
Nicolas Jager | 0a7b77d | 2016-10-26 12:26:43 -0400 | [diff] [blame] | 137 | }
|
| 138 | }
|
atraczyk | 4691003 | 2017-03-08 17:57:01 -0500 | [diff] [blame] | 139 |
|
atraczyk | 746f376 | 2017-02-28 14:12:51 -0500 | [diff] [blame^] | 140 | property unsigned _unreadMessages {
|
atraczyk | 4691003 | 2017-03-08 17:57:01 -0500 | [diff] [blame] | 141 | unsigned get() {
|
| 142 | return unreadMessages_;
|
| 143 | }
|
| 144 | void set(unsigned value) {
|
| 145 | unreadMessages_ = value;
|
| 146 | NotifyPropertyChanged("_unreadMessages");
|
atraczyk | 746f376 | 2017-02-28 14:12:51 -0500 | [diff] [blame^] | 147 | 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_;
|
atraczyk | 4691003 | 2017-03-08 17:57:01 -0500 | [diff] [blame] | 165 | }
|
| 166 | }
|
| 167 |
|
Nicolas Jager | 0a7b77d | 2016-10-26 12:26:43 -0400 | [diff] [blame] | 168 | property String^ _sipPassword; // refacto : think to encrypt password in memory
|
Nicolas Jager | bff5fbb | 2016-08-18 08:58:56 -0400 | [diff] [blame] | 169 |
|
atraczyk | 4691003 | 2017-03-08 17:57:01 -0500 | [diff] [blame] | 170 | 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 Jager | bff5fbb | 2016-08-18 08:58:56 -0400 | [diff] [blame] | 179 | protected:
|
| 180 | void NotifyPropertyChanged(String^ propertyName);
|
| 181 |
|
Nicolas Jager | 813cf4d | 2016-10-06 10:54:46 -0400 | [diff] [blame] | 182 | private:
|
atraczyk | 4691003 | 2017-03-08 17:57:01 -0500 | [diff] [blame] | 183 | IVector<Contact^>^ contactsList_;
|
| 184 |
|
Nicolas Jager | 0a7b77d | 2016-10-26 12:26:43 -0400 | [diff] [blame] | 185 | String^ alias_;
|
atraczyk | 746f376 | 2017-02-28 14:12:51 -0500 | [diff] [blame^] | 186 | String^ username_;
|
Nicolas Jager | 7168df9 | 2016-10-25 13:23:03 -0400 | [diff] [blame] | 187 | String^ ringID__;
|
Nicolas Jager | 0a7b77d | 2016-10-26 12:26:43 -0400 | [diff] [blame] | 188 | String^ sipUsername_;
|
atraczyk | 4691003 | 2017-03-08 17:57:01 -0500 | [diff] [blame] | 189 | unsigned unreadMessages_;
|
atraczyk | 746f376 | 2017-02-28 14:12:51 -0500 | [diff] [blame^] | 190 | unsigned unreadContactRequests_;
|
Nicolas Jager | bff5fbb | 2016-08-18 08:58:56 -0400 | [diff] [blame] | 191 | };
|
| 192 | }
|
| 193 |
|