Commit b5853350 authored by yanmorin's avatar yanmorin
Browse files

New AudioDriver testing button
parent adda9e4b
......@@ -13,7 +13,7 @@ endif
# cd qt && make
SUBDIRS = $(serverdir) $(qtdir) cli
SUBDIRS = $(serverdir) $(qtdir) cli qt
noinst_LTLIBRARIES = libguiframework.la
......
......@@ -264,7 +264,7 @@ GuiFramework::getRegistrationState(std::string& stateCode, std::string& stateMes
}
bool
GuiFramework::setSwitch(const std::string& switchName)
GuiFramework::setSwitch(const std::string& switchName, std::string& returnMessage)
{
return Manager::instance().setSwitch(switchName);
return Manager::instance().setSwitch(switchName, returnMessage);
}
......@@ -92,7 +92,7 @@ public:
bool setMicVolume(int volume);
int getSpkrVolume();
int getMicVolume();
bool setSwitch(const std::string& switchName);
bool setSwitch(const std::string& switchName, std::string& returnMessage);
bool hasLoadedSetup();
const CallID& getCurrentId();
......
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
/*
* Copyright (C) 2004-2006 Savoir-Faire Linux inc.
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
* Author: Jean-Philippe Barrette-LaPierre
<jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
......@@ -56,9 +57,9 @@ ConfigurationManagerImpl::save()
while(pos != mEntries.end()) {
VariableMap::iterator vpos = pos->second.begin();
while(vpos != pos->second.end()) {
ConfigEntry entry(vpos->second);
mSession->configSet(entry.section, entry.name, entry.value);
vpos++;
ConfigEntry entry(vpos->second);
mSession->configSet(entry.section, entry.name, entry.value);
vpos++;
}
pos++;
......@@ -100,7 +101,45 @@ void
ConfigurationManagerImpl::add(const AudioDevice &entry)
{
mAudioDevices.push_back(entry);
emit audioDevicesUpdated();
// emit audioDevicesUpdated(); // <-- wrong call with success
}
void
ConfigurationManagerImpl::addAudioDeviceIn(QString index,
QString hostApiName,
QString deviceName)
{
AudioDevice device;
device.index = index;
device.hostApiName = hostApiName;
device.deviceName = deviceName;
addIn(device);
}
void
ConfigurationManagerImpl::addIn(const AudioDevice &entry)
{
mAudioDevicesIn.push_back(entry);
//emit audioDevicesInUpdated(); // <-- wrong call with success()
}
void
ConfigurationManagerImpl::addAudioDeviceOut(QString index,
QString hostApiName,
QString deviceName)
{
AudioDevice device;
device.index = index;
device.hostApiName = hostApiName;
device.deviceName = deviceName;
addOut(device);
}
void
ConfigurationManagerImpl::addOut(const AudioDevice &entry)
{
mAudioDevicesOut.push_back(entry);
//emit audioDevicesOutUpdated(); // <-- wrong call with success()
}
void
......@@ -136,6 +175,7 @@ ConfigurationManagerImpl::add(const Codec &entry)
mCodecs.push_back(entry);
emit codecsUpdated();
}
void
ConfigurationManagerImpl::set(const QString &section,
const QString &name,
......@@ -150,6 +190,13 @@ ConfigurationManagerImpl::set(const QString &section,
}
}
void
ConfigurationManagerImpl::save(const QString &section, const QString &name)
{
QString value = get(section, name);
mSession->configSet(section, name, value);
}
QString
ConfigurationManagerImpl::get(const QString &section,
const QString &name)
......
/**
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
/*
* Copyright (C) 2004-2006 Savoir-Faire Linux inc.
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
* Author: Jean-Philippe Barrette-LaPierre
<jean-philippe.barrette-lapierre@savoirfairelinux.com>
*
......@@ -88,6 +89,8 @@ class ConfigurationManagerImpl : public QObject
signals:
void audioDevicesUpdated();
void audioDevicesInUpdated();
void audioDevicesOutUpdated();
void ringtonesUpdated();
void codecsUpdated();
void updated();
......@@ -126,9 +129,17 @@ public:
void clearAudioDevices()
{mAudioDevices.clear();}
void clearAudioDevicesIn()
{mAudioDevices.clear();}
void clearAudioDevicesOut()
{mAudioDevices.clear();}
std::list< AudioDevice > getAudioDevices()
{return mAudioDevices;}
std::list< AudioDevice > getAudioDevicesIn()
{return mAudioDevicesIn;}
std::list< AudioDevice > getAudioDevicesOut()
{return mAudioDevicesOut;}
std::list< Ringtone > getRingtones()
{return mRingtones;}
......@@ -143,6 +154,7 @@ public:
{emit updated();}
void save();
void save(const QString& section, const QString& name);
void finishSave();
......@@ -152,6 +164,12 @@ public slots:
void addAudioDevice(QString index, QString hostApiName, QString deviceName);
void add(const AudioDevice &entry);
void addAudioDeviceIn(QString index, QString hostApiName, QString deviceName);
void addIn(const AudioDevice &entry);
void addAudioDeviceOut(QString index, QString hostApiName, QString deviceName);
void addOut(const AudioDevice &entry);
void addRingtone(QString index, QString filename);
void add(const Ringtone &entry);
......@@ -165,6 +183,8 @@ private:
SectionMap mEntries;
std::list< AudioDevice > mAudioDevices;
std::list< AudioDevice > mAudioDevicesIn;
std::list< AudioDevice > mAudioDevicesOut;
std::list< Ringtone > mRingtones;
std::list< Codec > mCodecs;
......
......@@ -741,22 +741,37 @@
<attribute name="title">
<string>Drivers</string>
</attribute>
<widget class="QButtonGroup">
<property name="name">
<cstring>DriverChoice</cstring>
</property>
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>410</width>
<height>180</height>
</rect>
</property>
<property name="title">
<string>Drivers list</string>
</property>
</widget>
<widget class="QLayoutWidget">
<property name="geometry">
<rect><x>0</x><y>0</y><width>410</width><height>360</height></rect>
</property>
<vbox>
<widget class="QVButtonGroup">
<property name="name"><cstring>DriverChoice</cstring></property>
<property name="title"><string>Driver for Speaker</string></property>
</widget>
<widget class="QVButtonGroup">
<property name="name"><cstring>DriverChoiceIn</cstring></property>
<property name="title"><string>Driver for Microphone</string></property>
</widget>
<widget class="QLayoutWidget">
<property name="name"><cstring>layoutforsounddriver</cstring></property>
<hbox>
<property name="name"><cstring>unnamed</cstring></property>
<widget class="QPushButton">
<property name="name"><cstring>buttonTestSoundDriver</cstring></property>
<property name="enabled"><bool>true</bool></property>
<property name="text"><string>Test</string></property>
</widget>
<widget class="QLabel">
<property name="name"><cstring>lblSoundDriver</cstring></property>
<property name="text"><string></string></property>
<property name="paletteForegroundColor"><color><red>255</red><green>0</green><blue>0</blue></color></property>
</widget>
</hbox>
</widget>
</vbox>
</widget>
</widget>
<widget class="QWidget">
<property name="name">
......@@ -766,7 +781,7 @@
<string>Codecs</string>
</attribute>
<widget class="QButtonGroup">
<property name="name">
<property name="name">
<cstring>CodecsChoice</cstring>
</property>
<property name="geometry">
......@@ -1405,12 +1420,30 @@ Montreal, Quebec H2T 1S6&lt;/p&gt;</string>
<receiver>ConfigurationPanel</receiver>
<slot>changeTabSlot()</slot>
</connection>
<connection>
<sender>buttonRegister</sender>
<signal>clicked()</signal>
<receiver>ConfigurationPanel</receiver>
<slot>slotRegister()</slot>
</connection>
<connection>
<sender>DriverChoice</sender>
<signal>clicked(int)</signal>
<receiver>ConfigurationPanel</receiver>
<slot>driverSlot(int)</slot>
</connection>
<connection>
<sender>DriverChoiceIn</sender>
<signal>clicked(int)</signal>
<receiver>ConfigurationPanel</receiver>
<slot>driverSlotIn(int)</slot>
</connection>
<connection>
<sender>buttonTestSoundDriver</sender>
<signal>clicked()</signal>
<receiver>ConfigurationPanel</receiver>
<slot>slotTestSoundDriver()</slot>
</connection>
<connection>
<sender>buttonCancel</sender>
<signal>clicked()</signal>
......@@ -1462,6 +1495,7 @@ Montreal, Quebec H2T 1S6&lt;/p&gt;</string>
<tabstop>sendDTMFas</tabstop>
<tabstop>Menu</tabstop>
<tabstop>Tab_Audio</tabstop>
<tabstop>buttonTestSoundDriver</tabstop>
<tabstop>codec1</tabstop>
<tabstop>codec2</tabstop>
<tabstop>codec3</tabstop>
......@@ -1474,20 +1508,26 @@ Montreal, Quebec H2T 1S6&lt;/p&gt;</string>
</includes>
<signals>
<signal>needRegister()</signal>
<signal>soundDriverChanged()</signal>
</signals>
<slots>
<slot>generate()</slot>
<slot>slotRegisterFailed( QString )</slot>
<slot>slotRegisterSucceed( QString )</slot>
<slot>slotRegister()</slot>
<slot>slotRegisterReturn( bool, QString )</slot>
<slot>slotTestSoundDriver()</slot>
<slot>slotSoundDriverReturn( bool, QString )</slot>
<slot>saveSlot()</slot>
<slot>changeTabSlot()</slot>
<slot>useStunSlot( int id )</slot>
<slot>applySkinSlot()</slot>
<slot>driverSlot( int id )</slot>
<slot>driverSlotIn( int id )</slot>
<slot>updateSkins()</slot>
<slot>updateRingtones()</slot>
<slot>updateCodecs()</slot>
<slot>updateAudioDevices()</slot>
<slot>updateAudioDevicesIn()</slot>
<slot>updateAudioDevicesOut()</slot>
<slot>SkinChoice_selected( const QString &amp; )</slot>
</slots>
<functions>
......
......@@ -34,6 +34,7 @@
#include <qmessagebox.h>
#include <qstringlist.h>
#include <qcolor.h>
#include <qvbuttongroup.h>
#include "globals.h"
#include "ConfigurationManager.hpp"
......@@ -109,12 +110,6 @@ void ConfigurationPanel::init()
TransparentWidget::retreive(ABOUT_IMAGE),
"About",
Menu);
// we save the configuration, then we try to register
QObject::connect(buttonRegister, SIGNAL(clicked()), this, SLOT(saveSlot()));
QObject::connect(buttonRegister, SIGNAL(clicked()),
this, SIGNAL(needRegister()));
}
void
......@@ -129,8 +124,7 @@ ConfigurationPanel::generate()
.get(AUDIO_SECTION, AUDIO_CODEC3));
ringsChoice->setCurrentText(ConfigurationManager::instance()
.get(AUDIO_SECTION,
ringsChoice->setCurrentText(ConfigurationManager::instance().get(AUDIO_SECTION,
AUDIO_RINGTONE));
QString account = ACCOUNT_DEFAULT_NAME;
......@@ -171,11 +165,17 @@ ConfigurationPanel::generate()
QRadioButton* device =
static_cast< QRadioButton * >(DriverChoice->find(ConfigurationManager::instance()
.get(AUDIO_SECTION,
AUDIO_DEFAULT_DEVICE).toUInt()));
AUDIO_DEFAULT_DEVICEOUT).toUInt()));
if(device) {
device->setChecked(true);
}
device = static_cast< QRadioButton * >(DriverChoiceIn->find(ConfigurationManager::instance()
.get(AUDIO_SECTION, AUDIO_DEFAULT_DEVICEIN).toUInt()));
if (device) {
device->setChecked(true);
}
//preference tab
updateSkins();
}
......@@ -220,33 +220,25 @@ void ConfigurationPanel::saveSlot()
QString::number(sendDTMFas->currentItem()));
if (codec1->currentText() != NULL) {
ConfigurationManager::instance().set(AUDIO_SECTION,
AUDIO_CODEC1,
codec1->currentText());
ConfigurationManager::instance().set(AUDIO_SECTION, AUDIO_CODEC1, codec1->currentText());
}
if (codec2->currentText() != NULL) {
ConfigurationManager::instance().set(AUDIO_SECTION,
AUDIO_CODEC2,
codec2->currentText());
ConfigurationManager::instance().set(AUDIO_SECTION, AUDIO_CODEC2, codec2->currentText());
}
if (codec3->currentText() != NULL) {
ConfigurationManager::instance().set(AUDIO_SECTION,
AUDIO_CODEC3,
codec3->currentText());
ConfigurationManager::instance().set(AUDIO_SECTION, AUDIO_CODEC3, codec3->currentText());
}
if (ringsChoice->currentText() != NULL) {
ConfigurationManager::instance().set(AUDIO_SECTION,
AUDIO_RINGTONE,
ringsChoice->currentText());
ConfigurationManager::instance().set(AUDIO_SECTION, AUDIO_RINGTONE, ringsChoice->currentText());
}
SkinManager::instance().load(SkinChoice->currentText());
SkinManager::instance().save();
#if 0
QMessageBox::information(this, "Save settings",
"You must restart SFLPhone",
QMessageBox::information(this, tr("Save settings"),
tr("You must restart SFLPhone"),
QMessageBox::Yes);
#endif
......@@ -258,14 +250,14 @@ void ConfigurationPanel::changeTabSlot()
{
switch (Menu->currentItem()) {
case 0:
TitleTab->setText("Setup signalisation");
TitleTab->setText(tr("Setup signalisation"));
Tab_Signalisations->show();
Tab_Audio->hide();
Tab_Preferences->hide();
Tab_About->hide();
break;
case 1:
TitleTab->setText("Setup audio");
TitleTab->setText(tr("Setup audio"));
Tab_Signalisations->hide();
Tab_Audio->show();
Tab_Preferences->hide();
......@@ -273,14 +265,14 @@ void ConfigurationPanel::changeTabSlot()
break;
case 2:
updateSkins();
TitleTab->setText("Setup preferences");
TitleTab->setText(tr("Setup preferences"));
Tab_Signalisations->hide();
Tab_Audio->hide();
Tab_Preferences->show();
Tab_About->hide();
break;
case 3:
TitleTab->setText("About");
TitleTab->setText(tr("About"));
Tab_Signalisations->hide();
Tab_Audio->hide();
Tab_Preferences->hide();
......@@ -308,8 +300,19 @@ void ConfigurationPanel::applySkinSlot()
void ConfigurationPanel::driverSlot(int id)
{
ConfigurationManager::instance().set(AUDIO_SECTION,
AUDIO_DEFAULT_DEVICE,
AUDIO_DEFAULT_DEVICEOUT,
QString::number(id));
lblSoundDriver->setPaletteForegroundColor(black);
lblSoundDriver->setText(tr("Not tested"));
}
void ConfigurationPanel::driverSlotIn(int id)
{
ConfigurationManager::instance().set(AUDIO_SECTION,
AUDIO_DEFAULT_DEVICEIN,
QString::number(id));
lblSoundDriver->setPaletteForegroundColor(black);
lblSoundDriver->setText(tr("Not tested"));
}
void ConfigurationPanel::updateSkins()
......@@ -346,8 +349,55 @@ void ConfigurationPanel::updateCodecs()
codec3->insertItem(pos->codecName);
}
}
void ConfigurationPanel::updateAudioDevicesIn()
{
static std::list< QRadioButton * > buttonsIn;
while(buttonsIn.begin() != buttonsIn.end()) {
DriverChoiceIn->remove(*buttonsIn.begin());
buttonsIn.pop_front();
}
int top = 0;
//In
std::list< AudioDevice > audio = ConfigurationManager::instance().getAudioDevicesIn();
std::list< AudioDevice >::iterator pos;
for (pos = audio.begin(); pos != audio.end(); pos++) {
QString hostApiName = pos->hostApiName;
QString deviceName = pos->deviceName;
QString name = hostApiName +
QObject::tr(" (device #%1)").arg(pos->index);
// New radio button with found device name
QRadioButton* device = new QRadioButton(DriverChoiceIn);
buttonsIn.push_back(device);
DriverChoiceIn->insert(device, pos->index.toUInt());
//device->setGeometry( QRect( 10, 30 + top, 360, 21 ) );
// Set label of radio button
//device->setText(deviceName);
// Add tooltip for each one
QString text = deviceName + " " + name;
if(text.length() > 50) {
device->setText(text.left(50) + "...");
}
else {
device->setText(text);
}
QToolTip::add(device, text);
top += 30;
}
// Set position of the button group, with appropriate length
//DriverChoiceIn->setGeometry( QRect( 10, 200, 410, top + 30 ) );
}
void ConfigurationPanel::updateAudioDevicesOut()
{
updateAudioDevices();
}
void ConfigurationPanel::updateAudioDevices()
{
......@@ -359,7 +409,7 @@ void ConfigurationPanel::updateAudioDevices()
}
int top = 0;
std::list< AudioDevice > audio = ConfigurationManager::instance().getAudioDevices();
std::list< AudioDevice > audio = ConfigurationManager::instance().getAudioDevicesOut();
std::list< AudioDevice >::iterator pos;
for (pos = audio.begin(); pos != audio.end(); pos++) {
......@@ -373,7 +423,7 @@ void ConfigurationPanel::updateAudioDevices()
QRadioButton* device = new QRadioButton(DriverChoice);
buttons.push_back(device);
DriverChoice->insert(device, pos->index.toUInt());
device->setGeometry( QRect( 10, 30 + top, 390, 21 ) );
//device->setGeometry( QRect( 10, 30 + top, 360, 21 ) );
// Set label of radio button
//device->setText(deviceName);
// Add tooltip for each one
......@@ -391,8 +441,10 @@ void ConfigurationPanel::updateAudioDevices()
top += 30;
}
// Set position of the button group, with appropriate length
DriverChoice->setGeometry( QRect( 10, 10, 410, top + 30 ) );
//DriverChoice->setGeometry( QRect( 10, 10, 410, top + 30 ) );
}
......@@ -402,19 +454,42 @@ ConfigurationPanel::SkinChoice_selected( const QString & )
}
void
ConfigurationPanel::slotRegister()
{
saveSlot();
emit needRegister();
}
void
ConfigurationPanel::slotRegisterFailed( QString message )
ConfigurationPanel::slotRegisterReturn( bool hasError, QString )
{
if (hasError) {
lblError->setPaletteForegroundColor(red); // red
lblError->setText("Register failed");
} else {
lblError->setPaletteForegroundColor(black); // black
lblError->setText("Register Succeed");
}
lblError->show();
}
void ConfigurationPanel::slotTestSoundDriver()
{
lblError->setPaletteForegroundColor(QColor(255,0,0)); // red
lblError->setText("Register failed");
lblError->show();
ConfigurationManager::instance().save(AUDIO_SECTION, AUDIO_DEFAULT_DEVICEOUT);
ConfigurationManager::instance().save(AUDIO_SECTION, AUDIO_DEFAULT_DEVICEIN);
emit soundDriverChanged();
}
void
ConfigurationPanel::slotRegisterSucceed( QString message )
ConfigurationPanel::slotSoundDriverReturn( bool hasError, QString message )
{
lblError->setPaletteForegroundColor(QColor(0,0,0)); // black
lblError->setText("Register Succeed");
lblError->show();
if (hasError) { // no error
lblSoundDriver->setPaletteForegroundColor(red); // error in red
} else {
lblSoundDriver->setPaletteForegroundColor(black);
}
lblSoundDriver->setText(message);
lblSoundDriver->show();
}
......@@ -68,14 +68,10 @@ PhoneLineManagerImpl::PhoneLineManagerImpl()
EventFactory::instance().registerEvent< BusyStatus >("114");
EventFactory::instance().registerEvent< CongestionStatus >("115");
EventFactory::instance().registerEvent< WrongNumberStatus >("116");
QObject::connect(this, SIGNAL(disconnected()),
this, SLOT(closeSession()));
QObject::connect(this, SIGNAL(readyToHandleEvents()),
this, SLOT(handleEvents()));
QObject::connect(this, SIGNAL(connected()),
this, SIGNAL(readyToSendStatus()));
QObject::connect(this, SIGNAL(readyToSendStatus()),
this, SLOT(startSession()));
QObject::connect(this, SIGNAL(disconnected()), this, SLOT(closeSession()));
QObject::connect(this, SIGNAL(readyToHandleEvents()), this, SLOT(handleEvents()));
QObject::connect(this, SIGNAL(connected()), this, SIGNAL(readyToSendStatus()));
QObject::connect(this, SIGNAL(readyToSendStatus()), this, SLOT(startSession()));
}
......@@ -129,10 +125,10 @@ PhoneLineManagerImpl::connect()
}
void
PhoneLineManagerImpl::registerToServer()