diff --git a/sflphone-client-kde/DEVELOPPER b/sflphone-client-kde/DEVELOPPER new file mode 100644 index 0000000000000000000000000000000000000000..7442486ecaf7f0c064b8537ed20381ad65f4e984 --- /dev/null +++ b/sflphone-client-kde/DEVELOPPER @@ -0,0 +1,23 @@ +From now on, those coding guideline must be applied to prevent more fragmentation of the coding style: +-Class name must start with a caps +-Funtion and variables names must -not- start with a caps +-Words in functions must be separated by caps "addNewCall" +-Pointer symbol should be merge with the type QWidget* aWidget +-Indentation must be 3 (three) -space- wide, every IDE have options to set that +-Classes and functions bracket must look like: + void MyClass::myFunction() + { + + } +-If, while, case and for most look like this: + if () { + + } + else { + + } +-One line if without braces are allowed +-The .h HAVE TO BE COMMENTED following the doxygen syntax +-"Autoconnect" functions are allowed +-Qt STL and macro are recommaded +-KDE class are prefered over pure Qt classes diff --git a/sflphone-client-kde/data/sflphone-client-kdeui.rc b/sflphone-client-kde/data/sflphone-client-kdeui.rc index 4402357f0571e624558ff8a88f7497ed08a03501..08c501092907c656132600c40881a845ad89fc08 100644 --- a/sflphone-client-kde/data/sflphone-client-kdeui.rc +++ b/sflphone-client-kde/data/sflphone-client-kdeui.rc @@ -5,8 +5,7 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.kde.org/standards/kxmlgui/1.0 http://www.kde.org/standards/kxmlgui/1.0/kxmlgui.xsd" > - --> - + --> <gui name="sflphone-client-kde" version="1"> <MenuBar> @@ -38,18 +37,20 @@ </Menu> </MenuBar> - <ToolBar name="callsToolBar" iconText="icononly" position="Top" noMerge="1" fullWidth="true" newline="true" > - <Action name="action_accept" /> - <Action name="action_refuse" /> - <Action name="action_hold" /> - <Action name="action_transfer" /> - <Action name="action_record" /> - <Action name="action_mailBox" /> + <ToolBar name="mainToolBar" iconText="icononly" position="Top" noMerge="1" fullWidth="true" newline="true" > + <Action name="action_accept" /> + <Action name="action_mailBox" /> </ToolBar> + <ToolBar name="callsToolBar" iconText="icononly" position="Top" noMerge="1" fullWidth="true" newline="true" > + <Action name="action_refuse" /> + <Action name="action_hold" /> + <Action name="action_transfer" /> + <Action name="action_record" /> + </ToolBar> <ToolBar name="screenToolBar" iconText="icononly" position="Top" noMerge="1" fullWidth="true" newline="true" > <Action name="action_main" /> <Action name="action_history" /> <Action name="action_addressBook" /> </ToolBar> -</gui> \ No newline at end of file +</gui> diff --git a/sflphone-client-kde/src/Account.cpp b/sflphone-client-kde/src/Account.cpp index 7e8ea5d350ea4b137ca88d8310824fd9bc87a4f4..fec334626d0d42ad385ea78df33f3d723007c421 100644 --- a/sflphone-client-kde/src/Account.cpp +++ b/sflphone-client-kde/src/Account.cpp @@ -30,25 +30,25 @@ const QString account_state_name(QString & s) { - if(s == QString(ACCOUNT_STATE_REGISTERED)) - return i18n("Registered" ); - if(s == QString(ACCOUNT_STATE_UNREGISTERED)) - return i18n("Not Registered"); - if(s == QString(ACCOUNT_STATE_TRYING)) - return i18n("Trying..."); - if(s == QString(ACCOUNT_STATE_ERROR)) - return i18n("Error"); - if(s == QString(ACCOUNT_STATE_ERROR_AUTH)) - return i18n("Authentication Failed"); - if(s == QString(ACCOUNT_STATE_ERROR_NETWORK)) - return i18n("Network unreachable"); - if(s == QString(ACCOUNT_STATE_ERROR_HOST)) - return i18n("Host unreachable"); - if(s == QString(ACCOUNT_STATE_ERROR_CONF_STUN)) - return i18n("Stun configuration error"); - if(s == QString(ACCOUNT_STATE_ERROR_EXIST_STUN)) - return i18n("Stun server invalid"); - return i18n("Invalid"); + if(s == QString(ACCOUNT_STATE_REGISTERED)) + return i18n("Registered" ); + if(s == QString(ACCOUNT_STATE_UNREGISTERED)) + return i18n("Not Registered"); + if(s == QString(ACCOUNT_STATE_TRYING)) + return i18n("Trying..."); + if(s == QString(ACCOUNT_STATE_ERROR)) + return i18n("Error"); + if(s == QString(ACCOUNT_STATE_ERROR_AUTH)) + return i18n("Authentication Failed"); + if(s == QString(ACCOUNT_STATE_ERROR_NETWORK)) + return i18n("Network unreachable"); + if(s == QString(ACCOUNT_STATE_ERROR_HOST)) + return i18n("Host unreachable"); + if(s == QString(ACCOUNT_STATE_ERROR_CONF_STUN)) + return i18n("Stun configuration error"); + if(s == QString(ACCOUNT_STATE_ERROR_EXIST_STUN)) + return i18n("Stun server invalid"); + return i18n("Invalid"); } //Constructors @@ -60,136 +60,125 @@ Account::Account():accountId(NULL) void Account::initItem() { - if(item != NULL) - { - delete item; - } - item = new QListWidgetItem(); - item->setSizeHint(QSize(140,25)); - item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled|Qt::ItemIsEnabled); - initItemWidget(); + if(item != NULL) + delete item; + item = new QListWidgetItem(); + item->setSizeHint(QSize(140,25)); + item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled|Qt::ItemIsEnabled); + initItemWidget(); } void Account::initItemWidget() { - if(itemWidget != NULL) - { - delete itemWidget; - } - bool enabled = getAccountDetail(ACCOUNT_ENABLED) == ACCOUNT_ENABLED_TRUE; - itemWidget = new AccountItemWidget(); - itemWidget->setEnabled(enabled); - itemWidget->setAccountText(getAccountDetail(ACCOUNT_ALIAS)); - - if(isNew() || !enabled) - { - itemWidget->setState(AccountItemWidget::Unregistered); - } - else if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) - { - itemWidget->setState(AccountItemWidget::Registered); - } - else - { - itemWidget->setState(AccountItemWidget::NotWorking); - } - connect(itemWidget, SIGNAL(checkStateChanged(bool)), this, SLOT(setEnabled(bool))); + if(itemWidget != NULL) + delete itemWidget; + + bool enabled = getAccountDetail(ACCOUNT_ENABLED) == ACCOUNT_ENABLED_TRUE; + itemWidget = new AccountItemWidget(); + itemWidget->setEnabled(enabled); + itemWidget->setAccountText(getAccountDetail(ACCOUNT_ALIAS)); + + if(isNew() || !enabled) + itemWidget->setState(AccountItemWidget::Unregistered); + else if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) + itemWidget->setState(AccountItemWidget::Registered); + else + itemWidget->setState(AccountItemWidget::NotWorking); + connect(itemWidget, SIGNAL(checkStateChanged(bool)), this, SLOT(setEnabled(bool))); } Account * Account::buildExistingAccountFromId(QString _accountId) { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - Account * a = new Account(); - a->accountId = new QString(_accountId); - a->accountDetails = new MapStringString( configurationManager.getAccountDetails(_accountId).value() ); - a->initItem(); - return a; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + Account * a = new Account(); + a->accountId = new QString(_accountId); + a->accountDetails = new MapStringString( configurationManager.getAccountDetails(_accountId).value() ); + a->initItem(); + return a; } Account * Account::buildNewAccountFromAlias(QString alias) { - Account * a = new Account(); - a->accountDetails = new MapStringString(); - a->setAccountDetail(ACCOUNT_ALIAS,alias); - a->initItem(); - return a; + Account * a = new Account(); + a->accountDetails = new MapStringString(); + a->setAccountDetail(ACCOUNT_ALIAS,alias); + a->initItem(); + return a; } Account::~Account() { - delete accountId; - delete accountDetails; - delete item; + delete accountId; + delete accountDetails; + delete item; } //Getters bool Account::isNew() const { - return (accountId == NULL); + return (accountId == NULL); } bool Account::isChecked() const { - return itemWidget->getEnabled(); + return itemWidget->getEnabled(); } const QString & Account::getAccountId() const { - if (isNew()) - { - qDebug() << "Error : getting AccountId of a new account."; - } - return *accountId; + if (isNew()) + qDebug() << "Error : getting AccountId of a new account."; + return *accountId; } MapStringString & Account::getAccountDetails() const { - return *accountDetails; + return *accountDetails; } QListWidgetItem * Account::getItem() { - return item; + return item; } AccountItemWidget * Account::getItemWidget() { - return itemWidget; + return itemWidget; } QString Account::getStateName(QString & state) { - return account_state_name(state); + return account_state_name(state); } QColor Account::getStateColor() { - if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_UNREGISTERED) - { return Qt::black; } - if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) - { return Qt::darkGreen; } - return Qt::red; + if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_UNREGISTERED) + return Qt::black; + if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) + return Qt::darkGreen; + return Qt::red; } QString Account::getStateColorName() { - if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_UNREGISTERED) - { return "black"; } - if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) - { return "darkGreen"; } - return "red"; + if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_UNREGISTERED) + return "black"; + if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) + return "darkGreen"; + return "red"; } QString Account::getAccountDetail(QString param) const { - return (*accountDetails)[param]; + return (*accountDetails)[param]; } QString Account::getAlias() const { - return getAccountDetail(ACCOUNT_ALIAS); + return getAccountDetail(ACCOUNT_ALIAS); } @@ -197,73 +186,67 @@ QString Account::getAlias() const void Account::setAccountDetails(MapStringString m) { - *accountDetails = m; + *accountDetails = m; } void Account::setAccountDetail(QString param, QString val) { - (*accountDetails)[param] = val; + (*accountDetails)[param] = val; } void Account::setAccountId(QString id) { - qDebug() << "accountId = " << accountId; - if (! isNew()) - { - qDebug() << "Error : setting AccountId of an existing account."; - } - accountId = new QString(id); + qDebug() << "accountId = " << accountId; + if (! isNew()) + qDebug() << "Error : setting AccountId of an existing account."; + accountId = new QString(id); } void Account::setEnabled(bool checked) { - setAccountDetail(ACCOUNT_ENABLED, checked ? ACCOUNT_ENABLED_TRUE : ACCOUNT_ENABLED_FALSE); + setAccountDetail(ACCOUNT_ENABLED, checked ? ACCOUNT_ENABLED_TRUE : ACCOUNT_ENABLED_FALSE); } bool Account::isEnabled() const { - qDebug() << "isEnabled = " << getAccountDetail(ACCOUNT_ENABLED); - return (getAccountDetail(ACCOUNT_ENABLED) == ACCOUNT_ENABLED_TRUE); + qDebug() << "isEnabled = " << getAccountDetail(ACCOUNT_ENABLED); + return (getAccountDetail(ACCOUNT_ENABLED) == ACCOUNT_ENABLED_TRUE); } bool Account::isRegistered() const { - qDebug() << "isRegistered = " << getAccountDetail(ACCOUNT_STATUS); - return (getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED); + qDebug() << "isRegistered = " << getAccountDetail(ACCOUNT_STATUS); + return (getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED); } void Account::updateState() { - qDebug() << "updateState"; - if(! isNew()) - { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - MapStringString details = configurationManager.getAccountDetails(getAccountId()).value(); - AccountItemWidget * itemWidget = getItemWidget(); - QString status = details[ACCOUNT_STATUS]; - setAccountDetail(ACCOUNT_STATUS, status); - if(getAccountDetail(ACCOUNT_ENABLED) != ACCOUNT_ENABLED_TRUE ) - { - qDebug() << "itemWidget->setState(AccountItemWidget::Unregistered);"; - itemWidget->setState(AccountItemWidget::Unregistered); - } - else if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) - { - qDebug() << "itemWidget->setState(AccountItemWidget::Registered);"; - itemWidget->setState(AccountItemWidget::Registered); - } - else - { - qDebug() << "itemWidget->setState(AccountItemWidget::NotWorking);"; - itemWidget->setState(AccountItemWidget::NotWorking); - } - } + qDebug() << "updateState"; + if(! isNew()) { + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + MapStringString details = configurationManager.getAccountDetails(getAccountId()).value(); + AccountItemWidget * itemWidget = getItemWidget(); + QString status = details[ACCOUNT_STATUS]; + setAccountDetail(ACCOUNT_STATUS, status); + if(getAccountDetail(ACCOUNT_ENABLED) != ACCOUNT_ENABLED_TRUE ) { + qDebug() << "itemWidget->setState(AccountItemWidget::Unregistered);"; + itemWidget->setState(AccountItemWidget::Unregistered); + } + else if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) { + qDebug() << "itemWidget->setState(AccountItemWidget::Registered);"; + itemWidget->setState(AccountItemWidget::Registered); + } + else { + qDebug() << "itemWidget->setState(AccountItemWidget::NotWorking);"; + itemWidget->setState(AccountItemWidget::NotWorking); + } + } } //Operators bool Account::operator==(const Account& a)const { - return *accountId == *a.accountId; + return *accountId == *a.accountId; } diff --git a/sflphone-client-kde/src/Account.h b/sflphone-client-kde/src/Account.h index 8760c9e6b055dff7537e591396e38329bdae9df2..45bb56b6013090fa3b3f9ab43c3ca618f4f051bd 100644 --- a/sflphone-client-kde/src/Account.h +++ b/sflphone-client-kde/src/Account.h @@ -36,54 +36,54 @@ class Account : public QObject, public Item<AccountItemWidget>{ Q_OBJECT private: - QString * accountId; - MapStringString * accountDetails; -// QListWidgetItem * item; -// AccountItemWidget * itemWidget; + QString * accountId; + MapStringString * accountDetails; +// QListWidgetItem * item; +// AccountItemWidget * itemWidget; - Account(); + Account(); public: - - ~Account(); - - //Constructors - static Account * buildExistingAccountFromId(QString _accountId); - static Account * buildNewAccountFromAlias(QString alias); - - //Getters - bool isNew() const; - bool isChecked() const; - const QString & getAccountId() const; - MapStringString & getAccountDetails() const; - QListWidgetItem * getItem(); - AccountItemWidget * getItemWidget(); - QString getStateName(QString & state); - QColor getStateColor(); - QString getStateColorName(); - QString getAccountDetail(QString param) const; - QString getAlias() const; - bool isEnabled() const; - bool isRegistered() const; - - //Setters - void setAccountId(QString id); - void setAccountDetails(MapStringString m); - void setAccountDetail(QString param, QString val); - - //Updates - void initItem(); - void initItemWidget(); - void updateState(); - - //Operators - bool operator==(const Account&)const; - + + ~Account(); + + //Constructors + static Account * buildExistingAccountFromId(QString _accountId); + static Account * buildNewAccountFromAlias(QString alias); + + //Getters + bool isNew() const; + bool isChecked() const; + const QString & getAccountId() const; + MapStringString & getAccountDetails() const; + QListWidgetItem * getItem(); + AccountItemWidget * getItemWidget(); + QString getStateName(QString & state); + QColor getStateColor(); + QString getStateColorName(); + QString getAccountDetail(QString param) const; + QString getAlias() const; + bool isEnabled() const; + bool isRegistered() const; + + //Setters + void setAccountId(QString id); + void setAccountDetails(MapStringString m); + void setAccountDetail(QString param, QString val); + + //Updates + void initItem(); + void initItemWidget(); + void updateState(); + + //Operators + bool operator==(const Account&)const; + public slots: - void setEnabled(bool checked); - - - + void setEnabled(bool checked); + + + }; diff --git a/sflphone-client-kde/src/AccountItemWidget.cpp b/sflphone-client-kde/src/AccountItemWidget.cpp index 1f57e83dd35ff999b3f1d5e4a1c173311dff3b7f..1e5d8ca4b37df217f73b4c30e59b2237b78c48ba 100644 --- a/sflphone-client-kde/src/AccountItemWidget.cpp +++ b/sflphone-client-kde/src/AccountItemWidget.cpp @@ -29,88 +29,87 @@ AccountItemWidget::AccountItemWidget(QWidget *parent) : QWidget(parent) { - checkBox = new QCheckBox(this); - checkBox->setObjectName("checkBox"); - led = new QLabel(); - led->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - textLabel = new QLabel(); - - QSpacerItem * horizontalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Preferred, QSizePolicy::Minimum); - QHBoxLayout* hlayout = new QHBoxLayout(); - hlayout->setContentsMargins(0,0,0,0); - hlayout->addWidget(checkBox); - hlayout->addWidget(textLabel); - hlayout->addItem(horizontalSpacer); - hlayout->addWidget(led); - this->setLayout(hlayout); - state = Unregistered; - enabled = false; - updateDisplay(); - - QMetaObject::connectSlotsByName(this); + checkBox = new QCheckBox(this); + checkBox->setObjectName("checkBox"); + led = new QLabel(); + led->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + textLabel = new QLabel(); + + QSpacerItem * horizontalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Preferred, QSizePolicy::Minimum); + QHBoxLayout* hlayout = new QHBoxLayout(); + hlayout->setContentsMargins(0,0,0,0); + hlayout->addWidget(checkBox); + hlayout->addWidget(textLabel); + hlayout->addItem(horizontalSpacer); + hlayout->addWidget(led); + this->setLayout(hlayout); + state = Unregistered; + enabled = false; + updateDisplay(); + + QMetaObject::connectSlotsByName(this); } AccountItemWidget::~AccountItemWidget() { - delete led; - delete checkBox; - delete textLabel; + delete led; + delete checkBox; + delete textLabel; } void AccountItemWidget::updateStateDisplay() { - switch(state) - { - case Registered: - led->setPixmap(QPixmap(ICON_ACCOUNT_LED_GREEN)); - break; - case Unregistered: - led->setPixmap(QPixmap(ICON_ACCOUNT_LED_GRAY)); - break; - case NotWorking: - led->setPixmap(QPixmap(ICON_ACCOUNT_LED_RED)); - break; - default: - qDebug() << "Calling AccountItemWidget::setState with value " << state << ", not part of enum AccountItemWidget::State."; - } + switch(state) { + case Registered: + led->setPixmap(QPixmap(ICON_ACCOUNT_LED_GREEN)); + break; + case Unregistered: + led->setPixmap(QPixmap(ICON_ACCOUNT_LED_GRAY)); + break; + case NotWorking: + led->setPixmap(QPixmap(ICON_ACCOUNT_LED_RED)); + break; + default: + qDebug() << "Calling AccountItemWidget::setState with value " << state << ", not part of enum AccountItemWidget::State."; + } } - + void AccountItemWidget::updateEnabledDisplay() { - checkBox->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); + checkBox->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); } - + void AccountItemWidget::updateDisplay() { - updateStateDisplay(); - updateEnabledDisplay(); + updateStateDisplay(); + updateEnabledDisplay(); } void AccountItemWidget::setState(int state) { - this->state = state; - updateStateDisplay(); + this->state = state; + updateStateDisplay(); } void AccountItemWidget::setEnabled(bool enabled) { - this->enabled = enabled; - updateEnabledDisplay(); + this->enabled = enabled; + updateEnabledDisplay(); } void AccountItemWidget::setAccountText(QString text) { - this->textLabel->setText(text); + this->textLabel->setText(text); } - + bool AccountItemWidget::getEnabled() { - return checkBox->checkState(); + return checkBox->checkState(); } void AccountItemWidget::on_checkBox_stateChanged(int state) { - emit checkStateChanged(state == Qt::Checked); + emit checkStateChanged(state == Qt::Checked); } diff --git a/sflphone-client-kde/src/AccountItemWidget.h b/sflphone-client-kde/src/AccountItemWidget.h index 60055a3e5b09728a0bc886d9c152eecaee791294..b74ee2946c19260cac432296f84763056bd826f1 100644 --- a/sflphone-client-kde/src/AccountItemWidget.h +++ b/sflphone-client-kde/src/AccountItemWidget.h @@ -28,7 +28,7 @@ #include <kled.h> /** - @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> + @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> */ class AccountItemWidget : public QWidget { @@ -36,40 +36,40 @@ Q_OBJECT private: - int state; - bool enabled; - QLabel * led; - QCheckBox * checkBox; - QLabel * textLabel; + int state; + bool enabled; + QLabel * led; + QCheckBox * checkBox; + QLabel * textLabel; public: - enum State {Registered, Unregistered, NotWorking}; + enum State {Registered, Unregistered, NotWorking}; - //Constructors & Destructors - AccountItemWidget(QWidget *parent = 0); - ~AccountItemWidget(); + //Constructors & Destructors + AccountItemWidget(QWidget *parent = 0); + ~AccountItemWidget(); - //Getters - int getState(); - bool getEnabled(); - - //Setters - void setState(int state); - void setEnabled(bool enabled); - void setAccountText(QString text); - - //Updates - void updateStateDisplay(); - void updateEnabledDisplay(); - void updateDisplay(); - -private slots: - void on_checkBox_stateChanged(int state); - - + //Getters + int getState(); + bool getEnabled(); + + //Setters + void setState(int state); + void setEnabled(bool enabled); + void setAccountText(QString text); + + //Updates + void updateStateDisplay(); + void updateEnabledDisplay(); + void updateDisplay(); + +private slots: + void on_checkBox_stateChanged(int state); + + signals: - void checkStateChanged(bool checked); + void checkStateChanged(bool checked); }; diff --git a/sflphone-client-kde/src/AccountList.cpp b/sflphone-client-kde/src/AccountList.cpp index b8af2a0249dd2c2e4dc4500956f57c67837202da..bca24da00b1e67b1b71570e496dd4fff5c55f577 100644 --- a/sflphone-client-kde/src/AccountList.cpp +++ b/sflphone-client-kde/src/AccountList.cpp @@ -29,205 +29,198 @@ AccountList::AccountList(QStringList & _accountIds) { -// firstAccount = QString(); - accounts = new QVector<Account *>(); - for (int i = 0; i < _accountIds.size(); ++i){ - (*accounts) += Account::buildExistingAccountFromId(_accountIds[i]); - } +// firstAccount = QString(); + accounts = new QVector<Account *>(); + for (int i = 0; i < _accountIds.size(); ++i) { + (*accounts) += Account::buildExistingAccountFromId(_accountIds[i]); + } } AccountList::AccountList(bool fill) { - accounts = new QVector<Account *>(); - if(fill) - { - updateAccounts(); - } + accounts = new QVector<Account *>(); + if(fill) + updateAccounts(); } void AccountList::update() { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - Account * current; - for (int i = 0; i < accounts->size(); i++){ - current = (*accounts)[i]; - if (!(*accounts)[i]->isNew()) - removeAccount(current); - } - //ask for the list of accounts ids to the configurationManager - QStringList accountIds = configurationManager.getAccountList().value(); - for (int i = 0; i < accountIds.size(); ++i){ - accounts->insert(i, Account::buildExistingAccountFromId(accountIds[i])); - } + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + Account * current; + for (int i = 0; i < accounts->size(); i++) { + current = (*accounts)[i]; + if (!(*accounts)[i]->isNew()) + removeAccount(current); + } + //ask for the list of accounts ids to the configurationManager + QStringList accountIds = configurationManager.getAccountList().value(); + for (int i = 0; i < accountIds.size(); ++i) { + accounts->insert(i, Account::buildExistingAccountFromId(accountIds[i])); + } } void AccountList::updateAccounts() { - qDebug() << "updateAccounts"; - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - QStringList accountIds = configurationManager.getAccountList().value(); - accounts->clear(); - for (int i = 0; i < accountIds.size(); ++i){ - (*accounts) += Account::buildExistingAccountFromId(accountIds[i]); - } - emit accountListUpdated(); + qDebug() << "updateAccounts"; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + QStringList accountIds = configurationManager.getAccountList().value(); + accounts->clear(); + for (int i = 0; i < accountIds.size(); ++i) { + (*accounts) += Account::buildExistingAccountFromId(accountIds[i]); + } + emit accountListUpdated(); } void AccountList::upAccount(int index) { - if(index <= 0 || index >= size()) - { - qDebug() << "Error : index or future index out of range in upAccount."; - return; - } - Account * account = getAccountAt(index); - accounts->remove(index); - accounts->insert(index - 1, account); + if(index <= 0 || index >= size()) { + qDebug() << "Error : index or future index out of range in upAccount."; + return; + } + Account * account = getAccountAt(index); + accounts->remove(index); + accounts->insert(index - 1, account); } void AccountList::downAccount(int index) { - if(index < 0 || index >= size() - 1) - { - qDebug() << "Error : index or future index out of range in upAccount."; - return; - } - Account * account = getAccountAt(index); - accounts->remove(index); - accounts->insert(index + 1, account); + if(index < 0 || index >= size() - 1) { + qDebug() << "Error : index or future index out of range in upAccount."; + return; + } + Account * account = getAccountAt(index); + accounts->remove(index); + accounts->insert(index + 1, account); } QString AccountList::getOrderedList() const { - QString order; - for( int i = 0 ; i < size() ; i++) - { - order += getAccountAt(i)->getAccountId() + "/"; - } - return order; + QString order; + for( int i = 0 ; i < size() ; i++) { + order += getAccountAt(i)->getAccountId() + "/"; + } + return order; } QVector<Account *> AccountList::registeredAccounts() const { - qDebug() << "registeredAccounts"; - QVector<Account *> registeredAccounts; - Account * current; - for (int i = 0; i < accounts->count(); ++i){ - current = (*accounts)[i]; - if(current->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) - { - qDebug() << current->getAlias() << " : " << current; - registeredAccounts.append(current); - } - } - return registeredAccounts; + qDebug() << "registeredAccounts"; + QVector<Account *> registeredAccounts; + Account * current; + for (int i = 0; i < accounts->count(); ++i) { + current = (*accounts)[i]; + if(current->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) { + qDebug() << current->getAlias() << " : " << current; + registeredAccounts.append(current); + } + } + return registeredAccounts; } Account * AccountList::firstRegisteredAccount() const { - Account * current; - for (int i = 0; i < accounts->count(); ++i){ - current = (*accounts)[i]; - if(current->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) - { - return current; - } - } - return NULL; + Account * current; + for (int i = 0; i < accounts->count(); ++i) { + current = (*accounts)[i]; + if(current->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) + { + return current; + } + } + return NULL; } AccountList::~AccountList() { - delete accounts; + delete accounts; } //Getters QVector<Account *> & AccountList::getAccounts() { - return *accounts; + return *accounts; } const Account * AccountList::getAccountAt (int i) const { - return (*accounts)[i]; + return (*accounts)[i]; } Account * AccountList::getAccountAt (int i) { - return (*accounts)[i]; + return (*accounts)[i]; } Account * AccountList::getAccountById(const QString & id) const { - if(id.isEmpty()) - { return NULL; } - for (int i = 0; i < accounts->size(); ++i) - { - if (!(*accounts)[i]->isNew() && (*accounts)[i]->getAccountId() == id) - { - return (*accounts)[i]; - } - } - return NULL; + if(id.isEmpty()) + return NULL; + for (int i = 0; i < accounts->size(); ++i) { + if (!(*accounts)[i]->isNew() && (*accounts)[i]->getAccountId() == id) + return (*accounts)[i]; + } + return NULL; } QVector<Account *> AccountList::getAccountByState(QString & state) { - QVector<Account *> v; - for (int i = 0; i < accounts->size(); ++i){ - if ((*accounts)[i]->getAccountDetail(ACCOUNT_STATUS) == state) - v += (*accounts)[i]; - } - return v; + QVector<Account *> v; + for (int i = 0; i < accounts->size(); ++i) { + if ((*accounts)[i]->getAccountDetail(ACCOUNT_STATUS) == state) + v += (*accounts)[i]; + } + return v; } Account * AccountList::getAccountByItem(QListWidgetItem * item) { - for (int i = 0; i < accounts->size(); ++i){ - if ( (*accounts)[i]->getItem() == item) - return (*accounts)[i]; - } - return NULL; + for (int i = 0; i < accounts->size(); ++i) { + if ( (*accounts)[i]->getItem() == item) + return (*accounts)[i]; + } + return NULL; } int AccountList::size() const { - return accounts->size(); + return accounts->size(); } //Setters Account * AccountList::addAccount(QString & alias) { - Account * a = Account::buildNewAccountFromAlias(alias); - (*accounts) += a; - return a; + Account * a = Account::buildNewAccountFromAlias(alias); + (*accounts) += a; + return a; } void AccountList::removeAccount(QListWidgetItem * item) { - if(!item) {qDebug() << "Attempting to remove an account from a NULL item."; return; } + if(!item) + qDebug() << "Attempting to remove an account from a NULL item."; return; - Account * a = getAccountByItem(item); - if(!a) {qDebug() << "Attempting to remove an unexisting account."; return; } + Account * a = getAccountByItem(item); + if(!a) + qDebug() << "Attempting to remove an unexisting account."; return; - accounts->remove(accounts->indexOf(a)); + accounts->remove(accounts->indexOf(a)); } void AccountList::removeAccount(Account * account) { - accounts->remove(accounts->indexOf(account)); + accounts->remove(accounts->indexOf(account)); } const Account * AccountList::operator[] (int i) const { - return (*accounts)[i]; + return (*accounts)[i]; } Account * AccountList::operator[] (int i) { - return (*accounts)[i]; + return (*accounts)[i]; } diff --git a/sflphone-client-kde/src/AccountList.h b/sflphone-client-kde/src/AccountList.h index 48032d89a3b3d5253ee7917fac7fdd0dc0abe705..4367c81965afe830d6e036c79fe34dcdebb53f7d 100644 --- a/sflphone-client-kde/src/AccountList.h +++ b/sflphone-client-kde/src/AccountList.h @@ -29,59 +29,59 @@ class AccountList : public QObject{ - Q_OBJECT - + Q_OBJECT + private: - QVector<Account *> * accounts; + QVector<Account *> * accounts; public: - //Constructors & Destructors - AccountList(QStringList & _accountIds); - /** - * Constructs a new accountList, empty if fill = false - * filled with accounts from configurationManager.getAccountList() if true - * @param fill Whether to fill the list with accounts from configurationManager or not. - */ - AccountList(bool fill = true); - ~AccountList(); - - //Getters - QVector<Account *> & getAccounts(); - Account * getAccountAt (int i); - const Account * getAccountAt (int i) const; - Account * getAccountById(const QString & id) const; - QVector<Account *> getAccountByState(QString & state); - Account * getAccountByItem(QListWidgetItem * item); - int size() const; - Account * firstRegisteredAccount() const; - QString getOrderedList() const; - - //Setters - Account * addAccount(QString & alias); - void removeAccount(Account * account); - void removeAccount(QListWidgetItem * item); - void upAccount(int index); - void downAccount(int index); + //Constructors & Destructors + AccountList(QStringList & _accountIds); + /** + * Constructs a new accountList, empty if fill = false + * filled with accounts from configurationManager.getAccountList() if true + * @param fill Whether to fill the list with accounts from configurationManager or not. + */ + AccountList(bool fill = true); + ~AccountList(); + + //Getters + QVector<Account *> & getAccounts(); + Account * getAccountAt (int i); + const Account * getAccountAt (int i) const; + Account * getAccountById(const QString & id) const; + QVector<Account *> getAccountByState(QString & state); + Account * getAccountByItem(QListWidgetItem * item); + int size() const; + Account * firstRegisteredAccount() const; + QString getOrderedList() const; + + //Setters + Account * addAccount(QString & alias); + void removeAccount(Account * account); + void removeAccount(QListWidgetItem * item); + void upAccount(int index); + void downAccount(int index); - //Operators - Account * operator[] (int i); - const Account * operator[] (int i) const; - QVector<Account *> registeredAccounts() const; - -public slots: - /** - * updates the list of accounts (removed, added, order...) with the configurationManager's list - */ - void update(); - /** - * updates the list and the details of accounts with the configurationManager's list - */ - void updateAccounts(); - + //Operators + Account * operator[] (int i); + const Account * operator[] (int i) const; + QVector<Account *> registeredAccounts() const; + +public slots: + /** + * updates the list of accounts (removed, added, order...) with the configurationManager's list + */ + void update(); + /** + * updates the list and the details of accounts with the configurationManager's list + */ + void updateAccounts(); + signals: - void accountListUpdated(); + void accountListUpdated(); }; diff --git a/sflphone-client-kde/src/AccountListModel.cpp b/sflphone-client-kde/src/AccountListModel.cpp index 3b83ffe11e1053895acc4094423b5bf504d4a84c..d1bbc9b992d7bb8877eee6019f94a0abcf4c64bf 100644 --- a/sflphone-client-kde/src/AccountListModel.cpp +++ b/sflphone-client-kde/src/AccountListModel.cpp @@ -26,7 +26,7 @@ AccountListModel::AccountListModel(QObject *parent) : QAbstractListModel(parent) { - this->accounts = new AccountList(); + this->accounts = new AccountList(); } @@ -36,104 +36,88 @@ AccountListModel::~AccountListModel() QVariant AccountListModel::data ( const QModelIndex & index, int role) const { - if (!index.isValid() || index.row() < 0 || index.row() >= rowCount()) - return QVariant(); - - const Account * account = (*accounts)[index.row()]; - if(index.column() == 0 && role == Qt::DisplayRole) - { - return QVariant(account->getAlias()); - } - else if(index.column() == 0 && role == Qt::CheckStateRole) - { - return QVariant(account->isEnabled() ? Qt::Checked : Qt::Unchecked); - } - else if(index.column() == 0 && role == Qt::DecorationRole) - { - if(! account->isEnabled()) - { - return QVariant(QIcon(ICON_ACCOUNT_LED_GRAY)); - } - else if(account->isRegistered()) - { - return QVariant(QIcon(ICON_ACCOUNT_LED_GREEN)); - } - else - { - return QVariant(QIcon(ICON_ACCOUNT_LED_RED)); - } - } - return QVariant(); + if (!index.isValid() || index.row() < 0 || index.row() >= rowCount()) + return QVariant(); + + const Account * account = (*accounts)[index.row()]; + if(index.column() == 0 && role == Qt::DisplayRole) + return QVariant(account->getAlias()); + else if(index.column() == 0 && role == Qt::CheckStateRole) + return QVariant(account->isEnabled() ? Qt::Checked : Qt::Unchecked); + else if(index.column() == 0 && role == Qt::DecorationRole) { + if(! account->isEnabled()) + return QVariant(QIcon(ICON_ACCOUNT_LED_GRAY)); + else if(account->isRegistered()) + return QVariant(QIcon(ICON_ACCOUNT_LED_GREEN)); + else + return QVariant(QIcon(ICON_ACCOUNT_LED_RED)); + } + return QVariant(); } Qt::ItemFlags AccountListModel::flags(const QModelIndex & index) const { - if (index.column() == 0) - { - return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable; - } - return QAbstractItemModel::flags(index); + if (index.column() == 0) + return QAbstractItemModel::flags(index) | Qt::ItemIsUserCheckable; + return QAbstractItemModel::flags(index); } bool AccountListModel::setData ( const QModelIndex & index, const QVariant &value, int role) { - qDebug() << "setData"; - if (index.isValid() && index.column() == 0 && role == Qt::CheckStateRole) { - (*accounts)[index.row()]->setEnabled(value.toBool()); - emit dataChanged(index, index); - return true; - } - return false; + qDebug() << "setData"; + if (index.isValid() && index.column() == 0 && role == Qt::CheckStateRole) { + (*accounts)[index.row()]->setEnabled(value.toBool()); + emit dataChanged(index, index); + return true; + } + return false; } bool AccountListModel::accountUp( int index ) { - if(index > 0 && index <= rowCount()) - { - accounts->upAccount(index); - emit dataChanged(this->index(index - 1, 0, QModelIndex()), this->index(index, 0, QModelIndex())); - return true; - } - return false; + if(index > 0 && index <= rowCount()) { + accounts->upAccount(index); + emit dataChanged(this->index(index - 1, 0, QModelIndex()), this->index(index, 0, QModelIndex())); + return true; + } + return false; } bool AccountListModel::accountDown( int index ) { - if(index >= 0 && index < rowCount()) - { - accounts->downAccount(index); - emit dataChanged(this->index(index, 0, QModelIndex()), this->index(index + 1, 0, QModelIndex())); - return true; - } - return false; + if(index >= 0 && index < rowCount()) { + accounts->downAccount(index); + emit dataChanged(this->index(index, 0, QModelIndex()), this->index(index + 1, 0, QModelIndex())); + return true; + } + return false; } bool AccountListModel::removeAccount( int index ) { - if(index >= 0 && index < rowCount()) - { - accounts->removeAccount(accounts->getAccountAt(index)); - emit dataChanged(this->index(index, 0, QModelIndex()), this->index(rowCount(), 0, QModelIndex())); - return true; - } - return false; + if(index >= 0 && index < rowCount()) { + accounts->removeAccount(accounts->getAccountAt(index)); + emit dataChanged(this->index(index, 0, QModelIndex()), this->index(rowCount(), 0, QModelIndex())); + return true; + } + return false; } bool AccountListModel::addAccount( QString alias ) { - accounts->addAccount(alias); - emit dataChanged(this->index(0, 0, QModelIndex()), this->index(rowCount(), 0, QModelIndex())); - return true; + accounts->addAccount(alias); + emit dataChanged(this->index(0, 0, QModelIndex()), this->index(rowCount(), 0, QModelIndex())); + return true; } int AccountListModel::rowCount(const QModelIndex & /*parent*/) const { - return accounts->size(); + return accounts->size(); } QString AccountListModel::getOrderedList() const { - return accounts->getOrderedList(); + return accounts->getOrderedList(); } diff --git a/sflphone-client-kde/src/AccountListModel.h b/sflphone-client-kde/src/AccountListModel.h index dc4a9b40e6267b35b0cedf08db76b0df5a62e780..fa23c0fa00ff3de0d2a4b3cb7ffd72bcd964eec5 100644 --- a/sflphone-client-kde/src/AccountListModel.h +++ b/sflphone-client-kde/src/AccountListModel.h @@ -26,34 +26,34 @@ #include "AccountList.h" /** - @author Jérémy Quentin <jeremy.quentin@gmail.com> + @author Jérémy Quentin <jeremy.quentin@gmail.com> */ class AccountListModel : public QAbstractListModel { Q_OBJECT private: - AccountList * accounts; + AccountList * accounts; public: - AccountListModel(QObject *parent = 0); + AccountListModel(QObject *parent = 0); - ~AccountListModel(); - - QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; - int rowCount(const QModelIndex & parent = QModelIndex()) const; -// int columnCount(const QModelIndex & parent = QModelIndex()) const; -// QVariant headerData(int section , Qt::Orientation orientation, int role) const; - Qt::ItemFlags flags(const QModelIndex & index) const; - virtual bool setData ( const QModelIndex & index, const QVariant &value, int role); - - bool accountUp( int index ); - bool accountDown( int index ); - bool removeAccount( int index ); - bool addAccount( QString alias ); - - QString getOrderedList() const; -// QStringList getActiveCodecList() const ; -// void setActiveCodecList(const QStringList & activeCodecListToSet); + ~AccountListModel(); + + QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; + int rowCount(const QModelIndex & parent = QModelIndex()) const; +// int columnCount(const QModelIndex & parent = QModelIndex()) const; +// QVariant headerData(int section , Qt::Orientation orientation, int role) const; + Qt::ItemFlags flags(const QModelIndex & index) const; + virtual bool setData ( const QModelIndex & index, const QVariant &value, int role); + + bool accountUp( int index ); + bool accountDown( int index ); + bool removeAccount( int index ); + bool addAccount( QString alias ); + + QString getOrderedList() const; +// QStringList getActiveCodecList() const ; +// void setActiveCodecList(const QStringList & activeCodecListToSet); }; diff --git a/sflphone-client-kde/src/AccountWizard.cpp b/sflphone-client-kde/src/AccountWizard.cpp index 97c4e5db2bfd30504406f48c5a74a34c9552c515..36708e5bb9715952ffda407d1a6dd61e9366294c 100644 --- a/sflphone-client-kde/src/AccountWizard.cpp +++ b/sflphone-client-kde/src/AccountWizard.cpp @@ -61,93 +61,94 @@ ***************************************************************************/ typedef struct { - bool success; - QString reason; - QString user; - QString passwd; + bool success; + QString reason; + QString user; + QString passwd; } rest_account; -int sendRequest(QString host, int port, QString req, QString & ret) { - - int s; - struct sockaddr_in servSockAddr; - struct hostent *servHostEnt; - long int length=0; - long int status=0; - int i=0; - FILE *f; - char buf[1024]; - - bzero(&servSockAddr, sizeof(servSockAddr)); - servHostEnt = gethostbyname(host.toLatin1()); - if (servHostEnt == NULL) { - ret = "gethostbyname"; - return -1; - } - bcopy((char *)servHostEnt->h_addr, (char *)&servSockAddr.sin_addr, servHostEnt->h_length); - servSockAddr.sin_port = htons(port); - servSockAddr.sin_family = AF_INET; +int sendRequest(QString host, int port, QString req, QString & ret) +{ + int s; + struct sockaddr_in servSockAddr; + struct hostent *servHostEnt; + long int length=0; + long int status=0; + int i=0; + FILE *f; + char buf[1024]; + + bzero(&servSockAddr, sizeof(servSockAddr)); + servHostEnt = gethostbyname(host.toLatin1()); + if (servHostEnt == NULL) { + ret = "gethostbyname"; + return -1; + } + bcopy((char *)servHostEnt->h_addr, (char *)&servSockAddr.sin_addr, servHostEnt->h_length); + servSockAddr.sin_port = htons(port); + servSockAddr.sin_family = AF_INET; - if ((s = socket(AF_INET,SOCK_STREAM,0)) < 0) { - ret = "socket"; - return -1; - } + if ((s = socket(AF_INET,SOCK_STREAM,0)) < 0) { + ret = "socket"; + return -1; + } - if(connect(s, (const struct sockaddr *) &servSockAddr, (socklen_t) sizeof(servSockAddr)) < 0 ) { - perror(NULL); - ret = "connect"; - return -1; - } + if(connect(s, (const struct sockaddr *) &servSockAddr, (socklen_t) sizeof(servSockAddr)) < 0 ) { + perror(NULL); + ret = "connect"; + return -1; + } - f = fdopen(s, "r+"); - - const char * req2 = req.toLatin1(); - const char * host2 = host.toLatin1(); - fprintf(f, "%s HTTP/1.1\r\n", req2); - fprintf(f, "Host: %s\r\n", host2); - fputs("User-Agent: SFLphone\r\n", f); - fputs("\r\n", f); - - while (strncmp(fgets(buf, sizeof(buf), f), "\r\n", 2)) { - const char *len_h = "content-length"; - const char *status_h = "HTTP/1.1"; - if (strncasecmp(buf, len_h, strlen(len_h)) == 0) - length = atoi(buf + strlen(len_h) + 1); - if (strncasecmp(buf, status_h, strlen(status_h)) == 0) - status = atoi(buf + strlen(status_h) + 1); - } - for (i = 0; i < length; i++) - ret[i] = fgetc(f); - - if (status != 200) { - ret = "http error: " + status; -// sprintf(ret, "http error: %ld", status); - return -1; - } - - fclose(f); - shutdown(s, 2); - close(s); - return 0; + f = fdopen(s, "r+"); + + const char * req2 = req.toLatin1(); + const char * host2 = host.toLatin1(); + fprintf(f, "%s HTTP/1.1\r\n", req2); + fprintf(f, "Host: %s\r\n", host2); + fputs("User-Agent: SFLphone\r\n", f); + fputs("\r\n", f); + + while (strncmp(fgets(buf, sizeof(buf), f), "\r\n", 2)) { + const char *len_h = "content-length"; + const char *status_h = "HTTP/1.1"; + if (strncasecmp(buf, len_h, strlen(len_h)) == 0) + length = atoi(buf + strlen(len_h) + 1); + if (strncasecmp(buf, status_h, strlen(status_h)) == 0) + status = atoi(buf + strlen(status_h) + 1); + } + for (i = 0; i < length; i++) + ret[i] = fgetc(f); + + if (status != 200) { + ret = "http error: " + status; +// sprintf(ret, "http error: %ld", status); + return -1; + } + + fclose(f); + shutdown(s, 2); + close(s); + return 0; } -rest_account get_rest_account(QString host, QString email) { - QString req = "GET /rest/accountcreator?email=" + email; - QString ret; - rest_account ra; - qDebug() << "HOST: " << host; - int res = sendRequest(host, 80, req, ret); - if (res != -1) { - QStringList list = ret.split("\n"); - ra.user = list[0]; - ra.passwd = list[1];\ - ra.success = true; - } else { - ra.success = false; - ra.reason = ret; - } - qDebug() << ret; - return ra; +rest_account get_rest_account(QString host, QString email) +{ + QString req = "GET /rest/accountcreator?email=" + email; + QString ret; + rest_account ra; + qDebug() << "HOST: " << host; + int res = sendRequest(host, 80, req, ret); + if (res != -1) { + QStringList list = ret.split("\n"); + ra.user = list[0]; + ra.passwd = list[1];\ + ra.success = true; + } else { + ra.success = false; + ra.reason = ret; + } + qDebug() << ret; + return ra; } /*************************************************************************** @@ -158,21 +159,21 @@ rest_account get_rest_account(QString host, QString email) { AccountWizard::AccountWizard(QWidget * parent) : QWizard(parent) { - setPage(Page_Intro, new WizardIntroPage); - setPage(Page_AutoMan, new WizardAccountAutoManualPage); - setPage(Page_Type, new WizardAccountTypePage); - setPage(Page_Email, new WizardAccountEmailAddressPage); - setPage(Page_SIPForm, new WizardAccountSIPFormPage); - setPage(Page_IAXForm, new WizardAccountIAXFormPage); - setPage(Page_Stun, new WizardAccountStunPage); - setPage(Page_Conclusion, new WizardAccountConclusionPage); - - setStartId(Page_Intro); - setWindowTitle(i18n("Account creation wizard")); - setWindowIcon(QIcon(ICON_SFLPHONE)); - setMinimumHeight(350); + setPage(Page_Intro, new WizardIntroPage); + setPage(Page_AutoMan, new WizardAccountAutoManualPage); + setPage(Page_Type, new WizardAccountTypePage); + setPage(Page_Email, new WizardAccountEmailAddressPage); + setPage(Page_SIPForm, new WizardAccountSIPFormPage); + setPage(Page_IAXForm, new WizardAccountIAXFormPage); + setPage(Page_Stun, new WizardAccountStunPage); + setPage(Page_Conclusion, new WizardAccountConclusionPage); + + setStartId(Page_Intro); + setWindowTitle(i18n("Account creation wizard")); + setWindowIcon(QIcon(ICON_SFLPHONE)); + setMinimumHeight(350); setMinimumWidth(500); - setPixmap(QWizard::WatermarkPixmap, QPixmap(ICON_SFLPHONE)); + setPixmap(QWizard::WatermarkPixmap, QPixmap(ICON_SFLPHONE)); } @@ -182,148 +183,138 @@ AccountWizard::~AccountWizard() void AccountWizard::accept() { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - - QString ret; - MapStringString accountDetails; - - QString & alias = accountDetails[QString(ACCOUNT_ALIAS)]; - QString & enabled = accountDetails[QString(ACCOUNT_ENABLED)]; - QString & mailbox = accountDetails[QString(ACCOUNT_MAILBOX)]; - QString & protocol = accountDetails[QString(ACCOUNT_TYPE)]; - QString & server = accountDetails[QString(ACCOUNT_HOSTNAME)]; - QString & user = accountDetails[QString(ACCOUNT_USERNAME)]; - QString & password = accountDetails[QString(ACCOUNT_PASSWORD)]; - - // sip only parameters - QString & stun_enabled = accountDetails[QString(ACCOUNT_SIP_STUN_ENABLED)]; - QString & stun_server = accountDetails[QString(ACCOUNT_SIP_STUN_SERVER)]; - - // zrtp only parameters - QString & srtp_enabled = accountDetails[QString(ACCOUNT_SRTP_ENABLED)]; - QString & key_exchange = accountDetails[QString(ACCOUNT_KEY_EXCHANGE)]; - QString & zrtp_display_sas = accountDetails[QString(ACCOUNT_ZRTP_DISPLAY_SAS)]; - QString & zrtp_not_supp_warning = accountDetails[QString(ACCOUNT_ZRTP_NOT_SUPP_WARNING)]; - QString & zrtp_hello_hash = accountDetails[QString(ACCOUNT_ZRTP_HELLO_HASH)]; - QString & display_sas_once = accountDetails[QString(ACCOUNT_DISPLAY_SAS_ONCE)]; - - // interface paramters - QString & locale_interface = accountDetails[QString(LOCAL_INTERFACE)]; - QString & published_address = accountDetails[QString(PUBLISHED_ADDRESS)]; - - bool is_using_sflphone_org = field(FIELD_SFL_ACCOUNT).toBool(); - bool is_using_sip = false; - bool is_create_account = false; - - // sflphone.org - if(is_using_sflphone_org) - { - QString emailAddress = field(FIELD_EMAIL_ADDRESS).toString(); - char charEmailAddress[1024]; - strncpy(charEmailAddress, emailAddress.toLatin1(), sizeof(charEmailAddress) - 1); - rest_account acc = get_rest_account(SFL_ACCOUNT_HOST, charEmailAddress); - - if(acc.success) - { - ret += i18n("This assistant is now finished.") + "\n"; - field(FIELD_SIP_ALIAS) = QString(acc.user) + "@" + SFL_ACCOUNT_HOST; - field(FIELD_SIP_VOICEMAIL) = QString(); - field(FIELD_SIP_SERVER) = QString(SFL_ACCOUNT_HOST); - field(FIELD_SIP_PASSWORD) = QString(acc.passwd); - field(FIELD_SIP_USER) = QString(acc.user); - - protocol = QString(ACCOUNT_TYPE_SIP); - server = QString(SFL_ACCOUNT_HOST); - password = QString(acc.passwd); - user = QString(acc.user); - enabled = QString(ACCOUNT_ENABLED_TRUE); - - is_create_account = true; - is_using_sip = true; - } - else - { - ret += i18n("Creation of account has failed for the reason") + " :\n"; - ret += acc.reason; - } - } - else if(field(FIELD_SIP_ACCOUNT).toBool()) //sip - { - ret += i18n("This assistant is now finished.") + "\n"; - - alias = field(FIELD_SIP_ALIAS).toString(); - enabled = QString(ACCOUNT_ENABLED_TRUE); - mailbox = field(FIELD_SIP_VOICEMAIL).toString(); - protocol = QString(ACCOUNT_TYPE_SIP); - server = field(FIELD_SIP_SERVER).toString(); - password = field(FIELD_SIP_PASSWORD).toString(); - user = field(FIELD_SIP_USER).toString(); - - is_create_account = true; - is_using_sip = true; - - } - else // iax - { - ret += i18n("This assistant is now finished.") + "\n"; - - alias = field(FIELD_IAX_ALIAS).toString(); - enabled = QString(ACCOUNT_ENABLED_TRUE); - mailbox = field(FIELD_IAX_VOICEMAIL).toString(); - protocol = QString(ACCOUNT_TYPE_IAX); - server = field(FIELD_IAX_SERVER).toString(); - password = field(FIELD_IAX_PASSWORD).toString(); - user = field(FIELD_IAX_USER).toString(); - - is_create_account = true; - is_using_sip = false; - } - - - // common sip paramaters - if(is_using_sip) - { - if(field(FIELD_SIP_ENABLE_STUN).toBool()) - { - stun_enabled = QString(ACCOUNT_ENABLED_TRUE); - stun_server = field(FIELD_SIP_STUN_SERVER).toString(); - } - else - { - stun_enabled = QString(ACCOUNT_ENABLED_FALSE); - stun_server = QString(); - } - - if(field(FIELD_ZRTP_ENABLED).toBool()) - { - srtp_enabled = QString(ACCOUNT_ENABLED_TRUE); - key_exchange = QString(ZRTP); - zrtp_display_sas = QString(ACCOUNT_ENABLED_TRUE); - zrtp_not_supp_warning = QString(ACCOUNT_ENABLED_TRUE); - zrtp_hello_hash = QString(ACCOUNT_ENABLED_TRUE); - display_sas_once = QString(ACCOUNT_ENABLED_FALSE); - } - - QStringList ifaceList = configurationManager.getAllIpInterface(); - - locale_interface = ifaceList.at(0); - published_address = ifaceList.at(0); - - ret += i18n("Alias") + " : " + alias + "\n"; - ret += i18n("Server") + " : " + server + "\n"; - ret += i18n("Username") + " : " + user + "\n"; - ret += i18n("Password") + " : " + password + "\n"; - ret += i18n("Protocol") + " : " + protocol + "\n"; - ret += i18n("Voicemail number") + " : " + mailbox + "\n"; - } - - if(is_create_account) - { - QString accountId = configurationManager.addAccount(accountDetails); - } - qDebug() << ret; - QDialog::accept(); - restart(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + + QString ret; + MapStringString accountDetails; + + QString & alias = accountDetails[QString(ACCOUNT_ALIAS)]; + QString & enabled = accountDetails[QString(ACCOUNT_ENABLED)]; + QString & mailbox = accountDetails[QString(ACCOUNT_MAILBOX)]; + QString & protocol = accountDetails[QString(ACCOUNT_TYPE)]; + QString & server = accountDetails[QString(ACCOUNT_HOSTNAME)]; + QString & user = accountDetails[QString(ACCOUNT_USERNAME)]; + QString & password = accountDetails[QString(ACCOUNT_PASSWORD)]; + + // sip only parameters + QString & stun_enabled = accountDetails[QString(ACCOUNT_SIP_STUN_ENABLED)]; + QString & stun_server = accountDetails[QString(ACCOUNT_SIP_STUN_SERVER)]; + + // zrtp only parameters + QString & srtp_enabled = accountDetails[QString(ACCOUNT_SRTP_ENABLED)]; + QString & key_exchange = accountDetails[QString(ACCOUNT_KEY_EXCHANGE)]; + QString & zrtp_display_sas = accountDetails[QString(ACCOUNT_ZRTP_DISPLAY_SAS)]; + QString & zrtp_not_supp_warning = accountDetails[QString(ACCOUNT_ZRTP_NOT_SUPP_WARNING)]; + QString & zrtp_hello_hash = accountDetails[QString(ACCOUNT_ZRTP_HELLO_HASH)]; + QString & display_sas_once = accountDetails[QString(ACCOUNT_DISPLAY_SAS_ONCE)]; + + // interface paramters + QString & locale_interface = accountDetails[QString(LOCAL_INTERFACE)]; + QString & published_address = accountDetails[QString(PUBLISHED_ADDRESS)]; + + bool is_using_sflphone_org = field(FIELD_SFL_ACCOUNT).toBool(); + bool is_using_sip = false; + bool is_create_account = false; + + // sflphone.org + if(is_using_sflphone_org) { + QString emailAddress = field(FIELD_EMAIL_ADDRESS).toString(); + char charEmailAddress[1024]; + strncpy(charEmailAddress, emailAddress.toLatin1(), sizeof(charEmailAddress) - 1); + rest_account acc = get_rest_account(SFL_ACCOUNT_HOST, charEmailAddress); + + if(acc.success) { + ret += i18n("This assistant is now finished.") + "\n"; + field(FIELD_SIP_ALIAS) = QString(acc.user) + "@" + SFL_ACCOUNT_HOST; + field(FIELD_SIP_VOICEMAIL) = QString(); + field(FIELD_SIP_SERVER) = QString(SFL_ACCOUNT_HOST); + field(FIELD_SIP_PASSWORD) = QString(acc.passwd); + field(FIELD_SIP_USER) = QString(acc.user); + + protocol = QString(ACCOUNT_TYPE_SIP); + server = QString(SFL_ACCOUNT_HOST); + password = QString(acc.passwd); + user = QString(acc.user); + enabled = QString(ACCOUNT_ENABLED_TRUE); + + is_create_account = true; + is_using_sip = true; + } + else { + ret += i18n("Creation of account has failed for the reason") + " :\n"; + ret += acc.reason; + } + } + else if(field(FIELD_SIP_ACCOUNT).toBool()) { //sip + ret += i18n("This assistant is now finished.") + "\n"; + + alias = field(FIELD_SIP_ALIAS).toString(); + enabled = QString(ACCOUNT_ENABLED_TRUE); + mailbox = field(FIELD_SIP_VOICEMAIL).toString(); + protocol = QString(ACCOUNT_TYPE_SIP); + server = field(FIELD_SIP_SERVER).toString(); + password = field(FIELD_SIP_PASSWORD).toString(); + user = field(FIELD_SIP_USER).toString(); + + is_create_account = true; + is_using_sip = true; + + } + else { // iax + ret += i18n("This assistant is now finished.") + "\n"; + + alias = field(FIELD_IAX_ALIAS).toString(); + enabled = QString(ACCOUNT_ENABLED_TRUE); + mailbox = field(FIELD_IAX_VOICEMAIL).toString(); + protocol = QString(ACCOUNT_TYPE_IAX); + server = field(FIELD_IAX_SERVER).toString(); + password = field(FIELD_IAX_PASSWORD).toString(); + user = field(FIELD_IAX_USER).toString(); + + is_create_account = true; + is_using_sip = false; + } + + + // common sip paramaters + if(is_using_sip) { + if(field(FIELD_SIP_ENABLE_STUN).toBool()) { + stun_enabled = QString(ACCOUNT_ENABLED_TRUE); + stun_server = field(FIELD_SIP_STUN_SERVER).toString(); + } + else { + stun_enabled = QString(ACCOUNT_ENABLED_FALSE); + stun_server = QString(); + } + + if(field(FIELD_ZRTP_ENABLED).toBool()) { + srtp_enabled = QString(ACCOUNT_ENABLED_TRUE); + key_exchange = QString(ZRTP); + zrtp_display_sas = QString(ACCOUNT_ENABLED_TRUE); + zrtp_not_supp_warning = QString(ACCOUNT_ENABLED_TRUE); + zrtp_hello_hash = QString(ACCOUNT_ENABLED_TRUE); + display_sas_once = QString(ACCOUNT_ENABLED_FALSE); + } + + QStringList ifaceList = configurationManager.getAllIpInterface(); + + locale_interface = ifaceList.at(0); + published_address = ifaceList.at(0); + + ret += i18n("Alias") + " : " + alias + "\n"; + ret += i18n("Server") + " : " + server + "\n"; + ret += i18n("Username") + " : " + user + "\n"; + ret += i18n("Password") + " : " + password + "\n"; + ret += i18n("Protocol") + " : " + protocol + "\n"; + ret += i18n("Voicemail number") + " : " + mailbox + "\n"; + } + + if(is_create_account) { + QString accountId = configurationManager.addAccount(accountDetails); + } + qDebug() << ret; + QDialog::accept(); + restart(); } @@ -337,26 +328,26 @@ void AccountWizard::accept() WizardIntroPage::WizardIntroPage(QWidget *parent) : QWizardPage(parent) { - setTitle(i18n("Account creation wizard")); - setSubTitle(i18n("Welcome to the Account creation wizard of SFLphone!")); + setTitle(i18n("Account creation wizard")); + setSubTitle(i18n("Welcome to the Account creation wizard of SFLphone!")); - introLabel = new QLabel(i18n("This installation wizard will help you configure an account.")); - introLabel->setWordWrap(true); + introLabel = new QLabel(i18n("This installation wizard will help you configure an account.")); + introLabel->setWordWrap(true); - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(introLabel); - setLayout(layout); + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(introLabel); + setLayout(layout); } WizardIntroPage::~WizardIntroPage() { - delete introLabel; + delete introLabel; } int WizardIntroPage::nextId() const { - return AccountWizard::Page_AutoMan; + return AccountWizard::Page_AutoMan; } /*************************************************************************** @@ -368,39 +359,35 @@ int WizardIntroPage::nextId() const WizardAccountAutoManualPage::WizardAccountAutoManualPage(QWidget *parent) : QWizardPage(parent) { - setTitle(i18n("Account")); - setSubTitle(i18n("Please select one of the following options")); + setTitle(i18n("Account")); + setSubTitle(i18n("Please select one of the following options")); - radioButton_SFL = new QRadioButton(i18n("Create a free SIP/IAX2 account on sflphone.org")); - radioButton_manual = new QRadioButton(i18n("Register an existing SIP or IAX2 account")); - radioButton_SFL->setChecked(true); + radioButton_SFL = new QRadioButton(i18n("Create a free SIP/IAX2 account on sflphone.org")); + radioButton_manual = new QRadioButton(i18n("Register an existing SIP or IAX2 account")); + radioButton_SFL->setChecked(true); - registerField(FIELD_SFL_ACCOUNT, radioButton_SFL); - registerField(FIELD_OTHER_ACCOUNT, radioButton_manual); + registerField(FIELD_SFL_ACCOUNT, radioButton_SFL); + registerField(FIELD_OTHER_ACCOUNT, radioButton_manual); - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(radioButton_SFL); - layout->addWidget(radioButton_manual); - setLayout(layout); + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(radioButton_SFL); + layout->addWidget(radioButton_manual); + setLayout(layout); } WizardAccountAutoManualPage::~WizardAccountAutoManualPage() { - delete radioButton_SFL; - delete radioButton_manual; + delete radioButton_SFL; + delete radioButton_manual; } int WizardAccountAutoManualPage::nextId() const { - if(radioButton_SFL->isChecked()) - { - return AccountWizard::Page_Email; - } - else - { - return AccountWizard::Page_Type; - } + if(radioButton_SFL->isChecked()) + return AccountWizard::Page_Email; + else + return AccountWizard::Page_Type; } /*************************************************************************** @@ -411,39 +398,35 @@ int WizardAccountAutoManualPage::nextId() const WizardAccountTypePage::WizardAccountTypePage(QWidget *parent) : QWizardPage(parent) { - setTitle(i18n("VoIP Protocols")); - setSubTitle(i18n("Select an account type")); - - radioButton_SIP = new QRadioButton(i18n("SIP (Session Initiation Protocol)")); - radioButton_IAX = new QRadioButton(i18n("IAX2 (InterAsterix Exchange)")); - radioButton_SIP->setChecked(true); - - registerField(FIELD_SIP_ACCOUNT, radioButton_SIP); - registerField(FIELD_IAX_ACCOUNT, radioButton_IAX); - - QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(radioButton_SIP); - layout->addWidget(radioButton_IAX); - setLayout(layout); + setTitle(i18n("VoIP Protocols")); + setSubTitle(i18n("Select an account type")); + + radioButton_SIP = new QRadioButton(i18n("SIP (Session Initiation Protocol)")); + radioButton_IAX = new QRadioButton(i18n("IAX2 (InterAsterix Exchange)")); + radioButton_SIP->setChecked(true); + + registerField(FIELD_SIP_ACCOUNT, radioButton_SIP); + registerField(FIELD_IAX_ACCOUNT, radioButton_IAX); + + QVBoxLayout *layout = new QVBoxLayout; + layout->addWidget(radioButton_SIP); + layout->addWidget(radioButton_IAX); + setLayout(layout); } WizardAccountTypePage::~WizardAccountTypePage() { - delete radioButton_SIP; - delete radioButton_IAX; + delete radioButton_SIP; + delete radioButton_IAX; } int WizardAccountTypePage::nextId() const { - if(radioButton_SIP->isChecked()) - { - return AccountWizard::Page_SIPForm; - } - else - { - return AccountWizard::Page_IAXForm; - } + if(radioButton_SIP->isChecked()) + return AccountWizard::Page_SIPForm; + else + return AccountWizard::Page_IAXForm; } /*************************************************************************** @@ -454,39 +437,39 @@ int WizardAccountTypePage::nextId() const WizardAccountEmailAddressPage::WizardAccountEmailAddressPage(QWidget *parent) : QWizardPage(parent) { - setTitle(i18n("Optional email address")); - setSubTitle(i18n("This email address will be used to send your voicemail messages.")); + setTitle(i18n("Optional email address")); + setSubTitle(i18n("This email address will be used to send your voicemail messages.")); - label_emailAddress = new QLabel(i18n("Email address")); - lineEdit_emailAddress = new QLineEdit(); - label_enableZrtp = new QLabel(i18n("Secure with ZRTP")); - checkBox_enableZrtp = new QCheckBox(); - - registerField(FIELD_EMAIL_ADDRESS, lineEdit_emailAddress); - registerField(FIELD_ZRTP_ENABLED, checkBox_enableZrtp); + label_emailAddress = new QLabel(i18n("Email address")); + lineEdit_emailAddress = new QLineEdit(); + label_enableZrtp = new QLabel(i18n("Secure with ZRTP")); + checkBox_enableZrtp = new QCheckBox(); + + registerField(FIELD_EMAIL_ADDRESS, lineEdit_emailAddress); + registerField(FIELD_ZRTP_ENABLED, checkBox_enableZrtp); - QFormLayout *layout = new QFormLayout; + QFormLayout *layout = new QFormLayout; - layout->setWidget(0, QFormLayout::LabelRole, label_emailAddress); - layout->setWidget(0, QFormLayout::FieldRole, lineEdit_emailAddress); - layout->setWidget(1, QFormLayout::LabelRole, label_enableZrtp); - layout->setWidget(1, QFormLayout::FieldRole, checkBox_enableZrtp); + layout->setWidget(0, QFormLayout::LabelRole, label_emailAddress); + layout->setWidget(0, QFormLayout::FieldRole, lineEdit_emailAddress); + layout->setWidget(1, QFormLayout::LabelRole, label_enableZrtp); + layout->setWidget(1, QFormLayout::FieldRole, checkBox_enableZrtp); - setLayout(layout); + setLayout(layout); } WizardAccountEmailAddressPage::~WizardAccountEmailAddressPage() { - delete label_emailAddress; - delete lineEdit_emailAddress; - delete label_enableZrtp; - delete checkBox_enableZrtp; + delete label_emailAddress; + delete lineEdit_emailAddress; + delete label_enableZrtp; + delete checkBox_enableZrtp; } int WizardAccountEmailAddressPage::nextId() const { - return AccountWizard::Page_Stun; + return AccountWizard::Page_Stun; } /*************************************************************************** @@ -497,71 +480,71 @@ int WizardAccountEmailAddressPage::nextId() const WizardAccountSIPFormPage::WizardAccountSIPFormPage(QWidget *parent) : QWizardPage(parent) { - setTitle(i18n("SIP account settings")); - setSubTitle(i18n("Please fill the following information")); - - label_alias = new QLabel(i18n("Alias") + " *"); - label_server = new QLabel(i18n("Server") + " *"); - label_user = new QLabel(i18n("Username") + " *"); - label_password = new QLabel(i18n("Password") + " *"); - label_voicemail = new QLabel(i18n("Voicemail number")); - label_enableZrtp = new QLabel(i18n("Secure with ZRTP")); - - lineEdit_alias = new QLineEdit; - lineEdit_server = new QLineEdit; - lineEdit_user = new QLineEdit; - lineEdit_password = new QLineEdit; - lineEdit_voicemail = new QLineEdit; - checkBox_enableZrtp = new QCheckBox; - - lineEdit_password->setEchoMode(QLineEdit::Password); - - registerField(QString(FIELD_SIP_ALIAS) + "*", lineEdit_alias); - registerField(QString(FIELD_SIP_SERVER) + "*", lineEdit_server); - registerField(QString(FIELD_SIP_USER) + "*", lineEdit_user); - registerField(QString(FIELD_SIP_PASSWORD) + "*", lineEdit_password); - registerField(QString(FIELD_SIP_VOICEMAIL), lineEdit_voicemail); - registerField(QString(FIELD_ZRTP_ENABLED), checkBox_enableZrtp); - - QFormLayout *layout = new QFormLayout; - - - layout->setWidget(0, QFormLayout::LabelRole, label_alias); - layout->setWidget(0, QFormLayout::FieldRole, lineEdit_alias); - layout->setWidget(1, QFormLayout::LabelRole, label_server); - layout->setWidget(1, QFormLayout::FieldRole, lineEdit_server); - layout->setWidget(2, QFormLayout::LabelRole, label_user); - layout->setWidget(2, QFormLayout::FieldRole, lineEdit_user); - layout->setWidget(3, QFormLayout::LabelRole, label_password); - layout->setWidget(3, QFormLayout::FieldRole, lineEdit_password); - layout->setWidget(4, QFormLayout::LabelRole, label_voicemail); - layout->setWidget(4, QFormLayout::FieldRole, lineEdit_voicemail); - layout->setWidget(5, QFormLayout::LabelRole, label_enableZrtp); - layout->setWidget(5, QFormLayout::FieldRole, checkBox_enableZrtp); - - setLayout(layout); + setTitle(i18n("SIP account settings")); + setSubTitle(i18n("Please fill the following information")); + + label_alias = new QLabel(i18n("Alias") + " *"); + label_server = new QLabel(i18n("Server") + " *"); + label_user = new QLabel(i18n("Username") + " *"); + label_password = new QLabel(i18n("Password") + " *"); + label_voicemail = new QLabel(i18n("Voicemail number")); + label_enableZrtp = new QLabel(i18n("Secure with ZRTP")); + + lineEdit_alias = new QLineEdit; + lineEdit_server = new QLineEdit; + lineEdit_user = new QLineEdit; + lineEdit_password = new QLineEdit; + lineEdit_voicemail = new QLineEdit; + checkBox_enableZrtp = new QCheckBox; + + lineEdit_password->setEchoMode(QLineEdit::Password); + + registerField(QString(FIELD_SIP_ALIAS) + "*", lineEdit_alias); + registerField(QString(FIELD_SIP_SERVER) + "*", lineEdit_server); + registerField(QString(FIELD_SIP_USER) + "*", lineEdit_user); + registerField(QString(FIELD_SIP_PASSWORD) + "*", lineEdit_password); + registerField(QString(FIELD_SIP_VOICEMAIL), lineEdit_voicemail); + registerField(QString(FIELD_ZRTP_ENABLED), checkBox_enableZrtp); + + QFormLayout *layout = new QFormLayout; + + + layout->setWidget(0, QFormLayout::LabelRole, label_alias); + layout->setWidget(0, QFormLayout::FieldRole, lineEdit_alias); + layout->setWidget(1, QFormLayout::LabelRole, label_server); + layout->setWidget(1, QFormLayout::FieldRole, lineEdit_server); + layout->setWidget(2, QFormLayout::LabelRole, label_user); + layout->setWidget(2, QFormLayout::FieldRole, lineEdit_user); + layout->setWidget(3, QFormLayout::LabelRole, label_password); + layout->setWidget(3, QFormLayout::FieldRole, lineEdit_password); + layout->setWidget(4, QFormLayout::LabelRole, label_voicemail); + layout->setWidget(4, QFormLayout::FieldRole, lineEdit_voicemail); + layout->setWidget(5, QFormLayout::LabelRole, label_enableZrtp); + layout->setWidget(5, QFormLayout::FieldRole, checkBox_enableZrtp); + + setLayout(layout); } WizardAccountSIPFormPage::~WizardAccountSIPFormPage() { - delete label_alias; - delete label_server; - delete label_user; - delete label_password; - delete label_voicemail; - delete label_enableZrtp; - delete lineEdit_alias; - delete lineEdit_server; - delete lineEdit_user; - delete lineEdit_password; - delete lineEdit_voicemail; - delete checkBox_enableZrtp; + delete label_alias; + delete label_server; + delete label_user; + delete label_password; + delete label_voicemail; + delete label_enableZrtp; + delete lineEdit_alias; + delete lineEdit_server; + delete lineEdit_user; + delete lineEdit_password; + delete lineEdit_voicemail; + delete checkBox_enableZrtp; } int WizardAccountSIPFormPage::nextId() const { - return AccountWizard::Page_Stun; + return AccountWizard::Page_Stun; } /*************************************************************************** @@ -572,63 +555,63 @@ int WizardAccountSIPFormPage::nextId() const WizardAccountIAXFormPage::WizardAccountIAXFormPage(QWidget *parent) : QWizardPage(parent) { - setTitle(i18n("IAX2 account settings")); - setSubTitle(i18n("Please fill the following information")); - - label_alias = new QLabel(i18n("Alias") + " *"); - label_server = new QLabel(i18n("Server") + " *"); - label_user = new QLabel(i18n("Username") + " *"); - label_password = new QLabel(i18n("Password") + " *"); - label_voicemail = new QLabel(i18n("Voicemail number")); - - lineEdit_alias = new QLineEdit; - lineEdit_server = new QLineEdit; - lineEdit_user = new QLineEdit; - lineEdit_password = new QLineEdit; - lineEdit_voicemail = new QLineEdit; - - lineEdit_password->setEchoMode(QLineEdit::Password); - - registerField(QString(FIELD_IAX_ALIAS) + "*", lineEdit_alias); - registerField(QString(FIELD_IAX_SERVER) + "*", lineEdit_server); - registerField(QString(FIELD_IAX_USER) + "*", lineEdit_user); - registerField(QString(FIELD_IAX_PASSWORD) + "*", lineEdit_password); - registerField(QString(FIELD_IAX_VOICEMAIL), lineEdit_voicemail); - - QFormLayout *layout = new QFormLayout; - - layout->setWidget(0, QFormLayout::LabelRole, label_alias); - layout->setWidget(0, QFormLayout::FieldRole, lineEdit_alias); - layout->setWidget(1, QFormLayout::LabelRole, label_server); - layout->setWidget(1, QFormLayout::FieldRole, lineEdit_server); - layout->setWidget(2, QFormLayout::LabelRole, label_user); - layout->setWidget(2, QFormLayout::FieldRole, lineEdit_user); - layout->setWidget(3, QFormLayout::LabelRole, label_password); - layout->setWidget(3, QFormLayout::FieldRole, lineEdit_password); - layout->setWidget(4, QFormLayout::LabelRole, label_voicemail); - layout->setWidget(4, QFormLayout::FieldRole, lineEdit_voicemail); - - setLayout(layout); + setTitle(i18n("IAX2 account settings")); + setSubTitle(i18n("Please fill the following information")); + + label_alias = new QLabel(i18n("Alias") + " *"); + label_server = new QLabel(i18n("Server") + " *"); + label_user = new QLabel(i18n("Username") + " *"); + label_password = new QLabel(i18n("Password") + " *"); + label_voicemail = new QLabel(i18n("Voicemail number")); + + lineEdit_alias = new QLineEdit; + lineEdit_server = new QLineEdit; + lineEdit_user = new QLineEdit; + lineEdit_password = new QLineEdit; + lineEdit_voicemail = new QLineEdit; + + lineEdit_password->setEchoMode(QLineEdit::Password); + + registerField(QString(FIELD_IAX_ALIAS) + "*", lineEdit_alias); + registerField(QString(FIELD_IAX_SERVER) + "*", lineEdit_server); + registerField(QString(FIELD_IAX_USER) + "*", lineEdit_user); + registerField(QString(FIELD_IAX_PASSWORD) + "*", lineEdit_password); + registerField(QString(FIELD_IAX_VOICEMAIL), lineEdit_voicemail); + + QFormLayout *layout = new QFormLayout; + + layout->setWidget(0, QFormLayout::LabelRole, label_alias); + layout->setWidget(0, QFormLayout::FieldRole, lineEdit_alias); + layout->setWidget(1, QFormLayout::LabelRole, label_server); + layout->setWidget(1, QFormLayout::FieldRole, lineEdit_server); + layout->setWidget(2, QFormLayout::LabelRole, label_user); + layout->setWidget(2, QFormLayout::FieldRole, lineEdit_user); + layout->setWidget(3, QFormLayout::LabelRole, label_password); + layout->setWidget(3, QFormLayout::FieldRole, lineEdit_password); + layout->setWidget(4, QFormLayout::LabelRole, label_voicemail); + layout->setWidget(4, QFormLayout::FieldRole, lineEdit_voicemail); + + setLayout(layout); } WizardAccountIAXFormPage::~WizardAccountIAXFormPage() { - delete label_alias; - delete label_server; - delete label_user; - delete label_password; - delete label_voicemail; - delete lineEdit_alias; - delete lineEdit_server; - delete lineEdit_user; - delete lineEdit_password; - delete lineEdit_voicemail; + delete label_alias; + delete label_server; + delete label_user; + delete label_password; + delete label_voicemail; + delete lineEdit_alias; + delete lineEdit_server; + delete lineEdit_user; + delete lineEdit_password; + delete lineEdit_voicemail; } int WizardAccountIAXFormPage::nextId() const { - return AccountWizard::Page_Conclusion; + return AccountWizard::Page_Conclusion; } /*************************************************************************** @@ -639,22 +622,22 @@ int WizardAccountIAXFormPage::nextId() const WizardAccountStunPage::WizardAccountStunPage(QWidget *parent) : QWizardPage(parent) { - setTitle(i18n("Network Address Translation (NAT)")); - setSubTitle(i18n("You should probably enable this if you are behind a firewall.")); + setTitle(i18n("Network Address Translation (NAT)")); + setSubTitle(i18n("You should probably enable this if you are behind a firewall.")); - checkBox_enableStun = new QCheckBox(i18n("Enable STUN")); - label_StunServer = new QLabel(i18n("Stun Server")); - lineEdit_StunServer = new QLineEdit(); + checkBox_enableStun = new QCheckBox(i18n("Enable STUN")); + label_StunServer = new QLabel(i18n("Stun Server")); + lineEdit_StunServer = new QLineEdit(); lineEdit_StunServer->setDisabled(true); - - registerField(FIELD_SIP_ENABLE_STUN, checkBox_enableStun); - registerField(FIELD_SIP_STUN_SERVER, lineEdit_StunServer); - - QFormLayout *layout = new QFormLayout; - layout->addWidget(checkBox_enableStun); - layout->addWidget(label_StunServer); - layout->addWidget(lineEdit_StunServer); - setLayout(layout); + + registerField(FIELD_SIP_ENABLE_STUN, checkBox_enableStun); + registerField(FIELD_SIP_STUN_SERVER, lineEdit_StunServer); + + QFormLayout *layout = new QFormLayout; + layout->addWidget(checkBox_enableStun); + layout->addWidget(label_StunServer); + layout->addWidget(lineEdit_StunServer); + setLayout(layout); connect(checkBox_enableStun, SIGNAL(toggled(bool)), lineEdit_StunServer, SLOT(setEnabled(bool))); } @@ -662,14 +645,14 @@ WizardAccountStunPage::WizardAccountStunPage(QWidget *parent) WizardAccountStunPage::~WizardAccountStunPage() { - delete checkBox_enableStun; - delete label_StunServer; - delete lineEdit_StunServer; + delete checkBox_enableStun; + delete label_StunServer; + delete lineEdit_StunServer; } int WizardAccountStunPage::nextId() const { - return AccountWizard::Page_Conclusion; + return AccountWizard::Page_Conclusion; } /*************************************************************************** @@ -680,11 +663,11 @@ int WizardAccountStunPage::nextId() const WizardAccountConclusionPage::WizardAccountConclusionPage(QWidget *parent) : QWizardPage(parent) { - setTitle(i18n("This assistant is now finished.")); - setSubTitle(i18n("After checking the settings you chose, click \"Finish\" to create the account.")); + setTitle(i18n("This assistant is now finished.")); + setSubTitle(i18n("After checking the settings you chose, click \"Finish\" to create the account.")); - QVBoxLayout *layout = new QVBoxLayout; - setLayout(layout); + QVBoxLayout *layout = new QVBoxLayout; + setLayout(layout); } WizardAccountConclusionPage::~WizardAccountConclusionPage() @@ -693,5 +676,5 @@ WizardAccountConclusionPage::~WizardAccountConclusionPage() int WizardAccountConclusionPage::nextId() const { - return -1; + return -1; } diff --git a/sflphone-client-kde/src/AccountWizard.h b/sflphone-client-kde/src/AccountWizard.h index f01c5170ccf0590190a540b2ea4ca7d53558ba9f..e55f900a8e378d1de2fb7efba8ef6c93f4f8ebd0 100644 --- a/sflphone-client-kde/src/AccountWizard.h +++ b/sflphone-client-kde/src/AccountWizard.h @@ -29,19 +29,19 @@ /** - @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> + @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> */ class AccountWizard : public QWizard { Q_OBJECT public: - - enum { Page_Intro, Page_AutoMan, Page_Type, Page_Email, Page_SIPForm, Page_IAXForm, Page_Stun, Page_Conclusion }; - - AccountWizard(QWidget * parent = 0); - ~AccountWizard(); - void accept(); + + enum { Page_Intro, Page_AutoMan, Page_Type, Page_Email, Page_SIPForm, Page_IAXForm, Page_Stun, Page_Conclusion }; + + AccountWizard(QWidget * parent = 0); + ~AccountWizard(); + void accept(); }; @@ -52,15 +52,15 @@ public: class WizardIntroPage : public QWizardPage { - Q_OBJECT + Q_OBJECT public: - WizardIntroPage(QWidget *parent = 0); - ~WizardIntroPage(); - int nextId() const; + WizardIntroPage(QWidget *parent = 0); + ~WizardIntroPage(); + int nextId() const; private: - QLabel * introLabel; + QLabel * introLabel; }; /*************************************************************************** @@ -71,16 +71,16 @@ private: class WizardAccountAutoManualPage : public QWizardPage { - Q_OBJECT + Q_OBJECT public: - WizardAccountAutoManualPage(QWidget *parent = 0); - ~WizardAccountAutoManualPage(); - int nextId() const; + WizardAccountAutoManualPage(QWidget *parent = 0); + ~WizardAccountAutoManualPage(); + int nextId() const; private: - QRadioButton * radioButton_SFL; - QRadioButton * radioButton_manual; + QRadioButton * radioButton_SFL; + QRadioButton * radioButton_manual; }; /*************************************************************************** @@ -90,16 +90,16 @@ private: class WizardAccountTypePage : public QWizardPage { - Q_OBJECT + Q_OBJECT public: - WizardAccountTypePage(QWidget *parent = 0); - ~WizardAccountTypePage(); - int nextId() const; + WizardAccountTypePage(QWidget *parent = 0); + ~WizardAccountTypePage(); + int nextId() const; private: - QRadioButton * radioButton_SIP; - QRadioButton * radioButton_IAX; + QRadioButton * radioButton_SIP; + QRadioButton * radioButton_IAX; }; /*************************************************************************** @@ -109,18 +109,18 @@ private: class WizardAccountEmailAddressPage : public QWizardPage { - Q_OBJECT + Q_OBJECT public: - WizardAccountEmailAddressPage(QWidget *parent = 0); - ~WizardAccountEmailAddressPage(); - int nextId() const; + WizardAccountEmailAddressPage(QWidget *parent = 0); + ~WizardAccountEmailAddressPage(); + int nextId() const; private: - QLabel * label_emailAddress; - QLineEdit * lineEdit_emailAddress; - QLabel * label_enableZrtp; - QCheckBox * checkBox_enableZrtp; + QLabel * label_emailAddress; + QLineEdit * lineEdit_emailAddress; + QLabel * label_enableZrtp; + QCheckBox * checkBox_enableZrtp; }; /*************************************************************************** @@ -130,30 +130,30 @@ private: class WizardAccountSIPFormPage : public QWizardPage { - Q_OBJECT + Q_OBJECT public: - - WizardAccountSIPFormPage(QWidget *parent = 0); - ~WizardAccountSIPFormPage(); - int nextId() const; + + WizardAccountSIPFormPage(QWidget *parent = 0); + ~WizardAccountSIPFormPage(); + int nextId() const; private: - int type; - - QLabel * label_alias; - QLabel * label_server; - QLabel * label_user; - QLabel * label_password; - QLabel * label_voicemail; - QLabel * label_enableZrtp; - - QLineEdit * lineEdit_alias; - QLineEdit * lineEdit_server; - QLineEdit * lineEdit_user; - QLineEdit * lineEdit_password; - QLineEdit * lineEdit_voicemail; - QCheckBox * checkBox_enableZrtp; + int type; + + QLabel * label_alias; + QLabel * label_server; + QLabel * label_user; + QLabel * label_password; + QLabel * label_voicemail; + QLabel * label_enableZrtp; + + QLineEdit * lineEdit_alias; + QLineEdit * lineEdit_server; + QLineEdit * lineEdit_user; + QLineEdit * lineEdit_password; + QLineEdit * lineEdit_voicemail; + QCheckBox * checkBox_enableZrtp; }; /*************************************************************************** @@ -163,28 +163,28 @@ private: class WizardAccountIAXFormPage : public QWizardPage { - Q_OBJECT + Q_OBJECT public: - - WizardAccountIAXFormPage(QWidget *parent = 0); - ~WizardAccountIAXFormPage(); - int nextId() const; + + WizardAccountIAXFormPage(QWidget *parent = 0); + ~WizardAccountIAXFormPage(); + int nextId() const; private: - int type; - - QLabel * label_alias; - QLabel * label_server; - QLabel * label_user; - QLabel * label_password; - QLabel * label_voicemail; - - QLineEdit * lineEdit_alias; - QLineEdit * lineEdit_server; - QLineEdit * lineEdit_user; - QLineEdit * lineEdit_password; - QLineEdit * lineEdit_voicemail; + int type; + + QLabel * label_alias; + QLabel * label_server; + QLabel * label_user; + QLabel * label_password; + QLabel * label_voicemail; + + QLineEdit * lineEdit_alias; + QLineEdit * lineEdit_server; + QLineEdit * lineEdit_user; + QLineEdit * lineEdit_password; + QLineEdit * lineEdit_voicemail; }; /*************************************************************************** @@ -194,17 +194,17 @@ private: class WizardAccountStunPage : public QWizardPage { - Q_OBJECT + Q_OBJECT public: - WizardAccountStunPage(QWidget *parent = 0); - ~WizardAccountStunPage(); - int nextId() const; + WizardAccountStunPage(QWidget *parent = 0); + ~WizardAccountStunPage(); + int nextId() const; private: - QCheckBox * checkBox_enableStun; - QLabel * label_StunServer; - QLineEdit * lineEdit_StunServer; + QCheckBox * checkBox_enableStun; + QLabel * label_StunServer; + QLineEdit * lineEdit_StunServer; }; /*************************************************************************** @@ -214,12 +214,12 @@ private: class WizardAccountConclusionPage : public QWizardPage { - Q_OBJECT + Q_OBJECT public: - WizardAccountConclusionPage(QWidget *parent = 0); - ~WizardAccountConclusionPage(); - int nextId() const; + WizardAccountConclusionPage(QWidget *parent = 0); + ~WizardAccountConclusionPage(); + int nextId() const; private: }; diff --git a/sflphone-client-kde/src/ActionSetAccountFirst.cpp b/sflphone-client-kde/src/ActionSetAccountFirst.cpp index 3033af2e2f65cd50cc311f5212cb33b5c8732af3..6041b665163e76b3bb0b9c0710e347f4c17be324 100644 --- a/sflphone-client-kde/src/ActionSetAccountFirst.cpp +++ b/sflphone-client-kde/src/ActionSetAccountFirst.cpp @@ -25,10 +25,10 @@ ActionSetAccountFirst::ActionSetAccountFirst(Account * account, QObject *parent) : QAction((account == NULL) ? i18n("Default account") : account->getAlias(), parent) { - setCheckable(true); - this->account = account; - connect(this, SIGNAL(triggered()), - this, SLOT(emitSetFirst())); + setCheckable(true); + this->account = account; + connect(this, SIGNAL(triggered()), + this, SLOT(emitSetFirst())); } @@ -38,5 +38,5 @@ ActionSetAccountFirst::~ActionSetAccountFirst() void ActionSetAccountFirst::emitSetFirst() { - emit setFirst(account); + emit setFirst(account); } diff --git a/sflphone-client-kde/src/ActionSetAccountFirst.h b/sflphone-client-kde/src/ActionSetAccountFirst.h index 4e832e0ae45288fa9399da38884c6d0118822246..f562739db7102c566979604aa930df19fe30f4b9 100644 --- a/sflphone-client-kde/src/ActionSetAccountFirst.h +++ b/sflphone-client-kde/src/ActionSetAccountFirst.h @@ -27,26 +27,26 @@ #include "Account.h" /** - @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> + @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> */ class ActionSetAccountFirst : public QAction { Q_OBJECT private: - - Account * account; + + Account * account; public: - ActionSetAccountFirst(Account * account, QObject *parent = 0); - ~ActionSetAccountFirst(); + ActionSetAccountFirst(Account * account, QObject *parent = 0); + ~ActionSetAccountFirst(); private slots: - void emitSetFirst(); - + void emitSetFirst(); + signals: - void setFirst(Account * account); + void setFirst(Account * account); }; diff --git a/sflphone-client-kde/src/Call.cpp b/sflphone-client-kde/src/Call.cpp index a93eb912f52a70225b74a0e09da928ad324174c2..3f40797bfb0ecde90a10b25ae83e27eaf180b10f 100644 --- a/sflphone-client-kde/src/Call.cpp +++ b/sflphone-client-kde/src/Call.cpp @@ -100,432 +100,376 @@ const char * Call::historyIcons[3] = {ICON_HISTORY_INCOMING, ICON_HISTORY_OUTGOI /*void Call::initCallItemWidget() { - itemWidget = new QWidget(); - labelIcon = new QLabel(); - labelCallNumber = new QLabel(peerPhoneNumber); - labelTransferPrefix = new QLabel(i18n("Transfer to : ")); - labelTransferNumber = new QLabel(); - QSpacerItem * horizontalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Preferred, QSizePolicy::Minimum); - - QHBoxLayout * mainLayout = new QHBoxLayout(); - mainLayout->setContentsMargins ( 3, 1, 2, 1); - mainLayout->setSpacing(4); - QVBoxLayout * descr = new QVBoxLayout(); - descr->setMargin(1); - descr->setSpacing(1); - QHBoxLayout * transfer = new QHBoxLayout(); - transfer->setMargin(0); - transfer->setSpacing(0); - mainLayout->addWidget(labelIcon); - if(! peerName.isEmpty()) - { - labelPeerName = new QLabel(peerName); - descr->addWidget(labelPeerName); - } - descr->addWidget(labelCallNumber); - transfer->addWidget(labelTransferPrefix); - transfer->addWidget(labelTransferNumber); - descr->addLayout(transfer); - mainLayout->addLayout(descr); - mainLayout->addItem(horizontalSpacer); - - itemWidget->setLayout(mainLayout); + itemWidget = new QWidget(); + labelIcon = new QLabel(); + labelCallNumber = new QLabel(peerPhoneNumber); + labelTransferPrefix = new QLabel(i18n("Transfer to : ")); + labelTransferNumber = new QLabel(); + QSpacerItem * horizontalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Preferred, QSizePolicy::Minimum); + + QHBoxLayout * mainLayout = new QHBoxLayout(); + mainLayout->setContentsMargins ( 3, 1, 2, 1); + mainLayout->setSpacing(4); + QVBoxLayout * descr = new QVBoxLayout(); + descr->setMargin(1); + descr->setSpacing(1); + QHBoxLayout * transfer = new QHBoxLayout(); + transfer->setMargin(0); + transfer->setSpacing(0); + mainLayout->addWidget(labelIcon); + if(! peerName.isEmpty()) + { + labelPeerName = new QLabel(peerName); + descr->addWidget(labelPeerName); + } + descr->addWidget(labelCallNumber); + transfer->addWidget(labelTransferPrefix); + transfer->addWidget(labelTransferNumber); + descr->addLayout(transfer); + mainLayout->addLayout(descr); + mainLayout->addItem(horizontalSpacer); + + itemWidget->setLayout(mainLayout); }*/ /*void Call::setItemIcon(const QString pixmap) { - labelIcon->setPixmap(QPixmap(pixmap)); - }*/ + labelIcon->setPixmap(QPixmap(pixmap)); + }*/ Call::Call(call_state startState, QString callId, QString peerName, QString peerNumber, QString account) { - this->callId = callId; - this->peerPhoneNumber = peerNumber; - this->peerName = peerName; - changeCurrentState(startState); - this->account = account; - this->recording = false; - // this->historyItemWidget = NULL; - this->startTime = NULL; - this->stopTime = NULL; - // this->initCallItemWidget(); + this->callId = callId; + this->peerPhoneNumber = peerNumber; + this->peerName = peerName; + changeCurrentState(startState); + this->account = account; + this->recording = false; + // this->historyItemWidget = NULL; + this->startTime = NULL; + this->stopTime = NULL; + // this->initCallItemWidget(); emit changed(); } #include <unistd.h> Call * Call::buildExistingCall(QString callId) { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - MapStringString details = callManager.getCallDetails(callId).value(); - qDebug() << "Constructing existing call with details : " << details; - QString peerNumber = details[CALL_PEER_NUMBER]; - QString peerName = details[CALL_PEER_NAME]; - call_state startState = getStartStateFromDaemonCallState(details[CALL_STATE], details[CALL_TYPE]); - QString account = details[CALL_ACCOUNTID]; - Call * call = new Call(startState, callId, peerName, peerNumber, account); - call->startTime = new QDateTime(QDateTime::currentDateTime()); - call->recording = callManager.getIsRecording(callId); - call->historyState = getHistoryStateFromDaemonCallState(details[CALL_STATE], details[CALL_TYPE]); - return call; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + MapStringString details = callManager.getCallDetails(callId).value(); + qDebug() << "Constructing existing call with details : " << details; + QString peerNumber = details[CALL_PEER_NUMBER]; + QString peerName = details[CALL_PEER_NAME]; + call_state startState = getStartStateFromDaemonCallState(details[CALL_STATE], details[CALL_TYPE]); + QString account = details[CALL_ACCOUNTID]; + Call * call = new Call(startState, callId, peerName, peerNumber, account); + call->startTime = new QDateTime(QDateTime::currentDateTime()); + call->recording = callManager.getIsRecording(callId); + call->historyState = getHistoryStateFromDaemonCallState(details[CALL_STATE], details[CALL_TYPE]); + return call; } Call::~Call() { - delete startTime; - delete stopTime; + delete startTime; + delete stopTime; } - + Call * Call::buildDialingCall(QString callId, const QString & peerName, QString account) { - Call * call = new Call(CALL_STATE_DIALING, callId, peerName, "", account); - call->historyState = NONE; - return call; + Call * call = new Call(CALL_STATE_DIALING, callId, peerName, "", account); + call->historyState = NONE; + return call; } Call * Call::buildIncomingCall(const QString & callId/*, const QString & from, const QString & account*/) { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - MapStringString details = callManager.getCallDetails(callId).value(); - qDebug() << "details = " << details; - QString from = details[CALL_PEER_NUMBER]; - QString account = details[CALL_ACCOUNTID]; - QString peerName = details[CALL_PEER_NAME]; - Call * call = new Call(CALL_STATE_INCOMING, callId, peerName, from, account); - call->historyState = MISSED; - return call; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + MapStringString details = callManager.getCallDetails(callId).value(); + qDebug() << "details = " << details; + QString from = details[CALL_PEER_NUMBER]; + QString account = details[CALL_ACCOUNTID]; + QString peerName = details[CALL_PEER_NAME]; + Call * call = new Call(CALL_STATE_INCOMING, callId, peerName, from, account); + call->historyState = MISSED; + return call; } Call * Call::buildRingingCall(const QString & callId) { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - MapStringString details = callManager.getCallDetails(callId).value(); - QString from = details[CALL_PEER_NUMBER]; - QString account = details[CALL_ACCOUNTID]; - QString peerName = details[CALL_PEER_NAME]; - Call * call = new Call(CALL_STATE_RINGING, callId, peerName, from, account); - call->historyState = OUTGOING; - return call; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + MapStringString details = callManager.getCallDetails(callId).value(); + QString from = details[CALL_PEER_NUMBER]; + QString account = details[CALL_ACCOUNTID]; + QString peerName = details[CALL_PEER_NAME]; + Call * call = new Call(CALL_STATE_RINGING, callId, peerName, from, account); + call->historyState = OUTGOING; + return call; } Call * Call::buildHistoryCall(const QString & callId, uint startTimeStamp, uint stopTimeStamp, QString account, QString name, QString number, QString type) { - if(name == "empty") name = ""; - Call * call = new Call(CALL_STATE_OVER, callId, name, number, account); - call->startTime = new QDateTime(QDateTime::fromTime_t(startTimeStamp)); - call->stopTime = new QDateTime(QDateTime::fromTime_t(stopTimeStamp)); - call->historyState = getHistoryStateFromType(type); - return call; + if(name == "empty") name = ""; + Call * call = new Call(CALL_STATE_OVER, callId, name, number, account); + call->startTime = new QDateTime(QDateTime::fromTime_t(startTimeStamp)); + call->stopTime = new QDateTime(QDateTime::fromTime_t(stopTimeStamp)); + call->historyState = getHistoryStateFromType(type); + return call; } history_state Call::getHistoryStateFromType(QString type) { - if(type == DAEMON_HISTORY_TYPE_MISSED) - { - return MISSED; - } - else if(type == DAEMON_HISTORY_TYPE_OUTGOING) - { - return OUTGOING; - } - else if(type == DAEMON_HISTORY_TYPE_INCOMING) - { - return INCOMING; - } - return NONE; + if(type == DAEMON_HISTORY_TYPE_MISSED) + return MISSED; + else if(type == DAEMON_HISTORY_TYPE_OUTGOING) + return OUTGOING; + else if(type == DAEMON_HISTORY_TYPE_INCOMING) + return INCOMING; + return NONE; } QString Call::getTypeFromHistoryState(history_state historyState) { - if(historyState == MISSED) - { - return DAEMON_HISTORY_TYPE_MISSED; - } - else if(historyState == OUTGOING) - { - return DAEMON_HISTORY_TYPE_OUTGOING; - } - else if(historyState == INCOMING) - { - return DAEMON_HISTORY_TYPE_INCOMING; - } - return QString(); + if(historyState == MISSED) + return DAEMON_HISTORY_TYPE_MISSED; + else if(historyState == OUTGOING) + return DAEMON_HISTORY_TYPE_OUTGOING; + else if(historyState == INCOMING) + return DAEMON_HISTORY_TYPE_INCOMING; + return QString(); } call_state Call::getStartStateFromDaemonCallState(QString daemonCallState, QString daemonCallType) { - if(daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT) - { - return CALL_STATE_CURRENT; - } - else if(daemonCallState == DAEMON_CALL_STATE_INIT_HOLD) - { - return CALL_STATE_HOLD; - } - else if(daemonCallState == DAEMON_CALL_STATE_INIT_BUSY) - { - return CALL_STATE_BUSY; - } - else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_INCOMING) - { - return CALL_STATE_INCOMING; - } - else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_OUTGOING) - { - return CALL_STATE_RINGING; - } - else if(daemonCallState == DAEMON_CALL_STATE_INIT_INCOMING) - { - return CALL_STATE_INCOMING; - } - else if(daemonCallState == DAEMON_CALL_STATE_INIT_RINGING) - { - return CALL_STATE_RINGING; - } - else - { - return CALL_STATE_FAILURE; - } + if(daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT) + return CALL_STATE_CURRENT; + else if(daemonCallState == DAEMON_CALL_STATE_INIT_HOLD) + return CALL_STATE_HOLD; + else if(daemonCallState == DAEMON_CALL_STATE_INIT_BUSY) + return CALL_STATE_BUSY; + else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_INCOMING) + { + return CALL_STATE_INCOMING; + } + else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_OUTGOING) + return CALL_STATE_RINGING; + else if(daemonCallState == DAEMON_CALL_STATE_INIT_INCOMING) + return CALL_STATE_INCOMING; + else if(daemonCallState == DAEMON_CALL_STATE_INIT_RINGING) + return CALL_STATE_RINGING; + else + return CALL_STATE_FAILURE; } history_state Call::getHistoryStateFromDaemonCallState(QString daemonCallState, QString daemonCallType) { - if((daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT || daemonCallState == DAEMON_CALL_STATE_INIT_HOLD) && daemonCallType == DAEMON_CALL_TYPE_INCOMING) - { - return INCOMING; - } - else if((daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT || daemonCallState == DAEMON_CALL_STATE_INIT_HOLD) && daemonCallType == DAEMON_CALL_TYPE_OUTGOING) - { - return OUTGOING; - } - else if(daemonCallState == DAEMON_CALL_STATE_INIT_BUSY) - { - return OUTGOING; - } - else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_INCOMING) - { - return INCOMING; - } - else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_OUTGOING) - { - return MISSED; - } - else - { - return NONE; - } + if((daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT || daemonCallState == DAEMON_CALL_STATE_INIT_HOLD) && daemonCallType == DAEMON_CALL_TYPE_INCOMING) + return INCOMING; + else if((daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT || daemonCallState == DAEMON_CALL_STATE_INIT_HOLD) && daemonCallType == DAEMON_CALL_TYPE_OUTGOING) + return OUTGOING; + else if(daemonCallState == DAEMON_CALL_STATE_INIT_BUSY) + return OUTGOING; + else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_INCOMING) + return INCOMING; + else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_OUTGOING) + return MISSED; + else + return NONE; } daemon_call_state Call::toDaemonCallState(const QString & stateName) { - if(stateName == QString(CALL_STATE_CHANGE_HUNG_UP)) - { - return DAEMON_CALL_STATE_HUNG_UP; - } - if(stateName == QString(CALL_STATE_CHANGE_RINGING)) - { - return DAEMON_CALL_STATE_RINGING; - } - if(stateName == QString(CALL_STATE_CHANGE_CURRENT)) - { - return DAEMON_CALL_STATE_CURRENT; - } - if(stateName == QString(CALL_STATE_CHANGE_UNHOLD_CURRENT)) - { - return DAEMON_CALL_STATE_CURRENT; - } - if(stateName == QString(CALL_STATE_CHANGE_UNHOLD_RECORD)) - { - return DAEMON_CALL_STATE_CURRENT; - } - if(stateName == QString(CALL_STATE_CHANGE_HOLD)) - { - return DAEMON_CALL_STATE_HOLD; - } - if(stateName == QString(CALL_STATE_CHANGE_BUSY)) - { - return DAEMON_CALL_STATE_BUSY; - } - if(stateName == QString(CALL_STATE_CHANGE_FAILURE)) - { - return DAEMON_CALL_STATE_FAILURE; - } - qDebug() << "stateChanged signal received with unknown state."; - return DAEMON_CALL_STATE_FAILURE; + if(stateName == QString(CALL_STATE_CHANGE_HUNG_UP)) + return DAEMON_CALL_STATE_HUNG_UP; + if(stateName == QString(CALL_STATE_CHANGE_RINGING)) + return DAEMON_CALL_STATE_RINGING; + if(stateName == QString(CALL_STATE_CHANGE_CURRENT)) + return DAEMON_CALL_STATE_CURRENT; + if(stateName == QString(CALL_STATE_CHANGE_UNHOLD_CURRENT)) + return DAEMON_CALL_STATE_CURRENT; + if(stateName == QString(CALL_STATE_CHANGE_UNHOLD_RECORD)) + return DAEMON_CALL_STATE_CURRENT; + if(stateName == QString(CALL_STATE_CHANGE_HOLD)) + return DAEMON_CALL_STATE_HOLD; + if(stateName == QString(CALL_STATE_CHANGE_BUSY)) + return DAEMON_CALL_STATE_BUSY; + if(stateName == QString(CALL_STATE_CHANGE_FAILURE)) + return DAEMON_CALL_STATE_FAILURE; + qDebug() << "stateChanged signal received with unknown state."; + return DAEMON_CALL_STATE_FAILURE; } Contact * Call::findContactForNumberInKAddressBook(QString number) { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - MapStringInt addressBookSettings = configurationManager.getAddressbookSettings().value(); - bool displayPhoto = addressBookSettings[ADDRESSBOOK_DISPLAY_CONTACT_PHOTO]; - AddressBook * ab = KABC::StdAddressBook::self(true); - QVector<Contact *> results = QVector<Contact *>(); - AddressBook::Iterator it; - for ( it = ab->begin(); it != ab->end(); ++it ) { - for(int i = 0 ; i < it->phoneNumbers().count() ; i++) - { - if(it->phoneNumbers().at(i) == number) - { - return new Contact( *it, it->phoneNumbers().at(i), displayPhoto ); - } - } - } - return NULL; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + MapStringInt addressBookSettings = configurationManager.getAddressbookSettings().value(); + bool displayPhoto = addressBookSettings[ADDRESSBOOK_DISPLAY_CONTACT_PHOTO]; + AddressBook * ab = KABC::StdAddressBook::self(true); + QVector<Contact *> results = QVector<Contact *>(); + AddressBook::Iterator it; + for ( it = ab->begin(); it != ab->end(); ++it ) { + for(int i = 0 ; i < it->phoneNumbers().count() ; i++) { + if(it->phoneNumbers().at(i) == number) { + return new Contact( *it, it->phoneNumbers().at(i), displayPhoto ); + } + } + } + return NULL; } /*QWidget * Call::getItemWidget() { - return itemWidget; - }*/ + return itemWidget; + }*/ QString Call::getStopTimeStamp() const { - if (stopTime == NULL) - { return QString(); } - return QString::number(stopTime->toTime_t()); + if (stopTime == NULL) + return QString(); + return QString::number(stopTime->toTime_t()); } QString Call::getStartTimeStamp() const { - if (startTime == NULL) - { return QString(); } - return QString::number(startTime->toTime_t()); + if (startTime == NULL) + return QString(); + return QString::number(startTime->toTime_t()); } QString Call::getTransferNumber() const { - return transferNumber; + return transferNumber; } void Call::setTransferNumber(QString number) { - transferNumber = number; + transferNumber = number; } QString Call::getCallNumber() const { - return callNumber; + return callNumber; } void Call::setCallNumber(QString number) { - callNumber = number; + callNumber = number; } - + /*QWidget * Call::getHistoryItemWidget() { - historyItemWidget = new QWidget(); - labelHistoryIcon = new QLabel(); - labelHistoryIcon->setPixmap(QPixmap(historyIcons[historyState])); - labelHistoryCallNumber = new QLabel(peerPhoneNumber); - if(startTime) - labelHistoryTime = new QLabel(startTime->toString(Qt::LocaleDate)); - else - labelHistoryTime = new QLabel(); - QSpacerItem * horizontalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Preferred, QSizePolicy::Minimum); - - QHBoxLayout * mainLayout = new QHBoxLayout(); - mainLayout->setContentsMargins ( 3, 1, 2, 1); - mainLayout->setSpacing(4); - QVBoxLayout * descr = new QVBoxLayout(); - descr->setMargin(1); - descr->setSpacing(1); - descr->setMargin(0); - descr->setSpacing(1); - mainLayout->addWidget(labelHistoryIcon); - if(! peerName.isEmpty()) - { - labelHistoryPeerName = new QLabel(peerName); - descr->addWidget(labelHistoryPeerName); - } - descr->addWidget(labelHistoryCallNumber); - descr->addWidget(labelHistoryTime); - mainLayout->addLayout(descr); - mainLayout->addItem(horizontalSpacer); - historyItemWidget->setLayout(mainLayout); - return historyItemWidget; - }*/ + historyItemWidget = new QWidget(); + labelHistoryIcon = new QLabel(); + labelHistoryIcon->setPixmap(QPixmap(historyIcons[historyState])); + labelHistoryCallNumber = new QLabel(peerPhoneNumber); + if(startTime) + labelHistoryTime = new QLabel(startTime->toString(Qt::LocaleDate)); + else + labelHistoryTime = new QLabel(); + QSpacerItem * horizontalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Preferred, QSizePolicy::Minimum); + + QHBoxLayout * mainLayout = new QHBoxLayout(); + mainLayout->setContentsMargins ( 3, 1, 2, 1); + mainLayout->setSpacing(4); + QVBoxLayout * descr = new QVBoxLayout(); + descr->setMargin(1); + descr->setSpacing(1); + descr->setMargin(0); + descr->setSpacing(1); + mainLayout->addWidget(labelHistoryIcon); + if(! peerName.isEmpty()) + { + labelHistoryPeerName = new QLabel(peerName); + descr->addWidget(labelHistoryPeerName); + } + descr->addWidget(labelHistoryCallNumber); + descr->addWidget(labelHistoryTime); + mainLayout->addLayout(descr); + mainLayout->addItem(horizontalSpacer); + historyItemWidget->setLayout(mainLayout); + return historyItemWidget; + }*/ call_state Call::getState() const { - return currentState; + return currentState; } history_state Call::getHistoryState() const { - return historyState; + return historyState; } bool Call::isHistory() const { - return (getState() == CALL_STATE_OVER); + return (getState() == CALL_STATE_OVER); } call_state Call::stateChanged(const QString & newStateName) { - call_state previousState = currentState; - daemon_call_state dcs = toDaemonCallState(newStateName); - //(this->*(stateChangedFunctionMap[currentState][dcs]))(); - changeCurrentState(stateChangedStateMap[currentState][dcs]); - (this->*(stateChangedFunctionMap[previousState][dcs]))(); - qDebug() << "Calling stateChanged " << newStateName << " -> " << toDaemonCallState(newStateName) << " on call with state " << previousState << ". Become " << currentState; - return currentState; + call_state previousState = currentState; + daemon_call_state dcs = toDaemonCallState(newStateName); + //(this->*(stateChangedFunctionMap[currentState][dcs]))(); + changeCurrentState(stateChangedStateMap[currentState][dcs]); + (this->*(stateChangedFunctionMap[previousState][dcs]))(); + qDebug() << "Calling stateChanged " << newStateName << " -> " << toDaemonCallState(newStateName) << " on call with state " << previousState << ". Become " << currentState; + return currentState; } call_state Call::actionPerformed(call_action action) { - call_state previousState = currentState; - //update the state - changeCurrentState(actionPerformedStateMap[previousState][action]); - //execute the action associated with this transition - (this->*(actionPerformedFunctionMap[previousState][action]))(); - qDebug() << "Calling action " << action << " on call with state " << previousState << ". Become " << currentState; - //return the new state - return currentState; + call_state previousState = currentState; + //update the state + changeCurrentState(actionPerformedStateMap[previousState][action]); + //execute the action associated with this transition + (this->*(actionPerformedFunctionMap[previousState][action]))(); + qDebug() << "Calling action " << action << " on call with state " << previousState << ". Become " << currentState; + //return the new state + return currentState; } QString Call::getCallId() const { - return callId; + return callId; } QString Call::getPeerPhoneNumber() const { - return peerPhoneNumber; + return peerPhoneNumber; } QString Call::getPeerName() const { - return peerName; + return peerName; } call_state Call::getCurrentState() const { - return currentState; + return currentState; } bool Call::getRecording() const { - return recording; + return recording; } QString Call::getAccountId() const { - return account; + return account; } /* void Call::putRecording() { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - bool daemonRecording = callManager.getIsRecording(this -> callId); - if(daemonRecording != recording) - { - callManager.setRecording(this->callId); - } + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + bool daemonRecording = callManager.getIsRecording(this -> callId); + if(daemonRecording != recording) + { + callManager.setRecording(this->callId); + } } */ @@ -541,209 +485,202 @@ void Call::nothing() void Call::accept() { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Accepting call. callId : " << callId; - callManager.accept(callId); - this->startTime = new QDateTime(QDateTime::currentDateTime()); - this->historyState = INCOMING; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + qDebug() << "Accepting call. callId : " << callId; + callManager.accept(callId); + this->startTime = new QDateTime(QDateTime::currentDateTime()); + this->historyState = INCOMING; } void Call::refuse() { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Refusing call. callId : " << callId; - callManager.refuse(callId); - this->startTime = new QDateTime(QDateTime::currentDateTime()); - this->historyState = MISSED; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + qDebug() << "Refusing call. callId : " << callId; + callManager.refuse(callId); + this->startTime = new QDateTime(QDateTime::currentDateTime()); + this->historyState = MISSED; } void Call::acceptTransf() { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Accepting call and transfering it to number : " << transferNumber << ". callId : " << callId; - callManager.accept(callId); - callManager.transfert(callId, transferNumber); -// historyState = TRANSFERED; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + qDebug() << "Accepting call and transfering it to number : " << transferNumber << ". callId : " << callId; + callManager.accept(callId); + callManager.transfert(callId, transferNumber); +// historyState = TRANSFERED; } void Call::acceptHold() { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Accepting call and holding it. callId : " << callId; - callManager.accept(callId); - callManager.hold(callId); - this->historyState = INCOMING; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + qDebug() << "Accepting call and holding it. callId : " << callId; + callManager.accept(callId); + callManager.hold(callId); + this->historyState = INCOMING; } void Call::hangUp() { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - this->stopTime = new QDateTime(QDateTime::currentDateTime()); - qDebug() << "Hanging up call. callId : " << callId; - callManager.hangUp(callId); + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + this->stopTime = new QDateTime(QDateTime::currentDateTime()); + qDebug() << "Hanging up call. callId : " << callId; + callManager.hangUp(callId); } void Call::cancel() { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Canceling call. callId : " << callId; - callManager.hangUp(callId); + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + qDebug() << "Canceling call. callId : " << callId; + callManager.hangUp(callId); } void Call::hold() { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Holding call. callId : " << callId; - callManager.hold(callId); + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + qDebug() << "Holding call. callId : " << callId; + callManager.hold(callId); } void Call::call() { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "account = " << account; - if(account.isEmpty()) - { - qDebug() << "account is not set, taking the first registered."; - this->account = SFLPhoneView::accountInUseId(); - } - if(!account.isEmpty()) - { - qDebug() << "Calling " << callNumber << " with account " << account << ". callId : " << callId; - callManager.placeCall(account, callId, callNumber); - this->account = account; - this->peerPhoneNumber = callNumber; -// Contact * contact = findContactForNumberInKAddressBook(peerPhoneNumber); -// if(contact) this->peerName = contact->getNickName(); - this->startTime = new QDateTime(QDateTime::currentDateTime()); - this->historyState = OUTGOING; - } - else - { - qDebug() << "Trying to call " << transferNumber << " with no account registered . callId : " << callId; - this->historyState = NONE; - throw "No account registered!"; - } + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + qDebug() << "account = " << account; + if(account.isEmpty()) { + qDebug() << "account is not set, taking the first registered."; + this->account = SFLPhoneView::accountInUseId(); + } + if(!account.isEmpty()) { + qDebug() << "Calling " << callNumber << " with account " << account << ". callId : " << callId; + callManager.placeCall(account, callId, callNumber); + this->account = account; + this->peerPhoneNumber = callNumber; +// Contact * contact = findContactForNumberInKAddressBook(peerPhoneNumber); +// if(contact) this->peerName = contact->getNickName(); + this->startTime = new QDateTime(QDateTime::currentDateTime()); + this->historyState = OUTGOING; + } + else { + qDebug() << "Trying to call " << transferNumber << " with no account registered . callId : " << callId; + this->historyState = NONE; + throw "No account registered!"; + } } void Call::transfer() { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Transfering call to number : " << transferNumber << ". callId : " << callId; - callManager.transfert(callId, transferNumber); - this->stopTime = new QDateTime(QDateTime::currentDateTime()); + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + qDebug() << "Transfering call to number : " << transferNumber << ". callId : " << callId; + callManager.transfert(callId, transferNumber); + this->stopTime = new QDateTime(QDateTime::currentDateTime()); } void Call::unhold() { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Unholding call. callId : " << callId; - callManager.unhold(callId); + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + qDebug() << "Unholding call. callId : " << callId; + callManager.unhold(callId); } /* void Call::switchRecord() { - qDebug() << "Switching record state for call automate. callId : " << callId; - recording = !recording; + qDebug() << "Switching record state for call automate. callId : " << callId; + recording = !recording; } */ void Call::setRecord() { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Setting record " << !recording << " for call. callId : " << callId; - callManager.setRecording(callId); - recording = !recording; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + qDebug() << "Setting record " << !recording << " for call. callId : " << callId; + callManager.setRecording(callId); + recording = !recording; } void Call::start() { - qDebug() << "Starting call. callId : " << callId; - this->startTime = new QDateTime(QDateTime::currentDateTime()); + qDebug() << "Starting call. callId : " << callId; + this->startTime = new QDateTime(QDateTime::currentDateTime()); } void Call::startStop() { - qDebug() << "Starting and stoping call. callId : " << callId; - this->startTime = new QDateTime(QDateTime::currentDateTime()); - this->stopTime = new QDateTime(QDateTime::currentDateTime()); + qDebug() << "Starting and stoping call. callId : " << callId; + this->startTime = new QDateTime(QDateTime::currentDateTime()); + this->stopTime = new QDateTime(QDateTime::currentDateTime()); } void Call::stop() { - qDebug() << "Stoping call. callId : " << callId; - this->stopTime = new QDateTime(QDateTime::currentDateTime()); + qDebug() << "Stoping call. callId : " << callId; + this->stopTime = new QDateTime(QDateTime::currentDateTime()); } void Call::startWeird() { - qDebug() << "Starting call. callId : " << callId; - this->startTime = new QDateTime(QDateTime::currentDateTime()); - qDebug() << "Warning : call " << callId << " had an unexpected transition of state at its start."; + qDebug() << "Starting call. callId : " << callId; + this->startTime = new QDateTime(QDateTime::currentDateTime()); + qDebug() << "Warning : call " << callId << " had an unexpected transition of state at its start."; } void Call::warning() { - qDebug() << "Warning : call " << callId << " had an unexpected transition of state."; + qDebug() << "Warning : call " << callId << " had an unexpected transition of state."; } void Call::appendText(QString str) { - QString * editNumber; - - switch (currentState) - { - case CALL_STATE_TRANSFER: - case CALL_STATE_TRANSF_HOLD: - editNumber = &transferNumber; - break; - case CALL_STATE_DIALING: - editNumber = &callNumber; - break; - default: - qDebug() << "Backspace on call not editable. Doing nothing."; - return; - } + QString * editNumber; + + switch (currentState) { + case CALL_STATE_TRANSFER: + case CALL_STATE_TRANSF_HOLD: + editNumber = &transferNumber; + break; + case CALL_STATE_DIALING: + editNumber = &callNumber; + break; + default: + qDebug() << "Backspace on call not editable. Doing nothing."; + return; + } - editNumber->append(str); + editNumber->append(str); - emit changed(); + emit changed(); } void Call::backspaceItemText() { - QString * editNumber; - - switch (currentState) - { - case CALL_STATE_TRANSFER: - case CALL_STATE_TRANSF_HOLD: - editNumber = &transferNumber; - break; - case CALL_STATE_DIALING: - editNumber = &callNumber; - break; - default: - qDebug() << "Backspace on call not editable. Doing nothing."; - return; - } - QString text = *editNumber; - int textSize = text.size(); - if(textSize > 0) - { - *editNumber = text.remove(textSize-1, 1); - - emit changed(); - } - else - { - changeCurrentState(CALL_STATE_OVER); - } + QString * editNumber; + + switch (currentState) { + case CALL_STATE_TRANSFER: + case CALL_STATE_TRANSF_HOLD: + editNumber = &transferNumber; + break; + case CALL_STATE_DIALING: + editNumber = &callNumber; + break; + default: + qDebug() << "Backspace on call not editable. Doing nothing."; + return; + } + QString text = *editNumber; + int textSize = text.size(); + if(textSize > 0) { + *editNumber = text.remove(textSize-1, 1); + + emit changed(); + } + else { + changeCurrentState(CALL_STATE_OVER); + } } void Call::changeCurrentState(call_state newState) { - currentState = newState; + currentState = newState; - emit changed(); + emit changed(); } \ No newline at end of file diff --git a/sflphone-client-kde/src/Call.h b/sflphone-client-kde/src/Call.h index b67f3a1dfb0f71efc64f47ca9439abe0add8cf8c..251d89f8c32d86455b9676cc04f05ec7429d6839 100644 --- a/sflphone-client-kde/src/Call.h +++ b/sflphone-client-kde/src/Call.h @@ -139,146 +139,146 @@ typedef void (Call::*function)(); **/ class Call : public QObject { - Q_OBJECT + Q_OBJECT private: - //Call attributes - - QString account; - QString callId; - QString peerPhoneNumber; - QString peerName; - history_state historyState; - QDateTime * startTime; - QDateTime * stopTime; - - /* - QWidget * historyItemWidget; - QLabel * labelHistoryIcon; - QLabel * labelHistoryPeerName; - QLabel * labelHistoryCallNumber; - QLabel * labelHistoryTime; - */ + //Call attributes + + QString account; + QString callId; + QString peerPhoneNumber; + QString peerName; + history_state historyState; + QDateTime * startTime; + QDateTime * stopTime; + + /* + QWidget * historyItemWidget; + QLabel * labelHistoryIcon; + QLabel * labelHistoryPeerName; + QLabel * labelHistoryCallNumber; + QLabel * labelHistoryTime; + */ - QString transferNumber; - QString callNumber; - - //Automate attributes - /** - * actionPerformedStateMap[orig_state][action] - * Map of the states to go to when the action action is - * performed on a call in state orig_state. - **/ - static const call_state actionPerformedStateMap [11][5]; - - /** - * actionPerformedFunctionMap[orig_state][action] - * Map of the functions to call when the action action is - * performed on a call in state orig_state. - **/ - static const function actionPerformedFunctionMap [11][5]; - - /** - * stateChangedStateMap[orig_state][daemon_new_state] - * Map of the states to go to when the daemon sends the signal - * callStateChanged with arg daemon_new_state - * on a call in state orig_state. - **/ - static const call_state stateChangedStateMap [11][6]; - - /** - * stateChangedFunctionMap[orig_state][daemon_new_state] - * Map of the functions to call when the daemon sends the signal - * callStateChanged with arg daemon_new_state - * on a call in state orig_state. - **/ - static const function stateChangedFunctionMap [11][6]; - - static const char * historyIcons[3]; - - call_state currentState; - bool recording; - - static const char * callStateIcons[11]; + QString transferNumber; + QString callNumber; + + //Automate attributes + /** + * actionPerformedStateMap[orig_state][action] + * Map of the states to go to when the action action is + * performed on a call in state orig_state. + **/ + static const call_state actionPerformedStateMap [11][5]; + + /** + * actionPerformedFunctionMap[orig_state][action] + * Map of the functions to call when the action action is + * performed on a call in state orig_state. + **/ + static const function actionPerformedFunctionMap [11][5]; + + /** + * stateChangedStateMap[orig_state][daemon_new_state] + * Map of the states to go to when the daemon sends the signal + * callStateChanged with arg daemon_new_state + * on a call in state orig_state. + **/ + static const call_state stateChangedStateMap [11][6]; + + /** + * stateChangedFunctionMap[orig_state][daemon_new_state] + * Map of the functions to call when the daemon sends the signal + * callStateChanged with arg daemon_new_state + * on a call in state orig_state. + **/ + static const function stateChangedFunctionMap [11][6]; + + static const char * historyIcons[3]; + + call_state currentState; + bool recording; + + static const char * callStateIcons[11]; - Call(call_state startState, QString callId, QString peerNumber = "", QString account = "", QString peerName = ""); - - static daemon_call_state toDaemonCallState(const QString & stateName); - - //Automate functions - // See actionPerformedFunctionMap and stateChangedFunctionMap - // to know when it is called. - void nothing(); - void accept(); - void refuse(); - void acceptTransf(); - void acceptHold(); - void hangUp(); - void cancel(); - void hold(); - void call(); - void transfer(); - void unhold(); - void switchRecord(); - void setRecord(); - void start(); - void startStop(); - void stop(); - void startWeird(); - void warning(); + Call(call_state startState, QString callId, QString peerNumber = "", QString account = "", QString peerName = ""); + + static daemon_call_state toDaemonCallState(const QString & stateName); + + //Automate functions + // See actionPerformedFunctionMap and stateChangedFunctionMap + // to know when it is called. + void nothing(); + void accept(); + void refuse(); + void acceptTransf(); + void acceptHold(); + void hangUp(); + void cancel(); + void hold(); + void call(); + void transfer(); + void unhold(); + void switchRecord(); + void setRecord(); + void start(); + void startStop(); + void stop(); + void startWeird(); + void warning(); public: - - //Constructors & Destructors - ~Call(); -// void initCallItemWidget(); - static Call * buildDialingCall(QString callId, const QString & peerName, QString account = ""); - static Call * buildIncomingCall(const QString & callId); - static Call * buildRingingCall(const QString & callId); - static Call * buildHistoryCall(const QString & callId, uint startTimeStamp, uint stopTimeStamp, QString account, QString name, QString number, QString type); - static Call * buildExistingCall(QString callId); - - static history_state getHistoryStateFromType(QString type); - static QString getTypeFromHistoryState(history_state historyState); - static call_state getStartStateFromDaemonCallState(QString daemonCallState, QString daemonCallType); - static history_state getHistoryStateFromDaemonCallState(QString daemonCallState, QString daemonCallType); - - //Getters - call_state getState() const; - QString getCallId() const; - QString getPeerPhoneNumber() const; - QString getPeerName() const; - call_state getCurrentState() const; - history_state getHistoryState() const; - bool getRecording() const; - QString getAccountId() const; - bool isHistory() const; - QString getStopTimeStamp() const; - QString getStartTimeStamp() const; + + //Constructors & Destructors + ~Call(); +// void initCallItemWidget(); + static Call * buildDialingCall(QString callId, const QString & peerName, QString account = ""); + static Call * buildIncomingCall(const QString & callId); + static Call * buildRingingCall(const QString & callId); + static Call * buildHistoryCall(const QString & callId, uint startTimeStamp, uint stopTimeStamp, QString account, QString name, QString number, QString type); + static Call * buildExistingCall(QString callId); + + static history_state getHistoryStateFromType(QString type); + static QString getTypeFromHistoryState(history_state historyState); + static call_state getStartStateFromDaemonCallState(QString daemonCallState, QString daemonCallType); + static history_state getHistoryStateFromDaemonCallState(QString daemonCallState, QString daemonCallType); + + //Getters + call_state getState() const; + QString getCallId() const; + QString getPeerPhoneNumber() const; + QString getPeerName() const; + call_state getCurrentState() const; + history_state getHistoryState() const; + bool getRecording() const; + QString getAccountId() const; + bool isHistory() const; + QString getStopTimeStamp() const; + QString getStartTimeStamp() const; - QString getTransferNumber() const; - void setTransferNumber(QString number); + QString getTransferNumber() const; + void setTransferNumber(QString number); - QString getCallNumber() const; - void setCallNumber(QString number); + QString getCallNumber() const; + void setCallNumber(QString number); - //Automate calls - call_state stateChanged(const QString & newState); - call_state actionPerformed(call_action action); - - //Setters -// void appendItemText(QString text); - void appendText(QString str); - void backspaceItemText(); -// void setItemIcon(const QString pixmap); -// void setPeerName(const QString peerName); - void changeCurrentState(call_state newState); - - //Utils - Contact * findContactForNumberInKAddressBook(QString number); + //Automate calls + call_state stateChanged(const QString & newState); + call_state actionPerformed(call_action action); + + //Setters +// void appendItemText(QString text); + void appendText(QString str); + void backspaceItemText(); +// void setItemIcon(const QString pixmap); +// void setPeerName(const QString peerName); + void changeCurrentState(call_state newState); + + //Utils + Contact * findContactForNumberInKAddressBook(QString number); signals: - void changed(); + void changed(); }; #endif diff --git a/sflphone-client-kde/src/CallList.cpp b/sflphone-client-kde/src/CallList.cpp index c8cbda195f6f52e195a42b936b56f665591d9116..417f8bcf87072cb98bea2dc9f2827c643f968535 100644 --- a/sflphone-client-kde/src/CallList.cpp +++ b/sflphone-client-kde/src/CallList.cpp @@ -28,172 +28,160 @@ CallList::CallList(QObject * parent) : QObject(parent) { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - QStringList callList = callManager.getCallList(); - qDebug() << "Call List = " << callList; - calls = new QVector<Call *>(); - for(int i = 0 ; i < callList.size() ; i++) - { - calls->append(Call::buildExistingCall(callList[i])); - } + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + QStringList callList = callManager.getCallList(); + qDebug() << "Call List = " << callList; + calls = new QVector<Call *>(); + for(int i = 0 ; i < callList.size() ; i++) { + calls->append(Call::buildExistingCall(callList[i])); + } MapStringString historyMap = configurationManager.getHistory().value(); - qDebug() << "Call History = " << historyMap; - QMapIterator<QString, QString> i(historyMap); - while (i.hasNext()) { - i.next(); - uint startTimeStamp = i.key().toUInt(); - QStringList param = i.value().split("|"); - QString type = param[0]; - QString number = param[1]; - QString name = param[2]; - uint stopTimeStamp = param[3].toUInt(); - QString account = param[4]; - calls->insert(0, Call::buildHistoryCall(generateCallId(), startTimeStamp, stopTimeStamp, account, name, number, type)); + qDebug() << "Call History = " << historyMap; + QMapIterator<QString, QString> i(historyMap); + while (i.hasNext()) { + i.next(); + uint startTimeStamp = i.key().toUInt(); + QStringList param = i.value().split("|"); + QString type = param[0]; + QString number = param[1]; + QString name = param[2]; + uint stopTimeStamp = param[3].toUInt(); + QString account = param[4]; + calls->insert(0, Call::buildHistoryCall(generateCallId(), startTimeStamp, stopTimeStamp, account, name, number, type)); } } MapStringString CallList::getHistoryMap() { - MapStringString res; - for(int i = 0 ; i < size() ; i++) - { - Call * call = (*calls)[i]; - if( - call->getState() == CALL_STATE_OVER && - call->getHistoryState() != NONE - ) - { - QString key = call->getStartTimeStamp(); - QString val = Call::getTypeFromHistoryState(call->getHistoryState()) + "|" + call->getPeerPhoneNumber() + "|" + call->getPeerName() + "|" + call->getStopTimeStamp() + "|" + call->getAccountId(); - res[key] = val; - } - } - qDebug() << res; - return res; + MapStringString res; + for(int i = 0 ; i < size() ; i++) { + Call * call = (*calls)[i]; + if(call->getState() == CALL_STATE_OVER && call->getHistoryState() != NONE ) { + QString key = call->getStartTimeStamp(); + QString val = Call::getTypeFromHistoryState(call->getHistoryState()) + "|" + call->getPeerPhoneNumber() + "|" + call->getPeerName() + "|" + call->getStopTimeStamp() + "|" + call->getAccountId(); + res[key] = val; + } + } + qDebug() << res; + return res; } CallList::~CallList() { - for(int i=0 ; i<size() ; i++) - { - delete (*calls)[i]; - } - delete calls; + for(int i=0 ; i<size() ; i++) { + delete (*calls)[i]; + } + delete calls; } /* Call * CallList::operator[](const QListWidgetItem * item) { - for(int i = 0 ; i < size() ; i++) - { - if ((*calls)[i]->getItem() == item) - { - return (*calls)[i]; - } - } - return NULL; + for(int i = 0 ; i < size() ; i++) + { + if ((*calls)[i]->getItem() == item) + { + return (*calls)[i]; + } + } + return NULL; } Call * CallList::findCallByItem(const QListWidgetItem * item) { - for(int i = 0 ; i < size() ; i++) - { - if ((*calls)[i]->getItem() == item) - { - return (*calls)[i]; - } - } - return NULL; + for(int i = 0 ; i < size() ; i++) + { + if ((*calls)[i]->getItem() == item) + { + return (*calls)[i]; + } + } + return NULL; } Call * CallList::findCallByHistoryItem(const QListWidgetItem * item) { - for(int i = 0 ; i < size() ; i++) - { - if ((*calls)[i]->getHistoryItem() == item) - { - return (*calls)[i]; - } - } - return NULL; - }*/ + for(int i = 0 ; i < size() ; i++) + { + if ((*calls)[i]->getHistoryItem() == item) + { + return (*calls)[i]; + } + } + return NULL; + }*/ Call * CallList::findCallByCallId(const QString & callId) { - for(int i = 0 ; i < size() ; i++) - { - if ((*calls)[i]->getCallId() == callId) - { - return (*calls)[i]; - } - } - return NULL; + for(int i = 0 ; i < size() ; i++) { + if ((*calls)[i]->getCallId() == callId) { + return (*calls)[i]; + } + } + return NULL; } Call * CallList::operator[](const QString & callId) { - for(int i = 0 ; i < size() ; i++) - { - if ((*calls)[i]->getCallId() == callId) - { - return (*calls)[i]; - } - } - return NULL; + for(int i = 0 ; i < size() ; i++) { + if ((*calls)[i]->getCallId() == callId) { + return (*calls)[i]; + } + } + return NULL; } Call * CallList::operator[](int ind) { - return (*calls)[ind]; + return (*calls)[ind]; } QString CallList::generateCallId() { - int id = qrand(); - QString res = QString::number(id); - return res; + int id = qrand(); + QString res = QString::number(id); + return res; } int CallList::size() { - return calls->size(); + return calls->size(); } Call * CallList::addDialingCall(const QString & peerName, QString account) { - Call * call = Call::buildDialingCall(generateCallId(), peerName, account); - calls->insert(0, call); - return call; + Call * call = Call::buildDialingCall(generateCallId(), peerName, account); + calls->insert(0, call); + return call; } Call * CallList::addIncomingCall(const QString & callId/*, const QString & from, const QString & account*/) { - Call * call = Call::buildIncomingCall(callId/*, from, account*/); - calls->insert(0, call); - return call; + Call * call = Call::buildIncomingCall(callId/*, from, account*/); + calls->insert(0, call); + return call; } Call * CallList::addRingingCall(const QString & callId) { - Call * call = Call::buildRingingCall(callId); - calls->insert(0, call); - return call; + Call * call = Call::buildRingingCall(callId); + calls->insert(0, call); + return call; } void CallList::clearHistory() { - qDebug() << "clearHistory"; - Call * call; - QMutableVectorIterator<Call *> i(*calls); - while (i.hasNext()) - { - call = i.next(); - if (call->isHistory()) - { i.remove(); } - } + qDebug() << "clearHistory"; + Call * call; + QMutableVectorIterator<Call *> i(*calls); + while (i.hasNext()) { + call = i.next(); + if (call->isHistory()) + i.remove(); + } } Call * CallList::createConversationFromCall(Call* call1, Call* call2) { diff --git a/sflphone-client-kde/src/CallList.h b/sflphone-client-kde/src/CallList.h index 1226060b65f9c449f82e5ca6c779638265e8f7ef..3886c7d2ad9a17482985fa56f658408e675b65d5 100644 --- a/sflphone-client-kde/src/CallList.h +++ b/sflphone-client-kde/src/CallList.h @@ -34,35 +34,35 @@ Q_OBJECT private: - QVector<Call *> * calls; + QVector<Call *> * calls; public: - //Constructors & Destructors - CallList(QObject * parent = 0); - ~CallList(); + //Constructors & Destructors + CallList(QObject * parent = 0); + ~CallList(); - //Getters - // Call * findCallByItem(const QListWidgetItem * item); - // Call * findCallByHistoryItem(const QListWidgetItem * item); - Call * findCallByCallId(const QString & callId); - // Call * operator[](const QListWidgetItem * item); - Call * operator[](const QString & callId); - Call * operator[](int ind); - int size(); - MapStringString getHistoryMap(); + //Getters + // Call * findCallByItem(const QListWidgetItem * item); + // Call * findCallByHistoryItem(const QListWidgetItem * item); + Call * findCallByCallId(const QString & callId); + // Call * operator[](const QListWidgetItem * item); + Call * operator[](const QString & callId); + Call * operator[](int ind); + int size(); + MapStringString getHistoryMap(); - //Setters - Call * addDialingCall(const QString & peerName = "", QString account = ""); - Call * addIncomingCall(const QString & callId/*, const QString & from, const QString & account*/); - Call * addRingingCall(const QString & callId); + //Setters + Call * addDialingCall(const QString & peerName = "", QString account = ""); + Call * addIncomingCall(const QString & callId/*, const QString & from, const QString & account*/); + Call * addRingingCall(const QString & callId); Call * createConversationFromCall(Call* call1, Call* call2); - //GSetter - QString generateCallId(); - + //GSetter + QString generateCallId(); + public slots: - void clearHistory(); + void clearHistory(); }; diff --git a/sflphone-client-kde/src/CallTreeItem.cpp b/sflphone-client-kde/src/CallTreeItem.cpp index 07370977c50645e5967909043bf75e24af246c47..6406e1aff9a6df6a9db23fe4a77558f8810f50aa 100644 --- a/sflphone-client-kde/src/CallTreeItem.cpp +++ b/sflphone-client-kde/src/CallTreeItem.cpp @@ -35,7 +35,7 @@ CallTreeItem::CallTreeItem(const QVector<QVariant> &data, CallTreeItem *parent) itemWidget(0), itemData(data) { - + } CallTreeItem::CallTreeItem(const CallTreeItem *toCopy, CallTreeItem *parent) @@ -65,9 +65,7 @@ CallTreeItem::CallTreeItem(const CallTreeItem *toCopy, CallTreeItem *parent) int CallTreeItem::childNumber() const { if (parentItem) - { return parentItem->childItems.indexOf(const_cast<CallTreeItem*>(this)); - } return 0; } @@ -83,23 +81,20 @@ CallTreeItem::CallTreeItem(const CallTreeItem *toCopy, CallTreeItem *parent) Call* CallTreeItem::call() const { - return itemCall; + return itemCall; } QWidget* CallTreeItem::widget() const { - return itemWidget; + return itemWidget; } bool CallTreeItem::insertChildren(int position, int count, int columns) { if (position < 0 || position > childItems.size()) - { return false; - } - for (int row = 0; row < count; ++row) - { + for (int row = 0; row < count; ++row) { QVector<QVariant> data(columns); CallTreeItem *item = new CallTreeItem(data, this); childItems.insert(position, item); @@ -111,17 +106,13 @@ QWidget* CallTreeItem::widget() const bool CallTreeItem::insertColumns(int position, int columns) { if (position < 0 || position > itemData.size()) - { return false; - } - for (int column = 0; column < columns; ++column) - { + for (int column = 0; column < columns; ++column) { itemData.insert(position, QVariant()); } - foreach (CallTreeItem *child, childItems) - { + foreach (CallTreeItem *child, childItems) { child->insertColumns(position, columns); } @@ -136,12 +127,9 @@ QWidget* CallTreeItem::widget() const bool CallTreeItem::removeChildren(int position, int count) { if (position < 0 || position + count > childItems.size()) - { return false; - } - for (int row = 0; row < count; ++row) - { + for (int row = 0; row < count; ++row) { delete childItems.takeAt(position); } @@ -151,17 +139,13 @@ QWidget* CallTreeItem::widget() const bool CallTreeItem::removeColumns(int position, int columns) { if (position < 0 || position + columns > itemData.size()) - { return false; - } - for (int column = 0; column < columns; ++column) - { + for (int column = 0; column < columns; ++column) { itemData.remove(position); } - foreach (CallTreeItem *child, childItems) - { + foreach (CallTreeItem *child, childItems) { child->removeColumns(position, columns); } @@ -170,106 +154,98 @@ QWidget* CallTreeItem::widget() const bool CallTreeItem::setData(int column, const QVariant &value) { - itemData.resize(10); - if (column < 0 || column >= itemData.size()) - { - qDebug() << "Je suis ici!!!! " << itemData; - return false; - } - - itemData[column] = value; - return true; + itemData.resize(10); + if (column < 0 || column >= itemData.size()) { + qDebug() << "Je suis ici!!!! " << itemData; + return false; + } + + itemData[column] = value; + return true; } void CallTreeItem::setCall(Call *call) { - itemCall = call; + itemCall = call; - itemWidget = new QWidget(); + itemWidget = new QWidget(); - labelIcon = new QLabel(); - //labelCallNumber = new QLabel("123"/*itemCall->getPeerPhoneNumber()*/); + labelIcon = new QLabel(); + //labelCallNumber = new QLabel("123"/*itemCall->getPeerPhoneNumber()*/); labelCallNumber2 = new QLabel(itemCall->getPeerPhoneNumber()); - labelTransferPrefix = new QLabel(i18n("Transfer to : ")); - labelTransferNumber = new QLabel(); - QSpacerItem * horizontalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Preferred, QSizePolicy::Minimum); + labelTransferPrefix = new QLabel(i18n("Transfer to : ")); + labelTransferNumber = new QLabel(); + QSpacerItem * horizontalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Preferred, QSizePolicy::Minimum); QSpacerItem * verticalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Expanding, QSizePolicy::Expanding); - - QHBoxLayout * mainLayout = new QHBoxLayout(); - mainLayout->setContentsMargins ( 3, 1, 2, 1); - - mainLayout->setSpacing(4); - QVBoxLayout * descr = new QVBoxLayout(); - descr->setMargin(1); - descr->setSpacing(1); - QHBoxLayout * transfer = new QHBoxLayout(); - transfer->setMargin(0); - transfer->setSpacing(0); - mainLayout->addWidget(labelIcon); + + QHBoxLayout * mainLayout = new QHBoxLayout(); + mainLayout->setContentsMargins ( 3, 1, 2, 1); + + mainLayout->setSpacing(4); + QVBoxLayout * descr = new QVBoxLayout(); + descr->setMargin(1); + descr->setSpacing(1); + QHBoxLayout * transfer = new QHBoxLayout(); + transfer->setMargin(0); + transfer->setSpacing(0); + mainLayout->addWidget(labelIcon); - if(! itemCall->getPeerName().isEmpty()) - { - labelPeerName = new QLabel(itemCall->getPeerName()); - descr->addWidget(labelPeerName); - } - - descr->addWidget(labelCallNumber2); - transfer->addWidget(labelTransferPrefix); - transfer->addWidget(labelTransferNumber); - descr->addLayout(transfer); + if(! itemCall->getPeerName().isEmpty()) { + labelPeerName = new QLabel(itemCall->getPeerName()); + descr->addWidget(labelPeerName); + } + + descr->addWidget(labelCallNumber2); + transfer->addWidget(labelTransferPrefix); + transfer->addWidget(labelTransferNumber); + descr->addLayout(transfer); descr->addItem(verticalSpacer); - mainLayout->addLayout(descr); - //mainLayout->addItem(horizontalSpacer); - - itemWidget->setLayout(mainLayout); - itemWidget->setMinimumSize(QSize(50, 30)); + mainLayout->addLayout(descr); + //mainLayout->addItem(horizontalSpacer); + + itemWidget->setLayout(mainLayout); + itemWidget->setMinimumSize(QSize(50, 30)); - connect(itemCall, SIGNAL(changed()), - this, SLOT(updated())); + connect(itemCall, SIGNAL(changed()), + this, SLOT(updated())); - updated(); + updated(); } void CallTreeItem::updated() { - call_state state = itemCall->getState(); - bool recording = itemCall->getRecording(); - - if(state != CALL_STATE_OVER) - { - if(state == CALL_STATE_CURRENT && recording) - { - labelIcon->setPixmap(QPixmap(ICON_CURRENT_REC)); - } - else - { - QString str = QString(callStateIcons[state]); - labelIcon->setPixmap(QPixmap(str)); - } - bool transfer = state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD; - labelTransferPrefix->setVisible(transfer); - labelTransferNumber->setVisible(transfer); - - if(!transfer) - { - labelTransferNumber->setText(""); - } - //labelTransferNumber->setText(itemCall->getTransferNumber()); - labelCallNumber2->setText(itemCall->getPeerPhoneNumber()); + call_state state = itemCall->getState(); + bool recording = itemCall->getRecording(); + + if(state != CALL_STATE_OVER) { + if(state == CALL_STATE_CURRENT && recording) { + labelIcon->setPixmap(QPixmap(ICON_CURRENT_REC)); + } + else { + QString str = QString(callStateIcons[state]); + labelIcon->setPixmap(QPixmap(str)); + } + bool transfer = state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD; + labelTransferPrefix->setVisible(transfer); + labelTransferNumber->setVisible(transfer); + + if(!transfer) { + labelTransferNumber->setText(""); + } + //labelTransferNumber->setText(itemCall->getTransferNumber()); + labelCallNumber2->setText(itemCall->getPeerPhoneNumber()); - if(state == CALL_STATE_DIALING) - { + if(state == CALL_STATE_DIALING) { labelCallNumber2->setText(itemCall->getCallNumber()); } - } - else - { + } + else { emit over(itemCall); itemWidget->setVisible(false); - qDebug() << "Updating item of call of state OVER. Doing nothing."; - } + qDebug() << "Updating item of call of state OVER. Doing nothing."; + } - + } diff --git a/sflphone-client-kde/src/CallTreeItem.h b/sflphone-client-kde/src/CallTreeItem.h index 7d9fed0b2a773661178cd995bac4109674c95d72..fba7d7886d063689c6177ed96d600c584e5f7c59 100644 --- a/sflphone-client-kde/src/CallTreeItem.h +++ b/sflphone-client-kde/src/CallTreeItem.h @@ -40,50 +40,50 @@ class CallTreeItem : public QObject { - Q_OBJECT + Q_OBJECT public: - CallTreeItem(const QVector<QVariant> &data, CallTreeItem *parent); + CallTreeItem(const QVector<QVariant> &data, CallTreeItem *parent); CallTreeItem(const CallTreeItem *toCopy, CallTreeItem *parent); - ~CallTreeItem(); + ~CallTreeItem(); - CallTreeItem *child(int number); - int childCount() const; - int columnCount() const; - QVariant data(int column) const; - Call* call() const; - QWidget* widget() const; - bool insertChildren(int position, int count, int columns); - bool insertColumns(int position, int columns); - CallTreeItem *parent(); - bool removeChildren(int position, int count); - bool removeColumns(int position, int columns); - int childNumber() const; - bool setData(int column, const QVariant &value); - void setCall(Call *call); + CallTreeItem *child(int number); + int childCount() const; + int columnCount() const; + QVariant data(int column) const; + Call* call() const; + QWidget* widget() const; + bool insertChildren(int position, int count, int columns); + bool insertColumns(int position, int columns); + CallTreeItem *parent(); + bool removeChildren(int position, int count); + bool removeColumns(int position, int columns); + int childNumber() const; + bool setData(int column, const QVariant &value); + void setCall(Call *call); - static const char * callStateIcons[11]; + static const char * callStateIcons[11]; private: - QList<CallTreeItem*> childItems; - QVector<QVariant> itemData; - CallTreeItem *parentItem; - Call *itemCall; - QWidget *itemWidget; + QList<CallTreeItem*> childItems; + QVector<QVariant> itemData; + CallTreeItem *parentItem; + Call *itemCall; + QWidget *itemWidget; - QLabel * labelIcon; - QLabel * labelPeerName; - QLabel * labelCallNumber2; - QLabel * labelTransferPrefix; - QLabel * labelTransferNumber; - - QWidget * historyItemWidget; - QLabel * labelHistoryIcon; - QLabel * labelHistoryPeerName; - QLabel * labelHistoryCallNumber; - QLabel * labelHistoryTime; + QLabel * labelIcon; + QLabel * labelPeerName; + QLabel * labelCallNumber2; + QLabel * labelTransferPrefix; + QLabel * labelTransferNumber; + + QWidget * historyItemWidget; + QLabel * labelHistoryIcon; + QLabel * labelHistoryPeerName; + QLabel * labelHistoryCallNumber; + QLabel * labelHistoryTime; friend class CallTreeItem; public slots: - void updated(); + void updated(); signals: void over(Call*); }; diff --git a/sflphone-client-kde/src/CallTreeModel.cpp b/sflphone-client-kde/src/CallTreeModel.cpp index 28a840dcc72517fcf51ac7e0374fefe29718cc10..e91cc2460c2529e3cf2349f274fd4bf93b5cd84a 100644 --- a/sflphone-client-kde/src/CallTreeModel.cpp +++ b/sflphone-client-kde/src/CallTreeModel.cpp @@ -27,297 +27,269 @@ #include "calllist_interface_singleton.h" CallTreeModel::CallTreeModel(QObject *parent) - : QAbstractItemModel(parent), - rootItem(0) - + : QAbstractItemModel(parent), + rootItem(0) + { - QStringList data = QString("Calls").split("\n"); - QVector<QVariant> rootData; - rootData << i18n("Calls"); + QStringList data = QString("Calls").split("\n"); + QVector<QVariant> rootData; + rootData << i18n("Calls"); - rootItem = new CallTreeItem(rootData, 0); - setupModelData(data, rootItem); + rootItem = new CallTreeItem(rootData, 0); + setupModelData(data, rootItem); } CallTreeModel::~CallTreeModel() { - if(rootItem) - { - delete rootItem; - } + if(rootItem) { + delete rootItem; + } } int CallTreeModel::columnCount(const QModelIndex & /* parent */) const { - return rootItem->columnCount(); + return rootItem->columnCount(); } QVariant CallTreeModel::data(const QModelIndex &index, int role) const { - if (!index.isValid()) - { - return QVariant(); - } + if (!index.isValid()) { + return QVariant(); + } - if (role != Qt::DisplayRole && role != Qt::EditRole) - { - return QVariant(); - } + if (role != Qt::DisplayRole && role != Qt::EditRole) { + return QVariant(); + } - CallTreeItem *item = getItem(index); + CallTreeItem *item = getItem(index); - return item->data(index.column()); + return item->data(index.column()); } Call* CallTreeModel::call(const QModelIndex &index, int role) const { - if (!index.isValid()) - { - return 0; - } + if (!index.isValid()) { + return 0; + } - if (role != Qt::DisplayRole && role != Qt::EditRole) - { - return 0; - } + if (role != Qt::DisplayRole && role != Qt::EditRole) { + return 0; + } - CallTreeItem *item = getItem(index); + CallTreeItem *item = getItem(index); - return item->call(); + return item->call(); } Qt::ItemFlags CallTreeModel::flags(const QModelIndex &index) const { - if (!index.isValid()) - { - return 0; - } - Qt::ItemFlags val = Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; + if (!index.isValid()) { + return 0; + } + Qt::ItemFlags val = Qt::ItemIsEditable | Qt::ItemIsEnabled | Qt::ItemIsSelectable | Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled; - return val; + return val; } CallTreeItem *CallTreeModel::getItem(const QModelIndex &index) const { - if (index.isValid()) - { - CallTreeItem *item = static_cast<CallTreeItem*>(index.internalPointer()); - if (item) - { - return item; - } - } - return rootItem; + if (index.isValid()) { + CallTreeItem *item = static_cast<CallTreeItem*>(index.internalPointer()); + if (item) { + return item; + } + } + return rootItem; } QVariant CallTreeModel::headerData(int section, Qt::Orientation orientation, int role) const { - if (orientation == Qt::Horizontal && role == Qt::DisplayRole) - { - return rootItem->data(section); - } - return QVariant(); + if (orientation == Qt::Horizontal && role == Qt::DisplayRole) { + return rootItem->data(section); + } + return QVariant(); } QModelIndex CallTreeModel::index(int row, int column, const QModelIndex &parent) const { - if (parent.isValid() && parent.column() != 0) - { - return QModelIndex(); - } - - CallTreeItem *parentItem = getItem(parent); - CallTreeItem *childItem = parentItem->child(row); - - if (childItem) - { - return createIndex(row, column, childItem); - } - else - { - return QModelIndex(); - } + if (parent.isValid() && parent.column() != 0) { + return QModelIndex(); + } + + CallTreeItem *parentItem = getItem(parent); + CallTreeItem *childItem = parentItem->child(row); + + if (childItem) { + return createIndex(row, column, childItem); + } + else { + return QModelIndex(); + } } bool CallTreeModel::insertColumns(int position, int columns, const QModelIndex &parent) { - bool success; + bool success; - beginInsertColumns(parent, position, position + columns - 1); - success = rootItem->insertColumns(position, columns); - endInsertColumns(); + beginInsertColumns(parent, position, position + columns - 1); + success = rootItem->insertColumns(position, columns); + endInsertColumns(); - return success; + return success; } bool CallTreeModel::insertRows(int position, int rows, const QModelIndex &parent) { - CallTreeItem *parentItem = getItem(parent); - bool success; + CallTreeItem *parentItem = getItem(parent); + bool success; - beginInsertRows(parent, position, position + rows - 1); - success = parentItem->insertChildren(position, rows, rootItem->columnCount()); - endInsertRows(); + beginInsertRows(parent, position, position + rows - 1); + success = parentItem->insertChildren(position, rows, rootItem->columnCount()); + endInsertRows(); - return success; + return success; } QModelIndex CallTreeModel::parent(const QModelIndex &index) const { - if (!index.isValid()) - { - return QModelIndex(); - } + if (!index.isValid()) { + return QModelIndex(); + } - CallTreeItem *childItem = getItem(index); - CallTreeItem *parentItem = childItem->parent(); + CallTreeItem *childItem = getItem(index); + CallTreeItem *parentItem = childItem->parent(); - if (parentItem == rootItem) - { - return QModelIndex(); - } + if (parentItem == rootItem) { + return QModelIndex(); + } - return createIndex(parentItem->childNumber(), 0, parentItem); + return createIndex(parentItem->childNumber(), 0, parentItem); } bool CallTreeModel::removeColumns(int position, int columns, const QModelIndex &parent) { - bool success; + bool success; - beginRemoveColumns(parent, position, position + columns - 1); - success = rootItem->removeColumns(position, columns); - endRemoveColumns(); + beginRemoveColumns(parent, position, position + columns - 1); + success = rootItem->removeColumns(position, columns); + endRemoveColumns(); - if (rootItem->columnCount() == 0) - { - removeRows(0, rowCount()); - } + if (rootItem->columnCount() == 0) { + removeRows(0, rowCount()); + } - return success; + return success; } bool CallTreeModel::removeRows(int position, int rows, const QModelIndex &parent) { - CallTreeItem *parentItem = getItem(parent); - bool success = true; + CallTreeItem *parentItem = getItem(parent); + bool success = true; - beginRemoveRows(parent, position, position + rows - 1); - success = parentItem->removeChildren(position, rows); - endRemoveRows(); + beginRemoveRows(parent, position, position + rows - 1); + success = parentItem->removeChildren(position, rows); + endRemoveRows(); - return success; + return success; } int CallTreeModel::rowCount(const QModelIndex &parent) const { - CallTreeItem *parentItem = getItem(parent); + CallTreeItem *parentItem = getItem(parent); - return parentItem->childCount(); + return parentItem->childCount(); } bool CallTreeModel::setData(const QModelIndex &index, const QVariant &value, int role) { - if (role != Qt::EditRole) - { - return false; - } + if (role != Qt::EditRole) { + return false; + } - CallTreeItem *item = getItem(index); - bool result = item->setData(index.column(), value); + CallTreeItem *item = getItem(index); + bool result = item->setData(index.column(), value); //item->setData(1, QString("test")); //item->setData(2, QString("test2")); - if (result) - { - emit dataChanged(index, index); - } + if (result) { + emit dataChanged(index, index); + } - return result; + return result; } bool CallTreeModel::setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role) { - if (role != Qt::EditRole || orientation != Qt::Horizontal) - { - return false; - } + if (role != Qt::EditRole || orientation != Qt::Horizontal) { + return false; + } - bool result = rootItem->setData(section, value); + bool result = rootItem->setData(section, value); - if (result) - { - emit headerDataChanged(orientation, section, section); - } + if (result) { + emit headerDataChanged(orientation, section, section); + } - return result; + return result; } void CallTreeModel::setupModelData(const QStringList &lines, CallTreeItem *parent) { - QList<CallTreeItem*> parents; - QList<int> indentations; -// parents << parent; - indentations << 0; - - int number = 0; - - while (number < lines.count()) - { - int position = 0; - - while (position < lines[number].length()) - { - if (lines[number].mid(position, 1) != " ") - { - break; - } - position++; - } - - QString lineData = lines[number].mid(position).trimmed(); - - if (!lineData.isEmpty()) - { - // Read the column data from the rest of the line. - QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts); - QVector<QVariant> columnData; - for (int column = 0; column < columnStrings.count(); ++column) - { - columnData << columnStrings[column]; - } - - if (position > indentations.last()) - { - // The last child of the current parent is now the new parent - // unless the current parent has no children. - - if (parents.last()->childCount() > 0) - { - parents << parents.last()->child(parents.last()->childCount()-1); - indentations << position; - } - } - else - { - while (position < indentations.last() && parents.count() > 0) - { - parents.pop_back(); - indentations.pop_back(); - } - } - - // Append a new item to the current parent's list of children. - /*CallTreeItem *parent = parents.last(); - parent->insertChildren(parent->childCount(), 1, rootItem->columnCount()); - - for (int column = 0; column < columnData.size(); ++column) - { - parent->child(parent->childCount() - 1)->setData(column, columnData[column]); - }*/ - } - number++; - } + QList<CallTreeItem*> parents; + QList<int> indentations; +// parents << parent; + indentations << 0; + + int number = 0; + + while (number < lines.count()) { + int position = 0; + + while (position < lines[number].length()) { + if (lines[number].mid(position, 1) != " ") { + break; + } + position++; + } + + QString lineData = lines[number].mid(position).trimmed(); + + if (!lineData.isEmpty()) { + // Read the column data from the rest of the line. + QStringList columnStrings = lineData.split("\t", QString::SkipEmptyParts); + QVector<QVariant> columnData; + for (int column = 0; column < columnStrings.count(); ++column) { + columnData << columnStrings[column]; + } + + if (position > indentations.last()) { + // The last child of the current parent is now the new parent + // unless the current parent has no children. + + if (parents.last()->childCount() > 0) { + parents << parents.last()->child(parents.last()->childCount()-1); + indentations << position; + } + } + else { + while (position < indentations.last() && parents.count() > 0) { + parents.pop_back(); + indentations.pop_back(); + } + } + + // Append a new item to the current parent's list of children. + /*CallTreeItem *parent = parents.last(); + parent->insertChildren(parent->childCount(), 1, rootItem->columnCount()); + + for (int column = 0; column < columnData.size(); ++column) + { + parent->child(parent->childCount() - 1)->setData(column, columnData[column]); + }*/ + } + number++; + } } Qt::DropActions CallTreeModel::supportedDropActions() diff --git a/sflphone-client-kde/src/CallTreeModel.h b/sflphone-client-kde/src/CallTreeModel.h index 6de8b7c1b34198cf0f9c76ef90e4b40960e5f877..08ebd5600788755901a80ddd63c2924c759633ef 100644 --- a/sflphone-client-kde/src/CallTreeModel.h +++ b/sflphone-client-kde/src/CallTreeModel.h @@ -35,43 +35,43 @@ class Call; class CallTreeModel : public QAbstractItemModel { - Q_OBJECT + Q_OBJECT public: - CallTreeModel(QObject *parent = 0); - ~CallTreeModel(); + CallTreeModel(QObject *parent = 0); + ~CallTreeModel(); - QVariant data(const QModelIndex &index, int role) const; - Call* call(const QModelIndex &index, int role) const; + QVariant data(const QModelIndex &index, int role) const; + Call* call(const QModelIndex &index, int role) const; - QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; + QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; - QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; - QModelIndex parent(const QModelIndex &index) const; + QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + QModelIndex parent(const QModelIndex &index) const; - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; + int rowCount(const QModelIndex &parent = QModelIndex()) const; + int columnCount(const QModelIndex &parent = QModelIndex()) const; - Qt::ItemFlags flags(const QModelIndex &index) const; - bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); - bool setCall(const QModelIndex &index, Call *value, int role = Qt::EditRole); - bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole); + Qt::ItemFlags flags(const QModelIndex &index) const; + bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); + bool setCall(const QModelIndex &index, Call *value, int role = Qt::EditRole); + bool setHeaderData(int section, Qt::Orientation orientation, const QVariant &value, int role = Qt::EditRole); - bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex()); - bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex()); - bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex()); - bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex()); + bool insertColumns(int position, int columns, const QModelIndex &parent = QModelIndex()); + bool removeColumns(int position, int columns, const QModelIndex &parent = QModelIndex()); + bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex()); + bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex()); Qt::DropActions supportedDropActions(); virtual bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex &parent); QStringList mimeTypes() const; QMimeData* mimeData(const QModelIndexList &indexes) const; - CallTreeItem *getItem(const QModelIndex &index) const; + CallTreeItem *getItem(const QModelIndex &index) const; private: - void setupModelData(const QStringList &lines, CallTreeItem *parent); - CallTreeItem *rootItem; + void setupModelData(const QStringList &lines, CallTreeItem *parent); + CallTreeItem *rootItem; signals: void joinCall(QString callId1, QString callId2); diff --git a/sflphone-client-kde/src/CallTreeView.cpp b/sflphone-client-kde/src/CallTreeView.cpp index 12eff81aada362dfcbf6b51e208383f0a4be6f1d..5b7ad60a3da1ee51577154d615d64e9e5f9c0d0b 100644 --- a/sflphone-client-kde/src/CallTreeView.cpp +++ b/sflphone-client-kde/src/CallTreeView.cpp @@ -28,19 +28,19 @@ #include <QDebug> CallTreeView::CallTreeView(QWidget * parent) - : QTreeView(parent) -{ - treeModel = new CallTreeModel(this); - setModel(treeModel); + : QTreeView(parent) +{ + treeModel = new CallTreeModel(this); + setModel(treeModel); CallTreeItemDelegate *delegate = new CallTreeItemDelegate(); setItemDelegate(delegate); - setHeaderHidden(true); - setRootIsDecorated(false); - setSelectionMode(QAbstractItemView::SingleSelection); - setDragEnabled(true); - setAcceptDrops(true); - setUniformRowHeights(true); - setDropIndicatorShown(true); + setHeaderHidden(true); + setRootIsDecorated(false); + setSelectionMode(QAbstractItemView::SingleSelection); + setDragEnabled(true); + setAcceptDrops(true); + setUniformRowHeights(true); + setDropIndicatorShown(true); //setDragDropMode(QAbstractItemView::DragDrop); setSelectionMode(QAbstractItemView::ExtendedSelection); @@ -56,32 +56,29 @@ CallTreeView::CallTreeView(QWidget * parent) CallTreeView::~CallTreeView() { - delete treeModel; + delete treeModel; } CallTreeItem* CallTreeView::insert(Call *call) { - QModelIndex index = selectionModel()->currentIndex(); - int position = index.row()+1; - QModelIndex parent = index.parent(); - CallTreeItem *item; - - if (!treeModel->insertRow(position, parent)) - { - return 0; - } + QModelIndex index = selectionModel()->currentIndex(); + int position = index.row()+1; + QModelIndex parent = index.parent(); + CallTreeItem *item; + + if (!treeModel->insertRow(position, parent)) + return 0; QModelIndex child = model()->index(index.row()+1, 0, index.parent()); treeModel->setData(child, QVariant(""), Qt::EditRole); - for (int column = 1; column < treeModel->columnCount(index); ++column) - { + for (int column = 1; column < treeModel->columnCount(index); ++column) { QModelIndex child2 = treeModel->index(index.row()+1, column, index.parent()); treeModel->setData(child2, QString("test"), Qt::EditRole); } - item = treeModel->getItem(child); - item->setCall(call); + item = treeModel->getItem(child); + item->setCall(call); // qDebug() << "Will connect, id " << call << ", " << call->getPeerPhoneNumber(); // connect(call, SIGNAL(changed()), item, SLOT(updated())); // item->setCall(call); @@ -91,47 +88,43 @@ CallTreeItem* CallTreeView::insert(Call *call) // resizeColumnToContents(1); // resizeColumnToContents(2); // //item->updated(); - setIndexWidget(child, item->widget()); + setIndexWidget(child, item->widget()); } CallTreeItem* CallTreeView::insert(CallTreeItem *parent, Call *call) { - QModelIndex index = selectionModel()->currentIndex(); - - if (treeModel->columnCount(index) == 0) - { - if (!model()->insertColumn(0, index)) - { - return 0; - } - - } - - if (!treeModel->insertRow(0, index)) - { - return 0; - } - - CallTreeItem *item = treeModel->getItem(index); - - for (int column = 0; column < treeModel->columnCount(index); ++column) - { - QModelIndex child = treeModel->index(0, column, index); + QModelIndex index = selectionModel()->currentIndex(); + + if (treeModel->columnCount(index) == 0) { + if (!model()->insertColumn(0, index)) { + return 0; + } + + } + + if (!treeModel->insertRow(0, index)) { + return 0; + } + + CallTreeItem *item = treeModel->getItem(index); + + for (int column = 0; column < treeModel->columnCount(index); ++column) { + QModelIndex child = treeModel->index(0, column, index); qDebug() << "I just added data: 0, " << column << " \n\n\n\n"; - treeModel->setData(child, QVariant(""), Qt::EditRole); - } + treeModel->setData(child, QVariant(""), Qt::EditRole); + } - item->setCall(call); - selectionModel()->setCurrentIndex(model()->index(0, 0, index), QItemSelectionModel::ClearAndSelect); + item->setCall(call); + selectionModel()->setCurrentIndex(model()->index(0, 0, index), QItemSelectionModel::ClearAndSelect); - QModelIndex newIndex = selectionModel()->currentIndex(); + QModelIndex newIndex = selectionModel()->currentIndex(); - return treeModel->getItem(newIndex); + return treeModel->getItem(newIndex); } void CallTreeView::remove(QModelIndex & index) const { - treeModel->removeRow(index.row(), index.parent()); + treeModel->removeRow(index.row(), index.parent()); } void CallTreeView::remove(Call* call) const //BUG not used @@ -146,40 +139,39 @@ void CallTreeView::remove(Call* call) const //BUG not used void CallTreeView::removeCurrent() const { - QModelIndex index = selectionModel()->currentIndex(); - treeModel->removeRow(index.row(), index.parent()); + QModelIndex index = selectionModel()->currentIndex(); + treeModel->removeRow(index.row(), index.parent()); } CallTreeItem* CallTreeView::currentItem() { - QModelIndex index = selectionModel()->currentIndex(); + QModelIndex index = selectionModel()->currentIndex(); - CallTreeItem *item = treeModel->getItem(index); + CallTreeItem *item = treeModel->getItem(index); - if (!item->call()) - { - return 0; - } - return item; + if (!item->call()) { + return 0; + } + return item; } CallTreeItem* CallTreeView::getItem(const QModelIndex &index) { - return treeModel->getItem(index); + return treeModel->getItem(index); } void CallTreeView::setCurrentRow(int row) { - CallTreeModel * treeModel = static_cast<CallTreeModel*>(model()); + CallTreeModel * treeModel = static_cast<CallTreeModel*>(model()); - QModelIndex currentIndex = selectionModel()->currentIndex(); - QModelIndex index = treeModel->index(row, 0, currentIndex); - selectionModel()->setCurrentIndex(index, QItemSelectionModel::Current); + QModelIndex currentIndex = selectionModel()->currentIndex(); + QModelIndex index = treeModel->index(row, 0, currentIndex); + selectionModel()->setCurrentIndex(index, QItemSelectionModel::Current); } int CallTreeView::count() { - return model()->rowCount(); + return model()->rowCount(); } QStringList CallTreeView::mimeTypes() const diff --git a/sflphone-client-kde/src/CallTreeView.h b/sflphone-client-kde/src/CallTreeView.h index f025cc520a5a34dfcf8435ec3875f22da9fad3dc..c27e5a735d1a87752453350cb97f077f51c62d96 100644 --- a/sflphone-client-kde/src/CallTreeView.h +++ b/sflphone-client-kde/src/CallTreeView.h @@ -45,18 +45,18 @@ public: class CallTreeView : public QTreeView { - Q_OBJECT + Q_OBJECT public: - CallTreeView(QWidget *parent); - ~CallTreeView(); - void remove(QModelIndex & index) const; - void removeCurrent() const; - CallTreeItem* currentItem(); - CallTreeItem* getItem(const QModelIndex &index); - void setCurrentRow(int row); - int count(); - QStringList mimeTypes() const; - Qt::DropActions supportedDropActions () const; + CallTreeView(QWidget *parent); + ~CallTreeView(); + void remove(QModelIndex & index) const; + void removeCurrent() const; + CallTreeItem* currentItem(); + CallTreeItem* getItem(const QModelIndex &index); + void setCurrentRow(int row); + int count(); + QStringList mimeTypes() const; + Qt::DropActions supportedDropActions () const; CallTreeItem* insert(Call* call); CallTreeItem* insert(CallTreeItem *item, Call* call); @@ -64,7 +64,7 @@ public: // void dropEvent(QDropEvent* event); // private: - CallTreeModel *treeModel; + CallTreeModel *treeModel; QModelIndex currentModel; public slots: void remove(Call* call) const; @@ -74,8 +74,8 @@ private slots: void adaptColumns(const QModelIndex & topleft, const QModelIndex& bottomRight); signals: - void currentItemChanged(); - void itemChanged(); + void currentItemChanged(); + void itemChanged(); }; #endif // CALLTREE_VIEW_H diff --git a/sflphone-client-kde/src/Codec.cpp b/sflphone-client-kde/src/Codec.cpp index 3e94070c0de39b524cf2153406c0ac2d1a2cefa9..e162771df54ca14dd22b121f9d9649f888dacb21 100644 --- a/sflphone-client-kde/src/Codec.cpp +++ b/sflphone-client-kde/src/Codec.cpp @@ -25,40 +25,74 @@ Codec::Codec(int payload, bool enabled) { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - QStringList details = configurationManager.getCodecDetails(payload); - this->payload = QString::number(payload); - this->enabled = enabled; - this->name = details[CODEC_NAME]; - this->frequency = details[CODEC_SAMPLE_RATE]; - this->bitrate = details[CODEC_BIT_RATE]; - this->bandwidth = details[CODEC_BANDWIDTH]; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + QStringList details = configurationManager.getCodecDetails(payload); + this->payload = QString::number(payload); + this->enabled = enabled; + this->name = details[CODEC_NAME]; + this->frequency = details[CODEC_SAMPLE_RATE]; + this->bitrate = details[CODEC_BIT_RATE]; + this->bandwidth = details[CODEC_BANDWIDTH]; } QString Codec::getPayload() const -{ return payload; } +{ + return payload; +} + QString Codec::getName() const -{ return name; } +{ + return name; +} + QString Codec::getFrequency() const -{ return frequency; } +{ + return frequency; +} + QString Codec::getBitrate() const -{ return bitrate; } +{ + return bitrate; +} + QString Codec::getBandwidth() const -{ return bandwidth; } +{ + return bandwidth; +} + bool Codec::isEnabled() const -{ return enabled; } +{ + return enabled; +} void Codec::setPayload(QString payload) -{ this->payload = payload; } +{ + this->payload = payload; +} + void Codec::setName(QString name) -{ this->name = name; } +{ + this->name = name; +} + void Codec::setFrequency(QString frequency) -{ this->frequency = frequency; } +{ + this->frequency = frequency; +} + void Codec::setBitrate(QString bitrate) -{ this->bitrate = bitrate; } +{ + this->bitrate = bitrate; +} + void Codec::setBandwidth(QString bandwidth) -{ this->bandwidth = bandwidth; } +{ + this->bandwidth = bandwidth; +} + void Codec::setEnabled(bool enabled) -{ this->enabled = enabled; } +{ + this->enabled = enabled; +} diff --git a/sflphone-client-kde/src/Codec.h b/sflphone-client-kde/src/Codec.h index 9a86d604d5a9a293cf7a1e9b2a9b59cd463d86e8..aa07234477f4e302b1e465d3cfad3bbbc45e8f73 100644 --- a/sflphone-client-kde/src/Codec.h +++ b/sflphone-client-kde/src/Codec.h @@ -25,42 +25,42 @@ #include <QtCore/QString> /** - @author Jérémy Quentin <jeremy.quentin@gmail.com> + @author Jérémy Quentin <jeremy.quentin@gmail.com> */ class Codec : public QObject { Q_OBJECT private: - QString payload; - QString name; - QString frequency; - QString bitrate; - QString bandwidth; - bool enabled; + QString payload; + QString name; + QString frequency; + QString bitrate; + QString bandwidth; + bool enabled; public: - Codec(int payload, bool enabled); -// Codec(const Codec & codec); + Codec(int payload, bool enabled); +// Codec(const Codec & codec); -// ~Codec(); +// ~Codec(); - QString getPayload() const; - QString getName() const; - QString getFrequency() const; - QString getBitrate() const; - QString getBandwidth() const; - bool isEnabled() const; - - void setPayload(QString payload); - void setName(QString name); - void setFrequency(QString frequency); - void setBitrate(QString bitrate); - void setBandwidth(QString bandwidth); - void setEnabled(bool enabled); - - Codec & operator=(const Codec&); + QString getPayload() const; + QString getName() const; + QString getFrequency() const; + QString getBitrate() const; + QString getBandwidth() const; + bool isEnabled() const; + + void setPayload(QString payload); + void setName(QString name); + void setFrequency(QString frequency); + void setBitrate(QString bitrate); + void setBandwidth(QString bandwidth); + void setEnabled(bool enabled); + + Codec & operator=(const Codec&); - + }; #endif diff --git a/sflphone-client-kde/src/Contact.cpp b/sflphone-client-kde/src/Contact.cpp index af3ee5ea9644a29387c583e63c4d65456de471b5..71cd68b3d6768da25aaad57e04becb47bd1b414f 100644 --- a/sflphone-client-kde/src/Contact.cpp +++ b/sflphone-client-kde/src/Contact.cpp @@ -28,72 +28,70 @@ Contact::Contact(Addressee addressee, const PhoneNumber & number, bool displayPhoto) { - this->firstName = addressee.name(); - this->secondName = addressee.familyName(); - this->nickName = addressee.nickName(); - this->phoneNumber = number.number(); - this->type = number.type(); - this->displayPhoto = displayPhoto; - if(displayPhoto) - { - this->photo = new Picture(addressee.photo()); - } - else - { - this->photo = NULL; - } - - initItem(); + this->firstName = addressee.name(); + this->secondName = addressee.familyName(); + this->nickName = addressee.nickName(); + this->phoneNumber = number.number(); + this->type = number.type(); + this->displayPhoto = displayPhoto; + if(displayPhoto) { + this->photo = new Picture(addressee.photo()); + } + else { + this->photo = NULL; + } + + initItem(); } Contact::~Contact() { - delete item; - delete itemWidget; - delete photo; + delete item; + delete itemWidget; + delete photo; } void Contact::initItem() { - this->item = new QListWidgetItem(); - this->item->setSizeHint(QSize(140,CONTACT_ITEM_HEIGHT)); - initItemWidget(); + this->item = new QListWidgetItem(); + this->item->setSizeHint(QSize(140,CONTACT_ITEM_HEIGHT)); + initItemWidget(); } void Contact::initItemWidget() { - this->itemWidget = new ContactItemWidget(this, displayPhoto); + this->itemWidget = new ContactItemWidget(this, displayPhoto); } QString Contact::getPhoneNumber() const { - return phoneNumber; + return phoneNumber; } QString Contact::getNickName() const { - return nickName; + return nickName; } QString Contact::getFirstName() const { - return firstName; + return firstName; } QString Contact::getSecondName() const { - return secondName; + return secondName; } const Picture * Contact::getPhoto() const { - return photo; + return photo; } PhoneNumber::Type Contact::getType() const { - return type; + return type; } diff --git a/sflphone-client-kde/src/Contact.h b/sflphone-client-kde/src/Contact.h index bf4f4f987ca885bf41ebd3fcf4960b76ea49a7be..3abe00f9aee7f0d4930c80fdbbde44d89357a50c 100644 --- a/sflphone-client-kde/src/Contact.h +++ b/sflphone-client-kde/src/Contact.h @@ -36,35 +36,35 @@ using namespace KABC; class ContactItemWidget; /** - @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> + @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> */ class Contact : public QObject, public Item<ContactItemWidget>{ private: - QString firstName; - QString secondName; - QString nickName; - QString phoneNumber; - Picture * photo; - PhoneNumber::Type type; - bool displayPhoto; - + QString firstName; + QString secondName; + QString nickName; + QString phoneNumber; + Picture * photo; + PhoneNumber::Type type; + bool displayPhoto; + public: - //Constructors & Destructors - Contact(Addressee addressee, const PhoneNumber & number, bool displayPhoto); - ~Contact(); - - //Getters - QString getPhoneNumber() const; - QString getNickName() const; - QString getFirstName() const; - QString getSecondName() const; - const Picture * getPhoto() const; - PhoneNumber::Type getType() const; - void initItem(); - + //Constructors & Destructors + Contact(Addressee addressee, const PhoneNumber & number, bool displayPhoto); + ~Contact(); + + //Getters + QString getPhoneNumber() const; + QString getNickName() const; + QString getFirstName() const; + QString getSecondName() const; + const Picture * getPhoto() const; + PhoneNumber::Type getType() const; + void initItem(); + protected: - void initItemWidget(); + void initItemWidget(); }; diff --git a/sflphone-client-kde/src/ContactItemWidget.cpp b/sflphone-client-kde/src/ContactItemWidget.cpp index f32614c58dc753e3053516d5ec5755ba45cade85..c9f414c4399bbb1496b19333b417e36cea381d41 100644 --- a/sflphone-client-kde/src/ContactItemWidget.cpp +++ b/sflphone-client-kde/src/ContactItemWidget.cpp @@ -30,78 +30,70 @@ ContactItemWidget::ContactItemWidget(const Contact * contact, bool displayPhoto, QWidget *parent) : QWidget(parent) { - if(!contact->getNickName().isEmpty()) - { - contactName = new QLabel(contact->getNickName()); - } - else - { - contactName = new QLabel(contact->getFirstName()); - } - if(displayPhoto) - { - if(!contact->getPhoto()->isEmpty()) - { - QPixmap pixmap; - if(contact->getPhoto()->isIntern()) - { - contactPhoto = new QLabel(); - pixmap = QPixmap::fromImage(contact->getPhoto()->data()); - } - else - { - contactPhoto = new QLabel(); - pixmap = QPixmap(contact->getPhoto()->url()); - } - if(pixmap.height() > pixmap.width()) - contactPhoto->setPixmap(pixmap.scaledToHeight(CONTACT_ITEM_HEIGHT-4)); - else - contactPhoto->setPixmap(pixmap.scaledToWidth(CONTACT_ITEM_HEIGHT-4)); - } - else - { - contactPhoto = new QLabel(); - contactPhoto->setMinimumSize(CONTACT_ITEM_HEIGHT-4, 0); - } - } - contactType = new QLabel(PhoneNumber::typeLabel(contact->getType())); - contactNumber = new QLabel(contact->getPhoneNumber()); - QSpacerItem * horizontalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Preferred, QSizePolicy::Minimum); - QHBoxLayout * hlayout = new QHBoxLayout(this); - QVBoxLayout * vlayout = new QVBoxLayout(); - hlayout->setMargin(1); - hlayout->setSpacing(4); - vlayout->setMargin(1); - vlayout->setSpacing(2); - vlayout->addWidget(contactName); - vlayout->addWidget(contactNumber); - if(displayPhoto) - { - hlayout->addWidget(contactPhoto); - } - hlayout->addLayout(vlayout); - hlayout->addItem(horizontalSpacer); - hlayout->addWidget(contactType); - this->setLayout(hlayout); + if(!contact->getNickName().isEmpty()) { + contactName = new QLabel(contact->getNickName()); + } + else { + contactName = new QLabel(contact->getFirstName()); + } + if(displayPhoto) { + if(!contact->getPhoto()->isEmpty()) { + QPixmap pixmap; + if(contact->getPhoto()->isIntern()) { + contactPhoto = new QLabel(); + pixmap = QPixmap::fromImage(contact->getPhoto()->data()); + } + else { + contactPhoto = new QLabel(); + pixmap = QPixmap(contact->getPhoto()->url()); + } + if(pixmap.height() > pixmap.width()) + contactPhoto->setPixmap(pixmap.scaledToHeight(CONTACT_ITEM_HEIGHT-4)); + else + contactPhoto->setPixmap(pixmap.scaledToWidth(CONTACT_ITEM_HEIGHT-4)); + } + else { + contactPhoto = new QLabel(); + contactPhoto->setMinimumSize(CONTACT_ITEM_HEIGHT-4, 0); + } + } + contactType = new QLabel(PhoneNumber::typeLabel(contact->getType())); + contactNumber = new QLabel(contact->getPhoneNumber()); + QSpacerItem * horizontalSpacer = new QSpacerItem(16777215, 20, QSizePolicy::Preferred, QSizePolicy::Minimum); + QHBoxLayout * hlayout = new QHBoxLayout(this); + QVBoxLayout * vlayout = new QVBoxLayout(); + hlayout->setMargin(1); + hlayout->setSpacing(4); + vlayout->setMargin(1); + vlayout->setSpacing(2); + vlayout->addWidget(contactName); + vlayout->addWidget(contactNumber); + if(displayPhoto) { + hlayout->addWidget(contactPhoto); + } + hlayout->addLayout(vlayout); + hlayout->addItem(horizontalSpacer); + hlayout->addWidget(contactType); + this->setLayout(hlayout); } ContactItemWidget::~ContactItemWidget() { - delete contactName; - delete contactNumber; -// delete contactPhoto; - delete contactType; + delete contactName; + delete contactNumber; +// delete contactPhoto; + delete contactType; } QString ContactItemWidget::getContactName() { - return contactName->text(); + return contactName->text(); } QString ContactItemWidget::getContactNumber() { - return contactNumber->text(); + return contactNumber->text(); } diff --git a/sflphone-client-kde/src/ContactItemWidget.h b/sflphone-client-kde/src/ContactItemWidget.h index 517d0a78dc169411fd1e1be48584c6d53cfb3a8c..b6d8435a3da5cbbc82f148a4819dd46c2627b4e0 100644 --- a/sflphone-client-kde/src/ContactItemWidget.h +++ b/sflphone-client-kde/src/ContactItemWidget.h @@ -28,27 +28,27 @@ class Contact; /** - @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> + @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> */ class ContactItemWidget : public QWidget { Q_OBJECT private: - QLabel * contactName; - QLabel * contactNumber; - QLabel * contactPhoto; - QLabel * contactType; - + QLabel * contactName; + QLabel * contactNumber; + QLabel * contactPhoto; + QLabel * contactType; + public: - //Constructors & Destructors - ContactItemWidget(const Contact * contact, bool displayPhoto, QWidget *parent = 0); - ~ContactItemWidget(); - - //Getters - QString getContactName(); - QString getContactNumber(); + //Constructors & Destructors + ContactItemWidget(const Contact * contact, bool displayPhoto, QWidget *parent = 0); + ~ContactItemWidget(); + + //Getters + QString getContactName(); + QString getContactNumber(); }; diff --git a/sflphone-client-kde/src/Dialpad.cpp b/sflphone-client-kde/src/Dialpad.cpp index 8765434efe8e837d39f4e6bae7bf60f26a0270ce..1332ef3ffeebc6c573579a0e9692f5a6b0583c99 100644 --- a/sflphone-client-kde/src/Dialpad.cpp +++ b/sflphone-client-kde/src/Dialpad.cpp @@ -26,96 +26,95 @@ Dialpad::Dialpad(QWidget *parent) : QWidget(parent) { - gridLayout = new QGridLayout(this); - gridLayout->setObjectName(QString::fromUtf8("gridLayout")); + gridLayout = new QGridLayout(this); + gridLayout->setObjectName(QString::fromUtf8("gridLayout")); - pushButton_0 = new QPushButton(this); - pushButton_1 = new QPushButton(this); - pushButton_2 = new QPushButton(this); - pushButton_3 = new QPushButton(this); - pushButton_4 = new QPushButton(this); - pushButton_5 = new QPushButton(this); - pushButton_6 = new QPushButton(this); - pushButton_7 = new QPushButton(this); - pushButton_8 = new QPushButton(this); - pushButton_9 = new QPushButton(this); - pushButton_diese = new QPushButton(this); - pushButton_etoile = new QPushButton(this); - - pushButton_0->setObjectName(QString::fromUtf8("pushButton_0")); - pushButton_1->setObjectName(QString::fromUtf8("pushButton_1")); - pushButton_2->setObjectName(QString::fromUtf8("pushButton_2")); - pushButton_3->setObjectName(QString::fromUtf8("pushButton_3")); - pushButton_4->setObjectName(QString::fromUtf8("pushButton_4")); - pushButton_5->setObjectName(QString::fromUtf8("pushButton_5")); - pushButton_6->setObjectName(QString::fromUtf8("pushButton_6")); - pushButton_7->setObjectName(QString::fromUtf8("pushButton_7")); - pushButton_8->setObjectName(QString::fromUtf8("pushButton_8")); - pushButton_9->setObjectName(QString::fromUtf8("pushButton_9")); - pushButton_diese->setObjectName(QString::fromUtf8("pushButton_diese")); - pushButton_etoile->setObjectName(QString::fromUtf8("pushButton_etoile")); - - gridLayout->addWidget(pushButton_1, 0, 0); - gridLayout->addWidget(pushButton_2, 0, 1); - gridLayout->addWidget(pushButton_3, 0, 2); - gridLayout->addWidget(pushButton_4, 1, 0); - gridLayout->addWidget(pushButton_5, 1, 1); - gridLayout->addWidget(pushButton_6, 1, 2); - gridLayout->addWidget(pushButton_7, 2, 0); - gridLayout->addWidget(pushButton_8, 2, 1); - gridLayout->addWidget(pushButton_9, 2, 2); - gridLayout->addWidget(pushButton_etoile, 3, 0); - gridLayout->addWidget(pushButton_0, 3, 1); - gridLayout->addWidget(pushButton_diese, 3, 2); - - fillButtons(); - - QMetaObject::connectSlotsByName(this); + pushButton_0 = new QPushButton(this); + pushButton_1 = new QPushButton(this); + pushButton_2 = new QPushButton(this); + pushButton_3 = new QPushButton(this); + pushButton_4 = new QPushButton(this); + pushButton_5 = new QPushButton(this); + pushButton_6 = new QPushButton(this); + pushButton_7 = new QPushButton(this); + pushButton_8 = new QPushButton(this); + pushButton_9 = new QPushButton(this); + pushButton_diese = new QPushButton(this); + pushButton_etoile = new QPushButton(this); + + pushButton_0->setObjectName(QString::fromUtf8("pushButton_0")); + pushButton_1->setObjectName(QString::fromUtf8("pushButton_1")); + pushButton_2->setObjectName(QString::fromUtf8("pushButton_2")); + pushButton_3->setObjectName(QString::fromUtf8("pushButton_3")); + pushButton_4->setObjectName(QString::fromUtf8("pushButton_4")); + pushButton_5->setObjectName(QString::fromUtf8("pushButton_5")); + pushButton_6->setObjectName(QString::fromUtf8("pushButton_6")); + pushButton_7->setObjectName(QString::fromUtf8("pushButton_7")); + pushButton_8->setObjectName(QString::fromUtf8("pushButton_8")); + pushButton_9->setObjectName(QString::fromUtf8("pushButton_9")); + pushButton_diese->setObjectName(QString::fromUtf8("pushButton_diese")); + pushButton_etoile->setObjectName(QString::fromUtf8("pushButton_etoile")); + + gridLayout->addWidget(pushButton_1, 0, 0); + gridLayout->addWidget(pushButton_2, 0, 1); + gridLayout->addWidget(pushButton_3, 0, 2); + gridLayout->addWidget(pushButton_4, 1, 0); + gridLayout->addWidget(pushButton_5, 1, 1); + gridLayout->addWidget(pushButton_6, 1, 2); + gridLayout->addWidget(pushButton_7, 2, 0); + gridLayout->addWidget(pushButton_8, 2, 1); + gridLayout->addWidget(pushButton_9, 2, 2); + gridLayout->addWidget(pushButton_etoile, 3, 0); + gridLayout->addWidget(pushButton_0, 3, 1); + gridLayout->addWidget(pushButton_diese, 3, 2); + + fillButtons(); + + QMetaObject::connectSlotsByName(this); } void Dialpad::fillButtons() { - QHBoxLayout * layout; - QLabel * number; - QLabel * text; - int spacing = 5; - int numberSize = 14; - int textSize = 8; - - QPushButton * buttons[12] = - {pushButton_1, pushButton_2, pushButton_3, - pushButton_4, pushButton_5, pushButton_6, - pushButton_7, pushButton_8, pushButton_9, - pushButton_etoile, pushButton_0, pushButton_diese}; - - QString numbers[12] = - {"1", "2", "3", - "4", "5", "6", - "7", "8", "9", - "*", "0", "#"}; - - QString texts[12] = - { "" , "abc", "def" , - "ghi" , "jkl", "mno" , - "pqrs", "tuv", "wxyz", - "" , "" , "" }; - - for(int i = 0 ; i < 12 ; i++) - { - layout = new QHBoxLayout(); - layout->setSpacing(spacing); - number = new QLabel(numbers[i]); - number->setFont(QFont("", numberSize)); - layout->addWidget(number); - number->setAlignment(Qt::AlignRight | Qt::AlignVCenter); - text = new QLabel(texts[i]); - text->setFont(QFont("", textSize)); - layout->addWidget(text); - buttons[i]->setLayout(layout); - buttons[i]->setMinimumHeight(30); - buttons[i]->setText(""); - } + QHBoxLayout * layout; + QLabel * number; + QLabel * text; + int spacing = 5; + int numberSize = 14; + int textSize = 8; + + QPushButton * buttons[12] = + {pushButton_1, pushButton_2, pushButton_3, + pushButton_4, pushButton_5, pushButton_6, + pushButton_7, pushButton_8, pushButton_9, + pushButton_etoile, pushButton_0, pushButton_diese}; + + QString numbers[12] = + {"1", "2", "3", + "4", "5", "6", + "7", "8", "9", + "*", "0", "#"}; + + QString texts[12] = + { "" , "abc", "def" , + "ghi" , "jkl", "mno" , + "pqrs", "tuv", "wxyz", + "" , "" , "" }; + + for(int i = 0 ; i < 12 ; i++) { + layout = new QHBoxLayout(); + layout->setSpacing(spacing); + number = new QLabel(numbers[i]); + number->setFont(QFont("", numberSize)); + layout->addWidget(number); + number->setAlignment(Qt::AlignRight | Qt::AlignVCenter); + text = new QLabel(texts[i]); + text->setFont(QFont("", textSize)); + layout->addWidget(text); + buttons[i]->setLayout(layout); + buttons[i]->setMinimumHeight(30); + buttons[i]->setText(""); + } } diff --git a/sflphone-client-kde/src/Dialpad.h b/sflphone-client-kde/src/Dialpad.h index 3d7cc25714690c48b1e5dbcf4d61abeda9d2d0de..77cd854cfaad08514ef35479b4380905cc8e080e 100644 --- a/sflphone-client-kde/src/Dialpad.h +++ b/sflphone-client-kde/src/Dialpad.h @@ -28,26 +28,26 @@ /** A widget that represents a phone dialpad, with numbers and letters associated. - @author Jérémy Quentin <jeremy.quentin@gmail.com> + @author Jérémy Quentin <jeremy.quentin@gmail.com> */ class Dialpad : public QWidget { Q_OBJECT private: - QGridLayout * gridLayout; - QPushButton * pushButton_0; - QPushButton * pushButton_1; - QPushButton * pushButton_2; - QPushButton * pushButton_3; - QPushButton * pushButton_4; - QPushButton * pushButton_5; - QPushButton * pushButton_6; - QPushButton * pushButton_7; - QPushButton * pushButton_8; - QPushButton * pushButton_9; - QPushButton * pushButton_diese; - QPushButton * pushButton_etoile; + QGridLayout * gridLayout; + QPushButton * pushButton_0; + QPushButton * pushButton_1; + QPushButton * pushButton_2; + QPushButton * pushButton_3; + QPushButton * pushButton_4; + QPushButton * pushButton_5; + QPushButton * pushButton_6; + QPushButton * pushButton_7; + QPushButton * pushButton_8; + QPushButton * pushButton_9; + QPushButton * pushButton_diese; + QPushButton * pushButton_etoile; public: Dialpad(QWidget *parent = 0); @@ -55,28 +55,28 @@ public: // ~Dialpad(); private: - void fillButtons(); + void fillButtons(); private slots: - void on_pushButton_1_clicked(); - void on_pushButton_2_clicked(); - void on_pushButton_3_clicked(); - void on_pushButton_4_clicked(); - void on_pushButton_5_clicked(); - void on_pushButton_6_clicked(); - void on_pushButton_7_clicked(); - void on_pushButton_8_clicked(); - void on_pushButton_9_clicked(); - void on_pushButton_0_clicked(); - void on_pushButton_diese_clicked(); - void on_pushButton_etoile_clicked(); + void on_pushButton_1_clicked(); + void on_pushButton_2_clicked(); + void on_pushButton_3_clicked(); + void on_pushButton_4_clicked(); + void on_pushButton_5_clicked(); + void on_pushButton_6_clicked(); + void on_pushButton_7_clicked(); + void on_pushButton_8_clicked(); + void on_pushButton_9_clicked(); + void on_pushButton_0_clicked(); + void on_pushButton_diese_clicked(); + void on_pushButton_etoile_clicked(); signals: - /** - * This signal is emitted when the user types a button of the dialpad. - * @param text the text of the button typed by the user. - */ - void typed(QString text); + /** + * This signal is emitted when the user types a button of the dialpad. + * @param text the text of the button typed by the user. + */ + void typed(QString text); }; #endif diff --git a/sflphone-client-kde/src/Item.h b/sflphone-client-kde/src/Item.h index ed1063d6bac0e2203ca01581c7490808e2068d11..7d8829af6907da4fa5b5725fd2382c7b2cf2ddb2 100644 --- a/sflphone-client-kde/src/Item.h +++ b/sflphone-client-kde/src/Item.h @@ -26,73 +26,73 @@ #include <QWidget> /** - @author Jérémy Quentin <jeremy.quentin@gmail.com> - Represents an item of a list, that is displayed - by an QListWidgetItem with a QWidget inside. - The two objects are contained in this class, but their - initializations are pure virtual. - The template class WIDGET_TYPE should be derived from - QWidget. - The implementation of initItem should call initItemWidget + @author Jérémy Quentin <jeremy.quentin@gmail.com> + Represents an item of a list, that is displayed + by an QListWidgetItem with a QWidget inside. + The two objects are contained in this class, but their + initializations are pure virtual. + The template class WIDGET_TYPE should be derived from + QWidget. + The implementation of initItem should call initItemWidget */ template<class WIDGET_TYPE>class Item { protected: - QListWidgetItem * item; - WIDGET_TYPE * itemWidget; - + QListWidgetItem * item; + WIDGET_TYPE * itemWidget; + public: - /** - * Would be great to take the QListWidget as attribute - * to be able to add the itemWidget to the item in the list. - * For the moment, we have to do it from outside. - */ - Item(/*QListWidget *list=0*/) - { - item = NULL; - itemWidget = NULL; - } - - /** - * Be careful that it is not already deleted by QObject - * Commented for safety reasons... - */ - virtual ~Item() - { -// delete item; -// delete itemWidget; - } - - QListWidgetItem * getItem() - { - return item; - } - - WIDGET_TYPE * getItemWidget() - { - return itemWidget; - } - - const QListWidgetItem * getItem() const - { - return item; - } - const WIDGET_TYPE * getItemWidget() const - { - return itemWidget; - } - - /** - * Initializes the item and widget - * Implementation should call initItemWidget! - */ - virtual void initItem() = 0; - + /** + * Would be great to take the QListWidget as attribute + * to be able to add the itemWidget to the item in the list. + * For the moment, we have to do it from outside. + */ + Item(/*QListWidget *list=0*/) + { + item = NULL; + itemWidget = NULL; + } + + /** + * Be careful that it is not already deleted by QObject + * Commented for safety reasons... + */ + virtual ~Item() + { +// delete item; +// delete itemWidget; + } + + QListWidgetItem * getItem() + { + return item; + } + + WIDGET_TYPE * getItemWidget() + { + return itemWidget; + } + + const QListWidgetItem * getItem() const + { + return item; + } + const WIDGET_TYPE * getItemWidget() const + { + return itemWidget; + } + + /** + * Initializes the item and widget + * Implementation should call initItemWidget! + */ + virtual void initItem() = 0; + protected: - virtual void initItemWidget() = 0; - - + virtual void initItemWidget() = 0; + + }; #endif diff --git a/sflphone-client-kde/src/SFLPhone.cpp b/sflphone-client-kde/src/SFLPhone.cpp index 9e4332e80617216c070306f94e00397d65d198ce..ca976212f0cb86e3aa13a1cbc7856499db56d13f 100644 --- a/sflphone-client-kde/src/SFLPhone.cpp +++ b/sflphone-client-kde/src/SFLPhone.cpp @@ -24,7 +24,7 @@ #include <unistd.h> #include <KApplication> #include <KStandardAction> -#include <KMenuBar> +//#include <KMenuBar> #include <KMenu> #include <KAction> #include <KToolBar> @@ -52,8 +52,7 @@ SFLPhone::~SFLPhone() bool SFLPhone::initialize() { - if ( initialized_ ) - { + if ( initialized_ ) { qDebug() << "Already initialized."; return false; } @@ -85,13 +84,11 @@ bool SFLPhone::initialize() view->loadWindow(); move(QCursor::pos().x() - geometry().width()/2, QCursor::pos().y() - geometry().height()/2); - if( ! configurationManager.isStartHidden()) - { + if( ! configurationManager.isStartHidden()) { show(); } - if(configurationManager.getAccountList().value().isEmpty()) - { + if(configurationManager.getAccountList().value().isEmpty()) { (new AccountWizard())->show(); } @@ -109,124 +106,128 @@ void SFLPhone::setObjectNames() void SFLPhone::setupActions() { - qDebug() << "setupActions"; - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - - action_accept = new KAction(this); - action_refuse = new KAction(this); - action_hold = new KAction(this); - action_transfer = new KAction(this); - action_record = new KAction(this); - action_mailBox = new KAction(this); - - action_screen = new QActionGroup(this); - action_screen->setExclusive(true); - action_main = new KAction(KIcon(QIcon(ICON_SCREEN_MAIN)), i18n("Main screen"), action_screen); - action_history = new KAction(KIcon(QIcon(ICON_SCREEN_HISTORY)), i18n("Call history"), action_screen); - action_addressBook = new KAction(KIcon(QIcon(ICON_SCREEN_ADDRESS)), i18n("Address book"), action_screen); - action_main->setCheckable(true); - action_history->setCheckable(true); - action_addressBook->setCheckable(true); - action_main->setChecked(true); - action_screen->addAction(action_main); - action_screen->addAction(action_history); - action_screen->addAction(action_addressBook); - - action_close = KStandardAction::close(this, SLOT(close()), this); - action_quit = KStandardAction::quit(this, SLOT(quitButton()), this); - - action_configureSflPhone = KStandardAction::preferences(view, SLOT(configureSflPhone()), this); - action_configureSflPhone->setText(i18n("Configure SFLphone")); - - action_displayVolumeControls = new KAction(KIcon(QIcon(ICON_DISPLAY_VOLUME_CONSTROLS)), i18n("Display volume controls"), this); - action_displayDialpad = new KAction(KIcon(QIcon(ICON_DISPLAY_DIALPAD)), i18n("Display dialpad"), this); - action_displayDialpad->setCheckable(true); - - action_displayVolumeControls->setCheckable(true); - action_displayVolumeControls->setChecked(configurationManager.getVolumeControls()); - action_displayDialpad->setChecked(configurationManager.getDialpad()); - action_accountCreationWizard = new KAction(i18n("Account creation wizard"), this); - - connect(action_accept, SIGNAL(triggered()), view, SLOT(accept())); - connect(action_refuse, SIGNAL(triggered()), view, SLOT(refuse())); - connect(action_hold, SIGNAL(triggered()), view, SLOT(hold())); - connect(action_transfer, SIGNAL(triggered()), view, SLOT(transfer())); - connect(action_record, SIGNAL(triggered()), view, SLOT(record())); - connect(action_screen, SIGNAL(triggered(QAction *)), this, SLOT(updateScreen(QAction *))); - connect(action_mailBox, SIGNAL(triggered()), view, SLOT(mailBox())); - connect(action_displayVolumeControls, SIGNAL(triggered()), view, SLOT(displayVolumeControls())); - connect(action_displayDialpad, SIGNAL(triggered()), view, SLOT(displayDialpad())); - connect(action_accountCreationWizard, SIGNAL(triggered()), view, SLOT(accountCreationWizard())); - - action_screen->addAction(action_main); - action_screen->addAction(action_history); - action_screen->addAction(action_addressBook); - - actionCollection()->addAction("action_accept", action_accept); - actionCollection()->addAction("action_refuse", action_refuse); - actionCollection()->addAction("action_hold", action_hold); - actionCollection()->addAction("action_transfer", action_transfer); - actionCollection()->addAction("action_record", action_record); - actionCollection()->addAction("action_main", action_main); - actionCollection()->addAction("action_history", action_history); - actionCollection()->addAction("action_addressBook", action_addressBook); - actionCollection()->addAction("action_mailBox", action_mailBox); - actionCollection()->addAction("action_close", action_close); - actionCollection()->addAction("action_quit", action_quit); - - actionCollection()->addAction("action_displayVolumeControls", action_displayVolumeControls); - actionCollection()->addAction("action_displayDialpad", action_displayDialpad); - actionCollection()->addAction("action_configureSflPhone", action_configureSflPhone); - actionCollection()->addAction("action_accountCreationWizard", action_accountCreationWizard); - - QString rcFilePath = QString(DATA_INSTALL_DIR) + "/sflphone-client-kde/sflphone-client-kdeui.rc"; - - if(! QFile::exists(rcFilePath)) - { - QDir dir; - dir.cdUp(); - dir.cd("data"); - rcFilePath = dir.filePath("sflphone-client-kdeui.rc"); - qDebug() << "rcFilePath = " << rcFilePath ; - - if(! QFile::exists(rcFilePath)) - { - QDir dir; - dir.cdUp(); - dir.cdUp(); - dir.cd("data"); - rcFilePath = dir.filePath("sflphone-client-kdeui.rc"); - } - } - qDebug() << "rcFilePath = " << rcFilePath ; - createGUI(rcFilePath); + qDebug() << "setupActions"; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + + action_accept = new KAction(this); + action_refuse = new KAction(this); + action_hold = new KAction(this); + action_transfer = new KAction(this); + action_record = new KAction(this); + action_mailBox = new KAction(this); + + action_accept->setShortcut(Qt::CTRL + Qt::Key_A); + action_refuse->setShortcut(Qt::CTRL + Qt::Key_D); + action_hold->setShortcut(Qt::CTRL + Qt::Key_H); + action_transfer->setShortcut(Qt::CTRL + Qt::Key_T); + action_record->setShortcut(Qt::CTRL + Qt::Key_R); + action_mailBox->setShortcut(Qt::CTRL + Qt::Key_M); + + action_screen = new QActionGroup(this); + action_screen->setExclusive(true); + action_main = new KAction(KIcon(QIcon(ICON_SCREEN_MAIN)), i18n("Main screen"), action_screen); + action_history = new KAction(KIcon(QIcon(ICON_SCREEN_HISTORY)), i18n("Call history"), action_screen); + action_addressBook = new KAction(KIcon(QIcon(ICON_SCREEN_ADDRESS)), i18n("Address book"), action_screen); + action_main->setCheckable(true); + action_history->setCheckable(true); + action_addressBook->setCheckable(true); + action_main->setChecked(true); + action_screen->addAction(action_main); + action_screen->addAction(action_history); + action_screen->addAction(action_addressBook); + + action_close = KStandardAction::close(this, SLOT(close()), this); + action_quit = KStandardAction::quit(this, SLOT(quitButton()), this); + + action_configureSflPhone = KStandardAction::preferences(view, SLOT(configureSflPhone()), this); + action_configureSflPhone->setText(i18n("Configure SFLphone")); + + action_displayVolumeControls = new KAction(KIcon(QIcon(ICON_DISPLAY_VOLUME_CONSTROLS)), i18n("Display volume controls"), this); + action_displayDialpad = new KAction(KIcon(QIcon(ICON_DISPLAY_DIALPAD)), i18n("Display dialpad"), this); + action_displayDialpad->setCheckable(true); + + action_displayVolumeControls->setCheckable(true); + action_displayVolumeControls->setChecked(configurationManager.getVolumeControls()); + action_displayDialpad->setChecked(configurationManager.getDialpad()); + action_accountCreationWizard = new KAction(i18n("Account creation wizard"), this); + + connect(action_accept, SIGNAL(triggered()), view, SLOT(accept())); + connect(action_refuse, SIGNAL(triggered()), view, SLOT(refuse())); + connect(action_hold, SIGNAL(triggered()), view, SLOT(hold())); + connect(action_transfer, SIGNAL(triggered()), view, SLOT(transfer())); + connect(action_record, SIGNAL(triggered()), view, SLOT(record())); + connect(action_screen, SIGNAL(triggered(QAction *)), this, SLOT(updateScreen(QAction *))); + connect(action_mailBox, SIGNAL(triggered()), view, SLOT(mailBox())); + connect(action_displayVolumeControls, SIGNAL(triggered()), view, SLOT(displayVolumeControls())); + connect(action_displayDialpad, SIGNAL(triggered()), view, SLOT(displayDialpad())); + connect(action_accountCreationWizard, SIGNAL(triggered()), view, SLOT(accountCreationWizard())); + + action_screen->addAction(action_main); + action_screen->addAction(action_history); + action_screen->addAction(action_addressBook); + + actionCollection()->addAction("action_accept", action_accept); + actionCollection()->addAction("action_refuse", action_refuse); + actionCollection()->addAction("action_hold", action_hold); + actionCollection()->addAction("action_transfer", action_transfer); + actionCollection()->addAction("action_record", action_record); + actionCollection()->addAction("action_main", action_main); + actionCollection()->addAction("action_history", action_history); + actionCollection()->addAction("action_addressBook", action_addressBook); + actionCollection()->addAction("action_mailBox", action_mailBox); + actionCollection()->addAction("action_close", action_close); + actionCollection()->addAction("action_quit", action_quit); + + actionCollection()->addAction("action_displayVolumeControls", action_displayVolumeControls); + actionCollection()->addAction("action_displayDialpad", action_displayDialpad); + actionCollection()->addAction("action_configureSflPhone", action_configureSflPhone); + actionCollection()->addAction("action_accountCreationWizard", action_accountCreationWizard); + + QString rcFilePath = QString(DATA_INSTALL_DIR) + "/sflphone-client-kde/sflphone-client-kdeui.rc"; + + if(! QFile::exists(rcFilePath)) { + QDir dir; + dir.cdUp(); + dir.cd("data"); + rcFilePath = dir.filePath("sflphone-client-kdeui.rc"); + qDebug() << "rcFilePath = " << rcFilePath ; + + if(! QFile::exists(rcFilePath)) { + QDir dir; + dir.cdUp(); + dir.cdUp(); + dir.cd("data"); + rcFilePath = dir.filePath("sflphone-client-kdeui.rc"); + } + } + qDebug() << "rcFilePath = " << rcFilePath ; + createGUI(rcFilePath); } SFLPhoneView * SFLPhone::getView() { - return view; + return view; } bool SFLPhone::queryClose() { - qDebug() << "queryClose"; - hide(); - return false; + qDebug() << "queryClose"; + hide(); + return false; } void SFLPhone::quitButton() { - InstanceInterface & instance = InstanceInterfaceSingleton::getInstance(); - qDebug() << "quitButton : " << view->callTree->count() << " calls open."; - - if(view->callTree->count() > 0 && instance.getRegistrationCount() <= 1) - { - qDebug() << "Attempting to quit when still having some calls open."; - } - view->saveState(); - instance.Unregister(getpid()); - qApp->quit(); + InstanceInterface & instance = InstanceInterfaceSingleton::getInstance(); + qDebug() << "quitButton : " << view->callTree->count() << " calls open."; + + if(view->callTree->count() > 0 && instance.getRegistrationCount() <= 1) { + qDebug() << "Attempting to quit when still having some calls open."; + } + view->saveState(); + instance.Unregister(getpid()); + qApp->quit(); } void SFLPhone::sendNotif(QString caller) @@ -249,112 +250,110 @@ KNotification::event(KNotification::Notification, "New incomming call", "New cal void SFLPhone::changeEvent(QEvent * event) { - if (event->type() == QEvent::ActivationChange && iconChanged && isActiveWindow()) - { - iconChanged = false; - } + if (event->type() == QEvent::ActivationChange && iconChanged && isActiveWindow()) { + iconChanged = false; + } } void SFLPhone::on_view_statusMessageChangeAsked(const QString & message) { - qDebug() << "on_view_statusMessageChangeAsked : " + message; - statusBarWidget->setText(message); + qDebug() << "on_view_statusMessageChangeAsked : " + message; + statusBarWidget->setText(message); } void SFLPhone::on_view_windowTitleChangeAsked(const QString & message) { - qDebug() << "on_view_windowTitleChangeAsked : " + message; - setWindowTitle(message); + qDebug() << "on_view_windowTitleChangeAsked : " + message; + setWindowTitle(message); } void SFLPhone::on_view_enabledActionsChangeAsked(const bool * enabledActions) { - qDebug() << "on_view_enabledActionsChangeAsked"; - action_accept->setEnabled(enabledActions[SFLPhone::Accept]); - action_refuse->setEnabled(enabledActions[SFLPhone::Refuse]); - action_hold->setEnabled(enabledActions[SFLPhone::Hold]); - action_transfer->setEnabled(enabledActions[SFLPhone::Transfer]); - action_record->setEnabled(enabledActions[SFLPhone::Record]); - action_mailBox->setEnabled(enabledActions[SFLPhone::Mailbox]); + qDebug() << "on_view_enabledActionsChangeAsked"; + action_accept->setEnabled(enabledActions[SFLPhone::Accept]); + action_refuse->setEnabled(enabledActions[SFLPhone::Refuse]); + action_hold->setEnabled(enabledActions[SFLPhone::Hold]); + action_transfer->setEnabled(enabledActions[SFLPhone::Transfer]); + action_record->setEnabled(enabledActions[SFLPhone::Record]); + action_mailBox->setEnabled(enabledActions[SFLPhone::Mailbox]); } void SFLPhone::on_view_actionIconsChangeAsked(const QString * actionIcons) { - qDebug() << "on_view_actionIconsChangeAsked"; - action_accept->setIcon(QIcon(actionIcons[SFLPhone::Accept])); - action_refuse->setIcon(QIcon(actionIcons[SFLPhone::Refuse])); - action_hold->setIcon(QIcon(actionIcons[SFLPhone::Hold])); - action_transfer->setIcon(QIcon(actionIcons[SFLPhone::Transfer])); - action_record->setIcon(QIcon(actionIcons[SFLPhone::Record])); - action_mailBox->setIcon(QIcon(actionIcons[SFLPhone::Mailbox])); + qDebug() << "on_view_actionIconsChangeAsked"; + action_accept->setIcon(QIcon(actionIcons[SFLPhone::Accept])); + action_refuse->setIcon(QIcon(actionIcons[SFLPhone::Refuse])); + action_hold->setIcon(QIcon(actionIcons[SFLPhone::Hold])); + action_transfer->setIcon(QIcon(actionIcons[SFLPhone::Transfer])); + action_record->setIcon(QIcon(actionIcons[SFLPhone::Record])); + action_mailBox->setIcon(QIcon(actionIcons[SFLPhone::Mailbox])); } void SFLPhone::on_view_actionTextsChangeAsked(const QString * actionTexts) { - qDebug() << "on_view_actionTextsChangeAsked"; - action_accept->setText(actionTexts[SFLPhone::Accept]); - action_refuse->setText(actionTexts[SFLPhone::Refuse]); - action_hold->setText(actionTexts[SFLPhone::Hold]); - action_transfer->setText(actionTexts[SFLPhone::Transfer]); - action_record->setText(actionTexts[SFLPhone::Record]); - action_mailBox->setText(actionTexts[SFLPhone::Mailbox]); + qDebug() << "on_view_actionTextsChangeAsked"; + action_accept->setText(actionTexts[SFLPhone::Accept]); + action_refuse->setText(actionTexts[SFLPhone::Refuse]); + action_hold->setText(actionTexts[SFLPhone::Hold]); + action_transfer->setText(actionTexts[SFLPhone::Transfer]); + action_record->setText(actionTexts[SFLPhone::Record]); + action_mailBox->setText(actionTexts[SFLPhone::Mailbox]); } void SFLPhone::on_view_transferCheckStateChangeAsked(bool transferCheckState) { - qDebug() << "Changing transfer action checkState"; - action_transfer->setChecked(transferCheckState); + qDebug() << "Changing transfer action checkState"; + action_transfer->setChecked(transferCheckState); } void SFLPhone::on_view_recordCheckStateChangeAsked(bool recordCheckState) { - qDebug() << "Changing record action checkState"; - action_record->setChecked(recordCheckState); + qDebug() << "Changing record action checkState"; + action_record->setChecked(recordCheckState); } void SFLPhone::updateScreen(QAction * action) { - if(action == action_main) view->changeScreen(SCREEN_MAIN); - else if(action == action_history) view->changeScreen(SCREEN_HISTORY); - else if(action == action_addressBook) view->changeScreen(SCREEN_ADDRESS); + if(action == action_main) view->changeScreen(SCREEN_MAIN); + else if(action == action_history) view->changeScreen(SCREEN_HISTORY); + else if(action == action_addressBook) view->changeScreen(SCREEN_ADDRESS); } void SFLPhone::on_view_screenChanged(int screen) { - qDebug() << "on_view_screenChanged"; - if(screen == SCREEN_MAIN) action_main->setChecked(true); - else if(screen == SCREEN_HISTORY) action_history->setChecked(true); - else if(screen == SCREEN_ADDRESS) action_addressBook->setChecked(true); + qDebug() << "on_view_screenChanged"; + if(screen == SCREEN_MAIN) action_main->setChecked(true); + else if(screen == SCREEN_HISTORY) action_history->setChecked(true); + else if(screen == SCREEN_ADDRESS) action_addressBook->setChecked(true); } QList <QAction *> SFLPhone::getCallActions() { - QList<QAction *> callActions = QList<QAction *>(); - callActions.insert((int) Accept, action_accept); - callActions.insert((int) Refuse, action_refuse); - callActions.insert((int) Hold, action_hold); - callActions.insert((int)Transfer, action_transfer); - callActions.insert((int) Record, action_record); - callActions.insert((int) Mailbox, action_mailBox); - return callActions; + QList<QAction *> callActions = QList<QAction *>(); + callActions.insert((int) Accept, action_accept); + callActions.insert((int) Refuse, action_refuse); + callActions.insert((int) Hold, action_hold); + callActions.insert((int)Transfer, action_transfer); + callActions.insert((int) Record, action_record); + callActions.insert((int) Mailbox, action_mailBox); + return callActions; } void SFLPhone::on_view_incomingCall(const Call * call) { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); //trayIconSignal(); /*if(configurationManager.popupMode()) - { - putForeground(); + { + putForeground(); }*/ - if(configurationManager.getNotify()) - { - sendNotif(call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() : call->getPeerName()); - } + if(configurationManager.getNotify()) { + sendNotif(call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() : call->getPeerName()); + } } void SFLPhone::on_view_addressBookEnableAsked(bool enabled) { - action_addressBook->setVisible(enabled); + action_addressBook->setVisible(enabled); } diff --git a/sflphone-client-kde/src/SFLPhone.h b/sflphone-client-kde/src/SFLPhone.h index b9a467727cf9746f3a6c8b26a6a07f907e18b02b..929d7fcce44dc1d9522a5ef41f11b59ef3ca3a5a 100644 --- a/sflphone-client-kde/src/SFLPhone.h +++ b/sflphone-client-kde/src/SFLPhone.h @@ -74,66 +74,66 @@ enum CallAction { private: // Whether or not the object has been initialized bool initialized_; - KAction * action_accept; - KAction * action_refuse; - KAction * action_hold; - KAction * action_transfer; - KAction * action_record; - QActionGroup * action_screen; - KAction * action_main; - KAction * action_history; - KAction * action_addressBook; - KAction * action_mailBox; - KAction * action_close; - KAction * action_quit; - KAction * action_displayVolumeControls; - KAction * action_displayDialpad; - KAction * action_configureSflPhone; - KAction * action_accountCreationWizard; - - SFLPhoneView * view; - QMenu *trayIconMenu; - bool iconChanged; - SFLPhoneTray *trayIcon; - KNotification *notification; - QLabel * statusBarWidget; - + KAction * action_accept; + KAction * action_refuse; + KAction * action_hold; + KAction * action_transfer; + KAction * action_record; + QActionGroup * action_screen; + KAction * action_main; + KAction * action_history; + KAction * action_addressBook; + KAction * action_mailBox; + KAction * action_close; + KAction * action_quit; + KAction * action_displayVolumeControls; + KAction * action_displayDialpad; + KAction * action_configureSflPhone; + KAction * action_accountCreationWizard; + + SFLPhoneView * view; + QMenu *trayIconMenu; + bool iconChanged; + SFLPhoneTray *trayIcon; + KNotification *notification; + QLabel * statusBarWidget; + private: - void setObjectNames(); + void setObjectNames(); protected: - virtual bool queryClose(); - virtual void changeEvent(QEvent * event); - + virtual bool queryClose(); + virtual void changeEvent(QEvent * event); + public: - SFLPhone(QWidget *parent = 0); - ~SFLPhone(); + SFLPhone(QWidget *parent = 0); + ~SFLPhone(); bool initialize(); - void setupActions(); - void sendNotif(QString caller); - void trayIconSignal(); - SFLPhoneView * getView(); - QList<QAction *> getCallActions(); - - friend class SFLPhoneView; - - + void setupActions(); + void sendNotif(QString caller); + void trayIconSignal(); + SFLPhoneView * getView(); + QList<QAction *> getCallActions(); + + friend class SFLPhoneView; + + private slots: - void on_view_statusMessageChangeAsked(const QString & message); - void on_view_windowTitleChangeAsked(const QString & message); - void on_view_enabledActionsChangeAsked(const bool * enabledActions); - void on_view_actionIconsChangeAsked(const QString * actionIcons); - void on_view_actionTextsChangeAsked(const QString * actionTexts); - void on_view_transferCheckStateChangeAsked(bool transferCheckState); - void on_view_recordCheckStateChangeAsked(bool recordCheckState); - void on_view_addressBookEnableAsked(bool enabled); - void on_view_screenChanged(int screen); - void on_view_incomingCall(const Call * call); - - void updateScreen(QAction * action); - - void quitButton(); + void on_view_statusMessageChangeAsked(const QString & message); + void on_view_windowTitleChangeAsked(const QString & message); + void on_view_enabledActionsChangeAsked(const bool * enabledActions); + void on_view_actionIconsChangeAsked(const QString * actionIcons); + void on_view_actionTextsChangeAsked(const QString * actionTexts); + void on_view_transferCheckStateChangeAsked(bool transferCheckState); + void on_view_recordCheckStateChangeAsked(bool recordCheckState); + void on_view_addressBookEnableAsked(bool enabled); + void on_view_screenChanged(int screen); + void on_view_incomingCall(const Call * call); + + void updateScreen(QAction * action); + + void quitButton(); }; diff --git a/sflphone-client-kde/src/SFLPhoneTray.cpp b/sflphone-client-kde/src/SFLPhoneTray.cpp index 6b8b4763bc06b730c74ac6247650cf07821b46a8..aa4410ee54cbc7494d884847d520e45f2beb7d41 100644 --- a/sflphone-client-kde/src/SFLPhoneTray.cpp +++ b/sflphone-client-kde/src/SFLPhoneTray.cpp @@ -1,32 +1,32 @@ /************************************** ************************************* - * Copyright (C) 2009 by Savoir-Faire Linux * - * Author : Jérémy Quentin * - * jeremy.quentin@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 3 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ +* Copyright (C) 2009 by Savoir-Faire Linux * +* Author : Jérémy Quentin * +* jeremy.quentin@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 3 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., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ #include <QDebug> #include "SFLPhoneTray.h" SFLPhoneTray::SFLPhoneTray(QIcon icon, QWidget *parent) - : KSystemTrayIcon(icon, parent), - initialized_(false), - trayIconMenu(0) + : KSystemTrayIcon(icon, parent), + initialized_(false), + trayIconMenu(0) { } @@ -36,28 +36,27 @@ SFLPhoneTray::~SFLPhoneTray() bool SFLPhoneTray::initialize() { - if ( initialized_ ) - { - qDebug() << "Already initialized."; - return false; - } + if ( initialized_ ) { + qDebug() << "Already initialized."; + return false; + } - trayIconMenu = new QMenu(parentWidget()); - setContextMenu(trayIconMenu); + trayIconMenu = new QMenu(parentWidget()); + setContextMenu(trayIconMenu); - setupActions(); + setupActions(); - initialized_ = true; + initialized_ = true; - return true; + return true; } void SFLPhoneTray::addAction(KAction *action) { - trayIconMenu->addAction(action); + trayIconMenu->addAction(action); } void SFLPhoneTray::setupActions() { - qDebug() << "setupActions"; + qDebug() << "setupActions"; } diff --git a/sflphone-client-kde/src/SFLPhoneTray.h b/sflphone-client-kde/src/SFLPhoneTray.h index 35a5f09fae8e1e4210146ea256e2caccc689ea8a..bca6e14cb813cedbd94c390cd47cee575219b6c9 100644 --- a/sflphone-client-kde/src/SFLPhoneTray.h +++ b/sflphone-client-kde/src/SFLPhoneTray.h @@ -1,23 +1,23 @@ /*************************************************************************** - * Copyright (C) 2009 by Savoir-Faire Linux * - * Author : Jérémy Quentin * - * jeremy.quentin@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 3 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., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ +* Copyright (C) 2009 by Savoir-Faire Linux * +* Author : Jérémy Quentin * +* jeremy.quentin@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 3 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., * +* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * +***************************************************************************/ #ifndef SFLPHONETRAY_H #define SFLPHONETRAY_H @@ -32,15 +32,15 @@ class SFLPhoneTray : public KSystemTrayIcon Q_OBJECT public: - SFLPhoneTray(QIcon icon, QWidget *parent = 0); - ~SFLPhoneTray(); - bool initialize(); - void setupActions(); - void addAction(KAction *action); + SFLPhoneTray(QIcon icon, QWidget *parent = 0); + ~SFLPhoneTray(); + bool initialize(); + void setupActions(); + void addAction(KAction *action); private: - QMenu *trayIconMenu; - bool initialized_; + QMenu *trayIconMenu; + bool initialized_; }; #endif // SFLPHONETRAY_H diff --git a/sflphone-client-kde/src/SFLPhoneView.cpp b/sflphone-client-kde/src/SFLPhoneView.cpp index 16b8355e369b2aca7c4ab781c2af252d972827f1..0c4507df21fb60f54ca3adbe94eb5356e7daacb8 100644 --- a/sflphone-client-kde/src/SFLPhoneView.cpp +++ b/sflphone-client-kde/src/SFLPhoneView.cpp @@ -60,90 +60,87 @@ AccountList * SFLPhoneView::accountList; QString SFLPhoneView::priorAccountId; SFLPhoneView::SFLPhoneView(QWidget *parent) - : QWidget(parent) -{ - setupUi(this); - - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - - errorWindow = new QErrorMessage(this); - - callList = & CallListInterfaceSingleton::getInstance(); //CallList(this); - - callTree = new CallTreeView(page_callList); - historyTree = new CallTreeView(page_callHistory); - - page_callList->layout()->addWidget(callTree); - page_callHistory->layout()->addWidget(historyTree); - - historyLoaded = false; - - for(int i = 0 ; i < callList->size() ; i++) - { - Call * call = (*callList)[i]; - if(call->getState() == CALL_STATE_OVER) - { - addCallToCallHistory(call); - } - else - { - addCallToCallList(call); - } - } - - accountList = new AccountList(false); - accountList->updateAccounts(); - - configDialog = new ConfigurationDialog(this); - configDialog->setObjectName("configDialog"); - configDialog->setModal(true); - - wizard = new AccountWizard(this); - wizard->setModal(false); - - QPalette pal = QPalette(palette()); - pal.setColor(QPalette::AlternateBase, Qt::lightGray); - setPalette(pal); - - stackedWidget_screen->setCurrentWidget(page_callList); - - connect(&callManager, SIGNAL(callStateChanged(const QString &, const QString &)), - this, SLOT(on1_callStateChanged(const QString &, const QString &))); - connect(&callManager, SIGNAL(incomingCall(const QString &, const QString &, const QString &)), - this, SLOT(on1_incomingCall(const QString &, const QString &))); - connect(&callManager, SIGNAL(incomingMessage(const QString &, const QString &)), - this, SLOT(on1_incomingMessage(const QString &, const QString &))); - connect(&callManager, SIGNAL(voiceMailNotify(const QString &, int)), - this, SLOT(on1_voiceMailNotify(const QString &, int))); - connect(&callManager, SIGNAL(volumeChanged(const QString &, double)), - this, SLOT(on1_volumeChanged(const QString &, double))); - - connect(&configurationManager, SIGNAL(accountsChanged()), - accountList, SLOT(updateAccounts())); - - connect(&configurationManager, SIGNAL(audioManagerChanged()), - this, SLOT(on1_audioManagerChanged())); - - connect(configDialog, SIGNAL(clearCallHistoryAsked()), - callList, SLOT(clearHistory())); - - connect(configDialog, SIGNAL(changesApplied()), - this, SLOT(loadWindow())); - - connect(accountList, SIGNAL(accountListUpdated()), - this, SLOT(updateStatusMessage())); - connect(accountList, SIGNAL(accountListUpdated()), - this, SLOT(updateWindowCallState())); - - connect(callTree, SIGNAL(itemChanged()), //currentItemChanged - this, SLOT(on_callTree_currentItemChanged())); - connect(callTree, SIGNAL(itemChanged()), //ITem changed - this, SLOT(on_callTree_itemChanged())); - connect(callTree, SIGNAL(doubleClicked(const QModelIndex &)), - this, SLOT(on_callTree_itemDoubleClicked(const QModelIndex&))); + : QWidget(parent) +{ + setupUi(this); + + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + + errorWindow = new QErrorMessage(this); + + callList = & CallListInterfaceSingleton::getInstance(); //CallList(this); + + callTree = new CallTreeView(page_callList); + historyTree = new CallTreeView(page_callHistory); + + page_callList->layout()->addWidget(callTree); + page_callHistory->layout()->addWidget(historyTree); + + historyLoaded = false; + + for(int i = 0 ; i < callList->size() ; i++) { + Call * call = (*callList)[i]; + if(call->getState() == CALL_STATE_OVER) { + addCallToCallHistory(call); + } + else { + addCallToCallList(call); + } + } + + accountList = new AccountList(false); + accountList->updateAccounts(); + + configDialog = new ConfigurationDialog(this); + configDialog->setObjectName("configDialog"); + configDialog->setModal(true); + + wizard = new AccountWizard(this); + wizard->setModal(false); + + QPalette pal = QPalette(palette()); + pal.setColor(QPalette::AlternateBase, Qt::lightGray); + setPalette(pal); + + stackedWidget_screen->setCurrentWidget(page_callList); + + connect(&callManager, SIGNAL(callStateChanged(const QString &, const QString &)), + this, SLOT(on1_callStateChanged(const QString &, const QString &))); + connect(&callManager, SIGNAL(incomingCall(const QString &, const QString &, const QString &)), + this, SLOT(on1_incomingCall(const QString &, const QString &))); + connect(&callManager, SIGNAL(incomingMessage(const QString &, const QString &)), + this, SLOT(on1_incomingMessage(const QString &, const QString &))); + connect(&callManager, SIGNAL(voiceMailNotify(const QString &, int)), + this, SLOT(on1_voiceMailNotify(const QString &, int))); + connect(&callManager, SIGNAL(volumeChanged(const QString &, double)), + this, SLOT(on1_volumeChanged(const QString &, double))); + + connect(&configurationManager, SIGNAL(accountsChanged()), + accountList, SLOT(updateAccounts())); + + connect(&configurationManager, SIGNAL(audioManagerChanged()), + this, SLOT(on1_audioManagerChanged())); + + connect(configDialog, SIGNAL(clearCallHistoryAsked()), + callList, SLOT(clearHistory())); + + connect(configDialog, SIGNAL(changesApplied()), + this, SLOT(loadWindow())); + + connect(accountList, SIGNAL(accountListUpdated()), + this, SLOT(updateStatusMessage())); + connect(accountList, SIGNAL(accountListUpdated()), + this, SLOT(updateWindowCallState())); + + connect(callTree, SIGNAL(itemChanged()), //currentItemChanged + this, SLOT(on_callTree_currentItemChanged())); + connect(callTree, SIGNAL(itemChanged()), //ITem changed + this, SLOT(on_callTree_itemChanged())); + connect(callTree, SIGNAL(doubleClicked(const QModelIndex &)), + this, SLOT(on_callTree_itemDoubleClicked(const QModelIndex&))); - + } @@ -154,328 +151,284 @@ SFLPhoneView::~SFLPhoneView() void SFLPhoneView::saveState() { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - configurationManager.setHistory(callList->getHistoryMap()); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + configurationManager.setHistory(callList->getHistoryMap()); } void SFLPhoneView::loadWindow() { - qDebug() << "\nloadWindow"; - updateWindowCallState(); - updateRecordButton(); - updateVolumeButton(); - updateRecordBar(); - updateVolumeBar(); - updateVolumeControls(); - updateDialpad(); - updateSearchHistory(); - updateAddressBookEnabled(); - updateAddressBook(); - updateStatusMessage(); - qDebug() << "Finished loadWindow\n"; + qDebug() << "\nloadWindow"; + updateWindowCallState(); + updateRecordButton(); + updateVolumeButton(); + updateRecordBar(); + updateVolumeBar(); + updateVolumeControls(); + updateDialpad(); + updateSearchHistory(); + updateAddressBookEnabled(); + updateAddressBook(); + updateStatusMessage(); + qDebug() << "Finished loadWindow\n"; } Account * SFLPhoneView::accountInUse() { - Account * priorAccount = accountList->getAccountById(priorAccountId); - if(priorAccount && priorAccount->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED ) - { - return priorAccount; - } - else - { - return accountList->firstRegisteredAccount(); - } + Account * priorAccount = accountList->getAccountById(priorAccountId); + if(priorAccount && priorAccount->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED ) { + return priorAccount; + } + else { + return accountList->firstRegisteredAccount(); + } } QString SFLPhoneView::accountInUseId() { - Account * firstRegistered = accountInUse(); - if(firstRegistered == NULL) - { - return QString(); - } - else - { - return firstRegistered->getAccountId(); - } + Account * firstRegistered = accountInUse(); + if(firstRegistered == NULL) + { + return QString(); + } + else + { + return firstRegistered->getAccountId(); + } } AccountList * SFLPhoneView::getAccountList() { - return accountList; + return accountList; } QErrorMessage * SFLPhoneView::getErrorWindow() { - return errorWindow; + return errorWindow; } CallTreeItem* SFLPhoneView::addCallToCallList(Call * call) -{ - return callTree->insert(call); +{ + return callTree->insert(call); } CallTreeItem* SFLPhoneView::addCallToCallHistory(Call * call) { - return historyTree->insert(call); + return historyTree->insert(call); } void SFLPhoneView::addContactToContactList(Contact * contact) { - QListWidgetItem * item = contact->getItem(); - QWidget * widget = contact->getItemWidget(); - if(item && widget) - { - listWidget_addressBook->addItem(item); - listWidget_addressBook->setItemWidget(item, widget); - } + QListWidgetItem * item = contact->getItem(); + QWidget * widget = contact->getItemWidget(); + if(item && widget) { + listWidget_addressBook->addItem(item); + listWidget_addressBook->setItemWidget(item, widget); + } } void SFLPhoneView::typeString(QString str) { - qDebug() << "typeString"; - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - - if(stackedWidget_screen->currentWidget() == page_callList) - { - CallTreeItem * item = callTree->currentItem(); - callManager.playDTMF(str); - Call *currentCall = 0; - Call *candidate = 0; - - if(item) - { - Call *call = item->call(); - - if (call) - { - if(call->getState() == CALL_STATE_CURRENT) - { - currentCall = call; - } - } - } - - for(int i = callList->size() - 1 ; i >= 0 ; i--) - { - Call *call = (*callList)[i]; - - if(currentCall != call && call->getState() == CALL_STATE_CURRENT) - { - - action(call, CALL_ACTION_HOLD); - } - else if(call->getState() == CALL_STATE_DIALING) - { - candidate = call; - } - } - - if(!currentCall && !candidate) - { - qDebug() << "Typing when no item is selected. Opening an item."; - candidate = callList->addDialingCall(); - addCallToCallList(candidate); - callTree->setCurrentRow(callTree->count() + 1); - } - - if(!currentCall && candidate) - { - candidate->appendText(str); - } - } - if(stackedWidget_screen->currentWidget() == page_callHistory) - { - qDebug() << "In call history."; - lineEdit_searchHistory->setText(lineEdit_searchHistory->text() + str); - lineEdit_searchHistory->setFocus(); - } - if(stackedWidget_screen->currentWidget() == page_addressBook) - { - qDebug() << "In address book."; - lineEdit_addressBook->setText(lineEdit_addressBook->text() + str); - lineEdit_addressBook->setFocus(); - } + qDebug() << "typeString"; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + + if(stackedWidget_screen->currentWidget() == page_callList) { + CallTreeItem * item = callTree->currentItem(); + callManager.playDTMF(str); + Call *currentCall = 0; + Call *candidate = 0; + + if(item) { + Call *call = item->call(); + + if (call) { + if(call->getState() == CALL_STATE_CURRENT) { + currentCall = call; + } + } + } + + for(int i = callList->size() - 1 ; i >= 0 ; i--) + { + Call *call = (*callList)[i]; + + if(currentCall != call && call->getState() == CALL_STATE_CURRENT) { + + action(call, CALL_ACTION_HOLD); + } + else if(call->getState() == CALL_STATE_DIALING) { + candidate = call; + } + } + + if(!currentCall && !candidate) { + qDebug() << "Typing when no item is selected. Opening an item."; + candidate = callList->addDialingCall(); + addCallToCallList(candidate); + callTree->setCurrentRow(callTree->count() + 1); + } + + if(!currentCall && candidate) { + candidate->appendText(str); + } + } + if(stackedWidget_screen->currentWidget() == page_callHistory) { + qDebug() << "In call history."; + lineEdit_searchHistory->setText(lineEdit_searchHistory->text() + str); + lineEdit_searchHistory->setFocus(); + } + if(stackedWidget_screen->currentWidget() == page_addressBook) { + qDebug() << "In address book."; + lineEdit_addressBook->setText(lineEdit_addressBook->text() + str); + lineEdit_addressBook->setFocus(); + } } void SFLPhoneView::backspace() { - qDebug() << "backspace"; - if(stackedWidget_screen->currentWidget() == page_callList) - { - qDebug() << "In call list."; - CallTreeItem * item = callTree->currentItem(); - if(!item) - { - qDebug() << "Backspace when no item is selected. Doing nothing."; - } - else - { - Call * call = callTree->currentItem()->call(); - if(!call) - { - qDebug() << "Error : Backspace on unexisting call."; - } - else - { - call->backspaceItemText(); - if(call->getState() == CALL_STATE_OVER) - { - callTree->removeCurrent(); - - if(call->getHistoryState() != NONE) - { - historyTree->insert(call); - } - } - } - } - } + qDebug() << "backspace"; + if(stackedWidget_screen->currentWidget() == page_callList) { + qDebug() << "In call list."; + CallTreeItem * item = callTree->currentItem(); + if(!item) { + qDebug() << "Backspace when no item is selected. Doing nothing."; + } + else { + Call * call = callTree->currentItem()->call(); + if(!call) { + qDebug() << "Error : Backspace on unexisting call."; + } + else { + call->backspaceItemText(); + if(call->getState() == CALL_STATE_OVER) { + callTree->removeCurrent(); + + if(call->getHistoryState() != NONE) { + historyTree->insert(call); + } + } + } + } + } } void SFLPhoneView::escape() { - qDebug() << "escape"; - if(stackedWidget_screen->currentWidget() == page_callList ) - { - qDebug() << "In call list."; - CallTreeItem * item = callTree->currentItem(); - if(!item) - { - qDebug() << "Escape when no item is selected. Doing nothing."; - } - else - { - Call * call = item->call(); - - if(!call) - { - qDebug() << "Error : Escape on unexisting call."; - } - else - { - if(call->getState() == CALL_STATE_TRANSFER ||call->getState() == CALL_STATE_TRANSF_HOLD) - { - action(call, CALL_ACTION_TRANSFER); - } - else - { - action(call, CALL_ACTION_REFUSE); - } - } - } - } - if(stackedWidget_screen->currentWidget() == page_callHistory) - { - qDebug() << "In call history."; - lineEdit_searchHistory->clear(); - } - if(stackedWidget_screen->currentWidget() == page_addressBook) - { - qDebug() << "In address book."; - lineEdit_addressBook->clear(); - } + qDebug() << "escape"; + if(stackedWidget_screen->currentWidget() == page_callList ) { + qDebug() << "In call list."; + CallTreeItem * item = callTree->currentItem(); + if(!item) { + qDebug() << "Escape when no item is selected. Doing nothing."; + } + else { + Call * call = item->call(); + + if(!call) { + qDebug() << "Error : Escape on unexisting call."; + } + else { + if(call->getState() == CALL_STATE_TRANSFER ||call->getState() == CALL_STATE_TRANSF_HOLD) + { + action(call, CALL_ACTION_TRANSFER); + } + else + { + action(call, CALL_ACTION_REFUSE); + } + } + } + } + if(stackedWidget_screen->currentWidget() == page_callHistory) { + qDebug() << "In call history."; + lineEdit_searchHistory->clear(); + } + if(stackedWidget_screen->currentWidget() == page_addressBook) { + qDebug() << "In address book."; + lineEdit_addressBook->clear(); + } } void SFLPhoneView::enter() { - qDebug() << "enter"; - if(stackedWidget_screen->currentWidget() == page_callList ) - { - qDebug() << "In call list."; - CallTreeItem * item = callTree->currentItem(); - if(!item) - { - qDebug() << "Enter when no item is selected. Doing nothing."; - } - else - { - Call * call = item->call(); - if(!call) - { - qDebug() << "Error : Enter on unexisting call."; - } - else - { - int state = call->getState(); - if(state == CALL_STATE_INCOMING || state == CALL_STATE_DIALING || state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD) - { - action(call, CALL_ACTION_ACCEPT); - } - else - { - qDebug() << "Enter when call selected not in appropriate state. Doing nothing."; - } - } - } - } - if(stackedWidget_screen->currentWidget() == page_callHistory) - { - qDebug() << "In call history."; - CallTreeItem * item = historyTree->currentItem(); - if(!item) - { - qDebug() << "Enter when no item is selected. Doing nothing."; - } - else - { - changeScreen(SCREEN_MAIN); - - Call * pastCall = item->call(); - if (!pastCall) - { - qDebug() << "pastCall null"; - } - Call * call = callList->addDialingCall(pastCall->getPeerName(), pastCall->getAccountId()); - call->appendText(pastCall->getPeerPhoneNumber()); - addCallToCallList(call); - callTree->setCurrentRow(callTree->count() - 1); - action(call, CALL_ACTION_ACCEPT); - } - } - if(stackedWidget_screen->currentWidget() == page_addressBook) - { - qDebug() << "In address book."; - QListWidgetItem * item = listWidget_addressBook->currentItem(); - if(!item) - { - qDebug() << "Enter when no item is selected. Doing nothing."; - } - else - { - changeScreen(SCREEN_MAIN); - ContactItemWidget * w = (ContactItemWidget *) (listWidget_addressBook->itemWidget(item)); - Call * call = callList->addDialingCall(w->getContactName()); - call->appendText(w->getContactNumber()); - addCallToCallList(call); - callTree->setCurrentRow(callTree->count() - 1); - action(call, CALL_ACTION_ACCEPT); - } - } + qDebug() << "enter"; + if(stackedWidget_screen->currentWidget() == page_callList ) { + qDebug() << "In call list."; + CallTreeItem * item = callTree->currentItem(); + if(!item) { + qDebug() << "Enter when no item is selected. Doing nothing."; + } + else { + Call * call = item->call(); + if(!call) { + qDebug() << "Error : Enter on unexisting call."; + } + else { + int state = call->getState(); + if(state == CALL_STATE_INCOMING || state == CALL_STATE_DIALING || state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD) { + action(call, CALL_ACTION_ACCEPT); + } + else { + qDebug() << "Enter when call selected not in appropriate state. Doing nothing."; + } + } + } + } + if(stackedWidget_screen->currentWidget() == page_callHistory) { + qDebug() << "In call history."; + CallTreeItem * item = historyTree->currentItem(); + if(!item) { + qDebug() << "Enter when no item is selected. Doing nothing."; + } + else { + changeScreen(SCREEN_MAIN); + + Call * pastCall = item->call(); + if (!pastCall) + { + qDebug() << "pastCall null"; + } + Call * call = callList->addDialingCall(pastCall->getPeerName(), pastCall->getAccountId()); + call->appendText(pastCall->getPeerPhoneNumber()); + addCallToCallList(call); + callTree->setCurrentRow(callTree->count() - 1); + action(call, CALL_ACTION_ACCEPT); + } + } + if(stackedWidget_screen->currentWidget() == page_addressBook) { + qDebug() << "In address book."; + QListWidgetItem * item = listWidget_addressBook->currentItem(); + if(!item) { + qDebug() << "Enter when no item is selected. Doing nothing."; + } + else { + changeScreen(SCREEN_MAIN); + ContactItemWidget * w = (ContactItemWidget *) (listWidget_addressBook->itemWidget(item)); + Call * call = callList->addDialingCall(w->getContactName()); + call->appendText(w->getContactNumber()); + addCallToCallList(call); + callTree->setCurrentRow(callTree->count() - 1); + action(call, CALL_ACTION_ACCEPT); + } + } } void SFLPhoneView::action(Call * call, call_action action) { - if(! call) - { - qDebug() << "Error : action " << action << "applied on null object call. Should not happen."; - } - else - { - try - { - call->actionPerformed(action); - } - catch(const char * msg) - { - errorWindow->showMessage(QString(msg)); - } - - //updateCallItem(call); - updateWindowCallState(); - } + if(! call) { + qDebug() << "Error : action " << action << "applied on null object call. Should not happen."; + } + else { + try { + call->actionPerformed(action); + } + catch(const char * msg) { + errorWindow->showMessage(QString(msg)); + } + + //updateCallItem(call); + updateWindowCallState(); + } } @@ -485,409 +438,373 @@ void SFLPhoneView::action(Call * call, call_action action) void SFLPhoneView::updateWindowCallState() { - qDebug() << "updateWindowCallState"; - - bool enabledActions[6]= {true,true,true,true,true,true}; - QString buttonIconFiles[6] = {ICON_CALL, ICON_HANGUP, ICON_HOLD, ICON_TRANSFER, ICON_REC_DEL_OFF, ICON_MAILBOX}; - QString actionTexts[6] = {ACTION_LABEL_CALL, ACTION_LABEL_HANG_UP, ACTION_LABEL_HOLD, ACTION_LABEL_TRANSFER, ACTION_LABEL_RECORD, ACTION_LABEL_MAILBOX}; - - CallTreeItem * item; - - bool transfer = false; - bool recordActivated = false; //tells whether the call is in recording position - - enabledActions[SFLPhone::Mailbox] = accountInUse() && ! accountInUse()->getAccountDetail(ACCOUNT_MAILBOX).isEmpty(); - - - if(stackedWidget_screen->currentWidget() == page_callList) - { - item = callTree->currentItem(); - if (!item) - { - qDebug() << "No item selected."; - enabledActions[SFLPhone::Refuse] = false; - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; - enabledActions[SFLPhone::Record] = false; - } - else - { - Call * call = item->call(); - - if (call) - { - call_state state = call->getState(); - recordActivated = call->getRecording(); - - switch (state) - { - case CALL_STATE_INCOMING: - qDebug() << "Reached CALL_STATE_INCOMING with call " << call->getCallId(); - buttonIconFiles[SFLPhone::Accept] = ICON_ACCEPT; - buttonIconFiles[SFLPhone::Refuse] = ICON_REFUSE; - actionTexts[SFLPhone::Accept] = ACTION_LABEL_ACCEPT; - actionTexts[SFLPhone::Refuse] = ACTION_LABEL_REFUSE; - break; - case CALL_STATE_RINGING: - qDebug() << "Reached CALL_STATE_RINGING with call " << call->getCallId(); - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; - break; - case CALL_STATE_CURRENT: - qDebug() << "details = " << CallManagerInterfaceSingleton::getInstance().getCallDetails(call->getCallId()).value(); - qDebug() << "Reached CALL_STATE_CURRENT with call " << call->getCallId(); - buttonIconFiles[SFLPhone::Record] = ICON_REC_DEL_ON; - break; - case CALL_STATE_DIALING: - qDebug() << "Reached CALL_STATE_DIALING with call " << call->getCallId(); - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; - enabledActions[SFLPhone::Record] = false; - actionTexts[SFLPhone::Accept] = ACTION_LABEL_ACCEPT; - buttonIconFiles[SFLPhone::Accept] = ICON_ACCEPT; - break; - case CALL_STATE_HOLD: - qDebug() << "Reached CALL_STATE_HOLD with call " << call->getCallId(); - buttonIconFiles[SFLPhone::Hold] = ICON_UNHOLD; - actionTexts[SFLPhone::Hold] = ACTION_LABEL_UNHOLD; - break; - case CALL_STATE_FAILURE: - qDebug() << "Reached CALL_STATE_FAILURE with call " << call->getCallId(); - enabledActions[SFLPhone::Accept] = false; - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; - enabledActions[SFLPhone::Record] = false; - break; - case CALL_STATE_BUSY: - qDebug() << "Reached CALL_STATE_BUSY with call " << call->getCallId(); - enabledActions[SFLPhone::Accept] = false; - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; - enabledActions[SFLPhone::Record] = false; - break; - case CALL_STATE_TRANSFER: - qDebug() << "Reached CALL_STATE_TRANSFER with call " << call->getCallId(); - buttonIconFiles[SFLPhone::Accept] = ICON_EXEC_TRANSF; - actionTexts[SFLPhone::Transfer] = ACTION_LABEL_GIVE_UP_TRANSF; - transfer = true; - buttonIconFiles[SFLPhone::Record] = ICON_REC_DEL_ON; - break; - case CALL_STATE_TRANSF_HOLD: - qDebug() << "Reached CALL_STATE_TRANSF_HOLD with call " << call->getCallId(); - buttonIconFiles[SFLPhone::Accept] = ICON_EXEC_TRANSF; - buttonIconFiles[SFLPhone::Hold] = ICON_UNHOLD; - actionTexts[SFLPhone::Transfer] = ACTION_LABEL_GIVE_UP_TRANSF; - actionTexts[SFLPhone::Hold] = ACTION_LABEL_UNHOLD; - transfer = true; - break; - case CALL_STATE_OVER: - qDebug() << "Error : Reached CALL_STATE_OVER with call " << call->getCallId() << "!"; - break; - case CALL_STATE_ERROR: - qDebug() << "Error : Reached CALL_STATE_ERROR with call " << call->getCallId() << "!"; - break; - default: - qDebug() << "Error : Reached unexisting state for call " << call->getCallId() << "!"; - break; - } - } - } - } - if(stackedWidget_screen->currentWidget() == page_callHistory) - { - item = historyTree->currentItem(); - buttonIconFiles[SFLPhone::Accept] = ICON_ACCEPT; - actionTexts[SFLPhone::Accept] = ACTION_LABEL_CALL_BACK; - if (!item) - { - qDebug() << "No item selected."; - enabledActions[SFLPhone::Accept] = false; - enabledActions[SFLPhone::Refuse] = false; - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; - enabledActions[SFLPhone::Record] = false; - } - else - { - enabledActions[SFLPhone::Refuse] = false; - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; - enabledActions[SFLPhone::Record] = false; - } - } - if(stackedWidget_screen->currentWidget() == page_addressBook) - { - item = addressBookTree->currentItem(); - buttonIconFiles[SFLPhone::Accept] = ICON_ACCEPT; - if (!item) - { - qDebug() << "No item selected."; - enabledActions[SFLPhone::Accept] = false; - enabledActions[SFLPhone::Refuse] = false; - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; - enabledActions[SFLPhone::Record] = false; - } - else - { - enabledActions[SFLPhone::Refuse] = false; - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; - enabledActions[SFLPhone::Record] = false; - } - } - - qDebug() << "Updating Window."; - - emit enabledActionsChangeAsked(enabledActions); - emit actionIconsChangeAsked(buttonIconFiles); - emit actionTextsChangeAsked(actionTexts); - emit transferCheckStateChangeAsked(transfer); - emit recordCheckStateChangeAsked(recordActivated); - - qDebug() << "Window updated."; + qDebug() << "updateWindowCallState"; + + bool enabledActions[6]= {true,true,true,true,true,true}; + QString buttonIconFiles[6] = {ICON_CALL, ICON_HANGUP, ICON_HOLD, ICON_TRANSFER, ICON_REC_DEL_OFF, ICON_MAILBOX}; + QString actionTexts[6] = {ACTION_LABEL_CALL, ACTION_LABEL_HANG_UP, ACTION_LABEL_HOLD, ACTION_LABEL_TRANSFER, ACTION_LABEL_RECORD, ACTION_LABEL_MAILBOX}; + + CallTreeItem * item; + + bool transfer = false; + bool recordActivated = false; //tells whether the call is in recording position + + enabledActions[SFLPhone::Mailbox] = accountInUse() && ! accountInUse()->getAccountDetail(ACCOUNT_MAILBOX).isEmpty(); + + + if(stackedWidget_screen->currentWidget() == page_callList) { + item = callTree->currentItem(); + if (!item) { + qDebug() << "No item selected."; + enabledActions[SFLPhone::Refuse] = false; + enabledActions[SFLPhone::Hold] = false; + enabledActions[SFLPhone::Transfer] = false; + enabledActions[SFLPhone::Record] = false; + } + else { + Call * call = item->call(); + + if (call) { + call_state state = call->getState(); + recordActivated = call->getRecording(); + + switch (state) { + case CALL_STATE_INCOMING: + qDebug() << "Reached CALL_STATE_INCOMING with call " << call->getCallId(); + buttonIconFiles[SFLPhone::Accept] = ICON_ACCEPT; + buttonIconFiles[SFLPhone::Refuse] = ICON_REFUSE; + actionTexts[SFLPhone::Accept] = ACTION_LABEL_ACCEPT; + actionTexts[SFLPhone::Refuse] = ACTION_LABEL_REFUSE; + break; + case CALL_STATE_RINGING: + qDebug() << "Reached CALL_STATE_RINGING with call " << call->getCallId(); + enabledActions[SFLPhone::Hold] = false; + enabledActions[SFLPhone::Transfer] = false; + break; + case CALL_STATE_CURRENT: + qDebug() << "details = " << CallManagerInterfaceSingleton::getInstance().getCallDetails(call->getCallId()).value(); + qDebug() << "Reached CALL_STATE_CURRENT with call " << call->getCallId(); + buttonIconFiles[SFLPhone::Record] = ICON_REC_DEL_ON; + break; + case CALL_STATE_DIALING: + qDebug() << "Reached CALL_STATE_DIALING with call " << call->getCallId(); + enabledActions[SFLPhone::Hold] = false; + enabledActions[SFLPhone::Transfer] = false; + enabledActions[SFLPhone::Record] = false; + actionTexts[SFLPhone::Accept] = ACTION_LABEL_ACCEPT; + buttonIconFiles[SFLPhone::Accept] = ICON_ACCEPT; + break; + case CALL_STATE_HOLD: + qDebug() << "Reached CALL_STATE_HOLD with call " << call->getCallId(); + buttonIconFiles[SFLPhone::Hold] = ICON_UNHOLD; + actionTexts[SFLPhone::Hold] = ACTION_LABEL_UNHOLD; + break; + case CALL_STATE_FAILURE: + qDebug() << "Reached CALL_STATE_FAILURE with call " << call->getCallId(); + enabledActions[SFLPhone::Accept] = false; + enabledActions[SFLPhone::Hold] = false; + enabledActions[SFLPhone::Transfer] = false; + enabledActions[SFLPhone::Record] = false; + break; + case CALL_STATE_BUSY: + qDebug() << "Reached CALL_STATE_BUSY with call " << call->getCallId(); + enabledActions[SFLPhone::Accept] = false; + enabledActions[SFLPhone::Hold] = false; + enabledActions[SFLPhone::Transfer] = false; + enabledActions[SFLPhone::Record] = false; + break; + case CALL_STATE_TRANSFER: + qDebug() << "Reached CALL_STATE_TRANSFER with call " << call->getCallId(); + buttonIconFiles[SFLPhone::Accept] = ICON_EXEC_TRANSF; + actionTexts[SFLPhone::Transfer] = ACTION_LABEL_GIVE_UP_TRANSF; + transfer = true; + buttonIconFiles[SFLPhone::Record] = ICON_REC_DEL_ON; + break; + case CALL_STATE_TRANSF_HOLD: + qDebug() << "Reached CALL_STATE_TRANSF_HOLD with call " << call->getCallId(); + buttonIconFiles[SFLPhone::Accept] = ICON_EXEC_TRANSF; + buttonIconFiles[SFLPhone::Hold] = ICON_UNHOLD; + actionTexts[SFLPhone::Transfer] = ACTION_LABEL_GIVE_UP_TRANSF; + actionTexts[SFLPhone::Hold] = ACTION_LABEL_UNHOLD; + transfer = true; + break; + case CALL_STATE_OVER: + qDebug() << "Error : Reached CALL_STATE_OVER with call " << call->getCallId() << "!"; + break; + case CALL_STATE_ERROR: + qDebug() << "Error : Reached CALL_STATE_ERROR with call " << call->getCallId() << "!"; + break; + default: + qDebug() << "Error : Reached unexisting state for call " << call->getCallId() << "!"; + break; + } + } + } + } + if(stackedWidget_screen->currentWidget() == page_callHistory) { + item = historyTree->currentItem(); + buttonIconFiles[SFLPhone::Accept] = ICON_ACCEPT; + actionTexts[SFLPhone::Accept] = ACTION_LABEL_CALL_BACK; + if (!item) { + qDebug() << "No item selected."; + enabledActions[SFLPhone::Accept] = false; + enabledActions[SFLPhone::Refuse] = false; + enabledActions[SFLPhone::Hold] = false; + enabledActions[SFLPhone::Transfer] = false; + enabledActions[SFLPhone::Record] = false; + } + else { + enabledActions[SFLPhone::Refuse] = false; + enabledActions[SFLPhone::Hold] = false; + enabledActions[SFLPhone::Transfer] = false; + enabledActions[SFLPhone::Record] = false; + } + } + if(stackedWidget_screen->currentWidget() == page_addressBook) { + item = addressBookTree->currentItem(); + buttonIconFiles[SFLPhone::Accept] = ICON_ACCEPT; + if (!item) { + qDebug() << "No item selected."; + enabledActions[SFLPhone::Accept] = false; + enabledActions[SFLPhone::Refuse] = false; + enabledActions[SFLPhone::Hold] = false; + enabledActions[SFLPhone::Transfer] = false; + enabledActions[SFLPhone::Record] = false; + } + else { + enabledActions[SFLPhone::Refuse] = false; + enabledActions[SFLPhone::Hold] = false; + enabledActions[SFLPhone::Transfer] = false; + enabledActions[SFLPhone::Record] = false; + } + } + + qDebug() << "Updating Window."; + + emit enabledActionsChangeAsked(enabledActions); + emit actionIconsChangeAsked(buttonIconFiles); + emit actionTextsChangeAsked(actionTexts); + emit transferCheckStateChangeAsked(transfer); + emit recordCheckStateChangeAsked(recordActivated); + + qDebug() << "Window updated."; } void SFLPhoneView::updateSearchHistory() { - qDebug() << "updateSearchHistory"; - lineEdit_searchHistory->setVisible(!lineEdit_searchHistory->text().isEmpty()); + qDebug() << "updateSearchHistory"; + lineEdit_searchHistory->setVisible(!lineEdit_searchHistory->text().isEmpty()); } void SFLPhoneView::updateCallHistory() { - qDebug() << "updateCallHistory"; - while(listWidget_callHistory->count() > 0) - { - listWidget_callHistory->takeItem(0); - } - QString textSearched = lineEdit_searchHistory->text(); - for(int i = callList->size() - 1 ; i >= 0 ; i--) - { - Call * call = (*callList)[i]; - qDebug() << "" << call->getCallId(); - if( - call->getState() == CALL_STATE_OVER && - call->getHistoryState() != NONE && - (call->getPeerPhoneNumber().contains(textSearched) || call->getPeerName().contains(textSearched)) - ) - { - qDebug() << "call->getPeerPhoneNumber()=" << call->getPeerPhoneNumber() << " contains textSearched=" << textSearched; - addCallToCallHistory(call); - } - } -// alternateColors(listWidget_callHistory); + qDebug() << "updateCallHistory"; + while(listWidget_callHistory->count() > 0) { + listWidget_callHistory->takeItem(0); + } + QString textSearched = lineEdit_searchHistory->text(); + for(int i = callList->size() - 1 ; i >= 0 ; i--) { + Call * call = (*callList)[i]; + qDebug() << "" << call->getCallId(); + if( call->getState() == CALL_STATE_OVER && call->getHistoryState() != NONE && (call->getPeerPhoneNumber().contains(textSearched) || call->getPeerName().contains(textSearched)) ) { + qDebug() << "call->getPeerPhoneNumber()=" << call->getPeerPhoneNumber() << " contains textSearched=" << textSearched; + addCallToCallHistory(call); + } + } +// alternateColors(listWidget_callHistory); } void SFLPhoneView::updateAddressBook() { - qDebug() << "updateAddressBook"; - while(listWidget_addressBook->count() > 0) - { - QListWidgetItem * item = listWidget_addressBook->takeItem(0); - delete item; - } - if(isAddressBookEnabled()) - { - if(loadAddressBook()) - { - qDebug() << "add loaded"; - QString textSearched = lineEdit_addressBook->text(); - if(textSearched.isEmpty()) - { - label_addressBookFull->setVisible(false); - return; - } - bool full = false; - QVector<Contact *> contactsFound = findContactsInKAddressBook(textSearched, full); - qDebug() << "Full : " << full; - label_addressBookFull->setVisible(full); - for(int i = 0 ; i < contactsFound.size() ; i++) - { - Contact * contact = contactsFound[i]; - addContactToContactList(contact); - } - alternateColors(listWidget_addressBook); - } - else - { - lineEdit_addressBook->setClickMessage(i18n("Address book loading...")); - lineEdit_addressBook->setEnabled(false); - label_addressBookFull->setVisible(false); - } - } - + qDebug() << "updateAddressBook"; + while(listWidget_addressBook->count() > 0) { + QListWidgetItem * item = listWidget_addressBook->takeItem(0); + delete item; + } + + if(isAddressBookEnabled()) { + if(loadAddressBook()) + { + qDebug() << "add loaded"; + QString textSearched = lineEdit_addressBook->text(); + if(textSearched.isEmpty()) { + label_addressBookFull->setVisible(false); + return; + } + bool full = false; + QVector<Contact *> contactsFound = findContactsInKAddressBook(textSearched, full); + qDebug() << "Full : " << full; + label_addressBookFull->setVisible(full); + for(int i = 0 ; i < contactsFound.size() ; i++) { + Contact * contact = contactsFound[i]; + addContactToContactList(contact); + } + alternateColors(listWidget_addressBook); + } + else { + lineEdit_addressBook->setClickMessage(i18n("Address book loading...")); + lineEdit_addressBook->setEnabled(false); + label_addressBookFull->setVisible(false); + } + } + } void SFLPhoneView::alternateColors(QListWidget * listWidget) { - for(int i = 0 ; i < listWidget->count(); i++) - { - QListWidgetItem* item = listWidget->item(i); - QBrush c = (i % 2 == 1) ? palette().base() : palette().alternateBase(); - item->setBackground( c ); - } - listWidget->setUpdatesEnabled( true ); + for(int i = 0 ; i < listWidget->count(); i++) { + QListWidgetItem* item = listWidget->item(i); + QBrush c = (i % 2 == 1) ? palette().base() : palette().alternateBase(); + item->setBackground( c ); + } + listWidget->setUpdatesEnabled( true ); } QVector<Contact *> SFLPhoneView::findContactsInKAddressBook(QString textSearched, bool & full) { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - MapStringInt addressBookSettings = configurationManager.getAddressbookSettings().value(); - int maxResults = addressBookSettings[ADDRESSBOOK_MAX_RESULTS]; - int typesDisplayed = phoneNumberTypesDisplayed(); - bool displayPhoto = addressBookSettings[ADDRESSBOOK_DISPLAY_CONTACT_PHOTO]; - AddressBook * ab = KABC::StdAddressBook::self(true); - QVector<Contact *> results = QVector<Contact *>(); - AddressBook::Iterator it; - full = false; - int k = 0; - for ( it = ab->begin(); it != ab->end() && !full ; it++ ) { - if(it->name().contains(textSearched, Qt::CaseInsensitive) || it->nickName().contains(textSearched, Qt::CaseInsensitive)) - { - for(int i = 0 ; i < it->phoneNumbers().count() ; i++) - { - int typeFlag = it->phoneNumbers().at(i).type(); - if((typesDisplayed & typeFlag) != 0) - { - results.append(new Contact( *it, it->phoneNumbers().at(i), displayPhoto )); - k++; - } - } - } - if(k >= maxResults) - { - full = true; - } - } - return results; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + MapStringInt addressBookSettings = configurationManager.getAddressbookSettings().value(); + int maxResults = addressBookSettings[ADDRESSBOOK_MAX_RESULTS]; + int typesDisplayed = phoneNumberTypesDisplayed(); + bool displayPhoto = addressBookSettings[ADDRESSBOOK_DISPLAY_CONTACT_PHOTO]; + AddressBook * ab = KABC::StdAddressBook::self(true); + QVector<Contact *> results = QVector<Contact *>(); + AddressBook::Iterator it; + full = false; + int k = 0; + for ( it = ab->begin(); it != ab->end() && !full ; it++ ) { + if(it->name().contains(textSearched, Qt::CaseInsensitive) || it->nickName().contains(textSearched, Qt::CaseInsensitive)) { + for(int i = 0 ; i < it->phoneNumbers().count() ; i++) { + int typeFlag = it->phoneNumbers().at(i).type(); + if((typesDisplayed & typeFlag) != 0) { + results.append(new Contact( *it, it->phoneNumbers().at(i), displayPhoto )); + k++; + } + } + } + if(k >= maxResults) { + full = true; + } + } + return results; } int SFLPhoneView::phoneNumberTypesDisplayed() { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - MapStringInt addressBookSettings = configurationManager.getAddressbookSettings().value(); - int typesDisplayed = 0; - if(addressBookSettings[ADDRESSBOOK_DISPLAY_BUSINESS]) - { - typesDisplayed = typesDisplayed | PhoneNumber::Work; - } - if(addressBookSettings[ADDRESSBOOK_DISPLAY_MOBILE]) - { - typesDisplayed = typesDisplayed | PhoneNumber::Cell; - } - if(addressBookSettings[ADDRESSBOOK_DISPLAY_HOME]) - { - typesDisplayed = typesDisplayed | PhoneNumber::Home; - } - return typesDisplayed; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + MapStringInt addressBookSettings = configurationManager.getAddressbookSettings().value(); + int typesDisplayed = 0; + if(addressBookSettings[ADDRESSBOOK_DISPLAY_BUSINESS]) { + typesDisplayed = typesDisplayed | PhoneNumber::Work; + } + + if(addressBookSettings[ADDRESSBOOK_DISPLAY_MOBILE]) { + typesDisplayed = typesDisplayed | PhoneNumber::Cell; + } + + if(addressBookSettings[ADDRESSBOOK_DISPLAY_HOME]) { + typesDisplayed = typesDisplayed | PhoneNumber::Home; + } + + return typesDisplayed; } void SFLPhoneView::updateRecordButton() { - qDebug() << "updateRecordButton"; - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - double recVol = callManager.getVolume(RECORD_DEVICE); - if(recVol == 0.00) - { - toolButton_recVol->setIcon(QIcon(ICON_REC_VOL_0)); + qDebug() << "updateRecordButton"; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + double recVol = callManager.getVolume(RECORD_DEVICE); + if(recVol == 0.00) { + toolButton_recVol->setIcon(QIcon(ICON_REC_VOL_0)); toolButton_recVol_2->setIcon(QIcon(ICON_REC_VOL_0)); - } - else if(recVol < 0.33) - { - toolButton_recVol->setIcon(QIcon(ICON_REC_VOL_1)); + } + else if(recVol < 0.33) { + toolButton_recVol->setIcon(QIcon(ICON_REC_VOL_1)); toolButton_recVol_2->setIcon(QIcon(ICON_REC_VOL_1)); - } - else if(recVol < 0.67) - { - toolButton_recVol->setIcon(QIcon(ICON_REC_VOL_2)); + } + else if(recVol < 0.67) { + toolButton_recVol->setIcon(QIcon(ICON_REC_VOL_2)); toolButton_recVol_2->setIcon(QIcon(ICON_REC_VOL_2)); - } - else - { - toolButton_recVol->setIcon(QIcon(ICON_REC_VOL_3)); + } + else { + toolButton_recVol->setIcon(QIcon(ICON_REC_VOL_3)); toolButton_recVol_2->setIcon(QIcon(ICON_REC_VOL_3)); - } - if(recVol > 0) - { - toolButton_recVol->setChecked(false); + } + + if(recVol > 0) { + toolButton_recVol->setChecked(false); toolButton_recVol_2->setChecked(false); - } + } } void SFLPhoneView::updateVolumeButton() { - qDebug() << "updateVolumeButton"; - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - double sndVol = callManager.getVolume(SOUND_DEVICE); - if(sndVol == 0.00) - { - toolButton_sndVol->setIcon(QIcon(ICON_SND_VOL_0)); + qDebug() << "updateVolumeButton"; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + double sndVol = callManager.getVolume(SOUND_DEVICE); + + if(sndVol == 0.00) { + toolButton_sndVol->setIcon(QIcon(ICON_SND_VOL_0)); toolButton_sndVol_2->setIcon(QIcon(ICON_SND_VOL_0)); - } - else if(sndVol < 0.33) - { - toolButton_sndVol->setIcon(QIcon(ICON_SND_VOL_1)); + } + else if(sndVol < 0.33) { + toolButton_sndVol->setIcon(QIcon(ICON_SND_VOL_1)); toolButton_sndVol_2->setIcon(QIcon(ICON_SND_VOL_1)); - } - else if(sndVol < 0.67) - { - toolButton_sndVol->setIcon(QIcon(ICON_SND_VOL_2)); + } + else if(sndVol < 0.67) { + toolButton_sndVol->setIcon(QIcon(ICON_SND_VOL_2)); toolButton_sndVol_2->setIcon(QIcon(ICON_SND_VOL_2)); - } - else - { - toolButton_sndVol->setIcon(QIcon(ICON_SND_VOL_3)); + } + else { + toolButton_sndVol->setIcon(QIcon(ICON_SND_VOL_3)); toolButton_sndVol_2->setIcon(QIcon(ICON_SND_VOL_3)); - } - if(sndVol > 0) - { - toolButton_sndVol->setChecked(false); + } + + if(sndVol > 0) { + toolButton_sndVol->setChecked(false); toolButton_sndVol_2->setChecked(false); - } + } } void SFLPhoneView::updateRecordBar() { - qDebug() << "updateRecordBar"; - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - double recVol = callManager.getVolume(RECORD_DEVICE); - int value = (int)(recVol * 100); - slider_recVol->setValue(value); + qDebug() << "updateRecordBar"; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + double recVol = callManager.getVolume(RECORD_DEVICE); + int value = (int)(recVol * 100); + slider_recVol->setValue(value); } void SFLPhoneView::updateVolumeBar() { - qDebug() << "updateVolumeBar"; - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - double sndVol = callManager.getVolume(SOUND_DEVICE); - int value = (int)(sndVol * 100); - slider_sndVol->setValue(value); + qDebug() << "updateVolumeBar"; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + double sndVol = callManager.getVolume(SOUND_DEVICE); + int value = (int)(sndVol * 100); + slider_sndVol->setValue(value); } void SFLPhoneView::updateVolumeControls() { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - int display = 0; - - if(configurationManager.getAudioManager() == ConfigurationSkeleton::EnumInterface::ALSA) - { - display = configurationManager.getVolumeControls(); - - ((SFLPhone*)parent())->action_displayVolumeControls->setEnabled(true); - } - else - { - ((SFLPhone*)parent())->action_displayVolumeControls->setEnabled(false); - } - - qDebug() << "updateVolumeControls " << display; - - ((SFLPhone*)parent())->action_displayVolumeControls->setChecked(display); - //widget_recVol->setVisible(display); - //widget_sndVol->setVisible(display); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + int display = 0; + + if(configurationManager.getAudioManager() == ConfigurationSkeleton::EnumInterface::ALSA) { + display = configurationManager.getVolumeControls(); + + ((SFLPhone*)parent())->action_displayVolumeControls->setEnabled(true); + } + else { + ((SFLPhone*)parent())->action_displayVolumeControls->setEnabled(false); + } + + qDebug() << "updateVolumeControls " << display; + + ((SFLPhone*)parent())->action_displayVolumeControls->setChecked(display); + //widget_recVol->setVisible(display); + //widget_sndVol->setVisible(display); toolButton_recVol->setVisible(display); toolButton_sndVol->setVisible(display); slider_recVol->setVisible(display); @@ -896,30 +813,28 @@ void SFLPhoneView::updateVolumeControls() void SFLPhoneView::updateDialpad() { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - int display = configurationManager.getDialpad(); - - qDebug() << "updateDialpad " << display; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + int display = configurationManager.getDialpad(); + + qDebug() << "updateDialpad " << display; - widget_dialpad->setVisible(display); + widget_dialpad->setVisible(display); } void SFLPhoneView::updateStatusMessage() { - qDebug() << "updateStatusMessage"; - Account * account = accountInUse(); + qDebug() << "updateStatusMessage"; + Account * account = accountInUse(); - if(account == NULL) - { - emit statusMessageChangeAsked(i18n("No registered accounts")); - } - else - { - emit statusMessageChangeAsked(i18n("Using account") - + " \'" + account->getAlias() - + "\' (" + account->getAccountDetail(ACCOUNT_TYPE) + ")") ; - } + if(account == NULL) { + emit statusMessageChangeAsked(i18n("No registered accounts")); + } + else { + emit statusMessageChangeAsked(i18n("Using account") + + " \'" + account->getAlias() + + "\' (" + account->getAccountDetail(ACCOUNT_TYPE) + ")") ; + } } @@ -930,57 +845,57 @@ void SFLPhoneView::updateStatusMessage() void SFLPhoneView::displayVolumeControls() { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - int display = configurationManager.getVolumeControls(); - configurationManager.setVolumeControls(!display); - updateVolumeControls(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + int display = configurationManager.getVolumeControls(); + configurationManager.setVolumeControls(!display); + updateVolumeControls(); } void SFLPhoneView::displayDialpad() { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - int display = configurationManager.getDialpad(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + int display = configurationManager.getDialpad(); - configurationManager.setDialpad(!display); - updateDialpad(); + configurationManager.setDialpad(!display); + updateDialpad(); } void SFLPhoneView::on_widget_dialpad_typed(QString text) { - typeString(text); + typeString(text); } void SFLPhoneView::on_lineEdit_searchHistory_textChanged() { - qDebug() << "on_lineEdit_searchHistory_textChanged"; - updateSearchHistory(); - updateCallHistory(); - updateWindowCallState(); + qDebug() << "on_lineEdit_searchHistory_textChanged"; + updateSearchHistory(); + updateCallHistory(); + updateWindowCallState(); } void SFLPhoneView::on_lineEdit_addressBook_textChanged() { - qDebug() << "on_lineEdit_addressBook_textChanged"; - updateAddressBook(); - updateWindowCallState(); + qDebug() << "on_lineEdit_addressBook_textChanged"; + updateAddressBook(); + updateWindowCallState(); } void SFLPhoneView::on_slider_recVol_valueChanged(int value) { - qDebug() << "on_slider_recVol_valueChanged(" << value << ")"; - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - callManager.setVolume(RECORD_DEVICE, (double)value / 100.0); - updateRecordButton(); + qDebug() << "on_slider_recVol_valueChanged(" << value << ")"; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + callManager.setVolume(RECORD_DEVICE, (double)value / 100.0); + updateRecordButton(); } void SFLPhoneView::on_slider_sndVol_valueChanged(int value) { - qDebug() << "on_slider_sndVol_valueChanged(" << value << ")"; - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - callManager.setVolume(SOUND_DEVICE, (double)value / 100.0); - updateVolumeButton(); + qDebug() << "on_slider_sndVol_valueChanged(" << value << ")"; + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + callManager.setVolume(SOUND_DEVICE, (double)value / 100.0); + updateVolumeButton(); } void SFLPhoneView::on_slider_recVol_2_valueChanged(int value) @@ -995,23 +910,21 @@ void SFLPhoneView::on_slider_sndVol_2_valueChanged(int value) void SFLPhoneView::on_toolButton_recVol_clicked(bool checked) { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "on_toolButton_recVol_clicked()."; - if(!checked) - { - qDebug() << "checked"; - toolButton_recVol->setChecked(false); - slider_recVol->setEnabled(true); - callManager.setVolume(RECORD_DEVICE, (double)slider_recVol->value() / 100.0); - } - else - { - qDebug() << "unchecked"; - toolButton_recVol->setChecked(true); - slider_recVol->setEnabled(false); - callManager.setVolume(RECORD_DEVICE, 0.0); - } - updateRecordButton(); + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + qDebug() << "on_toolButton_recVol_clicked()."; + if(!checked) { + qDebug() << "checked"; + toolButton_recVol->setChecked(false); + slider_recVol->setEnabled(true); + callManager.setVolume(RECORD_DEVICE, (double)slider_recVol->value() / 100.0); + } + else { + qDebug() << "unchecked"; + toolButton_recVol->setChecked(true); + slider_recVol->setEnabled(false); + callManager.setVolume(RECORD_DEVICE, 0.0); + } + updateRecordButton(); } void SFLPhoneView::on_toolButton_recVol_2_clicked(bool checked) @@ -1027,504 +940,470 @@ void SFLPhoneView::on_toolButton_sndVol_2_clicked(bool checked) void SFLPhoneView::on_toolButton_sndVol_clicked(bool checked) { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "on_toolButton_sndVol_clicked()."; - if(!checked) - { - qDebug() << "checked"; - toolButton_sndVol->setChecked(false); - slider_sndVol->setEnabled(true); - callManager.setVolume(SOUND_DEVICE, (double)slider_sndVol->value() / 100.0); - } - else - { - qDebug() << "unchecked"; - toolButton_sndVol->setChecked(true); - slider_sndVol->setEnabled(false); - callManager.setVolume(SOUND_DEVICE, 0.0); - } - updateVolumeButton(); + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + qDebug() << "on_toolButton_sndVol_clicked()."; + if(!checked) { + qDebug() << "checked"; + toolButton_sndVol->setChecked(false); + slider_sndVol->setEnabled(true); + callManager.setVolume(SOUND_DEVICE, (double)slider_sndVol->value() / 100.0); + } + else { + qDebug() << "unchecked"; + toolButton_sndVol->setChecked(true); + slider_sndVol->setEnabled(false); + callManager.setVolume(SOUND_DEVICE, 0.0); + } + + updateVolumeButton(); } #include <unistd.h> void SFLPhoneView::on_callTree_currentItemChanged() { - qDebug() << "on_callTree_currentItemChanged"; - updateWindowCallState(); + qDebug() << "on_callTree_currentItemChanged"; + updateWindowCallState(); } void SFLPhoneView::on_callTree_itemChanged() { - qDebug() << "on_callTree_itemChanged"; - stackedWidget_screen->setCurrentWidget(page_callList); + qDebug() << "on_callTree_itemChanged"; + stackedWidget_screen->setCurrentWidget(page_callList); } void SFLPhoneView::on_callTree_itemDoubleClicked(const QModelIndex &index) { - qDebug() << "on_callTree_itemDoubleClicked"; - CallTreeItem *item = callTree->getItem(index); - Call * call = item->call(); - call_state state = call->getCurrentState(); - switch(state) - { - case CALL_STATE_HOLD: - action(call, CALL_ACTION_HOLD); - break; - case CALL_STATE_DIALING: - action(call, CALL_ACTION_ACCEPT); - break; - default: - qDebug() << "Double clicked an item with no action on double click."; - } + qDebug() << "on_callTree_itemDoubleClicked"; + CallTreeItem *item = callTree->getItem(index); + Call * call = item->call(); + call_state state = call->getCurrentState(); + switch(state) { + case CALL_STATE_HOLD: + action(call, CALL_ACTION_HOLD); + break; + case CALL_STATE_DIALING: + action(call, CALL_ACTION_ACCEPT); + break; + default: + qDebug() << "Double clicked an item with no action on double click."; + } } void SFLPhoneView::on_listWidget_callHistory_itemDoubleClicked(CallTreeItem * item) { - qDebug() << "on_listWidget_callHistory_itemDoubleClicked"; - changeScreen(SCREEN_MAIN); - Call * pastCall = item->call(); - Call * call = callList->addDialingCall(pastCall->getPeerName(), pastCall->getAccountId()); - call->appendText(pastCall->getPeerPhoneNumber()); - addCallToCallList(call); - callTree->setCurrentRow(callTree->count() - 1); - action(call, CALL_ACTION_ACCEPT); + qDebug() << "on_listWidget_callHistory_itemDoubleClicked"; + changeScreen(SCREEN_MAIN); + Call * pastCall = item->call(); + Call * call = callList->addDialingCall(pastCall->getPeerName(), pastCall->getAccountId()); + call->appendText(pastCall->getPeerPhoneNumber()); + addCallToCallList(call); + callTree->setCurrentRow(callTree->count() - 1); + action(call, CALL_ACTION_ACCEPT); } void SFLPhoneView::on_listWidget_addressBook_itemDoubleClicked(CallTreeItem * item) { - qDebug() << "on_listWidget_addressBook_itemDoubleClicked"; - changeScreen(SCREEN_MAIN); + qDebug() << "on_listWidget_addressBook_itemDoubleClicked"; + changeScreen(SCREEN_MAIN); // TOFIX -// ContactItemWidget * w = (ContactItemWidget *) (listWidget_addressBook->itemWidget(item)); -// Call * call = callList->addDialingCall(w->getContactName()); -// call->appendItemText(w->getContactNumber()); -// addCallToCallList(call); -// callTree->setCurrentRow(callTree->count() - 1); -// action(call, CALL_ACTION_ACCEPT); +// ContactItemWidget * w = (ContactItemWidget *) (listWidget_addressBook->itemWidget(item)); +// Call * call = callList->addDialingCall(w->getContactName()); +// call->appendItemText(w->getContactNumber()); +// addCallToCallList(call); +// callTree->setCurrentRow(callTree->count() - 1); +// action(call, CALL_ACTION_ACCEPT); } void SFLPhoneView::on_stackedWidget_screen_currentChanged(int index) { - qDebug() << "on_stackedWidget_screen_currentChanged"; - switch(index) - { - case SCREEN_MAIN: - qDebug() << "Switched to call list screen."; - emit windowTitleChangeAsked(i18n("SFLphone") + " - " + i18n("Main screen")); - break; - case SCREEN_HISTORY: - qDebug() << "Switched to call history screen."; - if(!historyLoaded) - { - updateCallHistory(); - historyLoaded = true; - } - alternateColors(listWidget_callHistory); - emit windowTitleChangeAsked(i18n("SFLphone") + " - " + i18n("Call history")); - break; - case SCREEN_ADDRESS: - qDebug() << "Switched to address book screen."; - updateAddressBook(); - emit windowTitleChangeAsked(i18n("SFLphone") + " - " + i18n("Address book")); - break; - default: - qDebug() << "Error : reached an unknown index \"" << index << "\" with stackedWidget_screen."; - break; - } + qDebug() << "on_stackedWidget_screen_currentChanged"; + switch(index) { + case SCREEN_MAIN: + qDebug() << "Switched to call list screen."; + emit windowTitleChangeAsked(i18n("SFLphone") + " - " + i18n("Main screen")); + break; + case SCREEN_HISTORY: + qDebug() << "Switched to call history screen."; + if(!historyLoaded) + { + updateCallHistory(); + historyLoaded = true; + } + alternateColors(listWidget_callHistory); + emit windowTitleChangeAsked(i18n("SFLphone") + " - " + i18n("Call history")); + break; + case SCREEN_ADDRESS: + qDebug() << "Switched to address book screen."; + updateAddressBook(); + emit windowTitleChangeAsked(i18n("SFLphone") + " - " + i18n("Address book")); + break; + default: + qDebug() << "Error : reached an unknown index \"" << index << "\" with stackedWidget_screen."; + break; + } } void SFLPhoneView::contextMenuEvent(QContextMenuEvent *event) { - KMenu menu(this); - if( ( stackedWidget_screen->currentWidget() == page_callHistory && listWidget_callHistory->currentItem() ) || - ( stackedWidget_screen->currentWidget() == page_addressBook && listWidget_addressBook->currentItem() ) ) - { - KAction * action_edit = new KAction(&menu); - action_edit->setText(i18n("Edit before call")); - connect(action_edit, SIGNAL(triggered()), - this , SLOT(editBeforeCall())); - menu.addAction(action_edit); - } - SFLPhone * window = (SFLPhone * ) this->parent(); - QList<QAction *> callActions = window->getCallActions(); - menu.addAction(callActions.at((int) SFLPhone::Accept)); - menu.addAction(callActions[SFLPhone::Refuse]); - menu.addAction(callActions[SFLPhone::Hold]); - menu.addAction(callActions[SFLPhone::Transfer]); - menu.addAction(callActions[SFLPhone::Record]); - menu.addSeparator(); - - QAction * action = new ActionSetAccountFirst(NULL, &menu); - action->setChecked(priorAccountId.isEmpty()); - connect(action, SIGNAL(setFirst(Account *)), - this , SLOT(setAccountFirst(Account *))); - menu.addAction(action); - - QVector<Account *> accounts = accountList->registeredAccounts(); - for (int i = 0 ; i < accounts.size() ; i++) - { - Account * account = accounts.at(i); - QAction * action = new ActionSetAccountFirst(account, &menu); - action->setChecked(account->getAccountId() == priorAccountId); - connect(action, SIGNAL(setFirst(Account *)), - this , SLOT(setAccountFirst(Account *))); - menu.addAction(action); - } - menu.exec(event->globalPos()); + KMenu menu(this); + if( ( stackedWidget_screen->currentWidget() == page_callHistory && listWidget_callHistory->currentItem() ) || ( stackedWidget_screen->currentWidget() == page_addressBook && listWidget_addressBook->currentItem() ) ) { + KAction * action_edit = new KAction(&menu); + action_edit->setText(i18n("Edit before call")); + connect(action_edit, SIGNAL(triggered()), + this , SLOT(editBeforeCall())); + menu.addAction(action_edit); + } + + SFLPhone * window = (SFLPhone * ) this->parent(); + QList<QAction *> callActions = window->getCallActions(); + menu.addAction(callActions.at((int) SFLPhone::Accept)); + menu.addAction(callActions[SFLPhone::Refuse]); + menu.addAction(callActions[SFLPhone::Hold]); + menu.addAction(callActions[SFLPhone::Transfer]); + menu.addAction(callActions[SFLPhone::Record]); + menu.addSeparator(); + + QAction * action = new ActionSetAccountFirst(NULL, &menu); + action->setChecked(priorAccountId.isEmpty()); + connect(action, SIGNAL(setFirst(Account *)), + this , SLOT(setAccountFirst(Account *))); + menu.addAction(action); + + QVector<Account *> accounts = accountList->registeredAccounts(); + for (int i = 0 ; i < accounts.size() ; i++) { + Account * account = accounts.at(i); + QAction * action = new ActionSetAccountFirst(account, &menu); + action->setChecked(account->getAccountId() == priorAccountId); + connect(action, SIGNAL(setFirst(Account *)), + this , SLOT(setAccountFirst(Account *))); + menu.addAction(action); + } + menu.exec(event->globalPos()); } void SFLPhoneView::editBeforeCall() { - qDebug() << "editBeforeCall"; - QString name; - QString number; - if(stackedWidget_screen->currentWidget() == page_callHistory) - { - CallTreeItem * item = historyTree->currentItem(); - if(item) - { - Call * call = item->call(); - if(call) - { - name = call->getPeerName(); - number = call->getPeerPhoneNumber(); - } - } - } - else if(stackedWidget_screen->currentWidget() == page_addressBook) - { - QListWidgetItem * item = listWidget_addressBook->currentItem(); - if(item) - { - ContactItemWidget * w = (ContactItemWidget *) (listWidget_addressBook->itemWidget(listWidget_addressBook->currentItem())); - name = w->getContactName(); - number = w->getContactNumber(); - } - } - else - { return; } - bool ok; - QString newNumber = QInputDialog::getText(this, i18n("Edit before call"), QString(), QLineEdit::Normal, number, &ok); - if(ok) - { - changeScreen(SCREEN_MAIN); - Call * call = callList->addDialingCall(name); - call->appendText(newNumber); - addCallToCallList(call); - callTree->setCurrentRow(callTree->count() - 1); - action(call, CALL_ACTION_ACCEPT); - } + qDebug() << "editBeforeCall"; + QString name; + QString number; + if(stackedWidget_screen->currentWidget() == page_callHistory) { + CallTreeItem * item = historyTree->currentItem(); + if(item) { + Call * call = item->call(); + if(call) { + name = call->getPeerName(); + number = call->getPeerPhoneNumber(); + } + } + } + else if(stackedWidget_screen->currentWidget() == page_addressBook) { + QListWidgetItem * item = listWidget_addressBook->currentItem(); + + if(item) { + ContactItemWidget * w = (ContactItemWidget *) (listWidget_addressBook->itemWidget(listWidget_addressBook->currentItem())); + name = w->getContactName(); + number = w->getContactNumber(); + } + } + else + return; + + bool ok; + QString newNumber = QInputDialog::getText(this, i18n("Edit before call"), QString(), QLineEdit::Normal, number, &ok); + if(ok) { + changeScreen(SCREEN_MAIN); + Call * call = callList->addDialingCall(name); + call->appendText(newNumber); + addCallToCallList(call); + callTree->setCurrentRow(callTree->count() - 1); + action(call, CALL_ACTION_ACCEPT); + } } void SFLPhoneView::setAccountFirst(Account * account) { - qDebug() << "setAccountFirst : " << (account ? account->getAlias() : QString()); - if(account) - { - priorAccountId = account->getAccountId(); - } - else - { - priorAccountId = QString(); - } - updateStatusMessage(); + qDebug() << "setAccountFirst : " << (account ? account->getAlias() : QString()); + if(account) { + priorAccountId = account->getAccountId(); + } + else { + priorAccountId = QString(); + } + updateStatusMessage(); } void SFLPhoneView::on_listWidget_callHistory_currentItemChanged() { - qDebug() << "on_listWidget_callHistory_currentItemChanged"; - updateWindowCallState(); + qDebug() << "on_listWidget_callHistory_currentItemChanged"; + updateWindowCallState(); } void SFLPhoneView::on_listWidget_addressBook_currentItemChanged() { - qDebug() << "on_listWidget_addressBook_currentItemChanged"; - updateWindowCallState(); + qDebug() << "on_listWidget_addressBook_currentItemChanged"; + updateWindowCallState(); } void SFLPhoneView::configureSflPhone() { - configDialog->reload(); - configDialog->show(); + configDialog->reload(); + configDialog->show(); } void SFLPhoneView::accountCreationWizard() { - wizard->show(); + wizard->show(); } - + void SFLPhoneView::accept() { - if(stackedWidget_screen->currentWidget() == page_callList) - { - CallTreeItem * item = callTree->currentItem(); - if(!item) - { - qDebug() << "Calling when no item is selected. Opening an item."; - Call * call = callList->addDialingCall(); - addCallToCallList(call); - callTree->setCurrentRow(callTree->count() - 1); - } - else - { - Call * call = item->call(); - if(!call) - { - qDebug() << "Error : Accept triggered on unexisting call."; - } - else - { - int state = call->getState(); - if(state == CALL_STATE_RINGING || state == CALL_STATE_CURRENT || state == CALL_STATE_HOLD || state == CALL_STATE_BUSY) - { - qDebug() << "Calling when item currently ringing, current, hold or busy. Opening an item."; - Call * call = callList->addDialingCall(); - addCallToCallList(call); - callTree->setCurrentRow(callTree->count() - 1); - } - else - { - action(call, CALL_ACTION_ACCEPT); - } - } - } - } - if(stackedWidget_screen->currentWidget() == page_callHistory) - { - changeScreen(SCREEN_MAIN); - Call * pastCall = historyTree->currentItem()->call(); - Call * call = callList->addDialingCall(pastCall->getPeerName()); - call->appendText(pastCall->getPeerPhoneNumber()); - addCallToCallList(call); - callTree->setCurrentRow(callTree->count() - 1); - action(call, CALL_ACTION_ACCEPT); - } - if(stackedWidget_screen->currentWidget() == page_addressBook) - { - changeScreen(SCREEN_MAIN); - ContactItemWidget * w = (ContactItemWidget *) (listWidget_addressBook->itemWidget(listWidget_addressBook->currentItem())); - Call * call = callList->addDialingCall(w->getContactName()); - call->appendText(w->getContactNumber()); - addCallToCallList(call); - callTree->setCurrentRow(callTree->count() - 1); - action(call, CALL_ACTION_ACCEPT); - } + if(stackedWidget_screen->currentWidget() == page_callList) { + CallTreeItem * item = callTree->currentItem(); + if(!item) { + qDebug() << "Calling when no item is selected. Opening an item."; + Call * call = callList->addDialingCall(); + addCallToCallList(call); + callTree->setCurrentRow(callTree->count() - 1); + } + else { + Call * call = item->call(); + if(!call) { + qDebug() << "Error : Accept triggered on unexisting call."; + } + else { + int state = call->getState(); + if(state == CALL_STATE_RINGING || state == CALL_STATE_CURRENT || state == CALL_STATE_HOLD || state == CALL_STATE_BUSY) + { + qDebug() << "Calling when item currently ringing, current, hold or busy. Opening an item."; + Call * call = callList->addDialingCall(); + addCallToCallList(call); + callTree->setCurrentRow(callTree->count() - 1); + } + else { + action(call, CALL_ACTION_ACCEPT); + } + } + } + } + + if(stackedWidget_screen->currentWidget() == page_callHistory) { + changeScreen(SCREEN_MAIN); + Call * pastCall = historyTree->currentItem()->call(); + Call * call = callList->addDialingCall(pastCall->getPeerName()); + call->appendText(pastCall->getPeerPhoneNumber()); + addCallToCallList(call); + callTree->setCurrentRow(callTree->count() - 1); + action(call, CALL_ACTION_ACCEPT); + } + + if(stackedWidget_screen->currentWidget() == page_addressBook) { + changeScreen(SCREEN_MAIN); + ContactItemWidget * w = (ContactItemWidget *) (listWidget_addressBook->itemWidget(listWidget_addressBook->currentItem())); + Call * call = callList->addDialingCall(w->getContactName()); + call->appendText(w->getContactNumber()); + addCallToCallList(call); + callTree->setCurrentRow(callTree->count() - 1); + action(call, CALL_ACTION_ACCEPT); + } } void SFLPhoneView::refuse() { - if(stackedWidget_screen->currentWidget() == page_callList) - { - CallTreeItem * item = callTree->currentItem(); - if(!item) - { - qDebug() << "Error : Hanging up when no item selected. Should not happen."; - } - else - { - action(item->call(), CALL_ACTION_REFUSE); - } - } - if(stackedWidget_screen->currentWidget() == page_callHistory) - { - lineEdit_searchHistory->clear(); - } - if(stackedWidget_screen->currentWidget() == page_addressBook) - { - lineEdit_addressBook->clear(); - } + if(stackedWidget_screen->currentWidget() == page_callList) { + CallTreeItem * item = callTree->currentItem(); + if(!item) { + qDebug() << "Error : Hanging up when no item selected. Should not happen."; + } + else { + action(item->call(), CALL_ACTION_REFUSE); + } + } + + if(stackedWidget_screen->currentWidget() == page_callHistory) { + lineEdit_searchHistory->clear(); + } + + if(stackedWidget_screen->currentWidget() == page_addressBook) { + lineEdit_addressBook->clear(); + } } void SFLPhoneView::hold() { - CallTreeItem * item = callTree->currentItem(); - if(!item) - { - qDebug() << "Error : Holding when no item selected. Should not happen."; - } - else - { - action(item->call(), CALL_ACTION_HOLD); - } + CallTreeItem * item = callTree->currentItem(); + if(!item) { + qDebug() << "Error : Holding when no item selected. Should not happen."; + } + else { + action(item->call(), CALL_ACTION_HOLD); + } } void SFLPhoneView::transfer() { - CallTreeItem * item = callTree->currentItem(); - if(!item) - { - qDebug() << "Error : Transfering when no item selected. Should not happen."; - } - else - { - action(item->call(), CALL_ACTION_TRANSFER); - } + CallTreeItem * item = callTree->currentItem(); + if(!item) { + qDebug() << "Error : Transfering when no item selected. Should not happen."; + } + else { + action(item->call(), CALL_ACTION_TRANSFER); + } } void SFLPhoneView::record() { - CallTreeItem * item = callTree->currentItem(); - if(!item) - { - qDebug() << "Error : Recording when no item selected. Should not happen."; - } - else - { - action(item->call(), CALL_ACTION_RECORD); - } + CallTreeItem * item = callTree->currentItem(); + if(!item) { + qDebug() << "Error : Recording when no item selected. Should not happen."; + } + else { + action(item->call(), CALL_ACTION_RECORD); + } } void SFLPhoneView::mailBox() { - Account * account = accountInUse(); - QString mailBoxNumber = account->getAccountDetail(ACCOUNT_MAILBOX); - Call * call = callList->addDialingCall(); - call->appendText(mailBoxNumber); - addCallToCallList(call); - callTree->setCurrentRow(callTree->count() - 1); - action(call, CALL_ACTION_ACCEPT); + Account * account = accountInUse(); + QString mailBoxNumber = account->getAccountDetail(ACCOUNT_MAILBOX); + Call * call = callList->addDialingCall(); + call->appendText(mailBoxNumber); + addCallToCallList(call); + callTree->setCurrentRow(callTree->count() - 1); + action(call, CALL_ACTION_ACCEPT); } void SFLPhoneView::on1_callStateChanged(const QString &callID, const QString &state) { - qDebug() << "Signal : Call State Changed for call " << callID << " . New state : " << state; - Call * call = callList->findCallByCallId(callID); - if(!call) - { - if(state == CALL_STATE_CHANGE_RINGING) - { - call = callList->addRingingCall(callID); - addCallToCallList(call); - } - else - { - qDebug() << "Call doesn't exist in this client. Might have been initialized by another client instance before this one started."; - return; - } - } - else - { - call->stateChanged(state); - } - // updateCallItem(call); - updateWindowCallState(); + qDebug() << "Signal : Call State Changed for call " << callID << " . New state : " << state; + Call * call = callList->findCallByCallId(callID); + if(!call) { + if(state == CALL_STATE_CHANGE_RINGING) { + call = callList->addRingingCall(callID); + addCallToCallList(call); + } + else { + qDebug() << "Call doesn't exist in this client. Might have been initialized by another client instance before this one started."; + return; + } + } + else { + call->stateChanged(state); + } + // updateCallItem(call); + updateWindowCallState(); } void SFLPhoneView::on1_error(MapStringString details) { - qDebug() << "Signal : Daemon error : " << details; + qDebug() << "Signal : Daemon error : " << details; } void SFLPhoneView::on1_incomingCall(const QString & /*accountID*/, const QString & callID) { - qDebug() << "Signal : Incoming Call ! ID = " << callID; - Call * call = callList->addIncomingCall(callID); - addCallToCallList(call); - callTree->setCurrentRow(callTree->count() - 1); + qDebug() << "Signal : Incoming Call ! ID = " << callID; + Call * call = callList->addIncomingCall(callID); + addCallToCallList(call); + callTree->setCurrentRow(callTree->count() - 1); - changeScreen(SCREEN_MAIN); + changeScreen(SCREEN_MAIN); - ((SFLPhone*)parent())->activateWindow(); - ((SFLPhone*)parent())->raise(); - ((SFLPhone*)parent())->setVisible(true); + ((SFLPhone*)parent())->activateWindow(); + ((SFLPhone*)parent())->raise(); + ((SFLPhone*)parent())->setVisible(true); - emit incomingCall(call); + emit incomingCall(call); } void SFLPhoneView::on1_incomingMessage(const QString &accountID, const QString &message) { - qDebug() << "Signal : Incoming Message for account " << accountID << " ! \nMessage : " << message; + qDebug() << "Signal : Incoming Message for account " << accountID << " ! \nMessage : " << message; } void SFLPhoneView::on1_voiceMailNotify(const QString &accountID, int count) { - qDebug() << "Signal : VoiceMail Notify ! " << count << " new voice mails for account " << accountID; + qDebug() << "Signal : VoiceMail Notify ! " << count << " new voice mails for account " << accountID; } void SFLPhoneView::on1_volumeChanged(const QString & /*device*/, double value) { - qDebug() << "Signal : Volume Changed !"; - if(! (toolButton_recVol->isChecked() && value == 0.0)) - updateRecordBar(); - if(! (toolButton_sndVol->isChecked() && value == 0.0)) - updateVolumeBar(); + qDebug() << "Signal : Volume Changed !"; + if(! (toolButton_recVol->isChecked() && value == 0.0)) + updateRecordBar(); + if(! (toolButton_sndVol->isChecked() && value == 0.0)) + updateVolumeBar(); } void SFLPhoneView::on1_audioManagerChanged() { - qDebug() << "Signal : Audio Manager Changed !"; + qDebug() << "Signal : Audio Manager Changed !"; - updateVolumeControls(); + updateVolumeControls(); } void SFLPhoneView::enableAddressBook() { - qDebug() << "\nenableAddressBook\n"; - lineEdit_addressBook->setClickMessage(QString()); - lineEdit_addressBook->setEnabled(true); - AddressBook * ab = StdAddressBook::self(true); - disconnect(ab, SIGNAL(addressBookChanged(AddressBook *)), - this, SLOT(enableAddressBook())); + qDebug() << "\nenableAddressBook\n"; + lineEdit_addressBook->setClickMessage(QString()); + lineEdit_addressBook->setEnabled(true); + AddressBook * ab = StdAddressBook::self(true); + disconnect(ab, SIGNAL(addressBookChanged(AddressBook *)), + this, SLOT(enableAddressBook())); } bool SFLPhoneView::loadAddressBook() { - qDebug() << "loadAddressBook"; - AddressBook * ab = StdAddressBook::self(true); - if(ab->loadingHasFinished()) - { - return true; - } - else - { - connect(ab, SIGNAL(addressBookChanged(AddressBook *)), - this, SLOT(enableAddressBook())); - return false; - } + qDebug() << "loadAddressBook"; + AddressBook * ab = StdAddressBook::self(true); + if(ab->loadingHasFinished()) { + return true; + } + else { + connect(ab, SIGNAL(addressBookChanged(AddressBook *)), + this, SLOT(enableAddressBook())); + return false; + } } void SFLPhoneView::updateAddressBookEnabled() { - qDebug() << "updateAddressBookEnabled"; - bool enabled = isAddressBookEnabled(); - emit addressBookEnableAsked(enabled); - if(! enabled && stackedWidget_screen->currentWidget() == page_addressBook) - { - changeScreen(SCREEN_MAIN); - } + qDebug() << "updateAddressBookEnabled"; + bool enabled = isAddressBookEnabled(); + emit addressBookEnableAsked(enabled); + if(! enabled && stackedWidget_screen->currentWidget() == page_addressBook) { + changeScreen(SCREEN_MAIN); + } } bool SFLPhoneView::isAddressBookEnabled() { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - MapStringInt addressBookSettings = configurationManager.getAddressbookSettings().value(); - return addressBookSettings[ADDRESSBOOK_ENABLE]; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + MapStringInt addressBookSettings = configurationManager.getAddressbookSettings().value(); + return addressBookSettings[ADDRESSBOOK_ENABLE]; } void SFLPhoneView::changeScreen(int screen) { - qDebug() << "changeScreen"; - switch(screen) - { - case SCREEN_MAIN: - stackedWidget_screen->setCurrentWidget(page_callList); - break; - case SCREEN_HISTORY: - stackedWidget_screen->setCurrentWidget(page_callHistory); - break; - case SCREEN_ADDRESS: - stackedWidget_screen->setCurrentWidget(page_addressBook); - break; - default: - break; - } - updateWindowCallState(); - emit screenChanged(screen); + qDebug() << "changeScreen"; + switch(screen) { + case SCREEN_MAIN: + stackedWidget_screen->setCurrentWidget(page_callList); + break; + case SCREEN_HISTORY: + stackedWidget_screen->setCurrentWidget(page_callHistory); + break; + case SCREEN_ADDRESS: + stackedWidget_screen->setCurrentWidget(page_addressBook); + break; + default: + break; + } + updateWindowCallState(); + emit screenChanged(screen); } diff --git a/sflphone-client-kde/src/SFLPhoneView.h b/sflphone-client-kde/src/SFLPhoneView.h index b6aacc196e962d8ba9bd859844378a63341e3390..7ae9b4b20ee463db12125ec3d12ed03ca2a0db82 100644 --- a/sflphone-client-kde/src/SFLPhoneView.h +++ b/sflphone-client-kde/src/SFLPhoneView.h @@ -55,307 +55,307 @@ class ConfigurationDialog; */ class SFLPhoneView : public QWidget, public Ui::SFLPhone_view { - Q_OBJECT + Q_OBJECT private: - static ConfigurationDialog * configDialog; - static AccountList * accountList; - AccountWizard * wizard; - //List of calls in the window, and past ones. - //Handles both current calls (dialing, ringing...) and history. - CallList * callList; - QErrorMessage * errorWindow; - //Account used prioritary if defined and registered. If not, the first registered account in accountList is used. - static QString priorAccountId; - bool historyLoaded; + static ConfigurationDialog * configDialog; + static AccountList * accountList; + AccountWizard * wizard; + //List of calls in the window, and past ones. + //Handles both current calls (dialing, ringing...) and history. + CallList * callList; + QErrorMessage * errorWindow; + //Account used prioritary if defined and registered. If not, the first registered account in accountList is used. + static QString priorAccountId; + bool historyLoaded; protected: - - /** - * override context menu handling - * @param event - */ - void contextMenuEvent(QContextMenuEvent *event); + + /** + * override context menu handling + * @param event + */ + void contextMenuEvent(QContextMenuEvent *event); public: - //Constructors & Destructors - /** - * This constructor does not load the window as it would - * better wait for the parent window to connect to the signals - * for updating it (statusMessageChangeAsked...). - * You should call the loadWindow() method once - * you have constructed the object and connected the - * expected signals. - * @param parent - */ - SFLPhoneView(QWidget *parent); - virtual ~SFLPhoneView(); - - //Getters - /** - * Seeks the account to use. - * If priorAccountId is defined and the corresponding - * account exists and is registered, uses this one, else, - * asks the first registered of accountList. - * If there is no account registered, returns NULL. - * @return the account to use if an outgoing call is placed. - */ - static Account * accountInUse(); - /** - * Seeks the ID of the account to use. - * If priorAccountId is defined and the corresponding - * account exists and is registered, uses this one, else, - * asks the first registered of accountList. - * If there is no account registered, returns an empty string. - * @return the ID of the account to use if an outgoing call is placed. - */ - static QString accountInUseId(); - - static AccountList * getAccountList(); - QErrorMessage * getErrorWindow(); - - //Daemon getters - /** - * Used to sort contacts according to their types with Kabc. - * @return the integer resulting to the flags of the types - * chosen to be displayed in SFLphone configuration. - */ - int phoneNumberTypesDisplayed(); - - /** - * - * @return true if the address book is enabled in config - */ - bool isAddressBookEnabled(); - - QVector<Contact *> findContactsInKAddressBook(QString textSearched, bool & full); - - /** - * Save the settings to save in the daemon before exit - */ - void saveState(); - - CallTreeView *callTree; - CallTreeView *historyTree; - CallTreeView *addressBookTree; + //Constructors & Destructors + /** + * This constructor does not load the window as it would + * better wait for the parent window to connect to the signals + * for updating it (statusMessageChangeAsked...). + * You should call the loadWindow() method once + * you have constructed the object and connected the + * expected signals. + * @param parent + */ + SFLPhoneView(QWidget *parent); + virtual ~SFLPhoneView(); + + //Getters + /** + * Seeks the account to use. + * If priorAccountId is defined and the corresponding + * account exists and is registered, uses this one, else, + * asks the first registered of accountList. + * If there is no account registered, returns NULL. + * @return the account to use if an outgoing call is placed. + */ + static Account * accountInUse(); + /** + * Seeks the ID of the account to use. + * If priorAccountId is defined and the corresponding + * account exists and is registered, uses this one, else, + * asks the first registered of accountList. + * If there is no account registered, returns an empty string. + * @return the ID of the account to use if an outgoing call is placed. + */ + static QString accountInUseId(); + + static AccountList * getAccountList(); + QErrorMessage * getErrorWindow(); + + //Daemon getters + /** + * Used to sort contacts according to their types with Kabc. + * @return the integer resulting to the flags of the types + * chosen to be displayed in SFLphone configuration. + */ + int phoneNumberTypesDisplayed(); + + /** + * + * @return true if the address book is enabled in config + */ + bool isAddressBookEnabled(); + + QVector<Contact *> findContactsInKAddressBook(QString textSearched, bool & full); + + /** + * Save the settings to save in the daemon before exit + */ + void saveState(); + + CallTreeView *callTree; + CallTreeView *historyTree; + CallTreeView *addressBookTree; private slots: - /** - * Performs the action action on the call call, then updates window. - * The call object will handle the action with its "actionPerformed" method. - * See the documentation for more details. - * @param call the call on which to perform the action - * @param action the code of the action to perform - */ - void action(Call * call, call_action action); - - /** - * Sets the account account to be the prior account. - * That means it's gonna be used when the user places a call - * if it's defined and registered, else the first registered of - * accountList will be used. - * @param account the account to use prior - */ - void setAccountFirst(Account * account); - - /** - * Handles the behaviour when the user types something with - * the dialpad widget or his keyboard (normally it's a one char - * string but we use a string just in case). - * Adds str to the selected item if in the main window - * and creates a new item if no item is selected. - * Send DTMF if appropriate according to current item's state. - * Adds str to the search bar if in history or address book. - * @param str the string sent by the user - */ - void typeString(QString str); + /** + * Performs the action action on the call call, then updates window. + * The call object will handle the action with its "actionPerformed" method. + * See the documentation for more details. + * @param call the call on which to perform the action + * @param action the code of the action to perform + */ + void action(Call * call, call_action action); + + /** + * Sets the account account to be the prior account. + * That means it's gonna be used when the user places a call + * if it's defined and registered, else the first registered of + * accountList will be used. + * @param account the account to use prior + */ + void setAccountFirst(Account * account); + + /** + * Handles the behaviour when the user types something with + * the dialpad widget or his keyboard (normally it's a one char + * string but we use a string just in case). + * Adds str to the selected item if in the main window + * and creates a new item if no item is selected. + * Send DTMF if appropriate according to current item's state. + * Adds str to the search bar if in history or address book. + * @param str the string sent by the user + */ + void typeString(QString str); - /** - * Handles the behaviour when the user types a backspace - * according to the current state (window, item selected...) - */ - void backspace(); + /** + * Handles the behaviour when the user types a backspace + * according to the current state (window, item selected...) + */ + void backspace(); - /** - * Handles the behaviour when the user types escape - * according to the current state (window, item selected...) - */ - void escape(); + /** + * Handles the behaviour when the user types escape + * according to the current state (window, item selected...) + */ + void escape(); - /** - * Handles the behaviour when the user types enter - * according to the current state (window, item selected...) - */ - void enter(); + /** + * Handles the behaviour when the user types enter + * according to the current state (window, item selected...) + */ + void enter(); - /** - * Displays a message window with editable text of the selected - * phone number in history or address book. - * Once the user accepts, place a call with the chosen phone number. - * Keeps the peer name of the contact or past call. - */ - void editBeforeCall(); - - /** - * Alternates colors of the list widget with the application's palettes's - * base and alternateBase colors. - * @param listWidget the list widget to which we alternate colors - */ - void alternateColors(QListWidget * listWidget); - - /** - * Adds the call's item to the call-list's listwidget. - * This function doesn't add anything to the callList object. - * @param call the call to add to the call-list's listwidget - */ - CallTreeItem* addCallToCallList(Call * call); + /** + * Displays a message window with editable text of the selected + * phone number in history or address book. + * Once the user accepts, place a call with the chosen phone number. + * Keeps the peer name of the contact or past call. + */ + void editBeforeCall(); + + /** + * Alternates colors of the list widget with the application's palettes's + * base and alternateBase colors. + * @param listWidget the list widget to which we alternate colors + */ + void alternateColors(QListWidget * listWidget); + + /** + * Adds the call's item to the call-list's listwidget. + * This function doesn't add anything to the callList object. + * @param call the call to add to the call-list's listwidget + */ + CallTreeItem* addCallToCallList(Call * call); - /** - * Adds the call's history-item to the call-history's listwidget. - * This function doesn't add anything to the callList object. - * @param call the past call to add to the call-history's listwidget - */ - CallTreeItem* addCallToCallHistory(Call * call); + /** + * Adds the call's history-item to the call-history's listwidget. + * This function doesn't add anything to the callList object. + * @param call the past call to add to the call-history's listwidget + */ + CallTreeItem* addCallToCallHistory(Call * call); - /** - * Adds the contact's item to the addressbook's listwidget. - * @param contact the contact to add to the addressbook's listwidget - */ - void addContactToContactList(Contact * contact); - - /** - * Updates the toolbar's actions' display according to the selected - * item's state. - */ - void updateWindowCallState(); + /** + * Adds the contact's item to the addressbook's listwidget. + * @param contact the contact to add to the addressbook's listwidget + */ + void addContactToContactList(Contact * contact); + + /** + * Updates the toolbar's actions' display according to the selected + * item's state. + */ + void updateWindowCallState(); - /** - * Updates the history's search bar's display according to the current - * text searched. - * If empty, hide the search bar. - */ - void updateSearchHistory(); - void updateCallHistory(); - void updateAddressBook(); - void updateRecordButton(); - void updateVolumeButton(); - void updateRecordBar(); - void updateVolumeBar(); - void updateVolumeControls(); - void updateDialpad(); + /** + * Updates the history's search bar's display according to the current + * text searched. + * If empty, hide the search bar. + */ + void updateSearchHistory(); + void updateCallHistory(); + void updateAddressBook(); + void updateRecordButton(); + void updateVolumeButton(); + void updateRecordBar(); + void updateVolumeBar(); + void updateVolumeControls(); + void updateDialpad(); public slots: - /** - * Updates all the display - * according to the settings. - */ - void loadWindow(); - - - void updateStatusMessage(); - - /** - * Enable the address book search line edit. - * To be called once the address book loading has finished. - */ - void enableAddressBook(); - - /** - * Loads the address book asynchronously. - * Calls enableAddressBook() once the address book - * loading has finished if it is not already loaded. - * @return true if address book has finished loading - */ - bool loadAddressBook(); - - /** - * Chooses to enable/disable (show/hide) the address book - * button according to the configuration's setting, and - * returns to the main window if is in address book - * whereas it is disabled. - */ - void updateAddressBookEnabled(); - - - virtual void keyPressEvent(QKeyEvent *event) - { - int key = event->key(); - if(key == Qt::Key_Escape) - escape(); - else if(key == Qt::Key_Return || key == Qt::Key_Enter) - enter(); - else if(key == Qt::Key_Backspace) - backspace(); - else - { - QString text = event->text(); - if(! event->text().isEmpty()) - { - typeString(text); - } - } - } + /** + * Updates all the display + * according to the settings. + */ + void loadWindow(); + + + void updateStatusMessage(); + + /** + * Enable the address book search line edit. + * To be called once the address book loading has finished. + */ + void enableAddressBook(); + + /** + * Loads the address book asynchronously. + * Calls enableAddressBook() once the address book + * loading has finished if it is not already loaded. + * @return true if address book has finished loading + */ + bool loadAddressBook(); + + /** + * Chooses to enable/disable (show/hide) the address book + * button according to the configuration's setting, and + * returns to the main window if is in address book + * whereas it is disabled. + */ + void updateAddressBookEnabled(); + + + virtual void keyPressEvent(QKeyEvent *event) + { + int key = event->key(); + if(key == Qt::Key_Escape) + escape(); + else if(key == Qt::Key_Return || key == Qt::Key_Enter) + enter(); + else if(key == Qt::Key_Backspace) + backspace(); + else + { + QString text = event->text(); + if(! event->text().isEmpty()) + { + typeString(text); + } + } + } - void displayVolumeControls(); - void displayDialpad(); - void configureSflPhone(); - void accountCreationWizard(); - void accept(); - void refuse(); - void hold(); - void transfer(); - void record(); - void mailBox(); - - void on_widget_dialpad_typed(QString text); - - void on_lineEdit_searchHistory_textChanged(); - void on_lineEdit_addressBook_textChanged(); - - void on_slider_recVol_valueChanged(int value); - void on_slider_sndVol_valueChanged(int value); + void displayVolumeControls(); + void displayDialpad(); + void configureSflPhone(); + void accountCreationWizard(); + void accept(); + void refuse(); + void hold(); + void transfer(); + void record(); + void mailBox(); + + void on_widget_dialpad_typed(QString text); + + void on_lineEdit_searchHistory_textChanged(); + void on_lineEdit_addressBook_textChanged(); + + void on_slider_recVol_valueChanged(int value); + void on_slider_sndVol_valueChanged(int value); void on_slider_recVol_2_valueChanged(int value); void on_slider_sndVol_2_valueChanged(int value); - - void on_toolButton_recVol_clicked(bool checked); - void on_toolButton_sndVol_clicked(bool checked); + + void on_toolButton_recVol_clicked(bool checked); + void on_toolButton_sndVol_clicked(bool checked); void on_toolButton_recVol_2_clicked(bool checked); void on_toolButton_sndVol_2_clicked(bool checked); - - void on_callTree_currentItemChanged(); - void on_callTree_itemChanged(); - void on_callTree_itemDoubleClicked(const QModelIndex &index); + + void on_callTree_currentItemChanged(); + void on_callTree_itemChanged(); + void on_callTree_itemDoubleClicked(const QModelIndex &index); - void on_listWidget_callHistory_currentItemChanged(); - void on_listWidget_callHistory_itemDoubleClicked(CallTreeItem * item); + void on_listWidget_callHistory_currentItemChanged(); + void on_listWidget_callHistory_itemDoubleClicked(CallTreeItem * item); - void on_listWidget_addressBook_currentItemChanged(); - void on_listWidget_addressBook_itemDoubleClicked(CallTreeItem * item); - - void on_stackedWidget_screen_currentChanged(int index); - - void on1_callStateChanged(const QString &callID, const QString &state); - void on1_error(MapStringString details); - void on1_incomingCall(const QString &accountID, const QString &callID/*, const QString &from*/); - void on1_incomingMessage(const QString &accountID, const QString &message); - void on1_voiceMailNotify(const QString &accountID, int count); - void on1_volumeChanged(const QString &device, double value); - void on1_audioManagerChanged(); - void changeScreen(int screen); - + void on_listWidget_addressBook_currentItemChanged(); + void on_listWidget_addressBook_itemDoubleClicked(CallTreeItem * item); + + void on_stackedWidget_screen_currentChanged(int index); + + void on1_callStateChanged(const QString &callID, const QString &state); + void on1_error(MapStringString details); + void on1_incomingCall(const QString &accountID, const QString &callID/*, const QString &from*/); + void on1_incomingMessage(const QString &accountID, const QString &message); + void on1_voiceMailNotify(const QString &accountID, int count); + void on1_volumeChanged(const QString &device, double value); + void on1_audioManagerChanged(); + void changeScreen(int screen); + signals: - void statusMessageChangeAsked(const QString & message); - void windowTitleChangeAsked(const QString & title); - void enabledActionsChangeAsked(const bool * enabledActions); - void actionIconsChangeAsked(const QString * actionIcons); - void actionTextsChangeAsked(const QString * actionTexts); - void transferCheckStateChangeAsked(bool transferCheckState); - void recordCheckStateChangeAsked(bool recordCheckState); - void addressBookEnableAsked(bool enableAddressBook); - void screenChanged(int screen); - void incomingCall(const Call * call); - + void statusMessageChangeAsked(const QString & message); + void windowTitleChangeAsked(const QString & title); + void enabledActionsChangeAsked(const bool * enabledActions); + void actionIconsChangeAsked(const QString * actionIcons); + void actionTextsChangeAsked(const QString * actionTexts); + void transferCheckStateChangeAsked(bool transferCheckState); + void recordCheckStateChangeAsked(bool recordCheckState); + void addressBookEnableAsked(bool enableAddressBook); + void screenChanged(int screen); + void incomingCall(const Call * call); + }; diff --git a/sflphone-client-kde/src/SFLPhoneapplication.cpp b/sflphone-client-kde/src/SFLPhoneapplication.cpp index bbb54dd82e90392fcc6b9549fad3de8cf44e24e8..a80c6b31958d6482e2b4ede4828c0f5b255e972e 100644 --- a/sflphone-client-kde/src/SFLPhoneapplication.cpp +++ b/sflphone-client-kde/src/SFLPhoneapplication.cpp @@ -56,13 +56,10 @@ void SFLPhoneApplication::initializeMainWindow() // Enable KDE session restore. int restoredWindow = -1; - if( kapp->isSessionRestored() ) - { + if( kapp->isSessionRestored() ) { int n = 0; - while( KMainWindow::canBeRestored( ++n ) ) - { - if( KMainWindow::classNameOfToplevel( n ) != QLatin1String( "SFLPhone" ) ) - { + while( KMainWindow::canBeRestored( ++n ) ) { + if( KMainWindow::classNameOfToplevel( n ) != QLatin1String( "SFLPhone" ) ) { continue; } @@ -73,8 +70,7 @@ void SFLPhoneApplication::initializeMainWindow() // Create the main window and initialize it sflphoneWindow_ = new SFLPhone(); - if( ! sflphoneWindow_->initialize() ) - { + if( ! sflphoneWindow_->initialize() ) { exit(1); return; } @@ -98,8 +94,7 @@ void SFLPhoneApplication::initializePaths() qDebug() << "KGlobal::dirs" << QString(DATA_INSTALL_DIR); // Test whether the prefix is correct. - if( KGlobal::dirs()->findResource( "appdata", "icons/hi128-apps-sflphone-client-kde.png" ).isNull() ) - { + if( KGlobal::dirs()->findResource( "appdata", "icons/hi128-apps-sflphone-client-kde.png" ).isNull() ) { kWarning() << "SFLPhone could not find resources in the search paths: " << KGlobal::dirs()->findDirs( "appdata", QString::null ).join(", ") << endl; } diff --git a/sflphone-client-kde/src/SFLPhoneapplication.h b/sflphone-client-kde/src/SFLPhoneapplication.h index 69bab3386503734b748a5c3ce06999fbfc4a3548..a9663809d42c02f169c71ffb3bcea2a128cb8968 100644 --- a/sflphone-client-kde/src/SFLPhoneapplication.h +++ b/sflphone-client-kde/src/SFLPhoneapplication.h @@ -13,14 +13,14 @@ class SFLPhoneApplication : public KApplication Q_OBJECT public: - // Constructor - SFLPhoneApplication(); + // Constructor + SFLPhoneApplication(); - // Destructor - virtual ~SFLPhoneApplication(); + // Destructor + virtual ~SFLPhoneApplication(); - // Return the contact list window - SFLPhone* getSFLPhoneWindow() const; + // Return the contact list window + SFLPhone* getSFLPhoneWindow() const; private: // private methods void initializeMainWindow(); diff --git a/sflphone-client-kde/src/SortableCodecListWidget.cpp b/sflphone-client-kde/src/SortableCodecListWidget.cpp index 62ba504a573a6fa7b5094980d4fa904bfab92b3b..1aaf8b1fee274ecbdcd7a8c284cb5a3d3f1b2e69 100644 --- a/sflphone-client-kde/src/SortableCodecListWidget.cpp +++ b/sflphone-client-kde/src/SortableCodecListWidget.cpp @@ -28,116 +28,112 @@ SortableCodecListWidget::SortableCodecListWidget(QWidget *parent) : QWidget(parent) { - codecTable = new QTableView(this); - codecTable->setObjectName("codecTable"); - codecTable->setSelectionBehavior(QAbstractItemView::SelectRows); - codecTable->verticalHeader()->hide(); - - codecUpButton = new KPushButton(this); - codecUpButton->setObjectName("codecUpButton"); - codecUpButton->setIcon(KIcon("go-up")); - - codecDownButton = new KPushButton(this); - codecDownButton->setObjectName("codecDownButton"); - codecDownButton->setIcon(KIcon("go-down")); - - QHBoxLayout * mainLayout = new QHBoxLayout(this); - QVBoxLayout * buttonsLayout = new QVBoxLayout(); - - buttonsLayout->addWidget(codecUpButton); - buttonsLayout->addWidget(codecDownButton); - - mainLayout->addWidget(codecTable); - mainLayout->addLayout(buttonsLayout); - - QMetaObject::connectSlotsByName(this); + codecTable = new QTableView(this); + codecTable->setObjectName("codecTable"); + codecTable->setSelectionBehavior(QAbstractItemView::SelectRows); + codecTable->verticalHeader()->hide(); + + codecUpButton = new KPushButton(this); + codecUpButton->setObjectName("codecUpButton"); + codecUpButton->setIcon(KIcon("go-up")); + + codecDownButton = new KPushButton(this); + codecDownButton->setObjectName("codecDownButton"); + codecDownButton->setIcon(KIcon("go-down")); + + QHBoxLayout * mainLayout = new QHBoxLayout(this); + QVBoxLayout * buttonsLayout = new QVBoxLayout(); + + buttonsLayout->addWidget(codecUpButton); + buttonsLayout->addWidget(codecDownButton); + + mainLayout->addWidget(codecTable); + mainLayout->addLayout(buttonsLayout); + + QMetaObject::connectSlotsByName(this); } void SortableCodecListWidget::setModel(CodecListModel * model) { - codecTable->setModel(model); - codecTable->resizeColumnsToContents(); - codecTable->resizeRowsToContents(); - connect(codecTable->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), - this, SLOT(updateCommands())); - connect(codecTable->model(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), - this, SIGNAL(dataChanged())); + codecTable->setModel(model); + codecTable->resizeColumnsToContents(); + codecTable->resizeRowsToContents(); + connect(codecTable->selectionModel(), SIGNAL(selectionChanged(const QItemSelection &, const QItemSelection &)), + this, SLOT(updateCommands())); + connect(codecTable->model(), SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), + this, SIGNAL(dataChanged())); } CodecListModel * SortableCodecListWidget::model() { - return (CodecListModel *) codecTable->model(); + return (CodecListModel *) codecTable->model(); } void SortableCodecListWidget::on_codecUpButton_clicked() { - qDebug() << "on_toolButton_codecUpButton_clicked"; - CodecListModel * model = (CodecListModel *) codecTable->model(); - int currentRow = selectedRow(); - model->codecUp(currentRow); - setSelectedRow(currentRow - 1); + qDebug() << "on_toolButton_codecUpButton_clicked"; + CodecListModel * model = (CodecListModel *) codecTable->model(); + int currentRow = selectedRow(); + model->codecUp(currentRow); + setSelectedRow(currentRow - 1); } void SortableCodecListWidget::on_codecDownButton_clicked() { - qDebug() << "on_codecDownButton_clicked"; - CodecListModel * model = (CodecListModel *) codecTable->model(); - int currentRow = selectedRow(); - model->codecDown(currentRow); - setSelectedRow(currentRow + 1); + qDebug() << "on_codecDownButton_clicked"; + CodecListModel * model = (CodecListModel *) codecTable->model(); + int currentRow = selectedRow(); + model->codecDown(currentRow); + setSelectedRow(currentRow + 1); } void SortableCodecListWidget::updateCommands() { - qDebug() << "SortableCodecListWidget::updateCommands"; - bool buttonsEnabled[2] = {true,true}; - if(selectedRow() == -1) - { - buttonsEnabled[0] = false; - buttonsEnabled[1] = false; - } - else - { - if(selectedRow() == 0) - { - buttonsEnabled[0] = false; - } - if(selectedRow() == codecTable->model()->rowCount() - 1) - { - buttonsEnabled[1] = false; - } - } - codecUpButton->setEnabled(buttonsEnabled[0]); - codecDownButton->setEnabled(buttonsEnabled[1]); + qDebug() << "SortableCodecListWidget::updateCommands"; + bool buttonsEnabled[2] = {true,true}; + if(selectedRow() == -1) { + buttonsEnabled[0] = false; + buttonsEnabled[1] = false; + } + else { + if(selectedRow() == 0) { + buttonsEnabled[0] = false; + } + + if(selectedRow() == codecTable->model()->rowCount() - 1) { + buttonsEnabled[1] = false; + } + } + codecUpButton->setEnabled(buttonsEnabled[0]); + codecDownButton->setEnabled(buttonsEnabled[1]); } QModelIndex SortableCodecListWidget::selectedIndex() { - QItemSelectionModel *selection = codecTable->selectionModel(); - const QModelIndexList selectedIndexes = selection->selectedIndexes(); - if ( !selectedIndexes.isEmpty() && selectedIndexes[0].isValid() ) - return selectedIndexes[0]; - else - return QModelIndex(); + QItemSelectionModel *selection = codecTable->selectionModel(); + const QModelIndexList selectedIndexes = selection->selectedIndexes(); + if ( !selectedIndexes.isEmpty() && selectedIndexes[0].isValid() ) + return selectedIndexes[0]; + else + return QModelIndex(); } int SortableCodecListWidget::selectedRow() { - QModelIndex index = selectedIndex(); - if(index.isValid()) - return index.row(); - else - return -1; + QModelIndex index = selectedIndex(); + if(index.isValid()) + return index.row(); + else + return -1; } void SortableCodecListWidget::setSelectedRow(int row) { - QItemSelectionModel * selection = codecTable->selectionModel(); - QAbstractItemModel * model = codecTable->model(); - QItemSelection newSelection = QItemSelection(model->index(row, 0, QModelIndex()), model->index(row +1 , model->columnCount(), QModelIndex())); - selection->clear(); - for(int i = 0 ; i < model->columnCount() ; i++) - { - selection->select(model->index(row, i, QModelIndex()) , QItemSelectionModel::Select); - } + QItemSelectionModel * selection = codecTable->selectionModel(); + QAbstractItemModel * model = codecTable->model(); + QItemSelection newSelection = QItemSelection(model->index(row, 0, QModelIndex()), model->index(row +1 , model->columnCount(), QModelIndex())); + selection->clear(); + for(int i = 0 ; i < model->columnCount() ; i++) { + selection->select(model->index(row, i, QModelIndex()) , QItemSelectionModel::Select); + } } \ No newline at end of file diff --git a/sflphone-client-kde/src/SortableCodecListWidget.h b/sflphone-client-kde/src/SortableCodecListWidget.h index 0ea9eae8fecad5859968f56d28585be317e81f66..1a8d48e5e9b2154333c8de0f1e3d00f2958cd489 100644 --- a/sflphone-client-kde/src/SortableCodecListWidget.h +++ b/sflphone-client-kde/src/SortableCodecListWidget.h @@ -27,37 +27,37 @@ #include "CodecListModel.h" /** - @author Jérémy Quentin <jeremy.quentin@gmail.com> + @author Jérémy Quentin <jeremy.quentin@gmail.com> */ class SortableCodecListWidget : public QWidget { Q_OBJECT private: - KPushButton * codecUpButton; - KPushButton * codecDownButton; - QTableView * codecTable; + KPushButton * codecUpButton; + KPushButton * codecDownButton; + QTableView * codecTable; public: - SortableCodecListWidget(QWidget *parent = 0); - - virtual void setModel(CodecListModel * model); - virtual CodecListModel * model(); - + SortableCodecListWidget(QWidget *parent = 0); + + virtual void setModel(CodecListModel * model); + virtual CodecListModel * model(); + private slots: - void on_codecUpButton_clicked(); - void on_codecDownButton_clicked(); - + void on_codecUpButton_clicked(); + void on_codecDownButton_clicked(); + public slots: - void updateCommands(); - + void updateCommands(); + private: - QModelIndex selectedIndex(); - int selectedRow(); + QModelIndex selectedIndex(); + int selectedRow(); - void setSelectedRow(int row); - + void setSelectedRow(int row); + signals: - void dataChanged(); + void dataChanged(); }; diff --git a/sflphone-client-kde/src/conf/ConfigurationDialog.cpp b/sflphone-client-kde/src/conf/ConfigurationDialog.cpp index c9a832b0207564d69abca59a00ed9889974c0756..e1c85f50e7d1a28f2a3f6a6ae4248d722feaad25 100644 --- a/sflphone-client-kde/src/conf/ConfigurationDialog.cpp +++ b/sflphone-client-kde/src/conf/ConfigurationDialog.cpp @@ -34,26 +34,26 @@ ConfigurationDialog::ConfigurationDialog(SFLPhoneView *parent) :KConfigDialog(parent, SETTINGS_NAME, ConfigurationSkeleton::self()) { - this->setWindowIcon(QIcon(ICON_SFLPHONE)); - - dlgGeneral = new DlgGeneral(this); - dlgDisplay = new DlgDisplay(this); - dlgAccounts = new DlgAccounts(this); - dlgAudio = new DlgAudio(this); - dlgAddressBook = new DlgAddressBook(this); - dlgHooks = new DlgHooks(this); - - addPage( dlgGeneral , i18n("General") , "sflphone-client-kde" ); - addPage( dlgDisplay , i18n("Display") , "applications-graphics" ); - addPage( dlgAccounts , i18n("Accounts") , "personal" ); - addPage( dlgAudio , i18n("Audio") , "voicecall" ); - addPage( dlgAddressBook , i18n("Address Book") , "x-office-address-book" ); - addPage( dlgHooks , i18n("Hooks") , "insert-link" ); - - connect(this, SIGNAL(applyClicked()), this, SLOT(applyCustomSettings())); - connect(this, SIGNAL(okClicked()), this, SLOT(applyCustomSettings())); - - connect(dlgGeneral, SIGNAL(clearCallHistoryAsked()), this, SIGNAL(clearCallHistoryAsked())); + this->setWindowIcon(QIcon(ICON_SFLPHONE)); + + dlgGeneral = new DlgGeneral(this); + dlgDisplay = new DlgDisplay(this); + dlgAccounts = new DlgAccounts(this); + dlgAudio = new DlgAudio(this); + dlgAddressBook = new DlgAddressBook(this); + dlgHooks = new DlgHooks(this); + + addPage( dlgGeneral , i18n("General") , "sflphone-client-kde" ); + addPage( dlgDisplay , i18n("Display") , "applications-graphics" ); + addPage( dlgAccounts , i18n("Accounts") , "personal" ); + addPage( dlgAudio , i18n("Audio") , "voicecall" ); + addPage( dlgAddressBook , i18n("Address Book") , "x-office-address-book" ); + addPage( dlgHooks , i18n("Hooks") , "insert-link" ); + + connect(this, SIGNAL(applyClicked()), this, SLOT(applyCustomSettings())); + connect(this, SIGNAL(okClicked()), this, SLOT(applyCustomSettings())); + + connect(dlgGeneral, SIGNAL(clearCallHistoryAsked()), this, SIGNAL(clearCallHistoryAsked())); } @@ -63,49 +63,48 @@ ConfigurationDialog::~ConfigurationDialog() void ConfigurationDialog::updateWidgets() { - qDebug() << "\nupdateWidgets"; - dlgAudio->updateWidgets(); - dlgAccounts->updateWidgets(); + qDebug() << "\nupdateWidgets"; + dlgAudio->updateWidgets(); + dlgAccounts->updateWidgets(); } void ConfigurationDialog::updateSettings() { - qDebug() << "\nupdateSettings"; - dlgAudio->updateSettings(); - dlgAccounts->updateSettings(); + qDebug() << "\nupdateSettings"; + dlgAudio->updateSettings(); + dlgAccounts->updateSettings(); } bool ConfigurationDialog::hasChanged() { - bool res = dlgAudio->hasChanged() || dlgAccounts->hasChanged(); - qDebug() << "hasChanged" << res; - return res; + bool res = dlgAudio->hasChanged() || dlgAccounts->hasChanged(); + qDebug() << "hasChanged" << res; + return res; } void ConfigurationDialog::updateButtons() { - bool changed = hasChanged(); - qDebug() << "updateButtons , hasChanged = " << changed; - enableButtonApply( changed ); + bool changed = hasChanged(); + qDebug() << "updateButtons , hasChanged = " << changed; + enableButtonApply( changed ); } void ConfigurationDialog::applyCustomSettings() { - qDebug() << "\napplyCustomSettings"; - if(hasChanged()) - { + qDebug() << "\napplyCustomSettings"; + if(hasChanged()) { ConfigurationSkeleton::self()->writeConfig(); - } - updateSettings(); - updateWidgets(); - updateButtons(); - emit changesApplied(); + } + updateSettings(); + updateWidgets(); + updateButtons(); + emit changesApplied(); } void ConfigurationDialog::reload() { - qDebug() << "reload"; - ConfigurationSkeleton::self()->readConfig(); - updateWidgets(); - updateButtons(); + qDebug() << "reload"; + ConfigurationSkeleton::self()->readConfig(); + updateWidgets(); + updateButtons(); } diff --git a/sflphone-client-kde/src/conf/ConfigurationDialog.h b/sflphone-client-kde/src/conf/ConfigurationDialog.h index 33c6dac81a6a75e539793cc173f4c466d0da855b..6751d65a8bdc2b135167ab68e316e89731d44037 100644 --- a/sflphone-client-kde/src/conf/ConfigurationDialog.h +++ b/sflphone-client-kde/src/conf/ConfigurationDialog.h @@ -41,76 +41,76 @@ class DlgHooks; class SFLPhoneView; /** - @author Jérémy Quentin <jeremy.quentin@gmail.com> - This class represents the config dialog for sflphone. - It uses the ConfigurationSkeleton class to handle most of the settings. - It inherits KConfigDialog with the pages defined in dlg... files. - A few complicated settings are handled directly by its pages. - Some custom behaviors have been added to handle specific cases, - as this config dialog is not the usual kind. - A few things might be done a cleaner way by passing the handling - to the skeleton like it has been done with codecs. + @author Jérémy Quentin <jeremy.quentin@gmail.com> + This class represents the config dialog for sflphone. + It uses the ConfigurationSkeleton class to handle most of the settings. + It inherits KConfigDialog with the pages defined in dlg... files. + A few complicated settings are handled directly by its pages. + Some custom behaviors have been added to handle specific cases, + as this config dialog is not the usual kind. + A few things might be done a cleaner way by passing the handling + to the skeleton like it has been done with codecs. */ class ConfigurationDialog : public KConfigDialog { Q_OBJECT private: - - DlgGeneral * dlgGeneral; - DlgDisplay * dlgDisplay; - DlgAccounts * dlgAccounts; - DlgAudio * dlgAudio; - DlgAddressBook * dlgAddressBook; - DlgHooks * dlgHooks; + + DlgGeneral * dlgGeneral; + DlgDisplay * dlgDisplay; + DlgAccounts * dlgAccounts; + DlgAudio * dlgAudio; + DlgAddressBook * dlgAddressBook; + DlgHooks * dlgHooks; public: - ConfigurationDialog(SFLPhoneView *parent = 0); + ConfigurationDialog(SFLPhoneView *parent = 0); - ~ConfigurationDialog(); - + ~ConfigurationDialog(); + public slots: - /** - * Reimplements KConfigDialog - */ - void updateWidgets(); - /** - * Reimplements KConfigDialog - */ - void updateSettings(); - /** - * Is implemented in KConfigDialog only from KDE4.3 - * It it implemented here for KDE4.2 users. - * I didn't test with KDE4.3 so I leave it even for 4.3 users. - * Causes problems for a few cases (item managed by kconfig switched, item not managed - * switched and then switched back, apply becomes disabled). - * Can't be resolved without a method to know if items managed by kconfig have changed. - * Disable/Enable Apply Button according to hasChanged() result - */ - void updateButtons(); - /** - * @return whether any custom widget has changed in the dialog. - */ - bool hasChanged(); - - /** - * reloads the informations before showing it. - */ - void reload(); - + /** + * Reimplements KConfigDialog + */ + void updateWidgets(); + /** + * Reimplements KConfigDialog + */ + void updateSettings(); + /** + * Is implemented in KConfigDialog only from KDE4.3 + * It it implemented here for KDE4.2 users. + * I didn't test with KDE4.3 so I leave it even for 4.3 users. + * Causes problems for a few cases (item managed by kconfig switched, item not managed + * switched and then switched back, apply becomes disabled). + * Can't be resolved without a method to know if items managed by kconfig have changed. + * Disable/Enable Apply Button according to hasChanged() result + */ + void updateButtons(); + /** + * @return whether any custom widget has changed in the dialog. + */ + bool hasChanged(); + + /** + * reloads the informations before showing it. + */ + void reload(); + private slots: - /** - * Apply settings not managed by kconfig (accounts) - * Should be removed when accounts are managed by kconfig. - */ - void applyCustomSettings(); + /** + * Apply settings not managed by kconfig (accounts) + * Should be removed when accounts are managed by kconfig. + */ + void applyCustomSettings(); signals: - void clearCallHistoryAsked(); - void changesApplied(); - + void clearCallHistoryAsked(); + void changesApplied(); + }; #endif diff --git a/sflphone-client-kde/src/conf/ConfigurationSkeleton.cpp b/sflphone-client-kde/src/conf/ConfigurationSkeleton.cpp index 92732eb4209536f7bcce33dd71aa2e273b74072b..fa0a54ccc2e3c08b9167227337b0cf97accfe7b8 100644 --- a/sflphone-client-kde/src/conf/ConfigurationSkeleton.cpp +++ b/sflphone-client-kde/src/conf/ConfigurationSkeleton.cpp @@ -26,18 +26,18 @@ ConfigurationSkeleton::ConfigurationSkeleton() : ConfigurationSkeletonBase() { - qDebug() << "Building ConfigurationSkeleton"; - //codecListModel = new CodecListModel(); - readConfig(); + qDebug() << "Building ConfigurationSkeleton"; + //codecListModel = new CodecListModel(); + readConfig(); } ConfigurationSkeleton * ConfigurationSkeleton::instance = NULL; ConfigurationSkeleton * ConfigurationSkeleton::self() { - if(instance == NULL) - { instance = new ConfigurationSkeleton(); } - return instance; + if(instance == NULL) + { instance = new ConfigurationSkeleton(); } + return instance; } @@ -47,255 +47,249 @@ ConfigurationSkeleton::~ConfigurationSkeleton() // CodecListModel * ConfigurationSkeleton::getCodecListModel() // { -// return codecListModel; +// return codecListModel; // } void ConfigurationSkeleton::readConfig() { - qDebug() << "\nReading config"; - - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - - //////////////////////// - ////General settings//// - //////////////////////// - - //Call history settings + qDebug() << "\nReading config"; + + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + + //////////////////////// + ////General settings//// + //////////////////////// + + //Call history settings setEnableHistory(QVariant(configurationManager.getHistoryEnabled()).toBool()); - setHistoryMax(configurationManager.getHistoryLimit()); - - //////////////////////// - ////Display settings//// - //////////////////////// + setHistoryMax(configurationManager.getHistoryLimit()); + + //////////////////////// + ////Display settings//// + //////////////////////// - //Notification settings - setNotifOnCalls(configurationManager.getNotify()); - setNotifOnMessages(configurationManager.getMailNotify()); - - //Window display settings - setDisplayOnStart(! configurationManager.isStartHidden()); - setDisplayOnCalls(configurationManager.popupMode()); - - ///////////////////////// - ////Accounts settings//// - ///////////////////////// - -// loadAccountList(); + //Notification settings + setNotifOnCalls(configurationManager.getNotify()); + setNotifOnMessages(configurationManager.getMailNotify()); + + //Window display settings + setDisplayOnStart(! configurationManager.isStartHidden()); + setDisplayOnCalls(configurationManager.popupMode()); + + ///////////////////////// + ////Accounts settings//// + ///////////////////////// + +// loadAccountList(); - - ////////////////////// - ////Audio settings//// - ////////////////////// - - //Audio Interface settings - int audioManager = configurationManager.getAudioManager(); - qDebug() << "audioManager = " << audioManager; - setInterface(audioManager); + + ////////////////////// + ////Audio settings//// + ////////////////////// + + //Audio Interface settings + int audioManager = configurationManager.getAudioManager(); + qDebug() << "audioManager = " << audioManager; + setInterface(audioManager); - //ringtones settings - setEnableRingtones(configurationManager.isRingtoneEnabled()); - QString ringtone = configurationManager.getRingtoneChoice(); - if(ringtone.isEmpty()) - { - setRingtone(QString(SHARE_INSTALL_PREFIX) + "sflphone/ringtones/konga.ul"); - } - else - { - setRingtone(ringtone); - } + //ringtones settings + setEnableRingtones(configurationManager.isRingtoneEnabled()); + QString ringtone = configurationManager.getRingtoneChoice(); + if(ringtone.isEmpty()) { + setRingtone(QString(SHARE_INSTALL_PREFIX) + "sflphone/ringtones/konga.ul"); + } + else { + setRingtone(ringtone); + } - //codecs settings - //setActiveCodecList(configurationManager.getActiveCodecList()); //Outdated + //codecs settings + //setActiveCodecList(configurationManager.getActiveCodecList()); //Outdated - qDebug() << "configurationManager.getCurrentAudioOutputPlugin() = " << configurationManager.getCurrentAudioOutputPlugin(); - setAlsaPlugin(configurationManager.getCurrentAudioOutputPlugin()); - bool ok; - QStringList devices = configurationManager.getCurrentAudioDevicesIndex(); + qDebug() << "configurationManager.getCurrentAudioOutputPlugin() = " << configurationManager.getCurrentAudioOutputPlugin(); + setAlsaPlugin(configurationManager.getCurrentAudioOutputPlugin()); + bool ok; + QStringList devices = configurationManager.getCurrentAudioDevicesIndex(); int inputDevice =0; if (devices.size() > 1) { qDebug() << "inputDevice = " << devices[1]; int inputDevice = devices[1].toInt(& ok); } else qDebug() << "Fatal: Too few audio devices"; - if(!ok) qDebug() << "inputDevice is not a number"; - setAlsaInputDevice(inputDevice); - - qDebug() << "outputDevice = " << devices[0]; - int outputDevice = devices[0].toInt(& ok); - if(!ok) qDebug() << "outputDevice is not a number"; - setAlsaOutputDevice(outputDevice); - - /////////////////////// - ////Record settings//// - /////////////////////// - - QString recordPath = configurationManager.getRecordPath(); - if(! recordPath.isEmpty()) - { - setDestinationFolder(recordPath); - } - else - { - setDestinationFolder(QDir::home().path()); - } - - - - ///////////////////////////// - ////Address book settings//// - ///////////////////////////// - - MapStringInt addressBookSettings = configurationManager.getAddressbookSettings().value(); - qDebug() << "getAddressbookSettings() : " << addressBookSettings; - setEnableAddressBook(addressBookSettings[ADDRESSBOOK_ENABLE]); - setMaxResults(addressBookSettings[ADDRESSBOOK_MAX_RESULTS]); - setDisplayPhoto(addressBookSettings[ADDRESSBOOK_DISPLAY_CONTACT_PHOTO]); - setBusiness(addressBookSettings[ADDRESSBOOK_DISPLAY_BUSINESS]); - setMobile(addressBookSettings[ADDRESSBOOK_DISPLAY_MOBILE]); - setHome(addressBookSettings[ADDRESSBOOK_DISPLAY_HOME]); - - ///////////////////////////// - ///////Hooks settings//////// - ///////////////////////////// - - MapStringString hooksSettings = configurationManager.getHookSettings().value(); - qDebug() << "getHooksSettings() : " << hooksSettings; - setAddPrefix(hooksSettings[HOOKS_ENABLED]=="1"); - setPrepend(hooksSettings[HOOKS_ADD_PREFIX]); - setEnableHooksSIP(hooksSettings[HOOKS_SIP_ENABLED]=="1"); - setEnableHooksIAX(hooksSettings[HOOKS_IAX2_ENABLED]=="1"); - setHooksSIPHeader(hooksSettings[HOOKS_SIP_FIELD]); - setHooksCommand(hooksSettings[HOOKS_COMMAND]); - - qDebug() << "Finished to read config\n"; + if(!ok) qDebug() << "inputDevice is not a number"; + setAlsaInputDevice(inputDevice); + + qDebug() << "outputDevice = " << devices[0]; + int outputDevice = devices[0].toInt(& ok); + if(!ok) qDebug() << "outputDevice is not a number"; + setAlsaOutputDevice(outputDevice); + + /////////////////////// + ////Record settings//// + /////////////////////// + + QString recordPath = configurationManager.getRecordPath(); + if(! recordPath.isEmpty()) { + setDestinationFolder(recordPath); + } + else { + setDestinationFolder(QDir::home().path()); + } + + + + ///////////////////////////// + ////Address book settings//// + ///////////////////////////// + + MapStringInt addressBookSettings = configurationManager.getAddressbookSettings().value(); + qDebug() << "getAddressbookSettings() : " << addressBookSettings; + setEnableAddressBook(addressBookSettings[ADDRESSBOOK_ENABLE]); + setMaxResults(addressBookSettings[ADDRESSBOOK_MAX_RESULTS]); + setDisplayPhoto(addressBookSettings[ADDRESSBOOK_DISPLAY_CONTACT_PHOTO]); + setBusiness(addressBookSettings[ADDRESSBOOK_DISPLAY_BUSINESS]); + setMobile(addressBookSettings[ADDRESSBOOK_DISPLAY_MOBILE]); + setHome(addressBookSettings[ADDRESSBOOK_DISPLAY_HOME]); + + ///////////////////////////// + ///////Hooks settings//////// + ///////////////////////////// + + MapStringString hooksSettings = configurationManager.getHookSettings().value(); + qDebug() << "getHooksSettings() : " << hooksSettings; + setAddPrefix(hooksSettings[HOOKS_ENABLED]=="1"); + setPrepend(hooksSettings[HOOKS_ADD_PREFIX]); + setEnableHooksSIP(hooksSettings[HOOKS_SIP_ENABLED]=="1"); + setEnableHooksIAX(hooksSettings[HOOKS_IAX2_ENABLED]=="1"); + setHooksSIPHeader(hooksSettings[HOOKS_SIP_FIELD]); + setHooksCommand(hooksSettings[HOOKS_COMMAND]); + + qDebug() << "Finished to read config\n"; } void ConfigurationSkeleton::writeConfig() { - qDebug() << "\nWriting config"; - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - - - //////////////////////// - ////General settings//// - //////////////////////// - - qDebug() << "Writing General settings"; - - //Call history settings + qDebug() << "\nWriting config"; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + + + //////////////////////// + ////General settings//// + //////////////////////// + + qDebug() << "Writing General settings"; + + //Call history settings if(enableHistory() != QVariant(configurationManager.getHistoryEnabled()).toBool() ) { configurationManager.setHistoryEnabled(); } - configurationManager.setHistoryLimit(historyMax()); + configurationManager.setHistoryLimit(historyMax()); - //////////////////////// - ////Display settings//// - //////////////////////// - - qDebug() << "Writing Display settings"; - - //Notification settings - if(notifOnCalls() != configurationManager.getNotify()) configurationManager.setNotify(); - if(notifOnMessages() != configurationManager.getMailNotify()) configurationManager.setMailNotify(); - - //Window display settings - //WARNING états inversés - if(displayOnStart() == configurationManager.isStartHidden()) configurationManager.startHidden(); - if(displayOnCalls() != configurationManager.popupMode()) configurationManager.switchPopupMode(); - - ///////////////////////// - ////Accounts settings//// - ///////////////////////// - - qDebug() << "Writing Accounts settings"; - -// saveAccountList(); + //////////////////////// + ////Display settings//// + //////////////////////// + + qDebug() << "Writing Display settings"; + + //Notification settings + if(notifOnCalls() != configurationManager.getNotify()) configurationManager.setNotify(); + if(notifOnMessages() != configurationManager.getMailNotify()) configurationManager.setMailNotify(); + + //Window display settings + //WARNING états inversés + if(displayOnStart() == configurationManager.isStartHidden()) configurationManager.startHidden(); + if(displayOnCalls() != configurationManager.popupMode()) configurationManager.switchPopupMode(); + + ///////////////////////// + ////Accounts settings//// + ///////////////////////// + + qDebug() << "Writing Accounts settings"; + +// saveAccountList(); - ////////////////////// - ////Audio settings//// - ////////////////////// - - qDebug() << "Writing Audio settings"; - - //Audio Interface settings - int prevManager = configurationManager.getAudioManager(); - int newManager = interface(); - if(prevManager != newManager) - { - configurationManager.setAudioManager(newManager); - } - - //ringtones settings - if(enableRingtones() != configurationManager.isRingtoneEnabled()) configurationManager.ringtoneEnabled(); - configurationManager.setRingtoneChoice(ringtone()); + ////////////////////// + ////Audio settings//// + ////////////////////// + + qDebug() << "Writing Audio settings"; + + //Audio Interface settings + int prevManager = configurationManager.getAudioManager(); + int newManager = interface(); + if(prevManager != newManager) { + configurationManager.setAudioManager(newManager); + } + + //ringtones settings + if(enableRingtones() != configurationManager.isRingtoneEnabled()) configurationManager.ringtoneEnabled(); + configurationManager.setRingtoneChoice(ringtone()); - //codecs settings - //qDebug() << "activeCodecList = " << activeCodecList(); - //configurationManager.setActiveCodecList(activeCodecList()); - + //codecs settings + //qDebug() << "activeCodecList = " << activeCodecList(); + //configurationManager.setActiveCodecList(activeCodecList()); + - //alsa settings - if(prevManager == CONST_ALSA && newManager == EnumInterface::ALSA) - { - qDebug() << "setting alsa settings"; - configurationManager.setOutputAudioPlugin(alsaPlugin()); - configurationManager.setAudioInputDevice(alsaInputDevice()); - configurationManager.setAudioOutputDevice(alsaOutputDevice()); - } - - - /////////////////////// - ////Record settings//// - /////////////////////// - - qDebug() << "Writing Record settings"; - - QString destination = destinationFolder(); - configurationManager.setRecordPath(destination); - - - ///////////////////////////// - ////Address Book settings//// - ///////////////////////////// - - qDebug() << "Writing Address Book settings"; - - MapStringInt addressBookSettings = MapStringInt(); - addressBookSettings[ADDRESSBOOK_ENABLE] = enableAddressBook(); - addressBookSettings[ADDRESSBOOK_MAX_RESULTS] = maxResults(); - addressBookSettings[ADDRESSBOOK_DISPLAY_CONTACT_PHOTO] = displayPhoto(); - addressBookSettings[ADDRESSBOOK_DISPLAY_BUSINESS] = business(); - addressBookSettings[ADDRESSBOOK_DISPLAY_MOBILE] = mobile(); - addressBookSettings[ADDRESSBOOK_DISPLAY_HOME] = home(); - configurationManager.setAddressbookSettings(addressBookSettings); - - ///////////////////////////// - ///////Hooks settings//////// - ///////////////////////////// - - qDebug() << "Writing Hooks settings"; - - MapStringString hooksSettings = MapStringString(); - hooksSettings[HOOKS_ENABLED] = addPrefix() ? "1" : "0"; - hooksSettings[HOOKS_ADD_PREFIX] = prepend(); - hooksSettings[HOOKS_SIP_ENABLED] = enableHooksSIP() ? "1" : "0"; - hooksSettings[HOOKS_IAX2_ENABLED] = enableHooksIAX() ? "1" : "0"; - hooksSettings[HOOKS_SIP_FIELD] = hooksSIPHeader(); - hooksSettings[HOOKS_COMMAND] = hooksCommand(); - configurationManager.setHookSettings(hooksSettings); - - qDebug() << "Finished to write config\n"; - - readConfig(); + //alsa settings + if(prevManager == CONST_ALSA && newManager == EnumInterface::ALSA) { + qDebug() << "setting alsa settings"; + configurationManager.setOutputAudioPlugin(alsaPlugin()); + configurationManager.setAudioInputDevice(alsaInputDevice()); + configurationManager.setAudioOutputDevice(alsaOutputDevice()); + } + + + /////////////////////// + ////Record settings//// + /////////////////////// + + qDebug() << "Writing Record settings"; + + QString destination = destinationFolder(); + configurationManager.setRecordPath(destination); + + + ///////////////////////////// + ////Address Book settings//// + ///////////////////////////// + + qDebug() << "Writing Address Book settings"; + + MapStringInt addressBookSettings = MapStringInt(); + addressBookSettings[ADDRESSBOOK_ENABLE] = enableAddressBook(); + addressBookSettings[ADDRESSBOOK_MAX_RESULTS] = maxResults(); + addressBookSettings[ADDRESSBOOK_DISPLAY_CONTACT_PHOTO] = displayPhoto(); + addressBookSettings[ADDRESSBOOK_DISPLAY_BUSINESS] = business(); + addressBookSettings[ADDRESSBOOK_DISPLAY_MOBILE] = mobile(); + addressBookSettings[ADDRESSBOOK_DISPLAY_HOME] = home(); + configurationManager.setAddressbookSettings(addressBookSettings); + + ///////////////////////////// + ///////Hooks settings//////// + ///////////////////////////// + + qDebug() << "Writing Hooks settings"; + + MapStringString hooksSettings = MapStringString(); + hooksSettings[HOOKS_ENABLED] = addPrefix() ? "1" : "0"; + hooksSettings[HOOKS_ADD_PREFIX] = prepend(); + hooksSettings[HOOKS_SIP_ENABLED] = enableHooksSIP() ? "1" : "0"; + hooksSettings[HOOKS_IAX2_ENABLED] = enableHooksIAX() ? "1" : "0"; + hooksSettings[HOOKS_SIP_FIELD] = hooksSIPHeader(); + hooksSettings[HOOKS_COMMAND] = hooksCommand(); + configurationManager.setHookSettings(hooksSettings); + + qDebug() << "Finished to write config\n"; + + readConfig(); } // QStringList ConfigurationSkeleton::activeCodecList() const // { -// return codecListModel->getActiveCodecList(); +// return codecListModel->getActiveCodecList(); // } // // void ConfigurationSkeleton::setActiveCodecList(const QStringList & v) // { -// codecListModel->setActiveCodecList(v); +// codecListModel->setActiveCodecList(v); // } diff --git a/sflphone-client-kde/src/conf/ConfigurationSkeleton.h b/sflphone-client-kde/src/conf/ConfigurationSkeleton.h index ed5d309784548cd24e82e88b930be4ed959a5de6..ed384619f3cf0897942a4b3b310124be247cb379 100644 --- a/sflphone-client-kde/src/conf/ConfigurationSkeleton.h +++ b/sflphone-client-kde/src/conf/ConfigurationSkeleton.h @@ -28,47 +28,47 @@ #include "AccountListModel.h" /** - @author Jérémy Quentin <jeremy.quentin@gmail.com> - This class represents the config skeleton for the config dialog. - It inherits the KConfigSkeleton "ConfigurationSkeletonBase"generated - by sflphone-client-kde.kcfg which handles most of the settings. - This class handles the codec list. - A few complicated settings are handled directly by the config dialog - and its pages (accounts, sound managers). - This class reimplements the writeConfig and readConfig functions to ask the - daemon instead of the normal behavior (read and write in a kconfig file). + @author Jérémy Quentin <jeremy.quentin@gmail.com> + This class represents the config skeleton for the config dialog. + It inherits the KConfigSkeleton "ConfigurationSkeletonBase"generated + by sflphone-client-kde.kcfg which handles most of the settings. + This class handles the codec list. + A few complicated settings are handled directly by the config dialog + and its pages (accounts, sound managers). + This class reimplements the writeConfig and readConfig functions to ask the + daemon instead of the normal behavior (read and write in a kconfig file). */ class ConfigurationSkeleton : public ConfigurationSkeletonBase { Q_OBJECT private: - static ConfigurationSkeleton * instance; - - //CodecListModel * codecListModel; + static ConfigurationSkeleton * instance; + + //CodecListModel * codecListModel; public: - ConfigurationSkeleton(); + ConfigurationSkeleton(); - ~ConfigurationSkeleton(); + ~ConfigurationSkeleton(); - /** - * @copydoc KCoreConfigSkeleton::readConfig() - */ - virtual void readConfig(); + /** + * @copydoc KCoreConfigSkeleton::readConfig() + */ + virtual void readConfig(); - /** - * @copydoc KCoreConfigSkeleton::writeConfig() - */ - virtual void writeConfig(); - - - static ConfigurationSkeleton * self(); - - //QStringList activeCodecList() const; - //void setActiveCodecList(const QStringList & v); - - //CodecListModel * getCodecListModel(); + /** + * @copydoc KCoreConfigSkeleton::writeConfig() + */ + virtual void writeConfig(); + + + static ConfigurationSkeleton * self(); + + //QStringList activeCodecList() const; + //void setActiveCodecList(const QStringList & v); + + //CodecListModel * getCodecListModel(); }; diff --git a/sflphone-client-kde/src/conf/dlgaccounts.cpp b/sflphone-client-kde/src/conf/dlgaccounts.cpp index 134a26a4c3ad80fdc2dd726efc226a3daa9bf227..b03f89e62a68b70db6eacf95ea5eae41b67e62c1 100644 --- a/sflphone-client-kde/src/conf/dlgaccounts.cpp +++ b/sflphone-client-kde/src/conf/dlgaccounts.cpp @@ -33,43 +33,43 @@ DlgAccounts::DlgAccounts(KConfigDialog *parent) : QWidget(parent) { - setupUi(this); - - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - button_accountUp->setIcon(KIcon("go-up")); - button_accountDown->setIcon(KIcon("go-down")); - button_accountAdd->setIcon(KIcon("list-add")); - button_accountRemove->setIcon(KIcon("list-remove")); - accountList = new AccountList(false); - loadAccountList(); + setupUi(this); + + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + button_accountUp->setIcon(KIcon("go-up")); + button_accountDown->setIcon(KIcon("go-down")); + button_accountAdd->setIcon(KIcon("list-add")); + button_accountRemove->setIcon(KIcon("list-remove")); + accountList = new AccountList(false); + loadAccountList(); loadCodecList(); - accountListHasChanged = false; - //toolButton_accountsApply->setEnabled(false); - - connect(edit1_alias, SIGNAL(textEdited(const QString &)), - this, SLOT(changedAccountList())); - connect(edit2_protocol, SIGNAL(activated(int)), - this, SLOT(changedAccountList())); - connect(edit3_server, SIGNAL(textEdited(const QString &)), - this, SLOT(changedAccountList())); - connect(edit4_user, SIGNAL(textEdited(const QString &)), - this, SLOT(changedAccountList())); - connect(edit5_password, SIGNAL(textEdited(const QString &)), - this, SLOT(changedAccountList())); - connect(edit6_mailbox, SIGNAL(textEdited(const QString &)), - this, SLOT(changedAccountList())); - connect(spinbox_regExpire, SIGNAL(editingFinished()), - this, SLOT(changedAccountList())); - connect(checkBox_conformRFC, SIGNAL(clicked(bool)), - this, SLOT(changedAccountList())); - connect(button_accountUp, SIGNAL(clicked()), - this, SLOT(changedAccountList())); - connect(button_accountDown, SIGNAL(clicked()), - this, SLOT(changedAccountList())); - connect(button_accountAdd, SIGNAL(clicked()), - this, SLOT(changedAccountList())); - connect(button_accountRemove, SIGNAL(clicked()), - this, SLOT(changedAccountList())); + accountListHasChanged = false; + //toolButton_accountsApply->setEnabled(false); + + connect(edit1_alias, SIGNAL(textEdited(const QString &)), + this, SLOT(changedAccountList())); + connect(edit2_protocol, SIGNAL(activated(int)), + this, SLOT(changedAccountList())); + connect(edit3_server, SIGNAL(textEdited(const QString &)), + this, SLOT(changedAccountList())); + connect(edit4_user, SIGNAL(textEdited(const QString &)), + this, SLOT(changedAccountList())); + connect(edit5_password, SIGNAL(textEdited(const QString &)), + this, SLOT(changedAccountList())); + connect(edit6_mailbox, SIGNAL(textEdited(const QString &)), + this, SLOT(changedAccountList())); + connect(spinbox_regExpire, SIGNAL(editingFinished()), + this, SLOT(changedAccountList())); + connect(checkBox_conformRFC, SIGNAL(clicked(bool)), + this, SLOT(changedAccountList())); + connect(button_accountUp, SIGNAL(clicked()), + this, SLOT(changedAccountList())); + connect(button_accountDown, SIGNAL(clicked()), + this, SLOT(changedAccountList())); + connect(button_accountAdd, SIGNAL(clicked()), + this, SLOT(changedAccountList())); + connect(button_accountRemove, SIGNAL(clicked()), + this, SLOT(changedAccountList())); connect(edit_tls_private_key_password, SIGNAL(textEdited(const QString &)), this, SLOT(changedAccountList())); connect(spinbox_tls_listener, SIGNAL(editingFinished()), @@ -98,15 +98,15 @@ DlgAccounts::DlgAccounts(KConfigDialog *parent) this, SLOT(changedAccountList())); connect(group_security_tls, SIGNAL(clicked(bool)), this, SLOT(changedAccountList())); - - connect(&configurationManager, SIGNAL(accountsChanged()), - this, SLOT(updateAccountStates())); + + connect(&configurationManager, SIGNAL(accountsChanged()), + this, SLOT(updateAccountStates())); connect(edit_tls_private_key_password, SIGNAL(textEdited(const QString &)), this, SLOT(changedAccountList())); - connect(this, SIGNAL(updateButtons()), parent, SLOT(updateButtons())); + connect(this, SIGNAL(updateButtons()), parent, SLOT(updateButtons())); connect(keditlistbox_codec->listView(), SIGNAL(clicked(QModelIndex)), @@ -121,99 +121,89 @@ DlgAccounts::DlgAccounts(KConfigDialog *parent) void DlgAccounts::saveAccountList() { - qDebug() << "saveAccountList"; - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - disconnectAccountsChangedSignal(); - - //save the account being edited - if(listWidget_accountList->currentItem()) - { - saveAccount(listWidget_accountList->currentItem()); - } - QStringList accountIds= QStringList(configurationManager.getAccountList().value()); - - //create or update each account from accountList - for (int i = 0; i < accountList->size(); i++) - { - Account * current = (*accountList)[i]; - QString currentId; - //if the account has no instanciated id, it has just been created in the client - if(current->isNew()) - { - MapStringString details = current->getAccountDetails(); - currentId = configurationManager.addAccount(details); - current->setAccountId(currentId); - } - //if the account has an instanciated id but it's not in configurationManager - else - { - if(! accountIds.contains(current->getAccountId())) - { - qDebug() << "The account with id " << current->getAccountId() << " doesn't exist. It might have been removed by another SFLphone client."; - currentId = QString(); - } - else - { - configurationManager.setAccountDetails(current->getAccountId(), current->getAccountDetails()); - currentId = QString(current->getAccountId()); - } - } - qDebug() << currentId << " : " << current->isChecked(); - } - //remove accounts that are in the configurationManager but not in the client - for (int i = 0; i < accountIds.size(); i++) - { - if(! accountList->getAccountById(accountIds[i])) - { - qDebug() << "remove account " << accountIds[i]; - configurationManager.removeAccount(accountIds[i]); - } - } - configurationManager.setAccountsOrder(accountList->getOrderedList()); - connectAccountsChangedSignal(); + qDebug() << "saveAccountList"; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + disconnectAccountsChangedSignal(); + + //save the account being edited + if(listWidget_accountList->currentItem()) { + saveAccount(listWidget_accountList->currentItem()); + } + QStringList accountIds= QStringList(configurationManager.getAccountList().value()); + + //create or update each account from accountList + for (int i = 0; i < accountList->size(); i++) { + Account * current = (*accountList)[i]; + QString currentId; + //if the account has no instanciated id, it has just been created in the client + if(current->isNew()) { + MapStringString details = current->getAccountDetails(); + currentId = configurationManager.addAccount(details); + current->setAccountId(currentId); + } + //if the account has an instanciated id but it's not in configurationManager + else { + if(! accountIds.contains(current->getAccountId())) { + qDebug() << "The account with id " << current->getAccountId() << " doesn't exist. It might have been removed by another SFLphone client."; + currentId = QString(); + } + else { + configurationManager.setAccountDetails(current->getAccountId(), current->getAccountDetails()); + currentId = QString(current->getAccountId()); + } + } + qDebug() << currentId << " : " << current->isChecked(); + } + //remove accounts that are in the configurationManager but not in the client + for (int i = 0; i < accountIds.size(); i++) { + if(! accountList->getAccountById(accountIds[i])) { + qDebug() << "remove account " << accountIds[i]; + configurationManager.removeAccount(accountIds[i]); + } + } + configurationManager.setAccountsOrder(accountList->getOrderedList()); + connectAccountsChangedSignal(); } void DlgAccounts::connectAccountsChangedSignal() { - qDebug() << "connectAccountsChangedSignal"; - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - connect(&configurationManager, SIGNAL(accountsChanged()), - this, SLOT(updateAccountStates())); + qDebug() << "connectAccountsChangedSignal"; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + connect(&configurationManager, SIGNAL(accountsChanged()), + this, SLOT(updateAccountStates())); } void DlgAccounts::disconnectAccountsChangedSignal() { - qDebug() << "disconnectAccountsChangedSignal"; - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - disconnect(&configurationManager, SIGNAL(accountsChanged()), - this, SLOT(updateAccountStates())); + qDebug() << "disconnectAccountsChangedSignal"; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + disconnect(&configurationManager, SIGNAL(accountsChanged()), + this, SLOT(updateAccountStates())); } void DlgAccounts::saveAccount(QListWidgetItem * item) { - QString protocolsTab[] = ACCOUNT_TYPES_TAB; - - if(! item) - { - qDebug() << "Attempting to save details of an account from a NULL item"; - return; - } - - Account * account = accountList->getAccountByItem(item); - if(! account) - { - qDebug() << "Attempting to save details of an unexisting account : " << item->text(); - return; - } - - account->setAccountDetail(ACCOUNT_ALIAS, edit1_alias->text()); - account->setAccountDetail(ACCOUNT_TYPE, protocolsTab[edit2_protocol->currentIndex()]); - account->setAccountDetail(ACCOUNT_HOSTNAME, edit3_server->text()); - account->setAccountDetail(ACCOUNT_USERNAME, edit4_user->text()); - account->setAccountDetail(ACCOUNT_PASSWORD, edit5_password->text()); - account->setAccountDetail(ACCOUNT_MAILBOX, edit6_mailbox->text()); - account->setAccountDetail(ACCOUNT_ENABLED, account->isChecked() ? ACCOUNT_ENABLED_TRUE : ACCOUNT_ENABLED_FALSE); + QString protocolsTab[] = ACCOUNT_TYPES_TAB; + + if(! item) { + qDebug() << "Attempting to save details of an account from a NULL item"; + return; + } + + Account * account = accountList->getAccountByItem(item); + if(! account) { + qDebug() << "Attempting to save details of an unexisting account : " << item->text(); + return; + } + + account->setAccountDetail(ACCOUNT_ALIAS, edit1_alias->text()); + account->setAccountDetail(ACCOUNT_TYPE, protocolsTab[edit2_protocol->currentIndex()]); + account->setAccountDetail(ACCOUNT_HOSTNAME, edit3_server->text()); + account->setAccountDetail(ACCOUNT_USERNAME, edit4_user->text()); + account->setAccountDetail(ACCOUNT_PASSWORD, edit5_password->text()); + account->setAccountDetail(ACCOUNT_MAILBOX, edit6_mailbox->text()); + account->setAccountDetail(ACCOUNT_ENABLED, account->isChecked() ? ACCOUNT_ENABLED_TRUE : ACCOUNT_ENABLED_FALSE); //Security account->setAccountDetail(TLS_PASSWORD,edit_tls_private_key_password->text()); @@ -249,32 +239,38 @@ void DlgAccounts::saveAccount(QListWidgetItem * item) void DlgAccounts::loadAccount(QListWidgetItem * item) { - if(! item ) { qDebug() << "Attempting to load details of an account from a NULL item"; return; } - - Account * account = accountList->getAccountByItem(item); - if(! account ) { qDebug() << "Attempting to load details of an unexisting account"; return; } - - edit1_alias->setText( account->getAccountDetail(ACCOUNT_ALIAS)); - - QString protocolsTab[] = ACCOUNT_TYPES_TAB; - QList<QString> * protocolsList = new QList<QString>(); - for(int i = 0 ; i < (int) (sizeof(protocolsTab) / sizeof(QString)) ; i++) - { - protocolsList->append(protocolsTab[i]); - } - QString accountName = account->getAccountDetail(ACCOUNT_TYPE); - int protocolIndex = protocolsList->indexOf(accountName); - delete protocolsList; - - edit2_protocol->setCurrentIndex( (protocolIndex < 0) ? 0 : protocolIndex ); - edit3_server->setText( account->getAccountDetail(ACCOUNT_HOSTNAME)); - edit4_user->setText( account->getAccountDetail(ACCOUNT_USERNAME)); - edit5_password->setText( account->getAccountDetail(ACCOUNT_PASSWORD)); - edit6_mailbox->setText( account->getAccountDetail(ACCOUNT_MAILBOX)); - checkBox_conformRFC->setChecked( account->getAccountDetail(ACCOUNT_RESOLVE_ONCE) != "TRUE" ); - bool ok; - int val = account->getAccountDetail(ACCOUNT_EXPIRE).toInt(&ok); - spinbox_regExpire->setValue(ok ? val : ACCOUNT_EXPIRE_DEFAULT); + if(! item ) { + qDebug() << "Attempting to load details of an account from a NULL item"; + return; + } + + Account * account = accountList->getAccountByItem(item); + if(! account ) { + qDebug() << "Attempting to load details of an unexisting account"; + return; + } + + edit1_alias->setText( account->getAccountDetail(ACCOUNT_ALIAS)); + + QString protocolsTab[] = ACCOUNT_TYPES_TAB; + QList<QString> * protocolsList = new QList<QString>(); + for(int i = 0 ; i < (int) (sizeof(protocolsTab) / sizeof(QString)) ; i++) { + protocolsList->append(protocolsTab[i]); + } + + QString accountName = account->getAccountDetail(ACCOUNT_TYPE); + int protocolIndex = protocolsList->indexOf(accountName); + delete protocolsList; + + edit2_protocol->setCurrentIndex( (protocolIndex < 0) ? 0 : protocolIndex ); + edit3_server->setText( account->getAccountDetail(ACCOUNT_HOSTNAME)); + edit4_user->setText( account->getAccountDetail(ACCOUNT_USERNAME)); + edit5_password->setText( account->getAccountDetail(ACCOUNT_PASSWORD)); + edit6_mailbox->setText( account->getAccountDetail(ACCOUNT_MAILBOX)); + checkBox_conformRFC->setChecked( account->getAccountDetail(ACCOUNT_RESOLVE_ONCE) != "TRUE" ); + bool ok; + int val = account->getAccountDetail(ACCOUNT_EXPIRE).toInt(&ok); + spinbox_regExpire->setValue(ok ? val : ACCOUNT_EXPIRE_DEFAULT); //Security edit_tls_private_key_password->setText( account->getAccountDetail(TLS_PASSWORD )); @@ -308,71 +304,69 @@ void DlgAccounts::loadAccount(QListWidgetItem * item) - if(protocolIndex == 0) // if sip selected - { - checkbox_stun->setChecked(account->getAccountDetail(ACCOUNT_SIP_STUN_ENABLED) == ACCOUNT_ENABLED_TRUE); - line_stun->setText( account->getAccountDetail(ACCOUNT_SIP_STUN_SERVER) ); - //checkbox_zrtp->setChecked(account->getAccountDetail(ACCOUNT_SRTP_ENABLED) == ACCOUNT_ENABLED_TRUE); - - tab_advanced->setEnabled(true); - line_stun->setEnabled(checkbox_stun->isChecked()); - } - else - { - checkbox_stun->setChecked(false); - line_stun->setText( account->getAccountDetail(ACCOUNT_SIP_STUN_SERVER) ); - //checkbox_zrtp->setChecked(false); - - tab_advanced->setEnabled(false); - } - - updateStatusLabel(account); - frame2_editAccounts->setEnabled(true); + if(protocolIndex == 0) { // if sip selected + checkbox_stun->setChecked(account->getAccountDetail(ACCOUNT_SIP_STUN_ENABLED) == ACCOUNT_ENABLED_TRUE); + line_stun->setText( account->getAccountDetail(ACCOUNT_SIP_STUN_SERVER) ); + //checkbox_zrtp->setChecked(account->getAccountDetail(ACCOUNT_SRTP_ENABLED) == ACCOUNT_ENABLED_TRUE); + + tab_advanced->setEnabled(true); + line_stun->setEnabled(checkbox_stun->isChecked()); + } + else { + checkbox_stun->setChecked(false); + line_stun->setText( account->getAccountDetail(ACCOUNT_SIP_STUN_SERVER) ); + //checkbox_zrtp->setChecked(false); + + tab_advanced->setEnabled(false); + } + + updateStatusLabel(account); + frame2_editAccounts->setEnabled(true); } void DlgAccounts::loadAccountList() { - qDebug() << "loadAccountList"; - accountList->updateAccounts(); - listWidget_accountList->clear(); - for (int i = 0; i < accountList->size(); ++i){ - addAccountToAccountList((*accountList)[i]); - } - if (listWidget_accountList->count() > 0 && listWidget_accountList->currentItem() == NULL) - listWidget_accountList->setCurrentRow(0); - else - frame2_editAccounts->setEnabled(false); + qDebug() << "loadAccountList"; + accountList->updateAccounts(); + listWidget_accountList->clear(); + for (int i = 0; i < accountList->size(); ++i) { + addAccountToAccountList((*accountList)[i]); + } + if (listWidget_accountList->count() > 0 && listWidget_accountList->currentItem() == NULL) + listWidget_accountList->setCurrentRow(0); + else + frame2_editAccounts->setEnabled(false); } void DlgAccounts::addAccountToAccountList(Account * account) { - QListWidgetItem * item = account->getItem(); - QWidget * widget = account->getItemWidget(); - connect(widget, SIGNAL(checkStateChanged(bool)), - this, SLOT(changedAccountList())); - listWidget_accountList->addItem(item); - listWidget_accountList->setItemWidget(item, widget); + QListWidgetItem * item = account->getItem(); + QWidget * widget = account->getItemWidget(); + connect(widget, SIGNAL(checkStateChanged(bool)), + this, SLOT(changedAccountList())); + listWidget_accountList->addItem(item); + listWidget_accountList->setItemWidget(item, widget); } void DlgAccounts::changedAccountList() { - qDebug() << "changedAccountList"; - accountListHasChanged = true; - emit updateButtons(); - //toolButton_accountsApply->setEnabled(true); + qDebug() << "changedAccountList"; + accountListHasChanged = true; + emit updateButtons(); + //toolButton_accountsApply->setEnabled(true); //<<<<<<< HEAD - -// int currentIndex = edit2_protocol->currentIndex(); - -// if(currentIndex==0) -// { -// tab_advanced->setEnabled(true); -// line_stun->setEnabled(checkbox_stun->isChecked()); -// } -// else -// { -// tab_advanced->setEnabled(false); -// } + +// int currentIndex = edit2_protocol->currentIndex(); + +// if(currentIndex==0) +// { +// tab_advanced->setEnabled(true); +// line_stun->setEnabled(checkbox_stun->isChecked()); +// } +// else +// { +// tab_advanced->setEnabled(false); +// } //======= //>>>>>>> master } @@ -381,164 +375,164 @@ void DlgAccounts::changedAccountList() void DlgAccounts::on_listWidget_accountList_currentItemChanged ( QListWidgetItem * current, QListWidgetItem * previous ) { - qDebug() << "on_listWidget_accountList_currentItemChanged"; - saveAccount(previous); - loadAccount(current); - updateAccountListCommands(); + qDebug() << "on_listWidget_accountList_currentItemChanged"; + saveAccount(previous); + loadAccount(current); + updateAccountListCommands(); } void DlgAccounts::on_button_accountUp_clicked() { - qDebug() << "on_button_accountUp_clicked"; - int currentRow = listWidget_accountList->currentRow(); - QListWidgetItem * prevItem = listWidget_accountList->takeItem(currentRow); - Account * account = accountList->getAccountByItem(prevItem); - //we need to build a new item to set the itemWidget back - account->initItem(); - QListWidgetItem * item = account->getItem(); - AccountItemWidget * widget = account->getItemWidget(); - accountList->upAccount(currentRow); - listWidget_accountList->insertItem(currentRow - 1 , item); - listWidget_accountList->setItemWidget(item, widget); - listWidget_accountList->setCurrentItem(item); + qDebug() << "on_button_accountUp_clicked"; + int currentRow = listWidget_accountList->currentRow(); + QListWidgetItem * prevItem = listWidget_accountList->takeItem(currentRow); + Account * account = accountList->getAccountByItem(prevItem); + //we need to build a new item to set the itemWidget back + account->initItem(); + QListWidgetItem * item = account->getItem(); + AccountItemWidget * widget = account->getItemWidget(); + accountList->upAccount(currentRow); + listWidget_accountList->insertItem(currentRow - 1 , item); + listWidget_accountList->setItemWidget(item, widget); + listWidget_accountList->setCurrentItem(item); } void DlgAccounts::on_button_accountDown_clicked() { - qDebug() << "on_button_accountDown_clicked"; - int currentRow = listWidget_accountList->currentRow(); - QListWidgetItem * prevItem = listWidget_accountList->takeItem(currentRow); - Account * account = accountList->getAccountByItem(prevItem); - //we need to build a new item to set the itemWidget back - account->initItem(); - QListWidgetItem * item = account->getItem(); - AccountItemWidget * widget = account->getItemWidget(); - accountList->downAccount(currentRow); - listWidget_accountList->insertItem(currentRow + 1 , item); - listWidget_accountList->setItemWidget(item, widget); - listWidget_accountList->setCurrentItem(item); + qDebug() << "on_button_accountDown_clicked"; + int currentRow = listWidget_accountList->currentRow(); + QListWidgetItem * prevItem = listWidget_accountList->takeItem(currentRow); + Account * account = accountList->getAccountByItem(prevItem); + //we need to build a new item to set the itemWidget back + account->initItem(); + QListWidgetItem * item = account->getItem(); + AccountItemWidget * widget = account->getItemWidget(); + accountList->downAccount(currentRow); + listWidget_accountList->insertItem(currentRow + 1 , item); + listWidget_accountList->setItemWidget(item, widget); + listWidget_accountList->setCurrentItem(item); } void DlgAccounts::on_button_accountAdd_clicked() { - qDebug() << "on_button_accountAdd_clicked"; - QString itemName = QInputDialog::getText(this, "New account", "Enter new account's alias"); - itemName = itemName.simplified(); - if (!itemName.isEmpty()) { - Account * account = accountList->addAccount(itemName); - addAccountToAccountList(account); - int r = listWidget_accountList->count() - 1; - listWidget_accountList->setCurrentRow(r); - frame2_editAccounts->setEnabled(true); - } + qDebug() << "on_button_accountAdd_clicked"; + QString itemName = QInputDialog::getText(this, "New account", "Enter new account's alias"); + itemName = itemName.simplified(); + if (!itemName.isEmpty()) { + Account * account = accountList->addAccount(itemName); + addAccountToAccountList(account); + int r = listWidget_accountList->count() - 1; + listWidget_accountList->setCurrentRow(r); + frame2_editAccounts->setEnabled(true); + } } void DlgAccounts::on_button_accountRemove_clicked() { - qDebug() << "on_button_accountRemove_clicked"; - int r = listWidget_accountList->currentRow(); - QListWidgetItem * item = listWidget_accountList->takeItem(r); - accountList->removeAccount(item); - listWidget_accountList->setCurrentRow( (r >= listWidget_accountList->count()) ? r-1 : r ); + qDebug() << "on_button_accountRemove_clicked"; + int r = listWidget_accountList->currentRow(); + QListWidgetItem * item = listWidget_accountList->takeItem(r); + accountList->removeAccount(item); + listWidget_accountList->setCurrentRow( (r >= listWidget_accountList->count()) ? r-1 : r ); } //<<<<<<< HEAD /*void DlgAccounts::on_toolButton_accountsApply_clicked() { - qDebug() << "on_toolButton_accountsApply_clicked"; - updateSettings(); - updateWidgets(); + qDebug() << "on_toolButton_accountsApply_clicked"; + updateSettings(); + updateWidgets(); }*/ //======= // void DlgAccounts::on_toolButton_accountsApply_clicked() //This button have been removed, coded kept for potential reversal // { -// qDebug() << "on_toolButton_accountsApply_clicked"; -// updateSettings(); -// updateWidgets(); +// qDebug() << "on_toolButton_accountsApply_clicked"; +// updateSettings(); +// updateWidgets(); // } //>>>>>>> master void DlgAccounts::on_edit1_alias_textChanged(const QString & text) { - qDebug() << "on_edit1_alias_textChanged"; - AccountItemWidget * widget = (AccountItemWidget *) listWidget_accountList->itemWidget(listWidget_accountList->currentItem()); - widget->setAccountText(text); + qDebug() << "on_edit1_alias_textChanged"; + AccountItemWidget * widget = (AccountItemWidget *) listWidget_accountList->itemWidget(listWidget_accountList->currentItem()); + widget->setAccountText(text); } void DlgAccounts::updateAccountListCommands() { - qDebug() << "updateAccountListCommands"; - bool buttonsEnabled[4] = {true,true,true,true}; - if(! listWidget_accountList->currentItem()) - { - buttonsEnabled[0] = false; - buttonsEnabled[1] = false; - buttonsEnabled[3] = false; - } - else if(listWidget_accountList->currentRow() == 0) - { - buttonsEnabled[0] = false; - } - if(listWidget_accountList->currentRow() == listWidget_accountList->count() - 1) - { - buttonsEnabled[1] = false; - } - button_accountUp->setEnabled(buttonsEnabled[0]); - button_accountDown->setEnabled(buttonsEnabled[1]); - button_accountAdd->setEnabled(buttonsEnabled[2]); - button_accountRemove->setEnabled(buttonsEnabled[3]); + qDebug() << "updateAccountListCommands"; + bool buttonsEnabled[4] = {true,true,true,true}; + if(! listWidget_accountList->currentItem()) { + buttonsEnabled[0] = false; + buttonsEnabled[1] = false; + buttonsEnabled[3] = false; + } + else if(listWidget_accountList->currentRow() == 0) { + buttonsEnabled[0] = false; + } + if(listWidget_accountList->currentRow() == listWidget_accountList->count() - 1) { + buttonsEnabled[1] = false; + } + + button_accountUp->setEnabled(buttonsEnabled[0]); + button_accountDown->setEnabled(buttonsEnabled[1]); + button_accountAdd->setEnabled(buttonsEnabled[2]); + button_accountRemove->setEnabled(buttonsEnabled[3]); } void DlgAccounts::updateAccountStates() { - qDebug() << "updateAccountStates"; - for (int i = 0; i < accountList->size(); i++) - { - Account * current = accountList->getAccountAt(i); - current->updateState(); - } - updateStatusLabel(listWidget_accountList->currentItem()); + qDebug() << "updateAccountStates"; + for (int i = 0; i < accountList->size(); i++) { + Account * current = accountList->getAccountAt(i); + current->updateState(); + } + updateStatusLabel(listWidget_accountList->currentItem()); } void DlgAccounts::updateStatusLabel(QListWidgetItem * item) { - if(! item ) { return; } - Account * account = accountList->getAccountByItem(item); - updateStatusLabel(account); + if(! item ) { + return; + } + Account * account = accountList->getAccountByItem(item); + updateStatusLabel(account); } void DlgAccounts::updateStatusLabel(Account * account) { - if(! account ) { return; } - QString status = account->getAccountDetail(ACCOUNT_STATUS); - edit7_state->setText( "<FONT COLOR=\"" + account->getStateColorName() + "\">" + status + "</FONT>" ); + if(! account ) { + return; + } + QString status = account->getAccountDetail(ACCOUNT_STATUS); + edit7_state->setText( "<FONT COLOR=\"" + account->getStateColorName() + "\">" + status + "</FONT>" ); } bool DlgAccounts::hasChanged() { - bool res = accountListHasChanged; - qDebug() << "DlgAccounts::hasChanged " << res; - return res; + bool res = accountListHasChanged; + qDebug() << "DlgAccounts::hasChanged " << res; + return res; } void DlgAccounts::updateSettings() { - qDebug() << "DlgAccounts::updateSettings"; - if(accountListHasChanged) - { - saveAccountList(); - //toolButton_accountsApply->setEnabled(false); - accountListHasChanged = false; - } + qDebug() << "DlgAccounts::updateSettings"; + if(accountListHasChanged) { + saveAccountList(); + //toolButton_accountsApply->setEnabled(false); + accountListHasChanged = false; + } } void DlgAccounts::updateWidgets() { - qDebug() << "DlgAccounts::updateWidgets"; - loadAccountList(); - //toolButton_accountsApply->setEnabled(false); - accountListHasChanged = false; + qDebug() << "DlgAccounts::updateWidgets"; + loadAccountList(); + //toolButton_accountsApply->setEnabled(false); + accountListHasChanged = false; } void DlgAccounts::loadCodecList() diff --git a/sflphone-client-kde/src/conf/dlgaccounts.h b/sflphone-client-kde/src/conf/dlgaccounts.h index b06bc622d05c108f883d79313fb89b5e85616553..abf80d30e3398f9f9a512cd1cc295858b880388f 100644 --- a/sflphone-client-kde/src/conf/dlgaccounts.h +++ b/sflphone-client-kde/src/conf/dlgaccounts.h @@ -74,70 +74,70 @@ class Private_AddCodecDialog : public KDialog { }; /** - @author Jérémy Quentin <jeremy.quentin@gmail.com> - - \note see ticket #1309 for advices about how to improve this class. + @author Jérémy Quentin <jeremy.quentin@gmail.com> + + \note see ticket #1309 for advices about how to improve this class. */ class DlgAccounts : public QWidget, public Ui_DlgAccountsBase { Q_OBJECT public: - DlgAccounts(KConfigDialog *parent = 0); + DlgAccounts(KConfigDialog *parent = 0); - void saveAccount(QListWidgetItem * item); - - /** - * Fills the settings form in the right side with the - * settings of @p item. - * - * \note When the user creates a new account, its accountDetails - * map is empty, so the form is filled with blank strings, - * zeros... And when the user clicks \e Apply , these settings are - * saved just after the account is created. So be careful the form - * is filled with the right default settings if blank (as 600 for - * registration expire). - * - * @param item the item with which to fill the settings form - */ - void loadAccount(QListWidgetItem * item); - + void saveAccount(QListWidgetItem * item); + + /** + * Fills the settings form in the right side with the + * settings of @p item. + * + * \note When the user creates a new account, its accountDetails + * map is empty, so the form is filled with blank strings, + * zeros... And when the user clicks \e Apply , these settings are + * saved just after the account is created. So be careful the form + * is filled with the right default settings if blank (as 600 for + * registration expire). + * + * @param item the item with which to fill the settings form + */ + void loadAccount(QListWidgetItem * item); + private: - AccountList * accountList; + AccountList * accountList; QList< StringHash > codecList; - bool accountListHasChanged; + bool accountListHasChanged; void loadCodecList(); public slots: - void saveAccountList(); - void loadAccountList(); - - bool hasChanged(); - void updateSettings(); - void updateWidgets(); - + void saveAccountList(); + void loadAccountList(); + + bool hasChanged(); + void updateSettings(); + void updateWidgets(); + private slots: - void changedAccountList(); - void connectAccountsChangedSignal(); - void disconnectAccountsChangedSignal(); - void on_button_accountUp_clicked(); - void on_button_accountDown_clicked(); - void on_button_accountAdd_clicked(); - void on_button_accountRemove_clicked(); - void on_edit1_alias_textChanged(const QString & text); - void on_listWidget_accountList_currentItemChanged ( QListWidgetItem * current, QListWidgetItem * previous ); -// //void on_toolButton_accountsApply_clicked(); //Disabled for future removal - void updateAccountStates(); - void addAccountToAccountList(Account * account); - void updateAccountListCommands(); - void updateStatusLabel(QListWidgetItem * item); - void updateStatusLabel(Account * account); + void changedAccountList(); + void connectAccountsChangedSignal(); + void disconnectAccountsChangedSignal(); + void on_button_accountUp_clicked(); + void on_button_accountDown_clicked(); + void on_button_accountAdd_clicked(); + void on_button_accountRemove_clicked(); + void on_edit1_alias_textChanged(const QString & text); + void on_listWidget_accountList_currentItemChanged ( QListWidgetItem * current, QListWidgetItem * previous ); +// //void on_toolButton_accountsApply_clicked(); //Disabled for future removal + void updateAccountStates(); + void addAccountToAccountList(Account * account); + void updateAccountListCommands(); + void updateStatusLabel(QListWidgetItem * item); + void updateStatusLabel(Account * account); void codecClicked(const QModelIndex & model); void addCodec(QString name = ""); void codecChanged(); - - + + signals: - void updateButtons(); + void updateButtons(); }; diff --git a/sflphone-client-kde/src/conf/dlgaddressbook.cpp b/sflphone-client-kde/src/conf/dlgaddressbook.cpp index e9f69d967a9daca2c3a6024d052b89a5cf3e1c29..6d73124517948ae3308ed1f2deea885552cbbc85 100644 --- a/sflphone-client-kde/src/conf/dlgaddressbook.cpp +++ b/sflphone-client-kde/src/conf/dlgaddressbook.cpp @@ -23,7 +23,7 @@ DlgAddressBook::DlgAddressBook(QWidget *parent) : QWidget(parent) { - setupUi(this); + setupUi(this); } diff --git a/sflphone-client-kde/src/conf/dlgaddressbook.h b/sflphone-client-kde/src/conf/dlgaddressbook.h index 6a6852f6e64a9fef0a9bbe85b2c29b1d8447e983..733538be6e337d0368e9acf30227811664b40fbb 100644 --- a/sflphone-client-kde/src/conf/dlgaddressbook.h +++ b/sflphone-client-kde/src/conf/dlgaddressbook.h @@ -32,9 +32,9 @@ class DlgAddressBook : public QWidget, public Ui_DlgAddressBookBase { Q_OBJECT public: - DlgAddressBook(QWidget *parent = 0); + DlgAddressBook(QWidget *parent = 0); - ~DlgAddressBook(); + ~DlgAddressBook(); }; diff --git a/sflphone-client-kde/src/conf/dlgaudio.cpp b/sflphone-client-kde/src/conf/dlgaudio.cpp index c2a16f93d70c486922a211afdad1eedd8cb5151d..a90d0cd79c463a2e20415a467233ac3915f4a151 100644 --- a/sflphone-client-kde/src/conf/dlgaudio.cpp +++ b/sflphone-client-kde/src/conf/dlgaudio.cpp @@ -31,33 +31,33 @@ DlgAudio::DlgAudio(KConfigDialog *parent) : QWidget(parent) { - setupUi(this); - - KUrlRequester_ringtone->setMode(KFile::File | KFile::ExistingOnly); - KUrlRequester_ringtone->lineEdit()->setObjectName("kcfg_ringtone"); - KUrlRequester_ringtone->lineEdit()->setReadOnly(true); + setupUi(this); + + KUrlRequester_ringtone->setMode(KFile::File | KFile::ExistingOnly); + KUrlRequester_ringtone->lineEdit()->setObjectName("kcfg_ringtone"); + KUrlRequester_ringtone->lineEdit()->setReadOnly(true); KUrlRequester_destinationFolder->setMode(KFile::Directory|KFile::ExistingOnly|KFile::LocalOnly); KUrlRequester_destinationFolder->setUrl(KUrl(QDir::home().path())); KUrlRequester_destinationFolder->lineEdit()->setObjectName("kcfg_destinationFolder"); KUrlRequester_destinationFolder->lineEdit()->setReadOnly(true); - - //codecTableHasChanged = false; - - ConfigurationSkeleton * skeleton = ConfigurationSkeleton::self(); - //CodecListModel * model = skeleton->getCodecListModel(); - //sortableCodecList->setModel(model); - -// loadAlsaSettings(); - connect(box_alsaPlugin, SIGNAL(activated(int)), - parent, SLOT(updateButtons())); - - connect(this, SIGNAL(updateButtons()), - parent, SLOT(updateButtons())); - - //connect(sortableCodecList, SIGNAL(dataChanged()), - //this, SLOT(codecTableChanged())); - + + //codecTableHasChanged = false; + + ConfigurationSkeleton * skeleton = ConfigurationSkeleton::self(); + //CodecListModel * model = skeleton->getCodecListModel(); + //sortableCodecList->setModel(model); + +// loadAlsaSettings(); + connect(box_alsaPlugin, SIGNAL(activated(int)), + parent, SLOT(updateButtons())); + + connect(this, SIGNAL(updateButtons()), + parent, SLOT(updateButtons())); + + //connect(sortableCodecList, SIGNAL(dataChanged()), + //this, SLOT(codecTableChanged())); + } @@ -67,67 +67,65 @@ DlgAudio::~DlgAudio() void DlgAudio::updateWidgets() { - loadAlsaSettings(); - - //codecTableHasChanged = false; + loadAlsaSettings(); + + //codecTableHasChanged = false; } void DlgAudio::updateSettings() { - qDebug() << "DlgAudio::updateSettings"; - //alsaPlugin - ConfigurationSkeleton * skeleton = ConfigurationSkeleton::self(); - skeleton->setAlsaPlugin(box_alsaPlugin->currentText()); - - //codecTableHasChanged = false; + qDebug() << "DlgAudio::updateSettings"; + //alsaPlugin + ConfigurationSkeleton * skeleton = ConfigurationSkeleton::self(); + skeleton->setAlsaPlugin(box_alsaPlugin->currentText()); + + //codecTableHasChanged = false; } bool DlgAudio::hasChanged() { - qDebug() << "DlgAudio::hasChanged"; - ConfigurationSkeleton * skeleton = ConfigurationSkeleton::self(); - bool alsaPluginHasChanged = - skeleton->interface() == ConfigurationSkeleton::EnumInterface::ALSA - && skeleton->alsaPlugin() != box_alsaPlugin->currentText(); - return alsaPluginHasChanged ;//|| codecTableHasChanged; + qDebug() << "DlgAudio::hasChanged"; + ConfigurationSkeleton * skeleton = ConfigurationSkeleton::self(); + bool alsaPluginHasChanged = + skeleton->interface() == ConfigurationSkeleton::EnumInterface::ALSA + && skeleton->alsaPlugin() != box_alsaPlugin->currentText(); + return alsaPluginHasChanged ;//|| codecTableHasChanged; } void DlgAudio::loadAlsaSettings() { - qDebug() << "DlgAudio::loadAlsaSettings"; - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - if(configurationManager.getAudioManager() == ConfigurationSkeleton::EnumInterface::ALSA) - { - ConfigurationSkeleton * skeleton = ConfigurationSkeleton::self(); - - QStringList pluginList = configurationManager.getOutputAudioPluginList(); - box_alsaPlugin->clear(); - box_alsaPlugin->addItems(pluginList); - int index = box_alsaPlugin->findText(skeleton->alsaPlugin()); - if(index < 0) index = 0; - box_alsaPlugin->setCurrentIndex(index); - - QStringList inputDeviceList = configurationManager.getAudioInputDeviceList(); - kcfg_alsaInputDevice->clear(); - kcfg_alsaInputDevice->addItems(inputDeviceList); - kcfg_alsaInputDevice->setCurrentIndex(skeleton->alsaInputDevice()); - - QStringList outputDeviceList = configurationManager.getAudioOutputDeviceList(); - kcfg_alsaOutputDevice->clear(); - kcfg_alsaOutputDevice->addItems(outputDeviceList); - kcfg_alsaOutputDevice->setCurrentIndex(skeleton->alsaOutputDevice()); - groupBox_alsa->setEnabled(true); - } - else - { - groupBox_alsa->setEnabled(false); - } + qDebug() << "DlgAudio::loadAlsaSettings"; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + if(configurationManager.getAudioManager() == ConfigurationSkeleton::EnumInterface::ALSA) { + ConfigurationSkeleton * skeleton = ConfigurationSkeleton::self(); + + QStringList pluginList = configurationManager.getOutputAudioPluginList(); + box_alsaPlugin->clear(); + box_alsaPlugin->addItems(pluginList); + int index = box_alsaPlugin->findText(skeleton->alsaPlugin()); + if(index < 0) index = 0; + box_alsaPlugin->setCurrentIndex(index); + + QStringList inputDeviceList = configurationManager.getAudioInputDeviceList(); + kcfg_alsaInputDevice->clear(); + kcfg_alsaInputDevice->addItems(inputDeviceList); + kcfg_alsaInputDevice->setCurrentIndex(skeleton->alsaInputDevice()); + + QStringList outputDeviceList = configurationManager.getAudioOutputDeviceList(); + kcfg_alsaOutputDevice->clear(); + kcfg_alsaOutputDevice->addItems(outputDeviceList); + kcfg_alsaOutputDevice->setCurrentIndex(skeleton->alsaOutputDevice()); + groupBox_alsa->setEnabled(true); + } + else { + groupBox_alsa->setEnabled(false); + } } // void DlgAudio::codecTableChanged() // { -// qDebug() << "codecTableChanged"; -// codecTableHasChanged = true; -// emit updateButtons(); +// qDebug() << "codecTableChanged"; +// codecTableHasChanged = true; +// emit updateButtons(); // } diff --git a/sflphone-client-kde/src/conf/dlgaudio.h b/sflphone-client-kde/src/conf/dlgaudio.h index d89b114ead971835d752834322c1a6b986995f10..d7124ee9d4292684a708f4f221937dfb86cc60d7 100644 --- a/sflphone-client-kde/src/conf/dlgaudio.h +++ b/sflphone-client-kde/src/conf/dlgaudio.h @@ -28,7 +28,7 @@ #include "conf/ConfigurationSkeleton.h" /** - @author Jérémy Quentin <jeremy.quentin@gmail.com> + @author Jérémy Quentin <jeremy.quentin@gmail.com> */ class DlgAudio : public QWidget, public Ui_DlgAudioBase { @@ -39,27 +39,27 @@ public: ~DlgAudio(); private: - //bool codecTableHasChanged; + //bool codecTableHasChanged; public slots: - void updateWidgets(); - void updateSettings(); - bool hasChanged(); - /** - * Loads the ALSA settings to fill the combo boxes - * of the ALSA settings. - * ALSA choices for input, output... can be load only - * when the daemon has set ALSA as sound manager. - * So we have to load these settings once the user choses - * ALSA. - */ - void loadAlsaSettings(); - + void updateWidgets(); + void updateSettings(); + bool hasChanged(); + /** + * Loads the ALSA settings to fill the combo boxes + * of the ALSA settings. + * ALSA choices for input, output... can be load only + * when the daemon has set ALSA as sound manager. + * So we have to load these settings once the user choses + * ALSA. + */ + void loadAlsaSettings(); + private slots: - //void codecTableChanged(); - + //void codecTableChanged(); + signals: - void updateButtons(); + void updateButtons(); }; #endif diff --git a/sflphone-client-kde/src/main.cpp b/sflphone-client-kde/src/main.cpp index de08783a7bdcdbfac1ef854a3bb3533ec2d0e760..e1a9c44474ac76656f6a3c6036b3768e2b067092 100644 --- a/sflphone-client-kde/src/main.cpp +++ b/sflphone-client-kde/src/main.cpp @@ -2,7 +2,7 @@ #include <QApplication> #include <QtCore/QString> #include <QtGui/QMenu> -#include <QtGui/QMenuBar> +//#include <QtGui/QMenuBar> #include <QtGui/QAction> #include <kcmdlineargs.h> @@ -27,45 +27,45 @@ static const char version[] = "0.9.6"; int main(int argc, char **argv) { - - try - { - KLocale::setMainCatalog("sflphone-client-kde"); - - KAboutData about( - "sflphone-client-kde", - "sflphone-client-kde", - ki18n("SFLphone KDE Client"), - version, - ki18n(description), - KAboutData::License_GPL_V3, - ki18n("(C) 2009 Savoir-faire Linux"), - KLocalizedString(), - "http://www.sflphone.org.", - "sflphone@lists.savoirfairelinux.net"); - about.addAuthor( ki18n("Jérémy Quentin"), KLocalizedString(), "jeremy.quentin@savoirfairelinux.com" ); - about.setTranslator( ki18nc("NAME OF TRANSLATORS","Your names"), ki18nc("EMAIL OF TRANSLATORS","Your emails") ); - KCmdLineArgs::init(argc, argv, &about); - KCmdLineOptions options; - KCmdLineArgs::addCmdLineOptions(options); - + + try + { + KLocale::setMainCatalog("sflphone-client-kde"); + + KAboutData about( + "sflphone-client-kde", + "sflphone-client-kde", + ki18n("SFLphone KDE Client"), + version, + ki18n(description), + KAboutData::License_GPL_V3, + ki18n("(C) 2009 Savoir-faire Linux"), + KLocalizedString(), + "http://www.sflphone.org.", + "sflphone@lists.savoirfairelinux.net"); + about.addAuthor( ki18n("Jérémy Quentin"), KLocalizedString(), "jeremy.quentin@savoirfairelinux.com" ); + about.setTranslator( ki18nc("NAME OF TRANSLATORS","Your names"), ki18nc("EMAIL OF TRANSLATORS","Your emails") ); + KCmdLineArgs::init(argc, argv, &about); + KCmdLineOptions options; + KCmdLineArgs::addCmdLineOptions(options); + //configuration dbus registerCommTypes(); - InstanceInterface & instance = InstanceInterfaceSingleton::getInstance(); - instance.Register(getpid(), APP_NAME); + InstanceInterface & instance = InstanceInterfaceSingleton::getInstance(); + instance.Register(getpid(), APP_NAME); SFLPhoneApplication app; return app.exec(); - - } - catch(const char * msg) - { - printf("%s\n",msg); - } - catch(QString msg) - { - qDebug() << msg; - } + + } + catch(const char * msg) + { + qDebug() << msg; + } + catch(QString msg) + { + qDebug() << msg; + } }