ConfigurationPanel.ui.h 18.2 KB
Newer Older
yanmorin's avatar
 
yanmorin committed
1
/*
yanmorin's avatar
 
yanmorin committed
2 3
 *  Copyright (C) 2004-2006 Savoir-Faire Linux inc.
 *  Author: Yan Morin <yan.morin@savoirfairelinux.com>
jpbl's avatar
jpbl committed
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
 *  Author: Jean-Philippe Barrette-LaPierre
 *             <jean-philippe.barrette-lapierre@savoirfairelinux.com>
 *                                                                              
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *                                                                              
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *                                                                              
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

/****************************************************************************
** ui.h extension file, included from the uic-generated form implementation.
**
** If you want to add, delete, or rename functions or slots, use
** Qt Designer to update this file, preserving your code.
**
** You should not define a constructor or destructor in this file.
** Instead, write your code in functions called init() and destroy().
** These will automatically be called by the form's constructor and
** destructor.
*****************************************************************************/
#include <qdir.h>
#include <qmessagebox.h>
#include <qstringlist.h>
yanmorin's avatar
 
yanmorin committed
36
#include <qcolor.h>
yanmorin's avatar
 
yanmorin committed
37
#include <qvbuttongroup.h>
jpbl's avatar
jpbl committed
38 39 40 41 42 43 44 45

#include "globals.h"
#include "ConfigurationManager.hpp"
#include "DebugOutput.hpp"
#include "QjListBoxPixmap.hpp"
#include "SkinManager.hpp"
#include "TransparentWidget.hpp"

yanmorin's avatar
yanmorin committed
46 47
#include <map>

jpbl's avatar
jpbl committed
48 49 50 51 52 53 54 55
#define SIGNALISATIONS_IMAGE "signalisations.png"
#define AUDIO_IMAGE "audio.png"
#define PREFERENCES_IMAGE "preferences.png"
#define ABOUT_IMAGE "about.png"


void ConfigurationPanel::init()
{
56
  _cutStringCombo = 30;
57
  //DebugOutput::instance() << "ConfigurationPanel::init()\n"; 
58 59 60 61 62
  lblError->hide();
  Tab_Signalisations->show();
  Tab_Audio->hide();
  Tab_Preferences->hide();
  Tab_About->hide();
jpbl's avatar
jpbl committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121

  /*
    // For reading settings at application startup
     // List skin choice from "skins" directory
   QDir dir(Skin::getPath(QString(SKINDIR)));
   if ( !dir.exists() ) {
        _debug("\nCannot find 'skins' directory\n");
		return;
    } else {
    dir.setFilter( QDir::Dirs | QDir::NoSymLinks);
    dir.setSorting( QDir::Name );
  
    QStringList list;
    list = dir.entryList();
    for (unsigned int i = 0; i < dir.count(); i++) {
     if (list[i] != "." && list[i] != ".." && list[i] != "CVS") {
    SkinChoice->insertItem(list[i]);
     }
    } 
 }
  */

   // For preferences tab

    /*
      SkinChoice->setCurrentText(QString(manager.getConfigString(PREFERENCES, SKIN_CHOICE)));
    confirmationToQuit->setChecked(manager.getConfigInt(PREFERENCES, CONFIRM_QUIT));
    zoneToneChoice->setCurrentText(QString(manager.getConfigString(
								   PREFERENCES, ZONE_TONE)));
    checkedTray->setChecked(manager.getConfigInt(
               PREFERENCES, CHECKED_TRAY));
  voicemailNumber->setText(QString(manager.getConfigString(
               PREFERENCES, VOICEMAIL_NUM)));
    */
   //  Init tab view order

    // Set items for QListBox

    new QjListBoxPixmap (QjListBoxPixmap::Above, 
			 TransparentWidget::retreive(SIGNALISATIONS_IMAGE),  
			 "Signalisation", 
			 Menu);
    new QjListBoxPixmap (QjListBoxPixmap::Above, 
			 TransparentWidget::retreive(AUDIO_IMAGE),
			 "Audio", Menu );
    new QjListBoxPixmap (QjListBoxPixmap::Above, 
    			 TransparentWidget::retreive(PREFERENCES_IMAGE),
    			 "Preferences", 
    			 Menu);
    new QjListBoxPixmap (QjListBoxPixmap::Above, 
			 TransparentWidget::retreive(ABOUT_IMAGE),
			 "About", 
			 Menu);
}

void 
ConfigurationPanel::generate()
{
   // For audio tab
122 123 124
  codec1->setCurrentText(ConfigurationManager::instance().get(AUDIO_SECTION, AUDIO_CODEC1));
  codec2->setCurrentText(ConfigurationManager::instance().get(AUDIO_SECTION, AUDIO_CODEC2));
  codec3->setCurrentText(ConfigurationManager::instance().get(AUDIO_SECTION, AUDIO_CODEC3));
jpbl's avatar
jpbl committed
125

126
  ringsChoice->setCurrentText(ConfigurationManager::instance().get(AUDIO_SECTION, AUDIO_RINGTONE));
yanmorin's avatar
 
yanmorin committed
127

jpbl's avatar
jpbl committed
128
  // For signalisations tab
yanmorin's avatar
 
yanmorin committed
129

130 131 132 133 134
  // Load account
  QComboBox* cbo = cboSIPAccount;
  cbo->clear();
  int nbItem = 4;
  for (int iItem = 0; iItem < nbItem; iItem++) {
yanmorin's avatar
yanmorin committed
135 136 137 138 139 140 141 142 143 144 145
    QString accountId = "SIP" + QString::number(iItem);	  
    QString aliasName = ConfigurationManager::instance().get(accountId, ACCOUNT_ALIAS);
    QString accountName;
    if (aliasName.isEmpty()) {
      accountName = QObject::tr("SIP Account #%1").arg(iItem+1);
    } else {
      if (aliasName.length() > 30) {
        aliasName = aliasName.left(30) + "...";
      }
      accountName = aliasName + " (" + QObject::tr("SIP Account #%1").arg(iItem+1) + ")";
    }
146 147 148
    cbo->insertItem(accountName,iItem);
  }
  loadSIPAccount(0);
yanmorin's avatar
 
yanmorin committed
149

150 151 152 153 154 155
  sendDTMFas->setCurrentItem(ConfigurationManager::instance().get(SIGNALISATION_SECTION,
	 SIGNALISATION_SEND_DTMF_AS).toUInt());
  playTones->setChecked(ConfigurationManager::instance().get(SIGNALISATION_SECTION, 
	SIGNALISATION_PLAY_TONES).toUInt());
  pulseLength->setValue(ConfigurationManager::instance().get(SIGNALISATION_SECTION, 
	SIGNALISATION_PULSE_LENGTH).toUInt());
yanmorin's avatar
 
yanmorin committed
156

yanmorin's avatar
yanmorin committed
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185

  // select the position index (combobox of the device index)
  // deviceIndexOut can be 8, but be at position 0 in the combo box
  int deviceIndexOut = ConfigurationManager::instance().get(AUDIO_SECTION, AUDIO_DEFAULT_DEVICEOUT).toInt();
  int deviceIndexIn  = ConfigurationManager::instance().get(AUDIO_SECTION, AUDIO_DEFAULT_DEVICEIN).toInt();
  int positionIndexIn  = 0;
  int positionIndexOut = 0;

  // search for deviceIndexIn, and get the positionIndex (key)
  std::map< int, int >::iterator it = _deviceInMap.begin();
  while (it != _deviceInMap.end()) {
    if ( it->second == deviceIndexIn) {
	  // we found the deviceIndex
	  positionIndexIn = it->first;
      break;
	}
	it++;
  }
  it = _deviceOutMap.begin();
  while (it != _deviceOutMap.end()) {
    if ( it->second == deviceIndexOut) {
	  // we found the deviceIndex
	  positionIndexOut = it->first;
      break;
	}
	it++;
  }
  cboDriverChoiceIn->setCurrentItem(positionIndexIn);
  cboDriverChoiceOut->setCurrentItem(positionIndexOut);
yanmorin's avatar
 
yanmorin committed
186

187 188 189 190 191 192 193 194
  // fill cboDriverRate here
  int nbRate = 5;
  int allowedRate[5] = {8000,16000,32000,44100,48000};
  cboDriverRate->clear();
  for(int iRate = 0; iRate < nbRate; iRate++) {
    cboDriverRate->insertItem(QString::number(allowedRate[iRate]));
  }
  cboDriverRate->setCurrentText(ConfigurationManager::instance().get(AUDIO_SECTION, AUDIO_SAMPLERATE));
195

jpbl's avatar
jpbl committed
196 197 198 199 200 201 202
  //preference tab
  updateSkins();
}

// For saving settings at application 'save'
void ConfigurationPanel::saveSlot()
{
203
  saveSIPAccount(cboSIPAccount->currentItem());
yanmorin's avatar
 
yanmorin committed
204

jpbl's avatar
jpbl committed
205 206 207 208 209 210 211 212 213 214 215
  ConfigurationManager::instance().set(SIGNALISATION_SECTION, 
				       SIGNALISATION_PULSE_LENGTH,
				       QString::number(pulseLength->value()));
  ConfigurationManager::instance().set(SIGNALISATION_SECTION, 
				       SIGNALISATION_PLAY_TONES,
				       QString::number(playTones->isChecked()));
  ConfigurationManager::instance().set(SIGNALISATION_SECTION, 
				       SIGNALISATION_SEND_DTMF_AS,
				       QString::number(sendDTMFas->currentItem()));

  if (codec1->currentText() != NULL) {
yanmorin's avatar
 
yanmorin committed
216
    ConfigurationManager::instance().set(AUDIO_SECTION, AUDIO_CODEC1, codec1->currentText());
jpbl's avatar
jpbl committed
217 218
  }
  if (codec2->currentText() != NULL) {
yanmorin's avatar
 
yanmorin committed
219
    ConfigurationManager::instance().set(AUDIO_SECTION, AUDIO_CODEC2, codec2->currentText());
jpbl's avatar
jpbl committed
220 221
  }
  if (codec3->currentText() != NULL) {
yanmorin's avatar
 
yanmorin committed
222
    ConfigurationManager::instance().set(AUDIO_SECTION, AUDIO_CODEC3, codec3->currentText());
jpbl's avatar
jpbl committed
223 224
  }
  if (ringsChoice->currentText() != NULL) {
yanmorin's avatar
 
yanmorin committed
225
    ConfigurationManager::instance().set(AUDIO_SECTION, AUDIO_RINGTONE, ringsChoice->currentText());
jpbl's avatar
jpbl committed
226
  }
yanmorin's avatar
yanmorin committed
227 228
  int cboPosition = 0;
  int deviceIndex = 0;
229
  if (cboDriverChoiceOut->currentText() != NULL) {
yanmorin's avatar
yanmorin committed
230 231 232
    cboPosition = cboDriverChoiceOut->currentItem();
    deviceIndex = _deviceOutMap[cboPosition]; // return 0 if not found and create it, by STL
    ConfigurationManager::instance().set(AUDIO_SECTION, AUDIO_DEFAULT_DEVICEOUT, QString::number(deviceIndex));
233 234
  }
  if (cboDriverChoiceIn->currentText() != NULL) {
yanmorin's avatar
yanmorin committed
235 236 237
    cboPosition = cboDriverChoiceIn->currentItem();
    deviceIndex = _deviceInMap[cboPosition]; // return 0 if not found and create it, by STL
    ConfigurationManager::instance().set(AUDIO_SECTION, AUDIO_DEFAULT_DEVICEIN, QString::number(deviceIndex));
238
  }
jpbl's avatar
jpbl committed
239 240 241 242 243

  SkinManager::instance().load(SkinChoice->currentText());
  SkinManager::instance().save();

#if 0 
yanmorin's avatar
 
yanmorin committed
244 245
  QMessageBox::information(this, tr("Save settings"),
			   tr("You must restart SFLPhone"),
jpbl's avatar
jpbl committed
246 247 248 249 250 251 252 253 254 255 256
			   QMessageBox::Yes);
#endif

  ConfigurationManager::instance().save();
}

// Handle tab view  according to current item of listbox
void ConfigurationPanel::changeTabSlot()
{
  switch (Menu->currentItem()) {
  case 0:
yanmorin's avatar
 
yanmorin committed
257
    TitleTab->setText(tr("Setup signalisation"));
jpbl's avatar
jpbl committed
258 259 260 261 262 263
    Tab_Signalisations->show();
    Tab_Audio->hide();
    Tab_Preferences->hide();
    Tab_About->hide();
    break;
  case 1:
yanmorin's avatar
 
yanmorin committed
264
    TitleTab->setText(tr("Setup audio"));
jpbl's avatar
jpbl committed
265 266 267 268 269 270 271
    Tab_Signalisations->hide();
    Tab_Audio->show();
    Tab_Preferences->hide();
    Tab_About->hide();
    break;
  case 2:
    updateSkins();
yanmorin's avatar
 
yanmorin committed
272
    TitleTab->setText(tr("Setup preferences"));
jpbl's avatar
jpbl committed
273 274 275 276 277 278
    Tab_Signalisations->hide();
    Tab_Audio->hide();
    Tab_Preferences->show();
    Tab_About->hide();
    break; 
  case 3:
yanmorin's avatar
 
yanmorin committed
279
    TitleTab->setText(tr("About"));
jpbl's avatar
jpbl committed
280 281 282 283 284 285 286 287 288 289 290
    Tab_Signalisations->hide();
    Tab_Audio->hide();
    Tab_Preferences->hide();
    Tab_About->show();
    break;
  }
}


void ConfigurationPanel::useStunSlot(int id)
{
yanmorin's avatar
 
yanmorin committed
291 292
  QString account = ACCOUNT_DEFAULT_NAME;
  ConfigurationManager::instance().set(account,
jpbl's avatar
jpbl committed
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307
				       SIGNALISATION_USE_STUN, 
				       QString::number(id));
}


void ConfigurationPanel::applySkinSlot()
{
  SkinManager::instance().load(SkinChoice->currentText());
}


void ConfigurationPanel::updateSkins()
{
  SkinChoice->clear();
  SkinChoice->insertStringList(SkinManager::instance().getSkins());
jpbl's avatar
jpbl committed
308
  SkinChoice->setSelected(SkinChoice->findItem(SkinManager::instance().getCurrentSkin(), Qt::ExactMatch), true);
jpbl's avatar
jpbl committed
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
}

void ConfigurationPanel::updateRingtones()
{
  std::list< Ringtone > rings = ConfigurationManager::instance().getRingtones();
  std::list< Ringtone >::iterator pos;

  ringsChoice->clear();
  
  for (pos = rings.begin(); pos != rings.end(); pos++) {
    ringsChoice->insertItem(pos->filename);
  } 
}

void ConfigurationPanel::updateCodecs()
{
  std::list< Codec > codecs = ConfigurationManager::instance().getCodecs();
  std::list< Codec >::iterator pos;

  codec1->clear();
  codec2->clear();
  codec3->clear();
  
  for (pos = codecs.begin(); pos != codecs.end(); pos++) {
    codec1->insertItem(pos->codecName);
    codec2->insertItem(pos->codecName);
    codec3->insertItem(pos->codecName);
  } 
}

yanmorin's avatar
 
yanmorin committed
339 340
void ConfigurationPanel::updateAudioDevicesIn() 
{
341
  QComboBox* cbo = cboDriverChoiceIn;
yanmorin's avatar
 
yanmorin committed
342 343
  std::list< AudioDevice > audio = ConfigurationManager::instance().getAudioDevicesIn();
  std::list< AudioDevice >::iterator pos;
344
  cbo->clear();
yanmorin's avatar
yanmorin committed
345 346 347
  _deviceInMap.clear();

  int iPos = 0;
yanmorin's avatar
 
yanmorin committed
348 349 350 351
  for (pos = audio.begin(); pos != audio.end(); pos++) {
    QString hostApiName = pos->hostApiName;
    QString deviceName = pos->deviceName;
    
352 353
    if (hostApiName.length() > _cutStringCombo) {
	    hostApiName = hostApiName.left(_cutStringCombo) + "...";
yanmorin's avatar
 
yanmorin committed
354
    }
355
    QString name = hostApiName + QObject::tr(" (device #%1-%2Hz)").arg(pos->index).arg(pos->defaultRate);
356
    cbo->insertItem(name);
yanmorin's avatar
yanmorin committed
357 358
    _deviceInMap[iPos] = pos->index.toInt();
	iPos++;
yanmorin's avatar
 
yanmorin committed
359 360 361 362 363 364 365
  }
}

void ConfigurationPanel::updateAudioDevicesOut() 
{
  updateAudioDevices();
}
jpbl's avatar
jpbl committed
366 367 368

void ConfigurationPanel::updateAudioDevices()
{
369
  QComboBox* cbo = cboDriverChoiceOut;
yanmorin's avatar
 
yanmorin committed
370
  std::list< AudioDevice > audio = ConfigurationManager::instance().getAudioDevicesOut();
jpbl's avatar
jpbl committed
371
  std::list< AudioDevice >::iterator pos;
372
  cbo->clear();
yanmorin's avatar
yanmorin committed
373
  _deviceOutMap.clear();
374
 
yanmorin's avatar
yanmorin committed
375
  int iPos = 0;
jpbl's avatar
jpbl committed
376 377 378 379
  for (pos = audio.begin(); pos != audio.end(); pos++) {
    QString hostApiName = pos->hostApiName;
    QString deviceName = pos->deviceName;
    
380 381
    if (hostApiName.length() > _cutStringCombo) {
	    hostApiName = hostApiName.left(_cutStringCombo) + "...";
jpbl's avatar
jpbl committed
382
    }
383
    //DebugOutput::instance() << hostApiName << pos->defaultRate;
384
    QString name = hostApiName + QObject::tr(" (device #%1-%2Hz)").arg(pos->index).arg(pos->defaultRate);
385
    cbo->insertItem(name);
yanmorin's avatar
yanmorin committed
386 387
    _deviceOutMap[iPos] = pos->index.toInt();
	iPos++;
jpbl's avatar
jpbl committed
388 389
  }
}
jpbl's avatar
jpbl committed
390 391


yanmorin's avatar
 
yanmorin committed
392 393 394 395 396 397
void 
ConfigurationPanel::SkinChoice_selected( const QString & )
{

}

yanmorin's avatar
 
yanmorin committed
398 399 400
void
ConfigurationPanel::slotRegister()
{
401 402
  saveSIPAccount(cboSIPAccount->currentItem());
  emit needRegister("SIP" + QString::number(cboSIPAccount->currentItem()));
yanmorin's avatar
 
yanmorin committed
403 404
}

yanmorin's avatar
 
yanmorin committed
405
void 
yanmorin's avatar
 
yanmorin committed
406 407 408 409
ConfigurationPanel::slotRegisterReturn( bool hasError, QString ) 
{
  if (hasError) {
    lblError->setPaletteForegroundColor(red); // red
yanmorin's avatar
yanmorin committed
410
    lblError->setText(QObject::tr("Register failed"));
yanmorin's avatar
 
yanmorin committed
411 412
  } else {
    lblError->setPaletteForegroundColor(black); // black
yanmorin's avatar
yanmorin committed
413
    lblError->setText(QObject::tr("Register Succeed"));
yanmorin's avatar
 
yanmorin committed
414 415 416 417
  }
  lblError->show();
}

yanmorin's avatar
yanmorin committed
418 419 420 421 422
/**
 * Test sound driver (save them before)
 */
void 
ConfigurationPanel::slotTestSoundDriver()
jpbl's avatar
jpbl committed
423
{
424
  // save driver in configuration manager
yanmorin's avatar
yanmorin committed
425 426
  int cboPosition = 0;
  int deviceIndex = 0;
427
  if (cboDriverChoiceOut->currentText() != NULL) {
yanmorin's avatar
yanmorin committed
428 429 430
    cboPosition = cboDriverChoiceOut->currentItem();
    deviceIndex = _deviceOutMap[cboPosition]; // return 0 if not found and create it, by STL
    ConfigurationManager::instance().set(AUDIO_SECTION, AUDIO_DEFAULT_DEVICEOUT, QString::number(deviceIndex));
431 432
  }
  if (cboDriverChoiceIn->currentText() != NULL) {
yanmorin's avatar
yanmorin committed
433 434 435
    cboPosition = cboDriverChoiceIn->currentItem();
    deviceIndex = _deviceInMap[cboPosition]; // return 0 if not found and create it, by STL
    ConfigurationManager::instance().set(AUDIO_SECTION, AUDIO_DEFAULT_DEVICEIN, QString::number(deviceIndex));
436
  }
437 438 439
  if (cboDriverRate->currentText() != NULL) {
    ConfigurationManager::instance().set(AUDIO_SECTION, AUDIO_SAMPLERATE, cboDriverRate->currentText());
  }
440 441

  // save driver on portaudio
yanmorin's avatar
 
yanmorin committed
442 443
  ConfigurationManager::instance().save(AUDIO_SECTION, AUDIO_DEFAULT_DEVICEOUT);
  ConfigurationManager::instance().save(AUDIO_SECTION, AUDIO_DEFAULT_DEVICEIN);
444
  ConfigurationManager::instance().save(AUDIO_SECTION, AUDIO_SAMPLERATE);
yanmorin's avatar
 
yanmorin committed
445
  emit soundDriverChanged();
yanmorin's avatar
 
yanmorin committed
446
}
jpbl's avatar
jpbl committed
447

yanmorin's avatar
yanmorin committed
448 449 450 451 452 453 454
void 
ConfigurationPanel::slotReloadSoundDriver()
{
  ConfigurationManager::instance().reloadSoundDriver();
}


yanmorin's avatar
 
yanmorin committed
455
void 
yanmorin's avatar
 
yanmorin committed
456
ConfigurationPanel::slotSoundDriverReturn( bool hasError, QString message ) 
yanmorin's avatar
 
yanmorin committed
457
{
yanmorin's avatar
 
yanmorin committed
458 459 460 461 462 463 464
  if (hasError) { // no error
    lblSoundDriver->setPaletteForegroundColor(red); // error in red
  } else {
    lblSoundDriver->setPaletteForegroundColor(black);
  }
  lblSoundDriver->setText(message);
  lblSoundDriver->show();
jpbl's avatar
jpbl committed
465
}
yanmorin's avatar
 
yanmorin committed
466

467 468 469 470
void 
ConfigurationPanel::slotSIPAccountChange(int index) 
{
  if (lastSIPAccount!=index) {
yanmorin's avatar
yanmorin committed
471
    
472
    QString account = "SIP" + QString::number(index);
473
    //DebugOutput::instance() << "Selecting SIP account " << account << "\n";
474 475

    saveSIPAccount(lastSIPAccount);
yanmorin's avatar
yanmorin committed
476
    loadSIPAccount(index);
477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492
    lblError->setText("");
  }
}

void
ConfigurationPanel::loadSIPAccount(int number) 
{
  QString account = "SIP" + QString::number(number);
  QString type    = ConfigurationManager::instance().get(account, ACCOUNT_TYPE);

  chkAutoregister->setChecked(ConfigurationManager::instance()
			   .get(account,ACCOUNT_AUTO_REGISTER).toUInt());

  chkEnable->setChecked(ConfigurationManager::instance()
			   .get(account,ACCOUNT_ENABLE).toUInt());

yanmorin's avatar
yanmorin committed
493 494 495 496 497
  QString aliasName = ConfigurationManager::instance().get(account, ACCOUNT_ALIAS);
  alias->setText(aliasName);
  // void QComboBox::changeItem ( const QString & t, int index);
  // 
	  
498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520
  fullName->setText(ConfigurationManager::instance()
		    .get(account,SIGNALISATION_FULL_NAME));
  userPart->setText(ConfigurationManager::instance()
		    .get(account,SIGNALISATION_USER_PART));
  username->setText(ConfigurationManager::instance()
		    .get(account,SIGNALISATION_AUTH_USER_NAME));
  password->setText(ConfigurationManager::instance()
		    .get(account,SIGNALISATION_PASSWORD));
  hostPart->setText(ConfigurationManager::instance()
		    .get(account,SIGNALISATION_HOST_PART));
  sipproxy->setText(ConfigurationManager::instance()
		    .get(account,SIGNALISATION_PROXY));
  STUNserver->setText(ConfigurationManager::instance()
		      .get(account,SIGNALISATION_STUN_SERVER));
  ((QRadioButton*)stunButtonGroup->find(ConfigurationManager::instance()
			.get(account,SIGNALISATION_USE_STUN).toUInt()))->setChecked(true); 
  lastSIPAccount = number;
}

void
ConfigurationPanel::saveSIPAccount(int number)
{
  QString account = "SIP" + QString::number(number);
yanmorin's avatar
yanmorin committed
521 522 523 524 525 526 527 528 529 530 531 532
  QString aliasName = alias->text();
  ConfigurationManager::instance().set(account, ACCOUNT_ALIAS, aliasName);
  QString accountName;
  if (aliasName.isEmpty()) {
    accountName = QObject::tr("SIP Account #%1").arg(number+1);
  } else {
    if (aliasName.length() > 30) {
	    aliasName = aliasName.left(30) + "...";
    }
     accountName = aliasName + " (" + QObject::tr("SIP Account #%1").arg(number+1) + ")";
  }
  cboSIPAccount->changeItem(accountName, number); 
533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560
  ConfigurationManager::instance().set(account, 
				       SIGNALISATION_FULL_NAME,
				       fullName->text());
  ConfigurationManager::instance().set(account, 
				       SIGNALISATION_USER_PART,
				       userPart->text());
  ConfigurationManager::instance().set(account, 
				       SIGNALISATION_AUTH_USER_NAME,
				       username->text());
  ConfigurationManager::instance().set(account, 
				       SIGNALISATION_PASSWORD,
				       password->text());
  ConfigurationManager::instance().set(account, 
				       SIGNALISATION_HOST_PART,
				       hostPart->text());
  ConfigurationManager::instance().set(account, 
				       SIGNALISATION_PROXY,
				       sipproxy->text());
  ConfigurationManager::instance().set(account, 
				       ACCOUNT_AUTO_REGISTER,
				       QString::number(chkAutoregister->isChecked()));
  ConfigurationManager::instance().set(account, 
				       ACCOUNT_ENABLE,
				       QString::number(chkEnable->isChecked()));
  ConfigurationManager::instance().set(account, 
				       SIGNALISATION_STUN_SERVER,
				       STUNserver->text());
}