~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to kde/src/lib/account.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/****************************************************************************
2
 
 *   Copyright (C) 2009-2013 by Savoir-Faire Linux                          *
 
2
 *   Copyright (C) 2009-2014 by Savoir-Faire Linux                          *
3
3
 *   Author : Jérémy Quentin <jeremy.quentin@savoirfairelinux.com>          *
4
4
 *            Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com> *
5
5
 *                                                                          *
27
27
 
28
28
//SFLPhone
29
29
#include "videocodecmodel.h"
 
30
#include "keyexchangemodel.h"
 
31
#include "tlsmethodmodel.h"
30
32
#include "sflphone_const.h"
31
33
#include "typedefs.h"
32
 
#include "dbus/metatypes.h"
 
34
// #include "dbus/metatypes.h"
33
35
class CredentialModel;
34
36
class AudioCodecModel;
35
37
class VideoCodecModel;
 
38
class RingToneModel  ;
 
39
class PhoneNumber    ;
36
40
 
37
41
const QString& account_state_name(const QString& s);
38
42
 
39
43
typedef void (Account::*account_function)();
40
44
 
41
 
///@enum AccountEditState: Manage how and when an account can be reloaded or change state
42
 
enum AccountEditState {
43
 
   READY    =0,
44
 
   EDITING  =1,
45
 
   OUTDATED =2,
46
 
   NEW      =3,
47
 
   MODIFIED =4,
48
 
   REMOVED  =5
49
 
};
50
 
 
51
 
///@enum AccountEditAction Actions that can be performed on the Account state
52
 
enum AccountEditAction {
53
 
   NOTHING =0,
54
 
   EDIT    =1,
55
 
   RELOAD  =2,
56
 
   SAVE    =3,
57
 
   REMOVE  =4,
58
 
   MODIFY  =5,
59
 
   CANCEL  =6
60
 
};
61
 
 
62
45
///@enum DtmfType Different method to send the DTMF (key sound) to the peer
63
46
enum DtmfType {
64
47
   OverRtp,
65
48
   OverSip
66
49
};
 
50
Q_ENUMS(DtmfType)
67
51
 
68
52
///Account: a daemon account (SIP or AIX)
69
53
class LIB_EXPORT Account : public QObject {
 
54
   #pragma GCC diagnostic push
 
55
   #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
70
56
   Q_OBJECT
 
57
   #pragma GCC diagnostic pop
 
58
 
 
59
   friend class AccountListModel;
 
60
 
 
61
   //Properties
 
62
   Q_PROPERTY(QString        alias                        READ alias                         WRITE setAlias                       )
 
63
   Q_PROPERTY(Account::Protocol protocol                  READ protocol                      WRITE setProtocol                    )
 
64
   Q_PROPERTY(QString        hostname                     READ hostname                      WRITE setHostname                    )
 
65
   Q_PROPERTY(QString        username                     READ username                      WRITE setUsername                    )
 
66
   Q_PROPERTY(QString        mailbox                      READ mailbox                       WRITE setMailbox                     )
 
67
   Q_PROPERTY(QString        proxy                        READ proxy                         WRITE setProxy                       )
 
68
   Q_PROPERTY(QString        tlsPassword                  READ tlsPassword                   WRITE setTlsPassword                 )
 
69
   Q_PROPERTY(QString        tlsCaListFile                READ tlsCaListFile                 WRITE setTlsCaListFile               )
 
70
   Q_PROPERTY(QString        tlsCertificateFile           READ tlsCertificateFile            WRITE setTlsCertificateFile          )
 
71
   Q_PROPERTY(QString        tlsPrivateKeyFile            READ tlsPrivateKeyFile             WRITE setTlsPrivateKeyFile           )
 
72
   Q_PROPERTY(QString        tlsCiphers                   READ tlsCiphers                    WRITE setTlsCiphers                  )
 
73
   Q_PROPERTY(QString        tlsServerName                READ tlsServerName                 WRITE setTlsServerName               )
 
74
   Q_PROPERTY(QString        sipStunServer                READ sipStunServer                 WRITE setSipStunServer               )
 
75
   Q_PROPERTY(QString        publishedAddress             READ publishedAddress              WRITE setPublishedAddress            )
 
76
   Q_PROPERTY(QString        localInterface               READ localInterface                WRITE setLocalInterface              )
 
77
   Q_PROPERTY(QString        ringtonePath                 READ ringtonePath                  WRITE setRingtonePath                )
 
78
   Q_PROPERTY(QString        lastErrorMessage             READ lastErrorMessage              WRITE setLastErrorMessage            )
 
79
   Q_PROPERTY(TlsMethodModel::Type tlsMethod              READ tlsMethod                     WRITE setTlsMethod                   )
 
80
   Q_PROPERTY(KeyExchangeModel::Type keyExchange          READ keyExchange                   WRITE setKeyExchange                 )
 
81
   Q_PROPERTY(int            lastErrorCode                READ lastErrorCode                 WRITE setLastErrorCode               )
 
82
   Q_PROPERTY(int            registrationExpire           READ registrationExpire            WRITE setRegistrationExpire          )
 
83
   Q_PROPERTY(int            tlsNegotiationTimeoutSec     READ tlsNegotiationTimeoutSec      WRITE setTlsNegotiationTimeoutSec    )
 
84
   Q_PROPERTY(int            tlsNegotiationTimeoutMsec    READ tlsNegotiationTimeoutMsec     WRITE setTlsNegotiationTimeoutMsec   )
 
85
   Q_PROPERTY(int            localPort                    READ localPort                     WRITE setLocalPort                   )
 
86
   Q_PROPERTY(int            tlsListenerPort              READ tlsListenerPort               WRITE setTlsListenerPort             )
 
87
   Q_PROPERTY(int            publishedPort                READ publishedPort                 WRITE setPublishedPort               )
 
88
   Q_PROPERTY(bool           enabled                      READ isEnabled                     WRITE setEnabled                     )
 
89
   Q_PROPERTY(bool           autoAnswer                   READ isAutoAnswer                  WRITE setAutoAnswer                  )
 
90
   Q_PROPERTY(bool           tlsVerifyServer              READ isTlsVerifyServer             WRITE setTlsVerifyServer             )
 
91
   Q_PROPERTY(bool           tlsVerifyClient              READ isTlsVerifyClient             WRITE setTlsVerifyClient             )
 
92
   Q_PROPERTY(bool           tlsRequireClientCertificate  READ isTlsRequireClientCertificate WRITE setTlsRequireClientCertificate )
 
93
   Q_PROPERTY(bool           tlsEnable                    READ isTlsEnable                   WRITE setTlsEnable                   )
 
94
   Q_PROPERTY(bool           displaySasOnce               READ isDisplaySasOnce              WRITE setDisplaySasOnce              )
 
95
   Q_PROPERTY(bool           srtpRtpFallback              READ isSrtpRtpFallback             WRITE setSrtpRtpFallback             )
 
96
   Q_PROPERTY(bool           zrtpDisplaySas               READ isZrtpDisplaySas              WRITE setZrtpDisplaySas              )
 
97
   Q_PROPERTY(bool           zrtpNotSuppWarning           READ isZrtpNotSuppWarning          WRITE setZrtpNotSuppWarning          )
 
98
   Q_PROPERTY(bool           zrtpHelloHash                READ isZrtpHelloHash               WRITE setZrtpHelloHash               )
 
99
   Q_PROPERTY(bool           sipStunEnabled               READ isSipStunEnabled              WRITE setSipStunEnabled              )
 
100
   Q_PROPERTY(bool           publishedSameAsLocal         READ isPublishedSameAsLocal        WRITE setPublishedSameAsLocal        )
 
101
   Q_PROPERTY(bool           ringtoneEnabled              READ isRingtoneEnabled             WRITE setRingtoneEnabled             )
 
102
   Q_PROPERTY(DtmfType       dTMFType                     READ DTMFType                      WRITE setDTMFType                    )
 
103
   Q_PROPERTY(int            voiceMailCount               READ voiceMailCount                WRITE setVoiceMailCount              )
 
104
//    Q_PROPERTY(QString        typeName                     READ type                          WRITE setType                        )
 
105
   Q_PROPERTY(bool           presenceStatus               READ presenceStatus                                                     )
 
106
   Q_PROPERTY(QString        presenceMessage              READ presenceMessage                                                    )
 
107
   Q_PROPERTY(bool           supportPresencePublish       READ supportPresencePublish                                             )
 
108
   Q_PROPERTY(bool           supportPresenceSubscribe     READ supportPresenceSubscribe                                           )
71
109
 
72
110
   public:
 
111
      ///@enum AccountEditState: Manage how and when an account can be reloaded or change state
 
112
      enum class AccountEditState {
 
113
         READY    = 0,
 
114
         EDITING  = 1,
 
115
         OUTDATED = 2,
 
116
         NEW      = 3,
 
117
         MODIFIED = 4,
 
118
         REMOVED  = 5
 
119
      };
 
120
 
 
121
      ///@enum AccountEditAction Actions that can be performed on the Account state
 
122
      enum class AccountEditAction {
 
123
         NOTHING = 0,
 
124
         EDIT    = 1,
 
125
         RELOAD  = 2,
 
126
         SAVE    = 3,
 
127
         REMOVE  = 4,
 
128
         MODIFY  = 5,
 
129
         CANCEL  = 6
 
130
      };
 
131
 
 
132
      class State {
 
133
      public:
 
134
         constexpr static const char* REGISTERED                = "REGISTERED"             ;
 
135
         constexpr static const char* READY                     = "READY"                  ;
 
136
         constexpr static const char* UNREGISTERED              = "UNREGISTERED"           ;
 
137
         constexpr static const char* TRYING                    = "TRYING"                 ;
 
138
         constexpr static const char* ERROR                     = "ERROR"                  ;
 
139
         constexpr static const char* ERROR_AUTH                = "ERRORAUTH"              ;
 
140
         constexpr static const char* ERROR_NETWORK             = "ERRORNETWORK"           ;
 
141
         constexpr static const char* ERROR_HOST                = "ERRORHOST"              ;
 
142
         constexpr static const char* ERROR_CONF_STUN           = "ERROR_CONF_STUN"        ;
 
143
         constexpr static const char* ERROR_EXIST_STUN          = "ERROREXISTSTUN"         ;
 
144
         constexpr static const char* ERROR_SERVICE_UNAVAILABLE = "ERRORSERVICEUNAVAILABLE";
 
145
         constexpr static const char* ERROR_NOT_ACCEPTABLE      = "ERRORNOTACCEPTABLE"     ;
 
146
         constexpr static const char* REQUEST_TIMEOUT           = "Request Timeout"        ;
 
147
      };
 
148
 
73
149
      ~Account();
74
150
      //Constructors
75
151
      static Account* buildExistingAccountFromId(const QString& _accountId);
76
152
      static Account* buildNewAccountFromAlias  (const QString& alias     );
77
153
 
 
154
      enum Role {
 
155
         Alias                       = 100,
 
156
         Proto                       = 101,
 
157
         Hostname                    = 102,
 
158
         Username                    = 103,
 
159
         Mailbox                     = 104,
 
160
         Proxy                       = 105,
 
161
         TlsPassword                 = 107,
 
162
         TlsCaListFile               = 108,
 
163
         TlsCertificateFile          = 109,
 
164
         TlsPrivateKeyFile           = 110,
 
165
         TlsCiphers                  = 111,
 
166
         TlsServerName               = 112,
 
167
         SipStunServer               = 113,
 
168
         PublishedAddress            = 114,
 
169
         LocalInterface              = 115,
 
170
         RingtonePath                = 116,
 
171
         TlsMethod                   = 117,
 
172
         KeyExchange                 = 190,
 
173
         RegistrationExpire          = 118,
 
174
         TlsNegotiationTimeoutSec    = 119,
 
175
         TlsNegotiationTimeoutMsec   = 120,
 
176
         LocalPort                   = 121,
 
177
         TlsListenerPort             = 122,
 
178
         PublishedPort               = 123,
 
179
         Enabled                     = 124,
 
180
         AutoAnswer                  = 125,
 
181
         TlsVerifyServer             = 126,
 
182
         TlsVerifyClient             = 127,
 
183
         TlsRequireClientCertificate = 128,
 
184
         TlsEnable                   = 129,
 
185
         DisplaySasOnce              = 130,
 
186
         SrtpRtpFallback             = 131,
 
187
         ZrtpDisplaySas              = 132,
 
188
         ZrtpNotSuppWarning          = 133,
 
189
         ZrtpHelloHash               = 134,
 
190
         SipStunEnabled              = 135,
 
191
         PublishedSameAsLocal        = 136,
 
192
         RingtoneEnabled             = 137,
 
193
         dTMFType                    = 138,
 
194
         Id                          = 139,
 
195
         Object                      = 140,
 
196
         TypeName                    = 141,
 
197
         PresenceStatus              = 142,
 
198
         PresenceMessage             = 143,
 
199
      };
 
200
 
 
201
      class MapField {
 
202
      public:
 
203
         constexpr static const char* ID                     = "Account.id"                        ;
 
204
         constexpr static const char* TYPE                   = "Account.type"                      ;
 
205
         constexpr static const char* ALIAS                  = "Account.alias"                     ;
 
206
         constexpr static const char* ENABLED                = "Account.enable"                    ;
 
207
         constexpr static const char* MAILBOX                = "Account.mailbox"                   ;
 
208
         constexpr static const char* DTMF_TYPE              = "Account.dtmfType"                  ;
 
209
         constexpr static const char* AUTOANSWER             = "Account.autoAnswer"                ;
 
210
         constexpr static const char* HOSTNAME               = "Account.hostname"                  ;
 
211
         constexpr static const char* USERNAME               = "Account.username"                  ;
 
212
         constexpr static const char* ROUTE                  = "Account.routeset"                  ;
 
213
         constexpr static const char* PASSWORD               = "Account.password"                  ;
 
214
         constexpr static const char* REALM                  = "Account.realm"                     ;
 
215
         constexpr static const char* LOCAL_INTERFACE        = "Account.localInterface"            ;
 
216
         constexpr static const char* PUBLISHED_SAMEAS_LOCAL = "Account.publishedSameAsLocal"      ;
 
217
         constexpr static const char* LOCAL_PORT             = "Account.localPort"                 ;
 
218
         constexpr static const char* PUBLISHED_PORT         = "Account.publishedPort"             ;
 
219
         constexpr static const char* PUBLISHED_ADDRESS      = "Account.publishedAddress"          ;
 
220
         class STUN {
 
221
         public:
 
222
            constexpr static const char* SERVER              = "STUN.server"                       ;
 
223
            constexpr static const char* ENABLED             = "STUN.enable"                       ;
 
224
         };
 
225
         class Presence {
 
226
         public:
 
227
            constexpr static const char* SUPPORT_PUBLISH     = "Account.presencePublishSupported"  ;
 
228
            constexpr static const char* SUPPORT_SUBSCRIBE   = "Account.presenceSubscribeSupported";
 
229
            constexpr static const char* ENABLE              = "Account.presenceEnabled"           ;
 
230
         };
 
231
         class Registration {
 
232
         public:
 
233
            constexpr static const char* EXPIRE              = "Account.registrationExpire"        ;
 
234
            constexpr static const char* STATUS              = "Account.registrationStatus"        ;
 
235
         };
 
236
         class Ringtone {
 
237
         public:
 
238
            constexpr static const char* PATH                = "Account.ringtonePath"              ;
 
239
            constexpr static const char* ENABLED             = "Account.ringtoneEnabled"           ;
 
240
         };
 
241
         class SRTP {
 
242
         public:
 
243
            constexpr static const char* KEY_EXCHANGE        = "SRTP.keyExchange"                  ;
 
244
            constexpr static const char* ENABLED             = "SRTP.enable"                       ;
 
245
            constexpr static const char* RTP_FALLBACK        = "SRTP.rtpFallback"                  ;
 
246
         };
 
247
         class ZRTP {
 
248
         public:
 
249
            constexpr static const char* DISPLAY_SAS         = "ZRTP.displaySAS"                   ;
 
250
            constexpr static const char* NOT_SUPP_WARNING    = "ZRTP.notSuppWarning"               ;
 
251
            constexpr static const char* HELLO_HASH          = "ZRTP.helloHashEnable"              ;
 
252
            constexpr static const char* DISPLAY_SAS_ONCE    = "ZRTP.displaySasOnce"               ;
 
253
         };
 
254
         class TLS {
 
255
         public:
 
256
            constexpr static const char* LISTENER_PORT       = "TLS.listenerPort"                  ;
 
257
            constexpr static const char* ENABLE              = "TLS.enable"                        ;
 
258
            constexpr static const char* PORT                = "TLS.port"                          ;
 
259
            constexpr static const char* CA_LIST_FILE        = "TLS.certificateListFile"           ;
 
260
            constexpr static const char* CERTIFICATE_FILE    = "TLS.certificateFile"               ;
 
261
            constexpr static const char* PRIVATE_KEY_FILE    = "TLS.privateKeyFile"                ;
 
262
            constexpr static const char* PASSWORD            = "TLS.password"                      ;
 
263
            constexpr static const char* METHOD              = "TLS.method"                        ;
 
264
            constexpr static const char* CIPHERS             = "TLS.ciphers"                       ;
 
265
            constexpr static const char* SERVER_NAME         = "TLS.serverName"                    ;
 
266
            constexpr static const char* VERIFY_SERVER       = "TLS.verifyServer"                  ;
 
267
            constexpr static const char* VERIFY_CLIENT       = "TLS.verifyClient"                  ;
 
268
            constexpr static const char* REQUIRE_CLIENT_CERTIFICATE = "TLS.requireClientCertificate";
 
269
            constexpr static const char* NEGOTIATION_TIMEOUT_SEC    = "TLS.negotiationTimeoutSec"   ;
 
270
            constexpr static const char* NEGOTIATION_TIMEOUT_MSEC   = "TLS.negotiationTimemoutMsec" ;
 
271
         };
 
272
      };
 
273
 
 
274
      class ProtocolName {
 
275
      public:
 
276
         constexpr static const char* SIP = "SIP";
 
277
         constexpr static const char* IAX = "IAX";
 
278
      };
 
279
 
 
280
      enum class Protocol {
 
281
         SIP = 0,
 
282
         IAX = 1,
 
283
      };
 
284
      Q_ENUMS(Protocol)
 
285
 
78
286
      /**
79
287
       *Perform an action
80
288
       * @return If the state changed
81
289
       */
82
 
      bool performAction(AccountEditAction action);
83
 
      AccountEditState currentState() const;
84
 
 
85
 
      //Getters
86
 
      bool                    isNew()                                const;
87
 
      const QString           getAccountId()                         const;
88
 
      const MapStringString&  getAccountDetails()                    const;
89
 
      const QString           getStateName(const QString& state)     const;
90
 
      const QString           getAccountDetail(const QString& param) const;
91
 
      const QString           getAlias()                             const;
92
 
      bool                    isEnabled()                            const;
93
 
      bool                    isRegistered()                         const;
94
 
      QModelIndex             getIndex()                                  ;
95
 
      QString                 getStateColorName()                    const;
96
 
      Qt::GlobalColor         getStateColor()                        const;
97
 
 
98
 
      CredentialModel*        getCredentialsModel();
99
 
      AudioCodecModel*        getAudioCodecModel();
100
 
      VideoCodecModel*        getVideoCodecModel();
101
 
 
102
 
      ///Return the account hostname
103
 
      QString getAccountHostname              () const;
104
 
      bool    isAccountEnabled                () const;
105
 
      bool    isAutoAnswer                    () const;
106
 
      QString getAccountUsername              () const;
107
 
      QString getAccountMailbox               () const;
108
 
      QString getAccountProxy                 () const;
109
 
      bool    isAccountDisplaySasOnce         () const;
110
 
      bool    isAccountSrtpRtpFallback        () const;
111
 
      bool    isAccountZrtpDisplaySas         () const;
112
 
      bool    isAccountZrtpNotSuppWarning     () const;
113
 
      bool    isAccountZrtpHelloHash          () const;
114
 
      bool    isAccountSipStunEnabled         () const;
115
 
      QString getAccountSipStunServer         () const;
116
 
      int     getAccountRegistrationExpire    () const;
117
 
      bool    isPublishedSameAsLocal          () const;
118
 
      QString getPublishedAddress             () const;
119
 
      int     getPublishedPort                () const;
120
 
      QString getTlsPassword                  () const;
121
 
      int     getTlsListenerPort              () const;
122
 
      QString getTlsCaListFile                () const;
123
 
      QString getTlsCertificateFile           () const;
124
 
      QString getTlsPrivateKeyFile            () const;
125
 
      QString getTlsCiphers                   () const;
126
 
      QString getTlsServerName                () const;
127
 
      int     getTlsNegotiationTimeoutSec     () const;
128
 
      int     getTlsNegotiationTimeoutMsec    () const;
129
 
      bool    isTlsVerifyServer               () const;
130
 
      bool    isTlsVerifyClient               () const;
131
 
      bool    isTlsRequireClientCertificate   () const;
132
 
      bool    isTlsEnable                     () const;
133
 
      int     getTlsMethod                    () const;
134
 
      QString getAccountAlias                 () const;
135
 
      bool    isRingtoneEnabled               () const;
136
 
      QString getRingtonePath                 () const;
137
 
      int     getLocalPort                    () const;
138
 
      QString getLocalInterface               () const;
139
 
      QString getAccountRegistrationStatus    () const;
140
 
      QString getAccountType                  () const;
141
 
      DtmfType getDTMFType                    () const;
142
 
   
 
290
      bool performAction(Account::AccountEditAction action);
 
291
      Account::AccountEditState state() const;
 
292
 
 
293
      //Getters
 
294
      bool            isNew()                             const;
 
295
      const QString   id()                                const;
 
296
      const QString   toHumanStateName()                  const;
 
297
      const QString   accountDetail(const QString& param) const;
 
298
      const QString   alias()                             const;
 
299
      bool            isRegistered()                      const;
 
300
      QModelIndex     index()                                  ;
 
301
      QString         stateColorName()                    const;
 
302
      QVariant        stateColor()                        const;
 
303
 
 
304
      Q_INVOKABLE CredentialModel*  credentialsModel() const;
 
305
      Q_INVOKABLE AudioCodecModel*  audioCodecModel () const;
 
306
      Q_INVOKABLE VideoCodecModel*  videoCodecModel () const;
 
307
      Q_INVOKABLE RingToneModel*    ringToneModel   () const;
 
308
      Q_INVOKABLE KeyExchangeModel* keyExchangeModel() const;
 
309
 
 
310
      //Getters
 
311
      QString hostname                     () const;
 
312
      bool    isEnabled                    () const;
 
313
      bool    isAutoAnswer                 () const;
 
314
      QString username                     () const;
 
315
      QString mailbox                      () const;
 
316
      QString proxy                        () const;
 
317
      QString password                     () const;
 
318
      bool    isDisplaySasOnce             () const;
 
319
      bool    isSrtpRtpFallback            () const;
 
320
      bool    isSrtpEnabled                () const;
 
321
      bool    isZrtpDisplaySas             () const;
 
322
      bool    isZrtpNotSuppWarning         () const;
 
323
      bool    isZrtpHelloHash              () const;
 
324
      bool    isSipStunEnabled             () const;
 
325
      QString sipStunServer                () const;
 
326
      int     registrationExpire           () const;
 
327
      bool    isPublishedSameAsLocal       () const;
 
328
      QString publishedAddress             () const;
 
329
      int     publishedPort                () const;
 
330
      QString tlsPassword                  () const;
 
331
      int     tlsListenerPort              () const;
 
332
      QString tlsCaListFile                () const;
 
333
      QString tlsCertificateFile           () const;
 
334
      QString tlsPrivateKeyFile            () const;
 
335
      QString tlsCiphers                   () const;
 
336
      QString tlsServerName                () const;
 
337
      int     tlsNegotiationTimeoutSec     () const;
 
338
      int     tlsNegotiationTimeoutMsec    () const;
 
339
      bool    isTlsVerifyServer            () const;
 
340
      bool    isTlsVerifyClient            () const;
 
341
      bool    isTlsRequireClientCertificate() const;
 
342
      bool    isTlsEnable                  () const;
 
343
      bool    isRingtoneEnabled            () const;
 
344
      QString ringtonePath                 () const;
 
345
      QString lastErrorMessage             () const;
 
346
      int     lastErrorCode                () const;
 
347
      int     localPort                    () const;
 
348
      int     voiceMailCount               () const;
 
349
      QString localInterface               () const;
 
350
      QString registrationStatus           () const;
 
351
      DtmfType DTMFType                    () const;
 
352
      bool    presenceStatus               () const;
 
353
      QString presenceMessage              () const;
 
354
      bool    supportPresencePublish       () const;
 
355
      bool    supportPresenceSubscribe     () const;
 
356
      bool    presenceEnabled              () const;
 
357
      Account::Protocol      protocol      () const;
 
358
      TlsMethodModel::Type   tlsMethod     () const;
 
359
      KeyExchangeModel::Type keyExchange   () const;
 
360
      QVariant roleData            (int role) const;
 
361
 
143
362
      //Setters
144
 
      void setAccountId      (const QString& id                        );
145
 
      void setAccountDetails (const MapStringString& m                 );
146
 
      bool setAccountDetail  (const QString& param, const QString& val );
147
 
      #ifdef ENABLE_VIDEO
148
 
      void setActiveVideoCodecList(const QList<VideoCodec*>& codecs);
149
 
      QList<VideoCodec*> getActiveVideoCodecList();
150
 
      #endif
151
 
      void setAccountAlias                  (QString detail);
152
 
      void setAccountType                   (QString detail);
153
 
      void setAccountHostname               (QString detail);
154
 
      void setAccountUsername               (QString detail);
155
 
      void setAccountMailbox                (QString detail);
156
 
      void setAccountProxy                  (QString detail);
157
 
      void setAccountPassword               (QString detail);
158
 
      void setTlsPassword                   (QString detail);
159
 
      void setTlsCaListFile                 (QString detail);
160
 
      void setTlsCertificateFile            (QString detail);
161
 
      void setTlsPrivateKeyFile             (QString detail);
162
 
      void setTlsCiphers                    (QString detail);
163
 
      void setTlsServerName                 (QString detail);
164
 
      void setAccountSipStunServer          (QString detail);
165
 
      void setPublishedAddress              (QString detail);
166
 
      void setLocalInterface                (QString detail);
167
 
      void setRingtonePath                  (QString detail);
168
 
      void setTlsMethod                     (int     detail);
169
 
      void setAccountRegistrationExpire     (int     detail);
170
 
      void setTlsNegotiationTimeoutSec      (int     detail);
171
 
      void setTlsNegotiationTimeoutMsec     (int     detail);
 
363
      void setId      (const QString& id);
 
364
      void setAlias                         (const QString& detail);
 
365
      void setProtocol                      (Account::Protocol proto);
 
366
      void setHostname                      (const QString& detail );
 
367
      void setUsername                      (const QString& detail );
 
368
      void setMailbox                       (const QString& detail );
 
369
      void setProxy                         (const QString& detail );
 
370
      void setPassword                      (const QString& detail );
 
371
      void setTlsPassword                   (const QString& detail );
 
372
      void setTlsCaListFile                 (const QString& detail );
 
373
      void setTlsCertificateFile            (const QString& detail );
 
374
      void setTlsPrivateKeyFile             (const QString& detail );
 
375
      void setTlsCiphers                    (const QString& detail );
 
376
      void setTlsServerName                 (const QString& detail );
 
377
      void setSipStunServer                 (const QString& detail );
 
378
      void setPublishedAddress              (const QString& detail );
 
379
      void setLocalInterface                (const QString& detail );
 
380
      void setRingtonePath                  (const QString& detail );
 
381
      void setLastErrorMessage              (const QString& message);
 
382
      void setTlsMethod                     (TlsMethodModel::Type   detail);
 
383
      void setKeyExchange                   (KeyExchangeModel::Type detail);
 
384
      void setLastErrorCode                 (int  code  );
 
385
      void setVoiceMailCount                (int  count );
 
386
      void setRegistrationExpire            (int  detail);
 
387
      void setTlsNegotiationTimeoutSec      (int  detail);
 
388
      void setTlsNegotiationTimeoutMsec     (int  detail);
172
389
      void setLocalPort                     (unsigned short detail);
173
390
      void setTlsListenerPort               (unsigned short detail);
174
391
      void setPublishedPort                 (unsigned short detail);
175
 
      void setAccountEnabled                (bool    detail);
176
 
      void setAutoAnswer                    (bool    detail);
177
 
      void setTlsVerifyServer               (bool    detail);
178
 
      void setTlsVerifyClient               (bool    detail);
179
 
      void setTlsRequireClientCertificate   (bool    detail);
180
 
      void setTlsEnable                     (bool    detail);
181
 
      void setAccountDisplaySasOnce         (bool    detail);
182
 
      void setAccountSrtpRtpFallback        (bool    detail);
183
 
      void setAccountZrtpDisplaySas         (bool    detail);
184
 
      void setAccountZrtpNotSuppWarning     (bool    detail);
185
 
      void setAccountZrtpHelloHash          (bool    detail);
186
 
      void setAccountSipStunEnabled         (bool    detail);
187
 
      void setPublishedSameAsLocal          (bool    detail);
188
 
      void setRingtoneEnabled               (bool    detail);
189
 
      void setDTMFType                      (DtmfType type );
190
 
   
 
392
      void setAutoAnswer                    (bool detail);
 
393
      void setTlsVerifyServer               (bool detail);
 
394
      void setTlsVerifyClient               (bool detail);
 
395
      void setTlsRequireClientCertificate   (bool detail);
 
396
      void setTlsEnable                     (bool detail);
 
397
      void setDisplaySasOnce                (bool detail);
 
398
      void setSrtpRtpFallback               (bool detail);
 
399
      void setSrtpEnabled                   (bool detail);
 
400
      void setZrtpDisplaySas                (bool detail);
 
401
      void setZrtpNotSuppWarning            (bool detail);
 
402
      void setZrtpHelloHash                 (bool detail);
 
403
      void setSipStunEnabled                (bool detail);
 
404
      void setPublishedSameAsLocal          (bool detail);
 
405
      void setRingtoneEnabled               (bool detail);
 
406
      void setPresenceEnabled               (bool enable);
 
407
      void setDTMFType                      (DtmfType type);
 
408
 
 
409
      void setRoleData(int role, const QVariant& value);
 
410
 
191
411
      //Updates
192
412
      virtual bool updateState();
193
 
   
 
413
 
194
414
      //Operators
195
415
      bool operator==(const Account&)const;
196
416
 
197
417
      //Mutator
198
 
      void saveCredentials  ();
199
 
      void saveAudioCodecs  ();
200
 
      void reloadCredentials();
201
 
      void reloadAudioCodecs();
202
 
 
203
 
   protected:
204
 
      //Constructors
205
 
      Account();
206
 
 
207
 
      //Attributes
208
 
      QString*         m_pAccountId     ;
209
 
      MapStringString* m_pAccountDetails;
 
418
      Q_INVOKABLE void saveCredentials  ();
 
419
      Q_INVOKABLE void saveAudioCodecs  ();
 
420
      Q_INVOKABLE void reloadCredentials();
 
421
      Q_INVOKABLE void reloadAudioCodecs();
 
422
 
210
423
 
211
424
   public Q_SLOTS:
212
425
      void setEnabled(bool checked);
213
426
 
214
427
   private Q_SLOTS:
215
 
      void accountChanged(QString accountId,QString stateName, int state);
 
428
      void slotPresentChanged        (bool  present  );
 
429
      void slotPresenceMessageChanged(const QString& );
216
430
 
217
431
   private:
 
432
      //Constructors
 
433
      Account();
 
434
 
 
435
      //Attributes
 
436
      QString                 m_AccountId      ;
 
437
      QHash<QString,QString>  m_hAccountDetails;
 
438
      PhoneNumber*            m_pAccountNumber ;
 
439
 
 
440
      //Setters
 
441
      void setAccountDetails (const QHash<QString,QString>& m          );
 
442
      bool setAccountDetail  (const QString& param, const QString& val );
 
443
 
218
444
      //State actions
219
445
      void nothing() {};
220
 
      void edit()   {m_CurrentState = EDITING ;emit changed(this);};
221
 
      void modify() {m_CurrentState = MODIFIED;emit changed(this);};
222
 
      void remove() {m_CurrentState = REMOVED ;emit changed(this);};
223
 
      void cancel() {m_CurrentState = READY   ;emit changed(this);};
224
 
      void outdate(){m_CurrentState = OUTDATED;emit changed(this);};
 
446
      void edit()    {m_CurrentState = AccountEditState::EDITING ;emit changed(this);};
 
447
      void modify()  {m_CurrentState = AccountEditState::MODIFIED;emit changed(this);};
 
448
      void remove()  {m_CurrentState = AccountEditState::REMOVED ;emit changed(this);};
 
449
      void cancel()  {m_CurrentState = AccountEditState::READY   ;emit changed(this);};
 
450
      void outdate() {m_CurrentState = AccountEditState::OUTDATED;emit changed(this);};
225
451
      void reload();
226
452
      void save();
227
453
      void reloadMod() {reload();modify();};
228
 
      
229
 
      CredentialModel* m_pCredentials;
230
 
      AudioCodecModel* m_pAudioCodecs;
231
 
      VideoCodecModel* m_pVideoCodecs;
 
454
 
 
455
      CredentialModel*  m_pCredentials     ;
 
456
      AudioCodecModel*  m_pAudioCodecs     ;
 
457
      VideoCodecModel*  m_pVideoCodecs     ;
 
458
      RingToneModel*    m_pRingToneModel   ;
 
459
      KeyExchangeModel* m_pKeyExchangeModel;
232
460
      AccountEditState m_CurrentState;
233
461
      static const account_function stateMachineActionsOnState[6][7];
234
462
 
 
463
      //Cached account details (as they are called too often for the hash)
 
464
      QString m_HostName;
 
465
      QString m_LastErrorMessage;
 
466
      int     m_LastErrorCode;
 
467
      int     m_VoiceMailCount;
 
468
 
235
469
 
236
470
   Q_SIGNALS:
237
471
      ///The account state (Invalif,Trying,Registered) changed
241
475
      ///The alias changed, take effect instantaneously
242
476
      void aliasChanged(const QString&);
243
477
};
 
478
// Q_DISABLE_COPY(Account)
 
479
Q_DECLARE_METATYPE(Account*)
244
480
#endif