diff --git a/sflphone_kde/Account.cpp b/sflphone_kde/Account.cpp index 1247e392adaf1062886456772cf1f04c7a2db97c..4d79eb7a22084525b8677ed5c57e42dfede2ab85 100644 --- a/sflphone_kde/Account.cpp +++ b/sflphone_kde/Account.cpp @@ -1,11 +1,10 @@ #include "Account.h" + +#include <QtGui/QApplication> + #include "sflphone_const.h" #include "configurationmanager_interface_singleton.h" -#include "kled.h" - -#include <iostream> -using namespace std; const QString account_state_name(QString & s) { @@ -61,41 +60,26 @@ void Account::setItemText(QString text) void Account::initAccountItem() { - ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + //ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); item = new QListWidgetItem(); item->setSizeHint(QSize(140,25)); item->setFlags(Qt::ItemIsSelectable|Qt::ItemIsDragEnabled|Qt::ItemIsDropEnabled|Qt::ItemIsEnabled); bool enabled = getAccountDetail(*(new QString(ACCOUNT_ENABLED))) == ACCOUNT_ENABLED_TRUE; setItemText(getAccountDetail(*(new QString(ACCOUNT_ALIAS)))); - itemWidget = new QWidget(); - QCheckBox * checkbox = new QCheckBox(itemWidget); - checkbox->setObjectName(QString(ACCOUNT_ITEM_CHECKBOX)); - checkbox->setCheckState(enabled ? Qt::Checked : Qt::Unchecked); - KLed * led = new KLed(itemWidget); - led->setObjectName(QString(ACCOUNT_ITEM_LED)); - led->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - if(! isNew() && enabled) + itemWidget = new AccountItemWidget(); + itemWidget->setEnabled(enabled); + if(isNew() || !enabled) + { + itemWidget->setState(AccountItemWidget::Unregistered); + } + else if(getAccountDetail(* new QString(ACCOUNT_STATUS)) == ACCOUNT_STATE_REGISTERED) { - led->setState(KLed::On); - if(getAccountDetail(* new QString(ACCOUNT_STATUS)) == ACCOUNT_STATE_REGISTERED) - { - led->setColor(QColor(0,255,0)); - } - else - { - led->setColor(QColor(255,0,0)); - } + itemWidget->setState(AccountItemWidget::Registered); } else { - led->setState(KLed::Off); + itemWidget->setState(AccountItemWidget::NotWorking); } - QHBoxLayout* hlayout = new QHBoxLayout(); - hlayout->setContentsMargins(0,0,0,0); - hlayout->addWidget(checkbox); - hlayout->addWidget(led); - itemWidget->setLayoutDirection(Qt::LeftToRight); - itemWidget->setLayout(hlayout); } Account * Account::buildExistingAccountFromId(QString _accountId) @@ -112,7 +96,7 @@ Account * Account::buildNewAccountFromAlias(QString alias) { Account * a = new Account(); a->accountDetails = new MapStringString(); - a->setAccountDetail(QString(ACCOUNT_ALIAS),alias); + a->setAccountDetail(ACCOUNT_ALIAS,alias); a->initAccountItem(); return a; } @@ -126,23 +110,26 @@ Account::~Account() //Getters -bool Account::isNew() +bool Account::isNew() const { - qDebug() << accountId; - return(!accountId); + return (accountId == NULL); } -bool Account::isChecked() +bool Account::isChecked() const { - return itemWidget->findChild<QCheckBox *>(QString(ACCOUNT_ITEM_CHECKBOX))->checkState() == Qt::Checked; + return itemWidget->getEnabled(); } QString & Account::getAccountId() { + if (isNew()) + { + qDebug() << "Error : getting AccountId of a new account."; + } return *accountId; } -MapStringString & Account::getAccountDetails() +MapStringString & Account::getAccountDetails() const { return *accountDetails; } @@ -150,14 +137,36 @@ MapStringString & Account::getAccountDetails() QListWidgetItem * Account::getItem() { if(!item) - cout<<"null"<<endl; + qDebug() << "null" ; return item; } -QWidget * Account::getItemWidget() +QListWidgetItem * Account::renewItem() { if(!item) - cout<<"null"<<endl; + qDebug() << "null" ; + item = new QListWidgetItem(*item); + return item; +} + +AccountItemWidget * Account::getItemWidget() +{ + delete itemWidget; + bool enabled = getAccountDetail(*(new QString(ACCOUNT_ENABLED))) == ACCOUNT_ENABLED_TRUE; + itemWidget = new AccountItemWidget(); + itemWidget->setEnabled(enabled); + if(isNew() || !enabled) + { + itemWidget->setState(AccountItemWidget::Unregistered); + } + else if(getAccountDetail(* new QString(ACCOUNT_STATUS)) == ACCOUNT_STATE_REGISTERED) + { + itemWidget->setState(AccountItemWidget::Registered); + } + else + { + itemWidget->setState(AccountItemWidget::NotWorking); + } return itemWidget; } @@ -185,11 +194,16 @@ QString Account::getStateColorName() return "red"; } -QString Account::getAccountDetail(QString & param) +QString Account::getAccountDetail(QString param) const { return (*accountDetails)[param]; } +QString Account::getAlias() +{ + return getAccountDetail(ACCOUNT_ALIAS); +} + //Setters diff --git a/sflphone_kde/Account.h b/sflphone_kde/Account.h index f3fedda48ecf39dda73aa0f46ba9ffe8936f9878..73be6d50fd33b032c4e18643faf847597b2e4b93 100644 --- a/sflphone_kde/Account.h +++ b/sflphone_kde/Account.h @@ -1,8 +1,12 @@ #ifndef ACCOUNT_H #define ACCOUNT_H -#include <QtGui> +#include <QtCore/QString> +#include <QtGui/QListWidgetItem> +#include <QtGui/QColor> + #include "metatypes.h" +#include "AccountItemWidget.h" const QString account_state_name(QString & s); @@ -13,7 +17,7 @@ private: QString * accountId; MapStringString * accountDetails; QListWidgetItem * item; - QWidget * itemWidget; + AccountItemWidget * itemWidget; Account(); @@ -26,16 +30,18 @@ public: ~Account(); //Getters - bool isNew(); - bool isChecked(); + bool isNew() const; + bool isChecked() const; QString & getAccountId(); - MapStringString & getAccountDetails(); + MapStringString & getAccountDetails() const; QListWidgetItem * getItem(); - QWidget * getItemWidget(); + QListWidgetItem * renewItem(); + AccountItemWidget * getItemWidget(); QString getStateName(QString & state); QColor getStateColor(); QString getStateColorName(); - QString getAccountDetail(QString & param); + QString getAccountDetail(QString param) const; + QString getAlias(); //Setters void setItemText(QString text); diff --git a/sflphone_kde/AccountItemWidget.cpp b/sflphone_kde/AccountItemWidget.cpp new file mode 100644 index 0000000000000000000000000000000000000000..11b7985d29dead6bb69ff77c7813d8e808b64c3f --- /dev/null +++ b/sflphone_kde/AccountItemWidget.cpp @@ -0,0 +1,102 @@ +/*************************************************************************** + * 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 "AccountItemWidget.h" + +#include <QtGui/QHBoxLayout> +#include <QtCore/QDebug> + +#include "sflphone_const.h" + +AccountItemWidget::AccountItemWidget(QWidget *parent) + : QWidget(parent) +{ + checkBox = new QCheckBox(this); + //checkbox->setObjectName(QString(ACCOUNT_ITEM_CHECKBOX)); + led = new KLed(this); + //led->setObjectName(QString(ACCOUNT_ITEM_LED)); + led->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); + + QHBoxLayout* hlayout = new QHBoxLayout(); + hlayout->setContentsMargins(0,0,0,0); + hlayout->addWidget(checkBox); + hlayout->addWidget(led); + this->setLayout(hlayout); + state = Unregistered; + enabled = false; + updateDisplay(); +} + + +AccountItemWidget::~AccountItemWidget() +{ +} + + +void AccountItemWidget::updateStateDisplay() +{ + switch(state) + { + case Registered: + led->setState(KLed::On); + led->setColor(QColor(0,255,0)); + break; + case Unregistered: + led->setState(KLed::Off); + led->setColor(QColor(0,255,0)); + break; + case NotWorking: + led->setState(KLed::On); + led->setColor(QColor(255,0,0)); + 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); +} + +void AccountItemWidget::updateDisplay() +{ + updateStateDisplay(); + updateEnabledDisplay(); +} + +void AccountItemWidget::setState(int state) +{ + this->state = state; + updateStateDisplay(); + //emit stateChanged; +} + +void AccountItemWidget::setEnabled(bool enabled) +{ + this->enabled = enabled; + updateEnabledDisplay(); + //emit enabledChanged; +} + +bool AccountItemWidget::getEnabled() +{ + return checkBox->checkState(); +} diff --git a/sflphone_kde/AccountItemWidget.h b/sflphone_kde/AccountItemWidget.h new file mode 100644 index 0000000000000000000000000000000000000000..3b5652891fbbed2d425ef4bbcfa417f67df265a0 --- /dev/null +++ b/sflphone_kde/AccountItemWidget.h @@ -0,0 +1,67 @@ +/*************************************************************************** + * 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 ACCOUNTITEMWIDGET_H +#define ACCOUNTITEMWIDGET_H + +#include <QWidget> +#include <QCheckBox> +#include "kled.h" + +/** + @author Jérémy Quentin <jeremy.quentin@gmail.com> +*/ +class AccountItemWidget : public QWidget +{ +Q_OBJECT + +private: + + int state; + bool enabled; + KLed * led; + QCheckBox * checkBox; + +public: + + enum State {Registered, Unregistered, NotWorking}; + + AccountItemWidget(QWidget *parent = 0); + + ~AccountItemWidget(); + + void setState(int state); + + void setEnabled(bool enabled); + + void updateStateDisplay(); + + void updateEnabledDisplay(); + + void updateDisplay(); + + int getState(); + + bool getEnabled(); + + +}; + +#endif diff --git a/sflphone_kde/AccountList.cpp b/sflphone_kde/AccountList.cpp index 915189f9419c428eca43234d485a6a18e1930f93..07c1d158ccbbd05684a22b72bbfa9a16c9099c41 100644 --- a/sflphone_kde/AccountList.cpp +++ b/sflphone_kde/AccountList.cpp @@ -1,6 +1,6 @@ #include "AccountList.h" #include "sflphone_const.h" - +#include "configurationmanager_interface_singleton.h" //Constructors /* @@ -15,6 +15,7 @@ AccountList::AccountList(VectorString & _accountIds) */ AccountList::AccountList(QStringList & _accountIds) { + firstAccount = NULL; accounts = new QVector<Account *>(); for (int i = 0; i < _accountIds.size(); ++i){ (*accounts) += Account::buildExistingAccountFromId(_accountIds[i]); @@ -23,6 +24,7 @@ AccountList::AccountList(QStringList & _accountIds) AccountList::AccountList() { + firstAccount = NULL; ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); //ask for the list of accounts ids to the configurationManager QStringList accountIds = configurationManager.getAccountList().value(); @@ -32,6 +34,58 @@ AccountList::AccountList() } } +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])); + } +} + +QVector<Account *> AccountList::registeredAccounts() const +{ + QVector<Account *> registeredAccounts; + Account * current; + for (int i = 0; i < accounts->count(); ++i){ + current = (*accounts)[i]; + if(current->getAccountDetail(ACCOUNT_STATUS) == QString(ACCOUNT_STATE_REGISTERED)) + { + registeredAccounts.append(current); + } + } + return registeredAccounts; +} + +Account * AccountList::firstRegisteredAccount() const +{ + if(firstAccount != NULL) + { + return firstAccount; + } + Account * current; + for (int i = 0; i < accounts->count(); ++i){ + current = (*accounts)[i]; + if(current->getAccountDetail(ACCOUNT_STATUS) == QString(ACCOUNT_STATE_REGISTERED)) + { + return current; + } + } + return NULL; +} + +void AccountList::setAccountFirst(Account * account) +{ + firstAccount = account; +} + AccountList::~AccountList() { delete accounts; @@ -45,11 +99,15 @@ QVector<Account *> & AccountList::getAccounts() Account * AccountList::getAccountById(QString & id) { - qDebug() << "for "; - for (int i = 0; i < accounts->size(); ++i){ - qDebug() << "account " << i << " (*accounts)[i]->getAccountId() " << (*accounts)[i]->getAccountId(); - if ((*accounts)[i]->getAccountId() == id) + qDebug() << "for " << accounts->size(); + for (int i = 0; i < accounts->size(); ++i) + { + qDebug() << "account " << i << " (*accounts)[i]->getAccountId() " << (*accounts)[i]; + if (!(*accounts)[i]->isNew() && (*accounts)[i]->getAccountId() == id) + { + qDebug() << "found "; return (*accounts)[i]; + } } return NULL; } @@ -108,6 +166,11 @@ void AccountList::removeAccount(QListWidgetItem * item) accounts->remove(accounts->indexOf(a)); } +void AccountList::removeAccount(Account * account) +{ + accounts->remove(accounts->indexOf(account)); +} + const Account & AccountList::operator[] (int i) const { return *((*accounts)[i]); diff --git a/sflphone_kde/AccountList.h b/sflphone_kde/AccountList.h index dba419d63f0b33c76bf45418b89fac132ffdaf29..4c6c95d5773700374efddb08bed2932483e824c9 100644 --- a/sflphone_kde/AccountList.h +++ b/sflphone_kde/AccountList.h @@ -1,7 +1,9 @@ #ifndef ACCOUNT_LIST_H #define ACCOUNT_LIST_H -#include <QtGui> + +#include <QtCore/QVector> + #include "Account.h" class AccountList{ @@ -9,11 +11,13 @@ class AccountList{ private: QVector<Account *> * accounts; + Account * firstAccount; public: //Constructors AccountList(QStringList & _accountIds); + AccountList(); ~AccountList(); //Getters @@ -22,14 +26,19 @@ public: QVector<Account *> getAccountByState(QString & state); Account * getAccountByItem(QListWidgetItem * item); int size(); + Account * firstRegisteredAccount() const; //Setters Account * addAccount(QString & alias); + void removeAccount(Account * account); void removeAccount(QListWidgetItem * item); + void setAccountFirst(Account * account); //Operators Account & operator[] (int i); const Account & operator[] (int i) const; + QVector<Account *> registeredAccounts() const; + void update(); }; diff --git a/sflphone_kde/AccountWizard.cpp b/sflphone_kde/AccountWizard.cpp index aaad97d8b51850fc7a2c23ead599dde454a690f6..552cc81723afc88241153d5feb86dfb76666ee2a 100644 --- a/sflphone_kde/AccountWizard.cpp +++ b/sflphone_kde/AccountWizard.cpp @@ -173,12 +173,13 @@ void AccountWizard::accept() { QString ret; MapStringString accountDetails; - accountDetails[QString(ACCOUNT_ALIAS)] = QString(); - accountDetails[QString(ACCOUNT_HOSTNAME)] = QString(); - accountDetails[QString(ACCOUNT_USERNAME)] = QString(); - accountDetails[QString(ACCOUNT_PASSWORD)] = QString(); - accountDetails[QString(ACCOUNT_TYPE)] = QString(); - accountDetails[QString(ACCOUNT_MAILBOX)] = QString(); + //accountDetails[QString(ACCOUNT_ALIAS)] = QString(); + //accountDetails[QString(ACCOUNT_HOSTNAME)] = QString(); + //accountDetails[QString(ACCOUNT_USERNAME)] = QString(); + //accountDetails[QString(ACCOUNT_PASSWORD)] = QString(); + //accountDetails[QString(ACCOUNT_TYPE)] = QString(); + //accountDetails[QString(ACCOUNT_MAILBOX)] = QString(); + //accountDetails[QString(ACCOUNT_ENABLED)] = QString(); QString & alias = accountDetails[QString(ACCOUNT_ALIAS)]; QString & server = accountDetails[QString(ACCOUNT_HOSTNAME)]; @@ -186,6 +187,7 @@ void AccountWizard::accept() QString & password = accountDetails[QString(ACCOUNT_PASSWORD)]; QString & protocol = accountDetails[QString(ACCOUNT_TYPE)]; QString & mailbox = accountDetails[QString(ACCOUNT_MAILBOX)]; + QString & enabled = accountDetails[QString(ACCOUNT_ENABLED)]; bool createAccount = false; bool sip = false; @@ -240,25 +242,17 @@ void AccountWizard::accept() } if(createAccount) { - mailbox = QString(ACCOUNT_MAILBOX_DEFAULT_VALUE); - qDebug() << "ligne1"; + mailbox = ACCOUNT_MAILBOX_DEFAULT_VALUE; + enabled = ACCOUNT_ENABLED_TRUE; ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - qDebug() << "ligne2"; QString accountId = configurationManager.addAccount(accountDetails); - qDebug() << "ligne3"; - configurationManager.sendRegister(accountId, 1); - qDebug() << "ligne4"; + //configurationManager.sendRegister(accountId, 1); if(sip) { - qDebug() << "ligne5"; bool enableStun = field(FIELD_ENABLE_STUN).toBool(); - qDebug() << "ligne6"; QString stunServer = field(FIELD_STUN_SERVER).toString(); - qDebug() << "ligne7"; if(enableStun != configurationManager.isStunEnabled()) configurationManager.enableStun(); - qDebug() << "ligne8"; if(enableStun) configurationManager.setStunServer(stunServer); - qDebug() << "ligne9"; } ret += tr("Alias : ") + alias + "\n"; ret += tr("Server : ") + server + "\n"; diff --git a/sflphone_kde/ActionSetAccountFirst.cpp b/sflphone_kde/ActionSetAccountFirst.cpp new file mode 100644 index 0000000000000000000000000000000000000000..bef7dbc8cd01fcf2bffd74d0537f804ae1c88e23 --- /dev/null +++ b/sflphone_kde/ActionSetAccountFirst.cpp @@ -0,0 +1,39 @@ +/*************************************************************************** + * 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 "ActionSetAccountFirst.h" + +ActionSetAccountFirst::ActionSetAccountFirst(Account * account, QObject *parent) + : QAction(account->getAlias(), parent) +{ + this->account = account; + connect(this, SIGNAL(triggered()), + this, SLOT(emitSetFirst())); +} + + +ActionSetAccountFirst::~ActionSetAccountFirst() +{ +} + +void ActionSetAccountFirst::emitSetFirst() +{ + emit setFirst(account); +} diff --git a/sflphone_kde/ActionSetAccountFirst.h b/sflphone_kde/ActionSetAccountFirst.h new file mode 100644 index 0000000000000000000000000000000000000000..6d53166ff574cce5e0b14412a1e43860ca3e33b7 --- /dev/null +++ b/sflphone_kde/ActionSetAccountFirst.h @@ -0,0 +1,50 @@ +/*************************************************************************** + * 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 ACTION_SET_ACCOUNT_FIRST_H +#define ACTION_SET_ACCOUNT_FIRST_H + +#include <QAction> + +#include "Account.h" + +/** + @author Jérémy Quentin <jeremy.quentin@gmail.com> +*/ +class ActionSetAccountFirst : public QAction +{ +Q_OBJECT + +private: + Account * account; +public: + ActionSetAccountFirst(Account * account, QObject *parent = 0); + + ~ActionSetAccountFirst(); + +private slots: + void emitSetFirst(); + +signals: + void setFirst(Account * account); + +}; + +#endif diff --git a/sflphone_kde/Automate.cpp b/sflphone_kde/Automate.cpp deleted file mode 100644 index c80fea24f0be2be1508dac55cdf59e675b980dda..0000000000000000000000000000000000000000 --- a/sflphone_kde/Automate.cpp +++ /dev/null @@ -1,149 +0,0 @@ - -#include "Automate.h" - -#include "callmanager_interface_p.h" -#include "callmanager_interface_singleton.h" -#include "SFLPhone.h" - - - -const call_state Automate::stateMap [11][5] = -{ -// ACCEPT REFUSE TRANSFER HOLD RECORD -/*INCOMING */ {CALL_STATE_CURRENT , CALL_STATE_OVER , CALL_STATE_OVER , CALL_STATE_HOLD , CALL_STATE_INCOMING }, -/*RINGING */ {CALL_STATE_ERROR , CALL_STATE_OVER , CALL_STATE_ERROR , CALL_STATE_ERROR , CALL_STATE_RINGING }, -/*CURRENT */ {CALL_STATE_ERROR , CALL_STATE_OVER , CALL_STATE_TRANSFER , CALL_STATE_HOLD , CALL_STATE_CURRENT }, -/*DIALING */ {CALL_STATE_RINGING , CALL_STATE_OVER , CALL_STATE_ERROR , CALL_STATE_ERROR , CALL_STATE_DIALING }, -/*HOLD */ {CALL_STATE_ERROR , CALL_STATE_OVER , CALL_STATE_TRANSFER_HOLD , CALL_STATE_CURRENT , CALL_STATE_HOLD }, -/*FAILURE */ {CALL_STATE_ERROR , CALL_STATE_OVER , CALL_STATE_ERROR , CALL_STATE_ERROR , CALL_STATE_ERROR }, -/*BUSY */ {CALL_STATE_ERROR , CALL_STATE_OVER , CALL_STATE_ERROR , CALL_STATE_ERROR , CALL_STATE_ERROR }, -/*TRANSFER */ {CALL_STATE_OVER , CALL_STATE_OVER , CALL_STATE_CURRENT , CALL_STATE_TRANSFER_HOLD , CALL_STATE_TRANSFER }, -/*TRANSFER_HOLD */ {CALL_STATE_OVER , CALL_STATE_OVER , CALL_STATE_HOLD , CALL_STATE_TRANSFER , CALL_STATE_TRANSFER_HOLD }, -/*OVER */ {CALL_STATE_ERROR , CALL_STATE_ERROR , CALL_STATE_ERROR , CALL_STATE_ERROR , CALL_STATE_ERROR }, -/*ERROR */ {CALL_STATE_ERROR , CALL_STATE_ERROR , CALL_STATE_ERROR , CALL_STATE_ERROR , CALL_STATE_ERROR } -}; - -const function Automate::functionMap[11][5] = -{ -// ACCEPT REFUSE TRANSFER HOLD -/*INCOMING */ {&Automate::accept , &Automate::refuse , &Automate::acceptTransf , &Automate::acceptHold , &Automate::switchRecord }, -/*RINGING */ {&Automate::nothing , &Automate::hangUp , &Automate::nothing , &Automate::nothing , &Automate::switchRecord }, -/*CURRENT */ {&Automate::nothing , &Automate::hangUp , &Automate::nothing , &Automate::hold , &Automate::setRecord }, -/*DIALING */ {&Automate::call , &Automate::nothing , &Automate::nothing , &Automate::nothing , &Automate::switchRecord }, -/*HOLD */ {&Automate::nothing , &Automate::hangUp , &Automate::nothing , &Automate::unhold , &Automate::setRecord }, -/*FAILURE */ {&Automate::nothing , &Automate::hangUp , &Automate::nothing , &Automate::nothing , &Automate::nothing }, -/*BUSY */ {&Automate::nothing , &Automate::hangUp , &Automate::nothing , &Automate::nothing , &Automate::nothing }, -/*TRANSFERT */ {&Automate::transfer , &Automate::hangUp , &Automate::nothing , &Automate::hold , &Automate::setRecord }, -/*TRANSFERT_HOLD */ {&Automate::transfer , &Automate::hangUp , &Automate::nothing , &Automate::unhold , &Automate::setRecord }, -/*OVER */ {&Automate::nothing , &Automate::nothing , &Automate::nothing , &Automate::nothing , &Automate::nothing }, -/*ERROR */ {&Automate::nothing , &Automate::nothing , &Automate::nothing , &Automate::nothing , &Automate::nothing } -}; - -call_state Automate::action(call_action action, QString callId, QString number) -{ - call_state previousState = currentState; - //execute the action associated with this transition - (this->*(functionMap[currentState][action]))(callId, number); - //update the state - currentState = stateMap[currentState][action]; - qDebug() << "Calling action " << action << " on call with state " << previousState << ". Become " << currentState; - //return the new state - return currentState; -} - -Automate::Automate(call_state startState) -{ - //this->parent = parent; - recording = false; - currentState = startState; -} - -call_state Automate::getCurrentState() const -{ - return currentState; -} - -void Automate::nothing(QString callId, QString number) -{ -} - -void Automate::accept(QString callId, QString number) -{ - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Accepting call. callId : " << callId; - callManager.accept(callId); -} - -void Automate::refuse(QString callId, QString number) -{ - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Refusing call. callId : " << callId; - callManager.refuse(callId); -} - -void Automate::acceptTransf(QString callId, QString number) -{ - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Accepting call and transfering it to number : " << number << ". callId : " << callId; - callManager.accept(callId); - callManager.transfert(callId, number); -} - -void Automate::acceptHold(QString callId, QString number) -{ - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Accepting call and holding it. callId : " << callId; - callManager.accept(callId); - callManager.hold(callId); -} - -void Automate::hangUp(QString callId, QString number) -{ - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Hanging up call. callId : " << callId; - callManager.hangUp(callId); -} - -void Automate::hold(QString callId, QString number) -{ - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Holding call. callId : " << callId; - callManager.hold(callId); -} - -void Automate::call(QString callId, QString number) -{ - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - QString account = SFLPhone::firstAccount(); - qDebug() << "Calling " << number << " with account " << account << ". callId : " << callId; - callManager.placeCall(account, callId, number); -} - -void Automate::transfer(QString callId, QString number) -{ - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - QString account = SFLPhone::firstAccount(); - qDebug() << "Transfering call to number : " << number << ". callId : " << callId; - callManager.transfert(callId, number); -} - -void Automate::unhold(QString callId, QString number) -{ - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Unholding call. callId : " << callId; - callManager.unhold(callId); -} - -void Automate::switchRecord(QString callId, QString number) -{ - qDebug() << "Switching record state for call automate. callId : " << callId; - recording = !recording; -} - -void Automate::setRecord(QString callId, QString number) -{ - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Setting record for call. callId : " << callId; - callManager.unhold(callId); -} - diff --git a/sflphone_kde/Automate.h b/sflphone_kde/Automate.h deleted file mode 100644 index 8199d92559fb2f564aff896ed3abb562ab7ca50d..0000000000000000000000000000000000000000 --- a/sflphone_kde/Automate.h +++ /dev/null @@ -1,97 +0,0 @@ -#ifndef AUTOMATE_H -#define AUTOMATE_H - -#include <QtGui> -//#include "Call.h" - -/** @enum call_state_t - * This enum have all the states a call can take. - */ -typedef enum -{ - /** Ringing incoming call */ - CALL_STATE_INCOMING, - /** Ringing outgoing call */ - CALL_STATE_RINGING, - /** Call to which the user can speak and hear */ - CALL_STATE_CURRENT, - /** Call which numbers are being added by the user */ - CALL_STATE_DIALING, - /** Call is on hold */ - CALL_STATE_HOLD, - /** Call has failed */ - CALL_STATE_FAILURE, - /** Call is busy */ - CALL_STATE_BUSY, - /** Call is being transfered. During this state, the user can enter the new number. */ - CALL_STATE_TRANSFER, - /** Call is on hold for transfer */ - CALL_STATE_TRANSFER_HOLD, - /** Call is over and should not be used */ - CALL_STATE_OVER, - /** This state should never be reached */ - CALL_STATE_ERROR -} call_state; - - -/** @enum call_action - * This enum have all the actions you can make on a call. - */ -typedef enum -{ - /** Green button, accept or new call or place call or place transfer */ - CALL_ACTION_ACCEPT, - /** Red button, refuse or hang up */ - CALL_ACTION_REFUSE, - /** Blue button, put into or out of transfer mode where you can type transfer number */ - CALL_ACTION_TRANSFER, - /** Blue-green button, hold or unhold the call */ - CALL_ACTION_HOLD, - /** Record button, enable or disable recording */ - CALL_ACTION_RECORD -} call_action; - - -class Automate; - -typedef void (Automate::*function)(QString callId, QString number); - -//class Call; - -class Automate -{ -private: - - static const call_state stateMap [11][5]; - - static const function functionMap[11][5]; - - //Call * parent; - call_state currentState; - bool recording; - -public: - - Automate(call_state startState); - call_state action(call_action action, QString callId, QString number = NULL); - call_state getCurrentState() const; - - void nothing(QString callId, QString number); - void accept(QString callId, QString number); - void refuse(QString callId, QString number); - void acceptTransf(QString callId, QString number); - void acceptHold(QString callId, QString number); - void hangUp(QString callId, QString number); - void hold(QString callId, QString number); - void call(QString callId, QString number); - void transfer(QString callId, QString number); - void unhold(QString callId, QString number); - void switchRecord(QString callId, QString number); - void setRecord(QString callId, QString number); - -}; - - - - -#endif \ No newline at end of file diff --git a/sflphone_kde/CMakeLists.txt b/sflphone_kde/CMakeLists.txt index d12fd80b512b93097e6533c52de995cb6ffec63b..1f6176ef0927b9125c2604da5c466c5a34950452 100644 --- a/sflphone_kde/CMakeLists.txt +++ b/sflphone_kde/CMakeLists.txt @@ -11,7 +11,7 @@ SET( SFLPhone.cpp ConfigDialog.cpp main.cpp - sflphone_const.cpp + sflphone_const.h Account.cpp AccountList.cpp Call.cpp @@ -20,7 +20,12 @@ SET( configurationmanager_interface_singleton.cpp callmanager_interface.cpp callmanager_interface_singleton.cpp + instance_interface.cpp + instance_interface_singleton.cpp AccountWizard.cpp + AccountItemWidget.cpp + ActionSetAccountFirst.cpp + Contact.cpp ) SET(QtApp_RCCS resources.qrc) @@ -38,7 +43,7 @@ kde4_add_kcfg_files(sflphone_kde_SRCS settings.kcfgc ) kde4_add_executable(sflphone_kde ${sflphone_kde_SRCS} ${QtApp_RCC_SRCS}) -target_link_libraries(sflphone_kde ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS}) +target_link_libraries(sflphone_kde ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} ${KDE4_KABCdef_LIBS}) install(TARGETS sflphone_kde DESTINATION ${BIN_INSTALL_DIR} ) diff --git a/sflphone_kde/Call.cpp b/sflphone_kde/Call.cpp index fa61898d5330a3bbe4c0d5a592c99b29f30ff8d0..36bef1df4fc0da196c2f65c1b9a8d5095c2d4463 100644 --- a/sflphone_kde/Call.cpp +++ b/sflphone_kde/Call.cpp @@ -72,6 +72,7 @@ void Call::initCallItem() itemWidget = new QWidget(); labelIcon = new QLabel(itemWidget); + qDebug() << "labelIcon : " << labelIcon; labelCallNumber = new QLabel(peer, itemWidget); labelTransferPrefix = new QLabel("Transfer to : ", itemWidget); labelTransferNumber = new QLabel(itemWidget); @@ -84,14 +85,7 @@ void Call::initCallItem() layout->addWidget(labelTransferPrefix, 1, 1, 1, 1); layout->addWidget(labelTransferNumber, 1, 2, 1, 2); layout->addItem(horizontalSpacer, 0, 3, 1, 3); - //labelIcon->raise(); - //labelCallNumber->raise(); - //labelTransferTo->raise(); - //labelTransferNumber->raise(); - //itemWidget->setLayoutDirection(Qt::LeftToRight); itemWidget->setLayout(layout); - //item->setSizeHint(itemWidget->sizeHint()); - //setItemIcon(QString(ICON_REFUSE)); } void Call::setItemIcon(const QString pixmap) @@ -108,6 +102,9 @@ Call::Call(call_state startState, QString callId, QString from, QString account) this->account = account; this->recording = false; this->historyItem = NULL; + this->historyItemWidget = NULL; + this->startTime = NULL; + this->stopTime = NULL; } Call::~Call() @@ -115,12 +112,9 @@ Call::~Call() delete startTime; delete stopTime; delete item; - delete itemWidget; - delete labelIcon; - delete labelCallNumber; - delete labelTransferPrefix; - delete labelTransferNumber; + //delete itemWidget; delete historyItem; + //delete historyItemWidget; } Call * Call::buildDialingCall(QString callId) @@ -208,6 +202,11 @@ QListWidgetItem * Call::getHistoryItem() return historyItem; } +QWidget * Call::getHistoryItemWidget() +{ + return historyItemWidget; +} + call_state Call::getState() const { return currentState; @@ -332,7 +331,7 @@ void Call::call() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); QString number = labelCallNumber->text(); - this->account = SFLPhone::firstAccount(); + this->account = SFLPhone::firstAccountId(); if(!account.isEmpty()) { qDebug() << "Calling " << number << " with account " << account << ". callId : " << callId; diff --git a/sflphone_kde/Call.h b/sflphone_kde/Call.h index 0a788715ac80903f31ae59b432a3105b5e42b658..347ddc673c6c81402f0208ea406cc21e4fb8bd1b 100644 --- a/sflphone_kde/Call.h +++ b/sflphone_kde/Call.h @@ -1,7 +1,11 @@ #ifndef CALL_H #define CALL_H -#include <QtGui> -#include "Account.h" + +#include <QtCore/QString> +#include <QtCore/QDateTime> +#include <QtGui/QListWidgetItem> +#include <QtGui/QLabel> +#include <QtGui/QWidget> /** @enum call_state_t * This enum have all the states a call can take. @@ -90,6 +94,7 @@ class Call private: //Call attributes + QString account; QString callId; QString peer; @@ -104,6 +109,7 @@ private: QLabel * labelTransferNumber; QListWidgetItem * historyItem; + QWidget * historyItemWidget; //Automate attributes static const call_state actionPerformedStateMap [11][5]; @@ -144,6 +150,7 @@ public: QListWidgetItem * getItem(); QWidget * getItemWidget(); QListWidgetItem * getHistoryItem(); + QWidget * getHistoryItemWidget(); call_state getState() const; QString getCallId(); call_state stateChanged(const QString & newState); diff --git a/sflphone_kde/CallList.h b/sflphone_kde/CallList.h index 50842d3ca4952be76d039b75e8cd1ec1a4be3074..8ac1c7898c714936573099ef3253ac45e9d98eca 100644 --- a/sflphone_kde/CallList.h +++ b/sflphone_kde/CallList.h @@ -1,6 +1,10 @@ #ifndef CALL_LIST_H #define CALL_LIST_H +#include <QtCore/QVector> +#include <QtCore/QString> +#include <QtGui/QListWidgetItem> + #include "Call.h" class CallList diff --git a/sflphone_kde/ConfigDialog.cpp b/sflphone_kde/ConfigDialog.cpp index 461c16c549242e49c6687ef306378b1fd14b0e49..43ec28e59215a8c70a2b916986c4a1af7620ff2b 100644 --- a/sflphone_kde/ConfigDialog.cpp +++ b/sflphone_kde/ConfigDialog.cpp @@ -1,15 +1,19 @@ -#include <QtGui> -#include <QtCore> -#include <iostream> -#include <stdarg.h> +#include "ConfigDialog.h" + +#include <QtGui/QStyle> +#include <QErrorMessage> +#include <QtGui/QAbstractItemView> +#include <QtGui/QInputDialog> +#include <QtGui/QHeaderView> + + + #include "sflphone_const.h" #include "metatypes.h" -#include "ConfigDialog.h" #include "configurationmanager_interface_singleton.h" -using namespace std; - +AccountList * ConfigurationDialog::accountList; ConfigurationDialog::ConfigurationDialog(SFLPhone *parent) : QDialog(parent) { @@ -58,6 +62,11 @@ ConfigurationDialog::~ConfigurationDialog() delete codecPayloads; } +AccountList * ConfigurationDialog::getAccountList() +{ + return accountList; +} + void ConfigurationDialog::loadOptions() { ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); @@ -240,7 +249,7 @@ void ConfigurationDialog::loadAccountList() for (int i = 0; i < accountList->size(); ++i){ addAccountToAccountList(&(*accountList)[i]); } - if (listWidget_accountList->count() > 0) + if (listWidget_accountList->count() > 0 && listWidget_accountList->currentItem() == NULL) listWidget_accountList->setCurrentRow(0); else frame2_editAccounts->setEnabled(false); @@ -277,6 +286,7 @@ void ConfigurationDialog::saveAccountList() currentId = QString(current.getAccountId()); } } + qDebug() << currentId << " : " << current.isChecked(); configurationManager.sendRegister(currentId, current.isChecked() ? 1 : 0 ); } //remove accounts that are in the configurationManager but not in the client @@ -307,11 +317,11 @@ void ConfigurationDialog::loadAccount(QListWidgetItem * item) delete protocolsList; edit2_protocol->setCurrentIndex( (protocolIndex < 0) ? 0 : protocolIndex ); - edit3_server->setText( account->getAccountDetail(*(new QString(ACCOUNT_HOSTNAME)))); - edit4_user->setText( account->getAccountDetail(*(new QString(ACCOUNT_USERNAME)))); - edit5_password->setText( account->getAccountDetail(*(new QString(ACCOUNT_PASSWORD)))); - edit6_mailbox->setText( account->getAccountDetail(*(new QString(ACCOUNT_MAILBOX)))); - QString status = account->getAccountDetail(*(new QString(ACCOUNT_STATUS))); + 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)); + QString status = account->getAccountDetail(ACCOUNT_STATUS); qDebug() << "Color : " << account->getStateColorName(); edit7_state->setText( "<FONT COLOR=\"" + account->getStateColorName() + "\">" + status + "</FONT>" ); //edit7_Etat->setTextColor( account->getStateColor ); @@ -332,7 +342,7 @@ void ConfigurationDialog::saveAccount(QListWidgetItem * item) 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->getItemWidget()->findChild(*(new QString("checkbox"))).checkState() == Qt::Checked ? ACCOUNT_ENABLED_TRUE : ACCOUNT_ENABLED_FALSE); + account->setAccountDetail(ACCOUNT_ENABLED, account->isChecked() ? ACCOUNT_ENABLED_TRUE : ACCOUNT_ENABLED_FALSE); account->setItemText(edit1_alias->text()); } @@ -473,7 +483,7 @@ void ConfigurationDialog::on_spinBox_SIPPort_valueChanged ( int value ) label_WarningSIP->setVisible(true); } -void ConfigurationDialog::on_listWidget_codecs_currentItemChanged ( QListWidgetItem * current, QListWidgetItem * previous ) +void ConfigurationDialog::on_listWidget_codecs_currentItemChanged () { qDebug() << "on_listWidget_codecs_currentItemChanged"; updateCodecListCommands(); @@ -513,7 +523,7 @@ void ConfigurationDialog::on_toolButton_codecDown_clicked() void ConfigurationDialog::on_listWidget_accountList_currentItemChanged ( QListWidgetItem * current, QListWidgetItem * previous ) { - qDebug() << "on_listWidget_accountList_currentItemChanged"; + qDebug() << "on_listWidget_accountList_currentItemChanged : " << ((accountList->getAccountByItem(current) != NULL) ? accountList->getAccountByItem(current)->getAlias() : "null"); if(previous) saveAccount(previous); if(current) @@ -525,18 +535,35 @@ void ConfigurationDialog::on_button_accountUp_clicked() { qDebug() << "on_button_accountUp_clicked"; int currentRow = listWidget_accountList->currentRow(); - QListWidgetItem * item = listWidget_accountList->takeItem(currentRow); + QListWidgetItem * prevItem = listWidget_accountList->takeItem(currentRow); + Account * account = accountList->getAccountByItem(prevItem); + //we need to build a new item to set the itemWidget back + QListWidgetItem * item = account->renewItem(); + delete prevItem; listWidget_accountList->insertItem(currentRow - 1 , item); + listWidget_accountList->setItemWidget(item, account->getItemWidget()); listWidget_accountList->setCurrentItem(item); + //qDebug() << "setItemWidget " << account->getAccountDetail(ACCOUNT_ALIAS) << " , " << account->getItemWidget(); + } void ConfigurationDialog::on_button_accountDown_clicked() { qDebug() << "on_button_accountDown_clicked"; int currentRow = listWidget_accountList->currentRow(); - QListWidgetItem * item = listWidget_accountList->takeItem(currentRow); + qDebug() << "on_button_accountDown_clicked1"; + QListWidgetItem * prevItem = listWidget_accountList->takeItem(currentRow); + qDebug() << "on_button_accountDown_clicked2"; + Account * account = accountList->getAccountByItem(prevItem); + QListWidgetItem * item = account->renewItem(); + delete prevItem; + qDebug() << "on_button_accountDown_clicked3"; listWidget_accountList->insertItem(currentRow + 1 , item); + qDebug() << "on_button_accountDown_clicked4 : " << account->getAlias() << " " << account->getItemWidget(); + listWidget_accountList->setItemWidget(item, account->getItemWidget()); + qDebug() << "on_button_accountDown_clicked5"; listWidget_accountList->setCurrentItem(item); + qDebug() << "on_button_accountDown_clicked6"; } void ConfigurationDialog::on_button_accountAdd_clicked() @@ -562,6 +589,12 @@ void ConfigurationDialog::on_button_accountRemove_clicked() listWidget_accountList->setCurrentRow( (r >= listWidget_accountList->count()) ? r-1 : r ); } +void ConfigurationDialog::on_toolButton_accountsApply_clicked() +{ + qDebug() << "on_toolButton_accountsApply_clicked"; + saveAccountList(); +} + void ConfigurationDialog::on_buttonBoxDialog_clicked(QAbstractButton * button) { @@ -586,7 +619,7 @@ void ConfigurationDialog::on_buttonBoxDialog_clicked(QAbstractButton * button) } } -void ConfigurationDialog::on_tableWidget_codecs_currentItemChanged(QTableWidgetItem * current, QTableWidgetItem * previous) +void ConfigurationDialog::on_tableWidget_codecs_currentItemChanged(QTableWidgetItem * current) { qDebug() << "on_tableWidget_codecs_currentItemChanged"; int row = current->row(); @@ -598,7 +631,7 @@ void ConfigurationDialog::on_tableWidget_codecs_currentItemChanged(QTableWidgetI updateCodecListCommands(); } -void ConfigurationDialog::on_tableWidget_codecs_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn) +void ConfigurationDialog::on_tableWidget_codecs_currentCellChanged(int currentRow) { qDebug() << "on_tableWidget_codecs_currentCellChanged"; int nbCol = tableWidget_codecs->columnCount(); @@ -612,6 +645,13 @@ void ConfigurationDialog::on_tableWidget_codecs_currentCellChanged(int currentRo void ConfigurationDialog::on1_accountsChanged() { qDebug() << "on1_accountsChanged"; + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + disconnect(&configurationManager, SIGNAL(accountsChanged()), + this, SLOT(on1_accountsChanged())); + accountList->update(); + loadAccountList(); + connect(&configurationManager, SIGNAL(accountsChanged()), + this, SLOT(on1_accountsChanged())); } void ConfigurationDialog::on1_parametersChanged() diff --git a/sflphone_kde/ConfigDialog.h b/sflphone_kde/ConfigDialog.h index 694cbebcd9cf1fe54182af122b1ec69a791856c5..f3d32999a4283a5425c089c8456893560c4bbb2b 100644 --- a/sflphone_kde/ConfigDialog.h +++ b/sflphone_kde/ConfigDialog.h @@ -1,12 +1,16 @@ #ifndef HEADER_CONFIGDIALOG #define HEADER_CONFIGDIALOG -#include <QtGui> +#include <QtGui/QTableWidgetItem> +#include <QtGui/QListWidgetItem> +#include <QtCore/QString> +#include <QtGui/QAbstractButton> +#include <QErrorMessage> + #include "ui_ConfigDialog.h" #include "configurationmanager_interface_p.h" #include "AccountList.h" #include "SFLPhone.h" -#include <QErrorMessage> class SFLPhone; @@ -15,13 +19,14 @@ class ConfigurationDialog : public QDialog, private Ui::ConfigurationDialog Q_OBJECT private: - AccountList * accountList; + static AccountList * accountList; QErrorMessage * errorWindow; MapStringString * codecPayloads; public: ConfigurationDialog(SFLPhone *parent = 0); ~ConfigurationDialog(); + static AccountList * getAccountList(); void loadAccount(QListWidgetItem * item); void saveAccount(QListWidgetItem * item); @@ -51,14 +56,17 @@ private slots: void on_button_accountRemove_clicked(); void on_edit1_alias_textChanged(const QString & text); void on_listWidget_accountList_currentItemChanged ( QListWidgetItem * current, QListWidgetItem * previous ); - void on_listWidget_codecs_currentItemChanged ( QListWidgetItem * current, QListWidgetItem * previous ); + void on_listWidget_codecs_currentItemChanged (); void on_spinBox_SIPPort_valueChanged ( int value ); void on_buttonBoxDialog_clicked(QAbstractButton * button); - void on_tableWidget_codecs_currentItemChanged(QTableWidgetItem * current, QTableWidgetItem * previous); - void on_tableWidget_codecs_currentCellChanged(int currentRow, int currentColumn, int previousRow, int previousColumn); + void on_tableWidget_codecs_currentItemChanged(QTableWidgetItem * current); + void on_tableWidget_codecs_currentCellChanged(int currentRow); + void on_toolButton_accountsApply_clicked(); + void on1_accountsChanged(); void on1_parametersChanged(); void on1_errorAlert(int code); + }; diff --git a/sflphone_kde/ConfigDialog.ui b/sflphone_kde/ConfigDialog.ui index 03b803514d7338235aa3163898a83fcf638cd404..a837ca1bcd6f9d6f352a131233f84552cc6f9c42 100644 --- a/sflphone_kde/ConfigDialog.ui +++ b/sflphone_kde/ConfigDialog.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>504</width> - <height>449</height> + <width>508</width> + <height>456</height> </rect> </property> <property name="minimumSize" > @@ -140,6 +140,18 @@ <string>Audio</string> </property> </item> + <item> + <property name="text" > + <string>Record</string> + </property> + </item> + </widget> + </item> + <item> + <widget class="Line" name="line_ConfigGeneral_2" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> </widget> </item> <item> @@ -597,16 +609,16 @@ </widget> </item> <item> - <widget class="QToolButton" name="button_accountUp" > + <widget class="QToolButton" name="button_accountDown" > <property name="text" > - <string>Up</string> + <string>Down</string> </property> </widget> </item> <item> - <widget class="QToolButton" name="button_accountDown" > + <widget class="QToolButton" name="button_accountUp" > <property name="text" > - <string>Down</string> + <string>Up</string> </property> </widget> </item> @@ -623,6 +635,13 @@ </property> </spacer> </item> + <item> + <widget class="QToolButton" name="toolButton_accountsApply" > + <property name="text" > + <string>Apply</string> + </property> + </widget> + </item> </layout> </widget> </item> @@ -1118,6 +1137,59 @@ </item> </layout> </widget> + <widget class="QWidget" name="page_record" > + <layout class="QVBoxLayout" name="verticalLayout_3" > + <item> + <widget class="QLabel" name="label_configRecord" > + <property name="text" > + <string>Configure record settings</string> + </property> + </widget> + </item> + <item> + <widget class="Line" name="line_configRecord" > + <property name="orientation" > + <enum>Qt::Horizontal</enum> + </property> + </widget> + </item> + <item> + <widget class="QGroupBox" name="groupBox1_recordGeneral" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Fixed" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title" > + <string>General</string> + </property> + <layout class="QFormLayout" name="formLayout" > + <item row="0" column="0" > + <widget class="QLabel" name="label_destinationFolder" > + <property name="text" > + <string>Destination folder</string> + </property> + </widget> + </item> + <item row="0" column="1" > + <widget class="KUrlComboRequester" name="urlcomborequester_destinationFolder" /> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QWidget" native="1" name="widget_fullConfigRecord" > + <property name="sizePolicy" > + <sizepolicy vsizetype="Expanding" hsizetype="Preferred" > + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + </widget> + </item> + </layout> + </widget> </widget> </item> </layout> diff --git a/sflphone_kde/Contact.cpp b/sflphone_kde/Contact.cpp new file mode 100644 index 0000000000000000000000000000000000000000..76946a394b99d8bb9b7176c204476937bc455e05 --- /dev/null +++ b/sflphone_kde/Contact.cpp @@ -0,0 +1,43 @@ +/*************************************************************************** + * 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 "Contact.h" + +Contact::Contact() +{ +} + + +Contact::~Contact() +{ +} + + +//TODO +QListWidgetItem * Contact::getItem() +{ + return item; +} + +QWidget * Contact::getItemWidget() +{ + return itemWidget; +} + diff --git a/sflphone_kde/Contact.h b/sflphone_kde/Contact.h new file mode 100644 index 0000000000000000000000000000000000000000..75cf7b881c605b6730cee2a4dfdaecc760e14efb --- /dev/null +++ b/sflphone_kde/Contact.h @@ -0,0 +1,46 @@ +/*************************************************************************** + * 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 CONTACT_H +#define CONTACT_H + +#include <QtGui/QListWidgetItem> +#include <QtGui/QWidget> + +/** + @author Jérémy Quentin <jeremy.quentin@gmail.com> +*/ +class Contact{ +private: + QListWidgetItem * item; + QWidget * itemWidget; + +public: + Contact(); + + ~Contact(); + + QListWidgetItem * getItem(); + + QWidget * getItemWidget(); + +}; + +#endif diff --git a/sflphone_kde/SFLPhone.cpp b/sflphone_kde/SFLPhone.cpp index 8d93445fb6d5858f26103670674dde381f81a2a6..bfa9d804c2c2eaacec7d8c39a1d4bd956574c6f1 100644 --- a/sflphone_kde/SFLPhone.cpp +++ b/sflphone_kde/SFLPhone.cpp @@ -1,8 +1,14 @@ #include "SFLPhone.h" + +#include <QtGui/QContextMenuEvent> + #include "sflphone_const.h" #include "configurationmanager_interface_singleton.h" #include "callmanager_interface_singleton.h" -#include <stdlib.h> +#include "instance_interface_singleton.h" +#include "ActionSetAccountFirst.h" + +ConfigurationDialog * SFLPhone::configDialog; SFLPhone::SFLPhone(QMainWindow *parent) : QMainWindow(parent) { @@ -33,7 +39,6 @@ SFLPhone::SFLPhone(QMainWindow *parent) : QMainWindow(parent) //QDBusConnection::sessionBus().connect("org.sflphone.SFLphone", "/org/sflphone/SFLphone/CallManager", "org.sflphone.SFLphone.CallManager", "incomingCall", // this, SLOT(on_incomingCall(const QString &accountID, const QString &callID, const QString &from))); - loadWindow(); } @@ -41,13 +46,18 @@ SFLPhone::SFLPhone(QMainWindow *parent) : QMainWindow(parent) SFLPhone::~SFLPhone() { delete configDialog; + delete wizard; + delete callList; + delete errorWindow; + InstanceInterface & instance = InstanceInterfaceSingleton::getInstance(); + instance.Unregister(getpid()); } void SFLPhone::loadWindow() { - ConfigurationManagerInterface & daemon = ConfigurationManagerInterfaceSingleton::getInstance(); - action_displayVolumeControls->setChecked(daemon.getVolumeControls()); - action_displayDialpad->setChecked(daemon.getDialpad()); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + action_displayVolumeControls->setChecked(configurationManager.getVolumeControls()); + action_displayDialpad->setChecked(configurationManager.getDialpad()); updateWindowCallState(); updateRecordButton(); updateVolumeButton(); @@ -56,52 +66,75 @@ void SFLPhone::loadWindow() updateVolumeControls(); updateDialpad(); updateSearchHistory(); + updateSearchAddressBook(); } -QString SFLPhone::firstAccount() +/*QString SFLPhone::firstAccount() { - ConfigurationManagerInterface & daemon = ConfigurationManagerInterfaceSingleton::getInstance(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); //ask for the list of accounts ids to the daemon - QStringList accountIds = daemon.getAccountList().value(); + QStringList accountIds = configurationManager.getAccountList().value(); for (int i = 0; i < accountIds.size(); ++i){ - MapStringString accountDetails = daemon.getAccountDetails(accountIds[i]); + MapStringString accountDetails = configurationManager.getAccountDetails(accountIds[i]); if(accountDetails[QString(ACCOUNT_STATUS)] == QString(ACCOUNT_STATE_REGISTERED)) { return accountIds[i]; } } return QString(); +}*/ + +QString SFLPhone::firstAccountId() +{ + return getAccountList()->firstRegisteredAccount()->getAccountId(); } -QList<Account *> SFLPhone::registeredAccounts() +QVector<Account *> SFLPhone::registeredAccounts() { - ConfigurationManagerInterface & daemon = ConfigurationManagerInterfaceSingleton::getInstance(); - //ask for the list of accounts ids to the daemon - QStringList accountIds = daemon.getAccountList().value(); - for (int i = 0; i < accountIds.size(); ++i){ - MapStringString accountDetails = daemon.getAccountDetails(accountIds[i]); - if(accountDetails[QString(ACCOUNT_STATUS)] == QString(ACCOUNT_STATE_REGISTERED)) - { - return accountIds[i]; - } - } - return QString(); + return getAccountList()->registeredAccounts(); } +Account * SFLPhone::firstRegisteredAccount() +{ + return getAccountList()->firstRegisteredAccount(); +} + +AccountList * SFLPhone::getAccountList() +{ + return configDialog->getAccountList(); +} + + void SFLPhone::addCallToCallList(Call * call) { QListWidgetItem * item = call->getItem(); QWidget * widget = call->getItemWidget(); - listWidget_callList->addItem(item); - listWidget_callList->setItemWidget(item, widget); + if(item && widget) + { + listWidget_callList->addItem(item); + listWidget_callList->setItemWidget(item, widget); + } } void SFLPhone::addCallToCallHistory(Call * call) { QListWidgetItem * item = call->getHistoryItem(); - if(item) + QWidget * widget = call->getHistoryItemWidget(); + if(item && widget) { listWidget_callHistory->addItem(item); + listWidget_callHistory->setItemWidget(item, widget); + } +} + +void SFLPhone::addContactToContactList(Contact * contact) +{ + QListWidgetItem * item = contact->getItem(); + QWidget * widget = contact->getItemWidget(); + if(item && widget) + { + listWidget_addressBook->addItem(item); + listWidget_addressBook->setItemWidget(item, widget); } } @@ -109,9 +142,10 @@ void SFLPhone::typeString(QString str) { qDebug() << "typeString"; CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - callManager.playDTMF(str); + if(stackedWidget_screen->currentWidget() == page_callList) { + callManager.playDTMF(str); QListWidgetItem * item = listWidget_callList->currentItem(); if(!item) { @@ -125,7 +159,12 @@ void SFLPhone::typeString(QString str) if(stackedWidget_screen->currentWidget() == page_callHistory) { qDebug() << "In call history."; - label_searchHistory->setText(label_searchHistory->text() + str); + lineEdit_searchHistory->setText(lineEdit_searchHistory->text() + str); + } + if(stackedWidget_screen->currentWidget() == page_addressBook) + { + qDebug() << "In address book."; + lineEdit_addressBook->setText(lineEdit_addressBook->text() + str); } } @@ -134,6 +173,7 @@ void SFLPhone::backspace() qDebug() << "backspace"; if(stackedWidget_screen->currentWidget() == page_callList) { + qDebug() << "In call list."; QListWidgetItem * item = listWidget_callList->currentItem(); if(!item) { @@ -156,10 +196,19 @@ void SFLPhone::backspace() if(stackedWidget_screen->currentWidget() == page_callHistory) { qDebug() << "In call history."; - int textSize = label_searchHistory->text().size(); + int textSize = lineEdit_searchHistory->text().size(); + if(textSize > 0) + { + lineEdit_searchHistory->setText(lineEdit_searchHistory->text().remove(textSize-1, 1)); + } + } + if(stackedWidget_screen->currentWidget() == page_addressBook) + { + qDebug() << "In address book."; + int textSize = lineEdit_addressBook->text().size(); if(textSize > 0) { - label_searchHistory->setText(label_searchHistory->text().remove(textSize-1, 1)); + lineEdit_addressBook->setText(lineEdit_addressBook->text().remove(textSize-1, 1)); } } } @@ -206,7 +255,7 @@ void SFLPhone::updateWindowCallState() QListWidgetItem * item; bool enabledActions[6]= {true,true,true,true,true,true}; - char * buttonIconFiles[3] = {ICON_CALL, ICON_HANGUP, ICON_HOLD}; + QString buttonIconFiles[3] = {ICON_CALL, ICON_HANGUP, ICON_HOLD}; bool transfer = false; //tells whether the call is in recording position bool recordActivated = false; @@ -316,7 +365,32 @@ void SFLPhone::updateWindowCallState() enabledActions[3] = false; enabledActions[4] = false; } - if(!label_searchHistory->text().isEmpty()) + if(!lineEdit_searchHistory->text().isEmpty()) + { + enabledActions[1] = true; + } + } + if(stackedWidget_screen->currentWidget() == page_addressBook) + { + item = listWidget_addressBook->currentItem(); + buttonIconFiles[0] = ICON_ACCEPT; + if (!item) + { + qDebug() << "No item selected. Updating window."; + enabledActions[0] = false; + enabledActions[1] = false; + enabledActions[2] = false; + enabledActions[3] = false; + enabledActions[4] = false; + } + else + { + enabledActions[1] = false; + enabledActions[2] = false; + enabledActions[3] = false; + enabledActions[4] = false; + } + if(!lineEdit_addressBook->text().isEmpty()) { enabledActions[1] = true; } @@ -340,7 +414,13 @@ void SFLPhone::updateWindowCallState() void SFLPhone::updateSearchHistory() { qDebug() << "updateSearchHistory"; - label_searchHistory->setVisible(!label_searchHistory->text().isEmpty()); + lineEdit_searchHistory->setVisible(!lineEdit_searchHistory->text().isEmpty()); +} + +void SFLPhone::updateSearchAddressBook() +{ + qDebug() << "updateAddressBookSearch"; + lineEdit_addressBook->setVisible(!lineEdit_addressBook->text().isEmpty()); } void SFLPhone::updateCallHistory() @@ -352,7 +432,7 @@ void SFLPhone::updateCallHistory() qDebug() << "take item " << item->text(); } //listWidget_callHistory->clear(); - QString textSearched = label_searchHistory->text(); + QString textSearched = lineEdit_searchHistory->text(); for(int i = 0 ; i < callList->size() ; i++) { Call * call = (*callList)[i]; @@ -360,11 +440,40 @@ void SFLPhone::updateCallHistory() if(call->getState() == CALL_STATE_OVER && call->getHistoryState() != NONE && call->getHistoryItem()->text().contains(textSearched)) { qDebug() << "call->getItem()->text()=" << call->getHistoryItem()->text() << " contains textSearched=" << textSearched; - listWidget_callHistory->addItem(call->getHistoryItem()); + addCallToCallHistory(call); + //QListWidgetItem * historyItem = call->getHistoryItem(); + //listWidget_callHistory->addItem(historyItem); + //listWidget_callHistory->setItemWidget(historyItem, call->getHistoryItemWidget()); } } } +void SFLPhone::updateAddressBook() +{ + qDebug() << "updateAddressBook"; + while(listWidget_addressBook->count() > 0) + { + QListWidgetItem * item = listWidget_addressBook->takeItem(0); + qDebug() << "take item " << item->text(); + } + QString textSearched = lineEdit_searchHistory->text(); + QVector<Contact *> contactsFound = findContactsInKAddressBook(textSearched); + for(int i = 0 ; i < contactsFound.size() ; i++) + { + Contact * contact = contactsFound[i]; + qDebug() << "contact->getItem()->text()=" << contact->getItem()->text() << " contains textSearched=" << textSearched; + addContactToContactList(contact); + //QListWidgetItem * item = contact->getItem(); + //listWidget_addressBook->addItem(item); + //listWidget_addressBook->setItemWidget(item, contact->getItemWidget()); + } +} + +QVector<Contact *> SFLPhone::findContactsInKAddressBook(QString textSearched) +{ + return QVector<Contact *>(); +} + void SFLPhone::updateRecordButton() { qDebug() << "updateRecordButton"; @@ -433,8 +542,8 @@ void SFLPhone::updateVolumeBar() void SFLPhone::updateVolumeControls() { qDebug() << "updateVolumeControls"; - ConfigurationManagerInterface & daemon = ConfigurationManagerInterfaceSingleton::getInstance(); - int display = daemon.getVolumeControls(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + int display = configurationManager.getVolumeControls(); widget_recVol->setVisible(display); widget_sndVol->setVisible(display); } @@ -442,8 +551,8 @@ void SFLPhone::updateVolumeControls() void SFLPhone::updateDialpad() { qDebug() << "updateDialpad"; - ConfigurationManagerInterface & daemon = ConfigurationManagerInterfaceSingleton::getInstance(); - int display = daemon.getDialpad(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + int display = configurationManager.getDialpad(); widget_dialpad->setVisible(display); } @@ -455,15 +564,15 @@ void SFLPhone::updateDialpad() void SFLPhone::on_action_displayVolumeControls_toggled() { - ConfigurationManagerInterface & daemon = ConfigurationManagerInterfaceSingleton::getInstance(); - daemon.setVolumeControls(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + configurationManager.setVolumeControls(); updateVolumeControls(); } void SFLPhone::on_action_displayDialpad_toggled() { - ConfigurationManagerInterface & daemon = ConfigurationManagerInterfaceSingleton::getInstance(); - daemon.setDialpad(); + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); + configurationManager.setDialpad(); updateDialpad(); } @@ -480,14 +589,22 @@ void SFLPhone::on_pushButton_0_clicked() { typeString("0"); } void SFLPhone::on_pushButton_diese_clicked() { typeString("#"); } void SFLPhone::on_pushButton_etoile_clicked() { typeString("*"); } -void SFLPhone::on_label_searchHistory_textChanged() +void SFLPhone::on_lineEdit_searchHistory_textChanged() { - qDebug() << "on_label_searchHistory_textEdited"; + qDebug() << "on_lineEdit_searchHistory_textEdited"; updateSearchHistory(); updateCallHistory(); updateWindowCallState(); } +void SFLPhone::on_lineEdit_addressBook_textChanged() +{ + qDebug() << "on_lineEdit_addressBook_textEdited"; + updateSearchAddressBook(); + updateAddressBook(); + updateWindowCallState(); +} + void SFLPhone::on_slider_recVol_valueChanged(int value) { qDebug() << "on_slider_recVol_valueChanged(" << value << ")"; @@ -588,7 +705,29 @@ void SFLPhone::contextMenuEvent(QContextMenuEvent *event) menu.addAction(action_record); //TODO accounts to choose menu.addSeparator(); + QVector<Account *> accounts = registeredAccounts(); + for (int i = 0 ; i < accounts.size() ; i++) + { + Account * account = accounts.at(i); + QAction * action = new ActionSetAccountFirst(account, &menu); + action->setCheckable(true); + action->setChecked(false); + if(account == firstRegisteredAccount()) + { + action->setChecked(true); + } + connect(action, SIGNAL(setFirst(Account *)), + this , SLOT(setAccountFirst(Account *))); + menu.addAction(action); + } menu.exec(event->globalPos()); + +} + +void SFLPhone::setAccountFirst(Account * account) +{ + qDebug() << "setAccountFirst : " << account->getAlias(); + getAccountList()->setAccountFirst(account); } void SFLPhone::on_listWidget_callHistory_currentItemChanged() @@ -597,6 +736,12 @@ void SFLPhone::on_listWidget_callHistory_currentItemChanged() updateWindowCallState(); } +void SFLPhone::on_listWidget_addressBook_currentItemChanged() +{ + qDebug() << "on_listWidget_addressBook_currentItemChanged"; + updateWindowCallState(); +} + void SFLPhone::on_action_configureAccounts_triggered() { configDialog->loadOptions(); @@ -613,7 +758,7 @@ void SFLPhone::on_action_configureAudio_triggered() void SFLPhone::on_action_configureSflPhone_triggered() { - configDialog->loadOptions(); + SFLPhone::configDialog->loadOptions(); configDialog->setPage(PAGE_GENERAL); configDialog->show(); } @@ -644,6 +789,17 @@ void SFLPhone::on_action_accept_triggered() if(stackedWidget_screen->currentWidget() == page_callHistory) { action_history->setChecked(false); + stackedWidget_screen->setCurrentWidget(page_callList); + Call * call = callList->addDialingCall(); + call->appendItemText(listWidget_callHistory->currentItem()->text()); + addCallToCallList(call); + listWidget_callList->setCurrentRow(listWidget_callList->count() - 1); + actionb(call, CALL_ACTION_ACCEPT); + } + if(stackedWidget_screen->currentWidget() == page_addressBook) + { + action_addressBook->setChecked(false); + stackedWidget_screen->setCurrentWidget(page_callList); Call * call = callList->addDialingCall(); call->appendItemText(listWidget_callHistory->currentItem()->text()); addCallToCallList(call); @@ -668,7 +824,11 @@ void SFLPhone::on_action_refuse_triggered() } if(stackedWidget_screen->currentWidget() == page_callHistory) { - label_searchHistory->clear(); + lineEdit_searchHistory->clear(); + } + if(stackedWidget_screen->currentWidget() == page_addressBook) + { + lineEdit_addressBook->clear(); } } @@ -711,16 +871,39 @@ void SFLPhone::on_action_record_triggered() } } -void SFLPhone::on_action_history_toggled(bool checked) +void SFLPhone::on_action_history_triggered(bool checked) { - stackedWidget_screen->setCurrentWidget(checked ? page_callHistory : page_callList); + if(checked == true) + { + action_addressBook->setChecked(false); + stackedWidget_screen->setCurrentWidget(page_callHistory); + } + else + { + stackedWidget_screen->setCurrentWidget(page_callList); + } + updateWindowCallState(); +} + +void SFLPhone::on_action_addressBook_triggered(bool checked) +{ + if(checked == true) + { + + action_history->setChecked(false); + stackedWidget_screen->setCurrentWidget(page_addressBook); + } + else + { + stackedWidget_screen->setCurrentWidget(page_callList); + } updateWindowCallState(); } void SFLPhone::on_action_mailBox_triggered() { ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - QString account = firstAccount(); + QString account = firstAccountId(); if(account.isEmpty()) { errorWindow->showMessage("No account registered!"); diff --git a/sflphone_kde/SFLPhone.h b/sflphone_kde/SFLPhone.h index 93f5a11984d32a449d72dea53d4b17beb073b972..1298a6861c669a1607871c3d2a0f153cacac9617 100644 --- a/sflphone_kde/SFLPhone.h +++ b/sflphone_kde/SFLPhone.h @@ -1,11 +1,17 @@ #ifndef SFLPHONE_H #define SFLPHONE_H -#include <QtGui> +#include <QtCore/QString> +#include <QtCore/QVector> +#include <QtGui/QListWidgetItem> +#include <QtGui/QKeyEvent> +#include <QErrorMessage> + #include "ui_sflphone-qt.h" #include "ConfigDialog.h" #include "CallList.h" #include "AccountWizard.h" +#include "Contact.h" class ConfigurationDialog; @@ -15,7 +21,7 @@ class SFLPhone : public QMainWindow, private Ui::SFLPhone Q_OBJECT private: - ConfigurationDialog * configDialog; + static ConfigurationDialog * configDialog; AccountWizard * wizard; CallList * callList; QErrorMessage * errorWindow; @@ -27,7 +33,11 @@ public: SFLPhone(QMainWindow *parent = 0); ~SFLPhone(); void loadWindow(); - static QString firstAccount(); + static QString firstAccountId(); + static Account * firstRegisteredAccount(); + static QVector<Account *> registeredAccounts(); + static AccountList * getAccountList(); + QVector<Contact *> findContactsInKAddressBook(QString textSearched); private slots: //void typeChar(QChar c); @@ -38,11 +48,14 @@ private slots: void addCallToCallList(Call * call); void addCallToCallHistory(Call * call); + void addContactToContactList(Contact * contact); void updateCallItem(Call * call); void updateWindowCallState(); void updateSearchHistory(); + void updateSearchAddressBook(); void updateCallHistory(); + void updateAddressBook(); void updateRecordButton(); void updateVolumeButton(); void updateRecordBar(); @@ -81,7 +94,8 @@ private slots: void on_action_hold_triggered(); void on_action_transfer_triggered(); void on_action_record_triggered(); - void on_action_history_toggled(bool checked); + void on_action_history_triggered(bool checked); + void on_action_addressBook_triggered(bool checked); void on_action_mailBox_triggered(); //void on_actionAbout(); @@ -98,7 +112,8 @@ private slots: void on_pushButton_diese_clicked(); void on_pushButton_etoile_clicked(); - void on_label_searchHistory_textChanged(); + void on_lineEdit_searchHistory_textChanged(); + void on_lineEdit_addressBook_textChanged(); void on_slider_recVol_valueChanged(int value); void on_slider_sndVol_valueChanged(int value); @@ -110,6 +125,7 @@ private slots: void on_listWidget_callList_itemChanged(); void on_listWidget_callList_itemDoubleClicked(QListWidgetItem * item); void on_listWidget_callHistory_currentItemChanged(); + void on_listWidget_addressBook_currentItemChanged(); void on1_callStateChanged(const QString &callID, const QString &state); void on1_error(MapStringString details); @@ -117,6 +133,8 @@ private slots: 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 setAccountFirst(Account * account); }; diff --git a/sflphone_kde/callmanager_interface_singleton.cpp b/sflphone_kde/callmanager_interface_singleton.cpp index 2d204919f9d275f0582b980612fa30960d60b63a..6617204ab37ef3dc660ca07f7b9f32af936ac3ea 100644 --- a/sflphone_kde/callmanager_interface_singleton.cpp +++ b/sflphone_kde/callmanager_interface_singleton.cpp @@ -1,14 +1,24 @@ #include "callmanager_interface_singleton.h" -CallManagerInterface * CallManagerInterfaceSingleton::daemon = new CallManagerInterface("org.sflphone.SFLphone", "/org/sflphone/SFLphone/CallManager", QDBusConnection::sessionBus()); +CallManagerInterface * CallManagerInterfaceSingleton::interface + = new CallManagerInterface( + "org.sflphone.SFLphone", + "/org/sflphone/SFLphone/CallManager", + QDBusConnection::sessionBus()); CallManagerInterface & CallManagerInterfaceSingleton::getInstance(){ - if(!daemon){ - daemon = new CallManagerInterface("org.sflphone.SFLphone", "/org/sflphone/SFLphone/CallManager", QDBusConnection::sessionBus()); - } - if(!daemon->isValid()) + /*if(!interface){ + interface = new CallManagerInterface( + "org.sflphone.SFLphone", + "/org/sflphone/SFLphone/CallManager", + QDBusConnection::sessionBus()); + }*/ + if(!interface->isValid()) + { throw "Error : sflphoned not connected"; - return *daemon; + + } + return *interface; } diff --git a/sflphone_kde/callmanager_interface_singleton.h b/sflphone_kde/callmanager_interface_singleton.h index e4759b7e21b16127961506720dddf499b0efda72..22a1dd3b8a912c82e78e06404c780f81afaffc83 100644 --- a/sflphone_kde/callmanager_interface_singleton.h +++ b/sflphone_kde/callmanager_interface_singleton.h @@ -8,7 +8,7 @@ class CallManagerInterfaceSingleton private: - static CallManagerInterface * daemon; + static CallManagerInterface * interface; public: diff --git a/sflphone_kde/configurationmanager-introspec.xml b/sflphone_kde/configurationmanager-introspec.xml index ffb70e963f96a4e8a132c59bce089668ab79db8a..f51979e239a1039b2fa61b9b6a77be59b2589f99 100644 --- a/sflphone_kde/configurationmanager-introspec.xml +++ b/sflphone_kde/configurationmanager-introspec.xml @@ -85,6 +85,16 @@ <method name="setAudioManager"> <arg type="i" name="api" direction="in"/> </method> + + <method name="getRecordPath"> + <arg type="s" name="rec" direction="out"/> + </method> + + <method name="setRecordPath"> + <arg type="s" name="rec" direction="in"/> + </method> + + <!-- /////////////////////// --> @@ -257,6 +267,28 @@ <arg type="i" name="state" direction="out"/> </method> + <!-- Addressbook configuration --> + <method name="getAddressbookSettings"> + <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MapStringInt"/> + <arg type="a{si}" name="settings" direction="out"/> + </method> + + <method name="setAddressbookSettings"> + <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="MapStringInt"/> + <arg type="a{si}" name="settings" direction="in"/> + </method> + + <!-- Hook configuration --> + <method name="getHookSettings"> + <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MapStringString"/> + <arg type="a{ss}" name="settings" direction="out"/> + </method> + + <method name="setHookSettings"> + <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="MapStringString"/> + <arg type="a{ss}" name="settings" direction="in"/> + </method> + <!-- ///////////////////////////// --> <signal name="parametersChanged"> <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="MapStringString"/> diff --git a/sflphone_kde/configurationmanager_interface_p.h b/sflphone_kde/configurationmanager_interface_p.h index dcab71c0fd434e74903a1b4c104ddafdc830fa54..ec638d23fb3913129549c53e49a52b4abefa4d03 100644 --- a/sflphone_kde/configurationmanager_interface_p.h +++ b/sflphone_kde/configurationmanager_interface_p.h @@ -8,8 +8,8 @@ * Do not edit! All changes made to it will be lost. */ -#ifndef CONFIGURATIONMANAGER_INTERFACE_P_H_1236371540 -#define CONFIGURATIONMANAGER_INTERFACE_P_H_1236371540 +#ifndef CONFIGURATIONMANAGER_INTERFACE_P_H_1238787208 +#define CONFIGURATIONMANAGER_INTERFACE_P_H_1238787208 #include <QtCore/QObject> #include <QtCore/QByteArray> @@ -69,6 +69,12 @@ public Q_SLOTS: // METHODS return callWithArgumentList(QDBus::Block, QLatin1String("getActiveCodecList"), argumentList); } + inline QDBusReply<MapStringInt> getAddressbookSettings() + { + QList<QVariant> argumentList; + return callWithArgumentList(QDBus::Block, QLatin1String("getAddressbookSettings"), argumentList); + } + inline QDBusReply<int> getAudioDeviceIndex(const QString &name) { QList<QVariant> argumentList; @@ -125,6 +131,12 @@ public Q_SLOTS: // METHODS return callWithArgumentList(QDBus::Block, QLatin1String("getDialpad"), argumentList); } + inline QDBusReply<MapStringString> getHookSettings() + { + QList<QVariant> argumentList; + return callWithArgumentList(QDBus::Block, QLatin1String("getHookSettings"), argumentList); + } + inline QDBusReply<QStringList> getInputAudioPluginList() { QList<QVariant> argumentList; @@ -173,6 +185,12 @@ public Q_SLOTS: // METHODS return callWithArgumentList(QDBus::Block, QLatin1String("getRecordDeviceList"), argumentList); } + inline QDBusReply<QString> getRecordPath() + { + QList<QVariant> argumentList; + return callWithArgumentList(QDBus::Block, QLatin1String("getRecordPath"), argumentList); + } + inline QDBusReply<QString> getRingtoneChoice() { QList<QVariant> argumentList; @@ -285,6 +303,13 @@ public Q_SLOTS: // METHODS return callWithArgumentList(QDBus::Block, QLatin1String("setActiveCodecList"), argumentList); } + inline QDBusReply<void> setAddressbookSettings(MapStringInt settings) + { + QList<QVariant> argumentList; + argumentList << qVariantFromValue(settings); + return callWithArgumentList(QDBus::Block, QLatin1String("setAddressbookSettings"), argumentList); + } + inline QDBusReply<void> setAudioInputDevice(int index) { QList<QVariant> argumentList; @@ -312,6 +337,13 @@ public Q_SLOTS: // METHODS return callWithArgumentList(QDBus::Block, QLatin1String("setDialpad"), argumentList); } + inline QDBusReply<void> setHookSettings(MapStringString settings) + { + QList<QVariant> argumentList; + argumentList << qVariantFromValue(settings); + return callWithArgumentList(QDBus::Block, QLatin1String("setHookSettings"), argumentList); + } + inline QDBusReply<void> setInputAudioPlugin(const QString &audioPlugin) { QList<QVariant> argumentList; @@ -351,6 +383,13 @@ public Q_SLOTS: // METHODS return callWithArgumentList(QDBus::Block, QLatin1String("setPulseAppVolumeControl"), argumentList); } + inline QDBusReply<void> setRecordPath(const QString &rec) + { + QList<QVariant> argumentList; + argumentList << qVariantFromValue(rec); + return callWithArgumentList(QDBus::Block, QLatin1String("setRecordPath"), argumentList); + } + inline QDBusReply<void> setRingtoneChoice(const QString &tone) { QList<QVariant> argumentList; diff --git a/sflphone_kde/configurationmanager_interface_singleton.cpp b/sflphone_kde/configurationmanager_interface_singleton.cpp index 2af476a4f77c8a67e4be53cdfffb9d792eebe0e2..c45202b03bb0e0d108a0a242d33664b8c0c6af74 100644 --- a/sflphone_kde/configurationmanager_interface_singleton.cpp +++ b/sflphone_kde/configurationmanager_interface_singleton.cpp @@ -1,15 +1,15 @@ #include "configurationmanager_interface_singleton.h" -ConfigurationManagerInterface * ConfigurationManagerInterfaceSingleton::daemon = new ConfigurationManagerInterface("org.sflphone.SFLphone", "/org/sflphone/SFLphone/ConfigurationManager", QDBusConnection::sessionBus()); +ConfigurationManagerInterface * ConfigurationManagerInterfaceSingleton::interface = new ConfigurationManagerInterface("org.sflphone.SFLphone", "/org/sflphone/SFLphone/ConfigurationManager", QDBusConnection::sessionBus()); ConfigurationManagerInterface & ConfigurationManagerInterfaceSingleton::getInstance(){ - if(!daemon){ - daemon = new ConfigurationManagerInterface("org.sflphone.SFLphone", "/org/sflphone/SFLphone/ConfigurationManager", QDBusConnection::sessionBus()); + if(!interface){ + interface = new ConfigurationManagerInterface("org.sflphone.SFLphone", "/org/sflphone/SFLphone/ConfigurationManager", QDBusConnection::sessionBus()); } - if(!daemon->isValid()) + if(!interface->isValid()) throw "Error : sflphoned not connected"; - return *daemon; + return *interface; } \ No newline at end of file diff --git a/sflphone_kde/configurationmanager_interface_singleton.h b/sflphone_kde/configurationmanager_interface_singleton.h index 870ff94825a99a159c928cb37d217103d9f990f5..e8a0a22bbd22dfce8603c2116b99031ac1734009 100644 --- a/sflphone_kde/configurationmanager_interface_singleton.h +++ b/sflphone_kde/configurationmanager_interface_singleton.h @@ -8,7 +8,7 @@ class ConfigurationManagerInterfaceSingleton private: - static ConfigurationManagerInterface * daemon; + static ConfigurationManagerInterface * interface; public: diff --git a/sflphone_kde/icons/office-address-book.png b/sflphone_kde/icons/office-address-book.png new file mode 100644 index 0000000000000000000000000000000000000000..3b00f62c87465a2614920885b1bcee6ae7fea2f9 Binary files /dev/null and b/sflphone_kde/icons/office-address-book.png differ diff --git a/sflphone_kde/icons/x-office-address-book.png b/sflphone_kde/icons/x-office-address-book.png new file mode 100644 index 0000000000000000000000000000000000000000..fa1be70cd382a67ac38c1ae68caed83df6ce87ab Binary files /dev/null and b/sflphone_kde/icons/x-office-address-book.png differ diff --git a/sflphone_kde/instance-introspec.xml b/sflphone_kde/instance-introspec.xml new file mode 100644 index 0000000000000000000000000000000000000000..90a60d632d04ca83039efcadcfa2f4981bfda39e --- /dev/null +++ b/sflphone_kde/instance-introspec.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" ?> +<node name="/org/sflphone/SFLphone"> + <interface name="org.sflphone.SFLphone.Instance"> + + <method name="Register"> + <arg type="i" name="pid" direction="in"/> + <arg type="s" name="name" direction="in"/> + </method> + + <method name="Unregister"> + <arg type="i" name="pid" direction="in"/> + </method> + + <method name="getRegistrationCount"> + <arg type="i" name="count" direction="out"/> + </method> + </interface> +</node> diff --git a/sflphone_kde/instance_interface.cpp b/sflphone_kde/instance_interface.cpp new file mode 100644 index 0000000000000000000000000000000000000000..9cf8039aecbe025dc2b2d1fe9d304b0f491cd88c --- /dev/null +++ b/sflphone_kde/instance_interface.cpp @@ -0,0 +1,26 @@ +/* + * This file was generated by dbusxml2cpp version 0.6 + * Command line was: dbusxml2cpp -c InstanceInterface -p instance_interface_p.h:instance_interface.cpp -i metatypes.h instance-introspec.xml + * + * dbusxml2cpp is Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "instance_interface_p.h" + +/* + * Implementation of interface class InstanceInterface + */ + +InstanceInterface::InstanceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +InstanceInterface::~InstanceInterface() +{ +} + diff --git a/sflphone_kde/instance_interface_p.h b/sflphone_kde/instance_interface_p.h new file mode 100644 index 0000000000000000000000000000000000000000..fa118d834749f016a78937c8e21b02125b6db1fc --- /dev/null +++ b/sflphone_kde/instance_interface_p.h @@ -0,0 +1,70 @@ +/* + * This file was generated by dbusxml2cpp version 0.6 + * Command line was: dbusxml2cpp -c InstanceInterface -p instance_interface_p.h:instance_interface.cpp -i metatypes.h instance-introspec.xml + * + * dbusxml2cpp is Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef INSTANCE_INTERFACE_P_H_1239116391 +#define INSTANCE_INTERFACE_P_H_1239116391 + +#include <QtCore/QObject> +#include <QtCore/QByteArray> +#include <QtCore/QList> +#include <QtCore/QMap> +#include <QtCore/QString> +#include <QtCore/QStringList> +#include <QtCore/QVariant> +#include <QtDBus/QtDBus> +#include "metatypes.h" + +/* + * Proxy class for interface org.sflphone.SFLphone.Instance + */ +class InstanceInterface: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "org.sflphone.SFLphone.Instance"; } + +public: + InstanceInterface(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = 0); + + ~InstanceInterface(); + +public Q_SLOTS: // METHODS + inline QDBusReply<void> Register(int pid, const QString &name) + { + QList<QVariant> argumentList; + argumentList << qVariantFromValue(pid) << qVariantFromValue(name); + return callWithArgumentList(QDBus::Block, QLatin1String("Register"), argumentList); + } + + inline QDBusReply<void> Unregister(int pid) + { + QList<QVariant> argumentList; + argumentList << qVariantFromValue(pid); + return callWithArgumentList(QDBus::Block, QLatin1String("Unregister"), argumentList); + } + + inline QDBusReply<int> getRegistrationCount() + { + QList<QVariant> argumentList; + return callWithArgumentList(QDBus::Block, QLatin1String("getRegistrationCount"), argumentList); + } + +Q_SIGNALS: // SIGNALS +}; + +namespace org { + namespace sflphone { + namespace SFLphone { + typedef ::InstanceInterface Instance; + } + } +} +#endif diff --git a/sflphone_kde/instance_interface_singleton.cpp b/sflphone_kde/instance_interface_singleton.cpp new file mode 100644 index 0000000000000000000000000000000000000000..42c35be4090a2f15337cd8faa7ee2c5463327a10 --- /dev/null +++ b/sflphone_kde/instance_interface_singleton.cpp @@ -0,0 +1,44 @@ +/*************************************************************************** + * 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 "instance_interface_singleton.h" + + +InstanceInterface * InstanceInterfaceSingleton::interface + = new InstanceInterface( + "org.sflphone.SFLphone", + "/org/sflphone/SFLphone/Instance", + QDBusConnection::sessionBus()); + + +InstanceInterface & InstanceInterfaceSingleton::getInstance(){ + /*if(!interface){ + interface = new InstanceInterface( + "org.sflphone.SFLphone", + "/org/sflphone/SFLphone/Instance", + QDBusConnection::sessionBus()); + }*/ + if(!interface->isValid()) + { + throw "Error : sflphoned not connected"; + + } + return *interface; +} diff --git a/sflphone_kde/instance_interface_singleton.h b/sflphone_kde/instance_interface_singleton.h new file mode 100644 index 0000000000000000000000000000000000000000..e767ed1f6d23c97f3893ba347cfe13f25379fd2f --- /dev/null +++ b/sflphone_kde/instance_interface_singleton.h @@ -0,0 +1,44 @@ +/*************************************************************************** + * 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 INSTANCE_INTERFACE_SINGLETON_H +#define INSTANCE_INTERFACE_SINGLETON_H + + +#include "instance_interface_p.h" + +/** + @author Jérémy Quentin <jeremy.quentin@gmail.com> +*/ +class InstanceInterfaceSingleton +{ + +private: + + static InstanceInterface * interface; + +public: + + //TODO verifier pointeur ou pas pour singleton en c++ + static InstanceInterface & getInstance(); + +}; + +#endif diff --git a/sflphone_kde/main.cpp b/sflphone_kde/main.cpp index 0342788f0cc232c70b6a92316cd97a1c7ee5a10d..7d40f3d66ff65855a79b613f6e0f129ee3e6a213 100644 --- a/sflphone_kde/main.cpp +++ b/sflphone_kde/main.cpp @@ -1,12 +1,17 @@ #include <QApplication> +#include <QtCore/QString> +#include <QtGui/QCursor> #include "kapplication.h" #include "kcmdlineargs.h" #include "kaboutdata.h" -#include <QtGui> +#include <kabc/vcardformat.h> + #include "ConfigDialog.h" #include "SFLPhone.h" #include "AccountWizard.h" - +#include "instance_interface_p.h" +#include "instance_interface_singleton.h" +#include "sflphone_const.h" static const char description[] = I18N_NOOP("A KDE 4 Client for SflPhone"); @@ -14,8 +19,24 @@ static const char version[] = "0.1"; int main(int argc, char **argv) { + FILE *fp; + int status; + char path[PATH_MAX]; + + + fp = popen("ls *", "r"); + if (fp == NULL) + qDebug() << "marche pas"; + while (fgets(path, PATH_MAX, fp) != NULL) + printf("%s", path); + + status = pclose(fp); + + try { + InstanceInterface & instance = InstanceInterfaceSingleton::getInstance(); + instance.Register(getpid(), APP_NAME); KAboutData about("sflphone_kde", 0, ki18n("sflphone_kde"), version, ki18n(description), KAboutData::License_GPL, ki18n("(C) 2009 Jérémy Quentin"), KLocalizedString(), 0, "jeremy.quentin@gsavoirfairelinux.com"); about.addAuthor( ki18n("Jérémy Quentin"), KLocalizedString(), "jeremy.quentin@gmail.com" ); @@ -32,6 +53,7 @@ int main(int argc, char **argv) SFLPhone fenetre; + fenetre.move(QCursor::pos()); fenetre.show(); return app.exec(); diff --git a/sflphone_kde/metatypes.h b/sflphone_kde/metatypes.h index 4f308db1d2b51db1072f70474cb13412bb95fec1..e5ae32d8fd449c7a20c28a3e93083b378047798f 100644 --- a/sflphone_kde/metatypes.h +++ b/sflphone_kde/metatypes.h @@ -3,20 +3,23 @@ #include <QtCore/QList> #include <QtCore/QMetaType> +#include <QtCore/QMap> +#include <QtCore/QString> #include <QtDBus/QtDBus> -#include <qmap.h> -#include <qstring.h> //class MapStringString:public QMap<QString, QString>{}; typedef QMap<QString, QString> MapStringString; -typedef QVector<QString> VectorString; +typedef QMap<QString, int> MapStringInt; +//typedef QVector<QString> VectorString; Q_DECLARE_METATYPE(MapStringString) +Q_DECLARE_METATYPE(MapStringInt) //Q_DECLARE_METATYPE(VectorString) inline void registerCommTypes() { qDBusRegisterMetaType<MapStringString>(); + qDBusRegisterMetaType<MapStringInt>(); //qDBusRegisterMetaType<VectorString>(); } diff --git a/sflphone_kde/resources.qrc b/sflphone_kde/resources.qrc index 97ac5653919b9eb9655ee13bc8dc132fe8c244c5..c2032d4914877f9f83f2408d230df5d86772e11d 100644 --- a/sflphone_kde/resources.qrc +++ b/sflphone_kde/resources.qrc @@ -1,5 +1,7 @@ <RCC> <qresource prefix="images" > + <file>icons/office-address-book.png</file> + <file>icons/x-office-address-book.png</file> <file>icons/add.png</file> <file>icons/remove.png</file> <file>icons/del_off.png</file> diff --git a/sflphone_kde/sflphone-qt.ui b/sflphone_kde/sflphone-qt.ui index 48bc455d9facec54325b12caa29fad66a2d003ba..a8f9bb4dcb56dc0b9563cac98746a2d06f098f2e 100644 --- a/sflphone_kde/sflphone-qt.ui +++ b/sflphone_kde/sflphone-qt.ui @@ -36,10 +36,20 @@ <widget class="QWidget" name="page_callHistory" > <layout class="QVBoxLayout" name="verticalLayout_3" > <item> - <widget class="QLineEdit" name="label_searchHistory" /> + <widget class="QListWidget" name="listWidget_callHistory" /> </item> <item> - <widget class="QListWidget" name="listWidget_callHistory" /> + <widget class="QLineEdit" name="lineEdit_searchHistory" /> + </item> + </layout> + </widget> + <widget class="QWidget" name="page_addressBook" > + <layout class="QVBoxLayout" name="verticalLayout_5" > + <item> + <widget class="QListWidget" name="listWidget_addressBook" /> + </item> + <item> + <widget class="QLineEdit" name="lineEdit_addressBook" /> </item> </layout> </widget> @@ -368,6 +378,7 @@ <addaction name="separator" /> <addaction name="action_mailBox" /> <addaction name="action_history" /> + <addaction name="action_addressBook" /> </widget> <widget class="QMenu" name="menu_Configure" > <property name="title" > @@ -411,6 +422,7 @@ <addaction name="separator" /> <addaction name="action_mailBox" /> <addaction name="action_history" /> + <addaction name="action_addressBook" /> </widget> <action name="action_accept" > <property name="icon" > @@ -551,6 +563,18 @@ <string>Account creation &wizard</string> </property> </action> + <action name="action_addressBook" > + <property name="checkable" > + <bool>true</bool> + </property> + <property name="icon" > + <iconset resource="resources.qrc" > + <normaloff>:/images/icons/x-office-address-book.png</normaloff>:/images/icons/x-office-address-book.png</iconset> + </property> + <property name="text" > + <string>Address book</string> + </property> + </action> </widget> <resources> <include location="resources.qrc" /> diff --git a/sflphone_kde/sflphone_const.cpp b/sflphone_kde/sflphone_const.cpp deleted file mode 100644 index 6df8222b49d10577545856b875f11d79a4847992..0000000000000000000000000000000000000000 --- a/sflphone_kde/sflphone_const.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "sflphone_const.h" - -int getProtocolIndexByName(QString protocolName) -{ - if(protocolName == (QString)"SIP") - return 0; - if(protocolName == (QString)"IAX") - return 1; - return -1; -} - -QString getProtocolNameByIndex(int protocolIndex) -{ - if(protocolIndex == 0) - return "SIP"; - if(protocolIndex == 1) - return "IAX"; - return "UNKNOWN PROTOCOLE INDEX"; -} \ No newline at end of file diff --git a/sflphone_kde/sflphone_const.h b/sflphone_kde/sflphone_const.h index f51a9519c330c78665a6e7a21a74cc01de9bacb2..9b0afdff3f6eb972030c8c3b47a6a159e6ead091 100644 --- a/sflphone_kde/sflphone_const.h +++ b/sflphone_kde/sflphone_const.h @@ -21,19 +21,21 @@ #define __SFLPHONE_CONST_H #include <libintl.h> -#include <QtGui> +#include <QtCore/QString> /* @file sflphone_const.h * @brief Contains the global variables for the client code */ + +#define APP_NAME "KDE Client" /** Locale */ -#define _(STRING) gettext( STRING ) +#define _(STRING) gettext( STRING ) /** Warnings unused variables **/ -#define UNUSED_VAR(var) (void*)var +#define UNUSED_VAR(var) (void*)var -#define UNUSED __attribute__((__unused__)) +#define UNUSED __attribute__((__unused__)) #define SIP 0 #define IAX 1 @@ -145,49 +147,45 @@ /** Tone to play when no voice mails */ -#define TONE_WITHOUT_MESSAGE 0 +#define TONE_WITHOUT_MESSAGE 0 /** Tone to play when voice mails */ -#define TONE_WITH_MESSAGE 1 +#define TONE_WITH_MESSAGE 1 /** Tells if the main window is reduced to the system tray or not */ -#define MINIMIZED TRUE +#define MINIMIZED TRUE /** Behaviour of the main window on incoming calls */ -#define __POPUP_WINDOW ( dbus_popup_mode() ) +#define __POPUP_WINDOW ( dbus_popup_mode() ) /** Show/Hide the dialpad */ -#define SHOW_DIALPAD ( dbus_get_dialpad() ) +#define SHOW_DIALPAD ( dbus_get_dialpad() ) /** Show/Hide the volume controls */ -#define SHOW_VOLUME ( dbus_get_volume_controls() ) +#define SHOW_VOLUME ( dbus_get_volume_controls() ) /** Show/Hide the dialpad */ -#define SHOW_SEARCHBAR ( dbus_get_searchbar() ) +#define SHOW_SEARCHBAR ( dbus_get_searchbar() ) /** Show/Hide the alsa configuration panel */ -#define SHOW_ALSA_CONF ( dbus_get_audio_manager() == ALSA ) +#define SHOW_ALSA_CONF ( dbus_get_audio_manager() == ALSA ) /** Audio Managers */ -#define ALSA 0 -#define PULSEAUDIO 1 +#define ALSA 0 +#define PULSEAUDIO 1 /** Notification levels */ -#define __NOTIF_LEVEL_MIN 0 -#define __NOTIF_LEVEL_MED 1 -#define __NOTIF_LEVEL_HIGH 2 +#define __NOTIF_LEVEL_MIN 0 +#define __NOTIF_LEVEL_MED 1 +#define __NOTIF_LEVEL_HIGH 2 /** Messages ID for the status bar - Incoming calls */ -#define __MSG_INCOMING_CALL 0 +#define __MSG_INCOMING_CALL 0 /** Messages ID for the status bar - Calling */ -#define __MSG_CALLING 1 +#define __MSG_CALLING 1 /** Messages ID for the status bar - Voice mails notification */ -#define __MSG_VOICE_MAILS 2 +#define __MSG_VOICE_MAILS 2 /** Messages ID for the status bar - Current account */ -#define __MSG_ACCOUNT_DEFAULT 3 +#define __MSG_ACCOUNT_DEFAULT 3 /** Desktop notifications - Time before to close the notification*/ -#define __TIMEOUT_MODE "default" +#define __TIMEOUT_MODE "default" /** Desktop notifications - Time before to close the notification*/ -#define __TIMEOUT_TIME 18000 // 30 secondes +#define __TIMEOUT_TIME 18000 // 30 secondes + -/* -//TODO constantes pour protocoles -int getProtocolIndexByName(QString protocolName); -QString getProtocolNameByIndex(int protocolIndex); -*/ #endif