~ubuntu-branches/ubuntu/wily/sflphone/wily

« back to all changes in this revision

Viewing changes to kde/src/accountwizard.cpp

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (1.1.11)
  • mto: This revision was merged to the branch mainline in revision 24.
  • Revision ID: package-import@ubuntu.com-20140128182336-3xenud1kbnwmf3mz
* 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
 *              ^^ Refuse any liability for this code                      *
37
37
 
38
38
//SFLphone
39
39
#include "lib/sflphone_const.h"
40
 
#include "lib/configurationmanager_interface_singleton.h"
 
40
#include "lib/account.h"
 
41
#include "lib/dbus/configurationmanager.h"
41
42
 
42
43
//Define
43
44
#define FIELD_SFL_ACCOUNT        "SFL"
71
72
 *                                                                         *
72
73
 **************************************************************************/
73
74
 
74
 
typedef struct {
75
 
   bool    success ;
76
 
   QString reason  ;
77
 
   QString user    ;
78
 
   QString passwd  ;
79
 
} rest_account;
 
75
 
80
76
 
81
77
///Validate if the connection can be done with the PBX
82
 
int sendRequest(QString host, int port, QString req, QString & ret)
 
78
int AccountWizard::sendRequest(const QString& host, int port, const QString& req, QString& ret)
83
79
{
84
80
   int s;
85
81
   struct sockaddr_in servSockAddr;
105
101
      return -1;
106
102
   }
107
103
 
108
 
   if(connect(s, (const struct sockaddr *) &servSockAddr, (socklen_t) sizeof(servSockAddr)) < 0 ) {
 
104
   if(::connect(s, (const struct sockaddr *) &servSockAddr, (socklen_t) sizeof(servSockAddr)) < 0 ) {
109
105
      perror(nullptr);
110
106
      ret = "connect";
 
107
      ::close(s);
111
108
      return -1;
112
109
   }
113
110
 
133
130
 
134
131
   if (status != 200) {
135
132
      ret = "http error: " + status;
 
133
      fclose(f);
136
134
//       sprintf(ret, "http error: %ld", status);
137
135
      return -1;
138
136
   }
139
137
 
140
138
   fclose(f);
141
139
   shutdown(s, 2);
142
 
   close(s);
 
140
   ::close(s);
143
141
   return 0;
144
142
}
145
143
 
146
144
///
147
 
rest_account get_rest_account(QString host, QString email)
 
145
rest_account AccountWizard::get_rest_account(const QString& host, const QString& email)
148
146
{
149
 
   QString req = "GET /rest/accountcreator?email=" + email;
 
147
   const QString req = "GET /rest/accountcreator?email=" + email;
150
148
   QString ret;
151
149
   rest_account ra;
152
150
   kDebug() << "HOST: " << host;
200
198
///The accept button have been pressed
201
199
void AccountWizard::accept()
202
200
{
203
 
   ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance();
 
201
   ConfigurationManagerInterface & configurationManager = DBus::ConfigurationManager::instance();
204
202
 
205
203
   QString ret;
206
204
   MapStringString accountDetails = configurationManager.getAccountTemplate();
207
205
 
208
 
   QString& alias    = accountDetails[ QString( ACCOUNT_ALIAS    ) ];
209
 
   QString& enabled  = accountDetails[ QString( ACCOUNT_ENABLED  ) ];
210
 
   QString& mailbox  = accountDetails[ QString( ACCOUNT_MAILBOX  ) ];
211
 
   QString& protocol = accountDetails[ QString( ACCOUNT_TYPE     ) ];
212
 
   QString& server   = accountDetails[ QString( ACCOUNT_HOSTNAME ) ];
213
 
   QString& user     = accountDetails[ QString( ACCOUNT_USERNAME ) ];
214
 
   QString& password = accountDetails[ QString( ACCOUNT_PASSWORD ) ];
 
206
   QString& alias    = accountDetails[ QString( Account::MapField::ALIAS    ) ];
 
207
   QString& enabled  = accountDetails[ QString( Account::MapField::ENABLED  ) ];
 
208
   QString& mailbox  = accountDetails[ QString( Account::MapField::MAILBOX  ) ];
 
209
   QString& protocol = accountDetails[ QString( Account::MapField::TYPE     ) ];
 
210
   QString& server   = accountDetails[ QString( Account::MapField::HOSTNAME ) ];
 
211
   QString& user     = accountDetails[ QString( Account::MapField::USERNAME ) ];
 
212
   QString& password = accountDetails[ QString( Account::MapField::PASSWORD ) ];
215
213
 
216
214
   // sip only parameters
217
 
   QString& stun_enabled = accountDetails[ QString(ACCOUNT_SIP_STUN_ENABLED) ];
218
 
   QString& stun_server  = accountDetails[ QString(ACCOUNT_SIP_STUN_SERVER)  ];
 
215
   QString& stun_enabled = accountDetails[ QString(Account::MapField::STUN::ENABLED) ];
 
216
   QString& stun_server  = accountDetails[ QString(Account::MapField::STUN::SERVER)  ];
219
217
 
220
218
   // zrtp only parameters
221
 
   QString& srtp_enabled          = accountDetails[ QString( ACCOUNT_SRTP_ENABLED          ) ];
222
 
   QString& key_exchange          = accountDetails[ QString( ACCOUNT_KEY_EXCHANGE          ) ];
223
 
   QString& zrtp_display_sas      = accountDetails[ QString( ACCOUNT_ZRTP_DISPLAY_SAS      ) ];
224
 
   QString& zrtp_not_supp_warning = accountDetails[ QString( ACCOUNT_ZRTP_NOT_SUPP_WARNING ) ];
225
 
   QString& zrtp_hello_hash       = accountDetails[ QString( ACCOUNT_ZRTP_HELLO_HASH       ) ];
226
 
   QString& display_sas_once      = accountDetails[ QString( ACCOUNT_DISPLAY_SAS_ONCE      ) ];
 
219
   QString& srtp_enabled          = accountDetails[ QString( Account::MapField::SRTP::ENABLED          ) ];
 
220
   QString& key_exchange          = accountDetails[ QString( Account::MapField::SRTP::KEY_EXCHANGE          ) ];
 
221
   QString& zrtp_display_sas      = accountDetails[ QString( Account::MapField::ZRTP::DISPLAY_SAS      ) ];
 
222
   QString& zrtp_not_supp_warning = accountDetails[ QString( Account::MapField::ZRTP::NOT_SUPP_WARNING ) ];
 
223
   QString& zrtp_hello_hash       = accountDetails[ QString( Account::MapField::ZRTP::HELLO_HASH       ) ];
 
224
   QString& display_sas_once      = accountDetails[ QString( Account::MapField::ZRTP::DISPLAY_SAS_ONCE      ) ];
227
225
 
228
226
   //  interface parameters
229
 
   QString& locale_interface  = accountDetails[ QString(LOCAL_INTERFACE)   ];
230
 
   QString& published_address = accountDetails[ QString(PUBLISHED_ADDRESS) ];
 
227
   QString& locale_interface  = accountDetails[ QString(Account::MapField::LOCAL_INTERFACE)   ];
 
228
   QString& published_address = accountDetails[ QString(Account::MapField::PUBLISHED_ADDRESS) ];
231
229
 
232
230
   bool is_using_sflphone_org = field(FIELD_SFL_ACCOUNT).toBool();
233
231
   bool is_using_sip          = false;
248
246
         field( FIELD_SIP_USER      ) = QString( acc.user                         );
249
247
         field( FIELD_SIP_VOICEMAIL ).clear();
250
248
 
251
 
         protocol = QString( ACCOUNT_TYPE_SIP          );
 
249
         protocol = QString( Account::ProtocolName::SIP    );
252
250
         server   = QString( SFL_ACCOUNT_HOST          );
253
251
         password = QString( acc.passwd                );
254
252
         user     = QString( acc.user                  );
267
265
      alias    = field   ( FIELD_SIP_ALIAS           ).toString();
268
266
      enabled  = QString ( REGISTRATION_ENABLED_TRUE )           ;
269
267
      mailbox  = field   ( FIELD_SIP_VOICEMAIL       ).toString();
270
 
      protocol = QString ( ACCOUNT_TYPE_SIP          )           ;
 
268
      protocol = QString ( Account::ProtocolName::SIP    )           ;
271
269
      server   = field   ( FIELD_SIP_SERVER          ).toString();
272
270
      password = field   ( FIELD_SIP_PASSWORD        ).toString();
273
271
      user     = field   ( FIELD_SIP_USER            ).toString();
282
280
      alias    = field   ( FIELD_IAX_ALIAS           ).toString();
283
281
      enabled  = QString ( REGISTRATION_ENABLED_TRUE )           ;
284
282
      mailbox  = field   ( FIELD_IAX_VOICEMAIL       ).toString();
285
 
      protocol = QString ( ACCOUNT_TYPE_IAX          )           ;
 
283
      protocol = QString ( Account::ProtocolName::IAX    )           ;
286
284
      server   = field   ( FIELD_IAX_SERVER          ).toString();
287
285
      password = field   ( FIELD_IAX_PASSWORD        ).toString();
288
286
      user     = field   ( FIELD_IAX_USER            ).toString();
304
302
      }
305
303
 
306
304
      if(field(FIELD_ZRTP_ENABLED).toBool()) {
307
 
         srtp_enabled          = QString( REGISTRATION_ENABLED_TRUE  );
308
 
         key_exchange          = QString( ZRTP                       );
309
 
         zrtp_display_sas      = QString( REGISTRATION_ENABLED_TRUE  );
310
 
         zrtp_not_supp_warning = QString( REGISTRATION_ENABLED_TRUE  );
311
 
         zrtp_hello_hash       = QString( REGISTRATION_ENABLED_TRUE  );
312
 
         display_sas_once      = QString( REGISTRATION_ENABLED_FALSE );
 
305
         srtp_enabled          = QString( REGISTRATION_ENABLED_TRUE       );
 
306
         key_exchange          = QString( KeyExchangeModel::Name::ZRTP );
 
307
         zrtp_display_sas      = QString( REGISTRATION_ENABLED_TRUE       );
 
308
         zrtp_not_supp_warning = QString( REGISTRATION_ENABLED_TRUE       );
 
309
         zrtp_hello_hash       = QString( REGISTRATION_ENABLED_TRUE       );
 
310
         display_sas_once      = QString( REGISTRATION_ENABLED_FALSE      );
313
311
      }
314
312
 
315
313
      QStringList ifaceList = configurationManager.getAllIpInterface();