diff --git a/daemon/src/managerimpl.cpp b/daemon/src/managerimpl.cpp index d4d2ef1ac9d4955e1cb04851c60228632ea67741..a59b99b4a88ae5c7755b433ce818d286251585f1 100644 --- a/daemon/src/managerimpl.cpp +++ b/daemon/src/managerimpl.cpp @@ -1108,6 +1108,7 @@ void ManagerImpl::removeParticipant (const std::string& call_id) removeStream(call_id); getMainBuffer()->stateInfo(); + _dbus.getCallManager()->conferenceChanged (conf->getConfID(), conf->getStateStr()); } void ManagerImpl::processRemainingParticipant (const std::string ¤t_call_id, Conference *conf) diff --git a/kde/data/sflphone-client-kdeui.rc b/kde/data/sflphone-client-kdeui.rc index 9c1a57fe7130ae11d4bc1244ace0508e04ae33b1..2485812adbd809b6346d86c466987214fefc51cd 100755 --- a/kde/data/sflphone-client-kdeui.rc +++ b/kde/data/sflphone-client-kdeui.rc @@ -30,6 +30,7 @@ <Action name="action_displayVolumeControls" /> <Action name="action_displayDialpad" /> <Separator /> + <Action name="action_configureShortcut" /> <Action name="action_configureSflPhone" /> <Separator /> <Action name="action_accountCreationWizard" /> diff --git a/kde/plasma/dataengine/sflphonEngine.cpp b/kde/plasma/dataengine/sflphonEngine.cpp index b48966ef04e711d1f6251b46e9faa64d59b1f231..e624414d8d9a7aaf44e4fe15f74dc086ba0535eb 100644 --- a/kde/plasma/dataengine/sflphonEngine.cpp +++ b/kde/plasma/dataengine/sflphonEngine.cpp @@ -10,49 +10,34 @@ #include "../../src/lib/sflphone_const.h" SFLPhoneEngine::SFLPhoneEngine(QObject* parent, const QVariantList& args) - : Plasma::DataEngine(parent, args), CallModelConvenience(ActiveCall) + : Plasma::DataEngine(parent, args) { Q_UNUSED(args) - initCall(); - initHistory(); - + m_pModel = new CallModelConvenience(CallModelConvenience::ActiveCall); + m_pModel->initCall(); + m_pModel->initHistory(); + ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); - connect(&callManager, SIGNAL(callStateChanged(const QString&, const QString&)), - this, SLOT(callStateChangedSignal(const QString&, const QString&))); - connect(&callManager, SIGNAL(incomingCall(const QString&, const QString&, const QString&)), - this, SLOT(incomingCallSignal(const QString&, const QString&))); - connect(&callManager, SIGNAL(conferenceCreated(const QString&)), - this, SLOT(conferenceCreatedSignal(const QString&))); - connect(&callManager, SIGNAL(conferenceChanged(const QString&, const QString&)), - this, SLOT(conferenceChangedSignal(const QString&, const QString&))); - connect(&callManager, SIGNAL(conferenceRemoved(const QString&)), - this, SLOT(conferenceRemovedSignal(const QString&))); - connect(&callManager, SIGNAL(incomingMessage(const QString&, const QString&)), - this, SLOT(incomingMessageSignal(const QString&, const QString&))); - connect(&callManager, SIGNAL(voiceMailNotify(const QString&, int)), - this, SLOT(voiceMailNotifySignal(const QString&, int))); - connect(&configurationManager, SIGNAL(accountsChanged()), - this, SLOT(accountChanged())); - connect(&configurationManager, SIGNAL(accountsChanged()), - getAccountList(), SLOT(updateAccounts())); - - //setMinimumPollingInterval(1000); + connect(m_pModel , SIGNAL( callStateChanged(Call*)) , this , SLOT(callStateChangedSignal(Call*) )); + connect(&callManager , SIGNAL( incomingCall(Call*)) , this , SLOT(incomingCallSignal(Call*) )); + connect(&callManager , SIGNAL( conferenceCreated(Call*)) , this , SLOT(conferenceCreatedSignal(Call*) )); + connect(&callManager , SIGNAL( conferenceChanged(Call*)) , this , SLOT(conferenceChangedSignal(Call*) )); } bool SFLPhoneEngine::sourceRequestEvent(const QString &name) { - if (name == "history") { + if ( name == "history" ) { updateHistory(); } - else if (name == "calls") { + else if ( name == "calls" ) { updateCallList(); } - else if (name == "conferences") { + else if ( name == "conferences" ) { updateConferenceList(); } - else if (name == "info") { + else if ( name == "info" ) { updateInfo(); } return true;//updateSourceEvent(name); @@ -100,22 +85,22 @@ QString SFLPhoneEngine::getCallStateName(call_state state) void SFLPhoneEngine::updateHistory() { - foreach (Call* oldCall, getHistory()) { - historyCall[oldCall->getCallId()]["Name"] = oldCall->getPeerName(); - historyCall[oldCall->getCallId()]["Number"] = oldCall->getPeerPhoneNumber(); - historyCall[oldCall->getCallId()]["Date"] = oldCall->getStopTimeStamp(); + foreach (Call* oldCall, m_pModel->getHistory()) { + historyCall[oldCall->getCallId()][ "Name" ] = oldCall->getPeerName(); + historyCall[oldCall->getCallId()][ "Number" ] = oldCall->getPeerPhoneNumber(); + historyCall[oldCall->getCallId()][ "Date" ] = oldCall->getStopTimeStamp(); setData("history", I18N_NOOP(oldCall->getCallId()), historyCall[oldCall->getCallId()]); } } void SFLPhoneEngine::updateCallList() { - foreach (Call* call, getCalls()) { - if ((!isConference(call)) && (call->getState() != CALL_STATE_OVER)) { - currentCall[call->getCallId()]["Name"] = call->getPeerName(); - currentCall[call->getCallId()]["Number"] = call->getPeerPhoneNumber(); - currentCall[call->getCallId()]["StateName"] = getCallStateName(call->getState()); - currentCall[call->getCallId()]["State"] = call->getState(); + foreach (Call* call, m_pModel->getCalls()) { + if ((!m_pModel->isConference(call)) && (call->getState() != CALL_STATE_OVER)) { + currentCall[call->getCallId()][ "Name" ] = call->getPeerName(); + currentCall[call->getCallId()][ "Number" ] = call->getPeerPhoneNumber(); + currentCall[call->getCallId()][ "StateName" ] = getCallStateName(call->getState()); + currentCall[call->getCallId()][ "State" ] = call->getState(); setData("calls", call->getCallId(), currentCall[call->getCallId()]); } } @@ -123,8 +108,8 @@ void SFLPhoneEngine::updateCallList() void SFLPhoneEngine::updateConferenceList() { - foreach (Call* call, getCalls()) { - if (isConference(call)) { + foreach (Call* call, m_pModel->getCalls()) { + if (m_pModel->isConference(call)) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); currentConferences[call->getConfId()] = callManager.getParticipantList(call->getConfId()); setData("conferences", call->getConfId(), currentConferences[call->getConfId()]); @@ -139,54 +124,34 @@ void SFLPhoneEngine::updateContacts() void SFLPhoneEngine::updateInfo() { - qDebug() << "Currentaccount: " << getCurrentAccountId(); - setData("info", I18N_NOOP("Account"), getCurrentAccountId()); + qDebug() << "Currentaccount: " << m_pModel->getCurrentAccountId(); + setData("info", I18N_NOOP("Account"), m_pModel->getCurrentAccountId()); } -void SFLPhoneEngine::callStateChangedSignal(const QString& callId, const QString& state) +void SFLPhoneEngine::callStateChangedSignal(Call* call) { - qDebug() << "Signal : Call State Changed for call " << callId << " . New state : " << state; - Call* call = findCallByCallId(callId); - if(!call) { - if(state == CALL_STATE_CHANGE_RINGING) { - call = addRingingCall(callId); - //addCallToCallList(call); - } - else { - qDebug() << "Call doesn't exist in this client. Might have been initialized by another client instance before this one started."; - return; - } - } - else { - call->stateChanged(state); - } + Q_UNUSED(call) updateCallList(); } -void SFLPhoneEngine::incomingCallSignal(const QString& accountId, const QString& callId) +void SFLPhoneEngine::incomingCallSignal(Call* call) { - Q_UNUSED(accountId) - addIncomingCall(callId); + Q_UNUSED(call) updateCallList(); } -void SFLPhoneEngine::conferenceCreatedSignal(const QString& confId) +void SFLPhoneEngine::conferenceCreatedSignal(Call* conf) { - addConference(confId); + Q_UNUSED(conf) updateConferenceList(); } -void SFLPhoneEngine::conferenceChangedSignal(const QString& confId, const QString& state) +void SFLPhoneEngine::conferenceChangedSignal(Call* conf) { - conferenceChanged(confId, state); + Q_UNUSED(conf) updateConferenceList(); } -void SFLPhoneEngine::conferenceRemovedSignal(const QString& confId) -{ - conferenceRemoved(confId); -} - void SFLPhoneEngine::incomingMessageSignal(const QString& accountId, const QString& message) { Q_UNUSED(accountId) diff --git a/kde/plasma/dataengine/sflphonEngine.h b/kde/plasma/dataengine/sflphonEngine.h index 1bcbc935c92ae59b5693aa0eb1db3a8ccace73f8..ab3569f664b888d9904ab8242aef069565dbd8bb 100644 --- a/kde/plasma/dataengine/sflphonEngine.h +++ b/kde/plasma/dataengine/sflphonEngine.h @@ -16,7 +16,7 @@ * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ + **************************************************************************/ #ifndef SFLPHONEENGINE_H #define SFLPHONEENGINE_H @@ -27,8 +27,9 @@ #include "../../src/lib/CallModel.h" typedef QHash<QString,QVariant> HashStringString; - -class SFLPhoneEngine : public Plasma::DataEngine, public CallModelConvenience +class Call; + +class SFLPhoneEngine : public Plasma::DataEngine { Q_OBJECT @@ -41,23 +42,24 @@ class SFLPhoneEngine : public Plasma::DataEngine, public CallModelConvenience bool updateSourceEvent(const QString& source); private: - QHash<QString, HashStringString > historyCall; - QHash<QString, HashStringString > currentCall; - QHash<QString, QStringList> currentConferences; + QHash<QString, HashStringString > historyCall ; + QHash<QString, HashStringString > currentCall ; + QHash<QString, QStringList> currentConferences ; + CallModelConvenience* m_pModel; QString getCallStateName(call_state state); - void updateHistory(); - void updateCallList(); - void updateContacts(); - void updateConferenceList(); + void updateHistory (); + void updateCallList (); + void updateContacts (); + void updateConferenceList (); void updateInfo(); private slots: - void callStateChangedSignal(const QString& callId, const QString& state); - void incomingCallSignal(const QString& accountId, const QString& callId); - void conferenceCreatedSignal(const QString& confId); - void conferenceChangedSignal(const QString& confId, const QString& state); - void conferenceRemovedSignal(const QString& confId); - void incomingMessageSignal(const QString& accountId, const QString& message); - void voiceMailNotifySignal(const QString& accountId, int count); + void callStateChangedSignal (Call* call); + void incomingCallSignal (Call* conf); + void conferenceCreatedSignal (Call* conf); + void conferenceChangedSignal (Call* conf); + //void conferenceRemovedSignal(const QString& confId); + void incomingMessageSignal( const QString& accountId, const QString& message ); + void voiceMailNotifySignal( const QString& accountId, int count ); void accountChanged(); }; diff --git a/kde/plasma/plasmoid/MainWidget.cpp b/kde/plasma/plasmoid/MainWidget.cpp index 465e850e93cbc352fb3acbfe71c4d4b774b7ac71..1bcb7b5e6352eabf73b21ff9d6e47464d03501c9 100644 --- a/kde/plasma/plasmoid/MainWidget.cpp +++ b/kde/plasma/plasmoid/MainWidget.cpp @@ -6,50 +6,51 @@ MainWidget::MainWidget() : Plasma::Frame(), m_mainLayout(0), frmCalls(0), frmContact(0), frmHistory(0),currentMode(CALL) { - mainTabs = new Plasma::TabBar(this); + mainTabs = new Plasma::TabBar ( this ); + frmCalls = new Plasma::Frame ( this ); + callLayout = new QGraphicsLinearLayout ( Qt::Vertical ); + callScrollArea = new Plasma::ScrollWidget ( this ); + frmContact = new Plasma::Frame ( this ); + contactScrollArea = new Plasma::ScrollWidget ( this ); + frmHistory = new Plasma::Frame ( this ); + historyLayout = new QGraphicsLinearLayout ( Qt::Vertical ); + historyScrollArea = new Plasma::ScrollWidget ( this ); + mainLayout()->addItem(mainTabs); //connect(mainTabs, SIGNAL(currentChanged(int)), this, SLOT(modeChanged(int))); - frmCalls = new Plasma::Frame(this); frmCalls->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - callLayout = new QGraphicsLinearLayout(Qt::Vertical); frmCalls->setLayout(callLayout); - callScrollArea = new Plasma::ScrollWidget(this); callScrollArea->setWidget(frmCalls); - frmContact = new Plasma::Frame(this); frmContact->setText("Contact"); frmContact->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - contactScrollArea = new Plasma::ScrollWidget(this); contactScrollArea->setWidget(frmContact); - frmHistory = new Plasma::Frame(this); frmHistory->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); - historyLayout = new QGraphicsLinearLayout(Qt::Vertical); frmHistory->setLayout(historyLayout); - historyScrollArea = new Plasma::ScrollWidget(this); historyScrollArea->setWidget(frmHistory); dialPage = new DialPage(); connect(dialPage, SIGNAL(call(QString)), this, SLOT(call(QString))); - QGraphicsLinearLayout* callTabLayout = new QGraphicsLinearLayout(Qt::Vertical); - QGraphicsLinearLayout* historyTabLayout = new QGraphicsLinearLayout(Qt::Vertical); - QGraphicsLinearLayout* contactTabLayout = new QGraphicsLinearLayout(Qt::Vertical); - QGraphicsLinearLayout* addTabLayout = new QGraphicsLinearLayout(Qt::Vertical); - - callTabLayout->addItem(callScrollArea); - historyTabLayout->addItem(historyScrollArea); - contactTabLayout->addItem(contactScrollArea); + QGraphicsLinearLayout* callTabLayout = new QGraphicsLinearLayout( Qt::Vertical ); + QGraphicsLinearLayout* historyTabLayout = new QGraphicsLinearLayout( Qt::Vertical ); + QGraphicsLinearLayout* contactTabLayout = new QGraphicsLinearLayout( Qt::Vertical ); + QGraphicsLinearLayout* addTabLayout = new QGraphicsLinearLayout( Qt::Vertical ); + + callTabLayout->addItem ( callScrollArea ); + historyTabLayout->addItem ( historyScrollArea ); + contactTabLayout->addItem ( contactScrollArea ); addTabLayout->addItem(dialPage); - mainTabs->addTab("Call", callTabLayout); - mainTabs->addTab("History", historyTabLayout); - mainTabs->addTab("Contact", contactTabLayout); - mainTabs->addTab(KIcon("list-add"),"", addTabLayout); + mainTabs->addTab( "Call" , callTabLayout ); + mainTabs->addTab( "History" , historyTabLayout ); + mainTabs->addTab( "Contact" , contactTabLayout ); + mainTabs->addTab( KIcon("list-add") , "", addTabLayout ); //mainLayout()->addItem(callTabLayout); @@ -58,9 +59,10 @@ MainWidget::MainWidget() : Plasma::Frame(), m_mainLayout(0), frmCalls(0), frmCon //mainLayout()->addItem(contactScrollArea); initPos = frmCalls->pos(); - frmCalls->setPos(initPos); - frmHistory->setPos(initPos); - frmContact->setPos(initPos); + + frmCalls->setPos ( initPos ); + frmHistory->setPos( initPos ); + frmContact->setPos( initPos ); setMinimumSize(285,390); } @@ -72,15 +74,15 @@ void MainWidget::dataUpdated(const QString& source, const Plasma::DataEngine::Da bool modified = false; foreach(QVariant call, value) { if (!callWidgetList[value.key(call)]) { - callWidgetList[value.key(call)] = new CallItem(); - callWidgetList[value.key(call)]->setCallId(value.key(call)); + callWidgetList[ value.key(call) ] = new CallItem(); + callWidgetList[ value.key(call) ]->setCallId(value.key(call)); callLayout->insertItem(0,callWidgetList[value.key(call)]); mainTabs->setCurrentIndex(CALL); modified = true; } - callWidgetList[value.key(call)]->setCallerName(call.toHash()["Name"].toString()); - callWidgetList[value.key(call)]->setCallerNumber(call.toHash()["Number"].toString()); - callWidgetList[value.key(call)]->setState(call.toHash()["State"].toInt()); + callWidgetList[value.key(call)]->setCallerName(call.toHash() [ "Name" ].toString()); + callWidgetList[value.key(call)]->setCallerNumber(call.toHash()[ "Number" ].toString()); + callWidgetList[value.key(call)]->setState(call.toHash() [ "State" ].toInt()); if (call.toHash()["State"].toInt() == CALL_STATE_INCOMING) { emit requierAttention(); @@ -93,7 +95,8 @@ void MainWidget::dataUpdated(const QString& source, const Plasma::DataEngine::Da //sflphoneEngine->connectSource("conferences", this,0/*Update only if something happen*/); } else if (source == "info") { - currentAccountId = data["Account"].toString(); + if (!data["Account"].isNull() || data["Account"].isValid()) + currentAccountId = data["Account"].toString(); } else if (source == "conferences") { QHash<QString, QVariant> value = data; @@ -122,15 +125,17 @@ void MainWidget::dataUpdated(const QString& source, const Plasma::DataEngine::Da } else if (source == "history") { QHash<QString, QVariant> value = data; - foreach(QVariant call, value) { - if (!historyWidgetList[value.key(call)]) { - historyWidgetList[value.key(call)] = new CallItem(); - historyWidgetList[value.key(call)]->setCallId(value.key(call)); - historyLayout->addItem(historyWidgetList[value.key(call)]); + for (QHash<QString, QVariant>::iterator i = value.begin(); i != value.end(); ++i) { + QString key = i.key(); + //QHash<QString, CallItem*> historyWidgetList; + if ( ! historyWidgetList[key]) { + historyWidgetList[ i.key() ] = new CallItem(); + historyWidgetList[ i.key() ]->setCallId(i.key()); + historyLayout->addItem(historyWidgetList[i.key()]); } - historyWidgetList[value.key(call)]->setCallerName(call.toHash()["Name"].toString()); - historyWidgetList[value.key(call)]->setCallerNumber(call.toHash()["Number"].toString()); - historyWidgetList[value.key(call)]->setDate(call.toHash()["Date"].toInt()); + historyWidgetList[ i.key() ]->setCallerName(i.value().toHash() [ "Name" ].toString()); + historyWidgetList[ i.key() ]->setCallerNumber(i.value().toHash() [ "Number" ].toString()); + historyWidgetList[ i.key() ]->setDate(i.value().toHash() [ "Date" ].toInt()) ; } } } @@ -148,7 +153,7 @@ QGraphicsLinearLayout* MainWidget::mainLayout() void MainWidget::call(QString number) { - qDebug() << "Calling " << number << " with account " << currentAccountId << ", " << CallModelConvenience::getAccountList()->size() << " account registred"; - CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); - callManager.placeCall(currentAccountId, CallModelConvenience::generateCallId(), number); +// qDebug() << "Calling " << number << " with account " << currentAccountId << ", " << CallModelConvenience::getAccountList()->size() << " account registred"; +// CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); +// callManager.placeCall(currentAccountId, CallModelConvenience::generateCallId(), number); } diff --git a/kde/plasma/plasmoid/MainWidget.h b/kde/plasma/plasmoid/MainWidget.h index fc356861ea4867f8137b2bcdbd20a0dbc01b3395..a5892ef228bd4023670d37fad07923d1bcfbe59c 100644 --- a/kde/plasma/plasmoid/MainWidget.h +++ b/kde/plasma/plasmoid/MainWidget.h @@ -12,6 +12,7 @@ #include <Plasma/DataEngine> #include <Plasma/ExtenderItem> #include <KIcon> +#include <QHash> #include "CallItem.h" #include "ConferenceItem.h" diff --git a/kde/plasma/plasmoid/SFLPhonePlasmoid.cpp b/kde/plasma/plasmoid/SFLPhonePlasmoid.cpp index d37a095b4f36475a767561100d0fe59f8c522c0e..d13e72ebab3033659d304637b09f4031f2c1b8d3 100644 --- a/kde/plasma/plasmoid/SFLPhonePlasmoid.cpp +++ b/kde/plasma/plasmoid/SFLPhonePlasmoid.cpp @@ -12,7 +12,7 @@ SFLPhonePlasmoid::SFLPhonePlasmoid(QObject* parent, const QVariantList& args) { //m_svg.setImagePath("widgets/background"); setBackgroundHints(DefaultBackground); - + CallModelConvenience::init(); setMinimumSize(24,24); diff --git a/kde/src/AccountListModel.cpp b/kde/src/AccountListModel.cpp index e65968e3311eb6280442c72eb29aeec2ded73b9c..b5b4ad6d818e4a50971fe9af782c29dd07c10024 100755 --- a/kde/src/AccountListModel.cpp +++ b/kde/src/AccountListModel.cpp @@ -21,6 +21,7 @@ #include "AccountListModel.h" #include "lib/sflphone_const.h" +#include "conf/ConfigAccountList.h" #include <QDebug> AccountListModel::AccountListModel(QObject *parent) diff --git a/kde/src/AccountListModel.h b/kde/src/AccountListModel.h index 5de0fd28dab25f977cbc241c6fe79e467ac64f80..2d70f68e2de4abc8bc7ce3badf9bf9e641c9521f 100755 --- a/kde/src/AccountListModel.h +++ b/kde/src/AccountListModel.h @@ -23,7 +23,8 @@ #include <QAbstractListModel> -#include "conf/ConfigAccountList.h" +//SFLPhone +class ConfigAccountList; /** @author Jérémy Quentin <jeremy.quentin@gmail.com> @@ -41,8 +42,6 @@ public: QVariant data ( const QModelIndex & index, int role = Qt::DisplayRole ) const; int rowCount(const QModelIndex & parent = QModelIndex()) const; -// int columnCount(const QModelIndex & parent = QModelIndex()) const; -// QVariant headerData(int section , Qt::Orientation orientation, int role) const; Qt::ItemFlags flags(const QModelIndex & index) const; virtual bool setData ( const QModelIndex & index, const QVariant &value, int role); @@ -52,9 +51,6 @@ public: bool addAccount( QString alias ); QString getOrderedList() const; -// QStringList getActiveCodecList() const ; -// void setActiveCodecList(const QStringList & activeCodecListToSet); - }; #endif diff --git a/kde/src/AccountView.cpp b/kde/src/AccountView.cpp index 9e1af78d7d7deeda07ab2648218138880ebeb3fb..015dfaea3894a7904841094b92b62bbe096f0523 100644 --- a/kde/src/AccountView.cpp +++ b/kde/src/AccountView.cpp @@ -1,15 +1,17 @@ #include "AccountView.h" #include <QDebug> - +#include <QtGui/QListWidgetItem> #include "lib/sflphone_const.h" #include "lib/configurationmanager_interface_singleton.h" +///Constructor AccountView::AccountView() : Account(), item2(0), itemWidget(0) { } +///Init void AccountView::initItem() { if(item2 != NULL) @@ -20,6 +22,7 @@ void AccountView::initItem() initItemWidget(); } +///Init widget void AccountView::initItemWidget() { if(itemWidget != NULL) @@ -39,16 +42,19 @@ void AccountView::initItemWidget() connect(itemWidget, SIGNAL(checkStateChanged(bool)), this, SLOT(setEnabled(bool))); } +///Get the current item QListWidgetItem* AccountView::getItem() { return item2; } +///Get the current widget AccountItemWidget* AccountView::getItemWidget() { return itemWidget; } +///Return the state color QColor AccountView::getStateColor() { if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_UNREGISTERED) @@ -58,7 +64,7 @@ QColor AccountView::getStateColor() return Qt::red; } - +///Get the color name QString AccountView::getStateColorName() { if(getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_UNREGISTERED) @@ -68,11 +74,13 @@ QString AccountView::getStateColorName() return "red"; } +///Is this item checked? bool AccountView::isChecked() const { return itemWidget->getEnabled(); } +///Build an item from an account id AccountView* AccountView::buildExistingAccountFromId(QString _accountId) { //Account* a = Account::buildExistingAccountFromId( _accountId); @@ -84,6 +92,7 @@ AccountView* AccountView::buildExistingAccountFromId(QString _accountId) return a; } +///Build an item from an alias AccountView* AccountView::buildNewAccountFromAlias(QString alias) { //Account* a = Account::buildNewAccountFromAlias(alias); @@ -94,6 +103,7 @@ AccountView* AccountView::buildNewAccountFromAlias(QString alias) return a; } +///Change LED color void AccountView::updateState() { qDebug() << "updateState"; diff --git a/kde/src/AccountView.h b/kde/src/AccountView.h index f13bf523bed64b2282368cac8a7bf97ee771465c..e3911997ce2c411f61929b542f62d4cedf5b5802 100644 --- a/kde/src/AccountView.h +++ b/kde/src/AccountView.h @@ -1,12 +1,15 @@ #ifndef ACCOUNT_VIEW_H #define ACCOUNT_VIEW_H -#include <QtGui/QListWidgetItem> - #include "lib/Item.h" #include "lib/Account.h" #include "widgets/AccountItemWidget.h" -#include "lib/sflphone_const.h" + +//Qt +class QListWidgetItem; + +//SFLPhone +class AccountItemWidget; class AccountView : public Account, public Item<AccountItemWidget> { public: diff --git a/kde/src/AccountWizard.cpp b/kde/src/AccountWizard.cpp index 2a23ef9fe88fa80b7e461b830d57c51f8e0d19a2..904f3b75d76718ec42ff387b34ce7e8e52d63019 100755 --- a/kde/src/AccountWizard.cpp +++ b/kde/src/AccountWizard.cpp @@ -24,6 +24,10 @@ #include <QFormLayout> #include "lib/sflphone_const.h" #include "lib/configurationmanager_interface_singleton.h" +#include <QLabel> +#include <QRadioButton> +#include <QLineEdit> +#include <QCheckBox> #include <klocale.h> @@ -61,12 +65,13 @@ ***************************************************************************/ typedef struct { - bool success; - QString reason; - QString user; - QString passwd; + bool success ; + QString reason ; + QString user ; + QString passwd ; } rest_account; +///Validate if the connection can be done with the PBX int sendRequest(QString host, int port, QString req, QString & ret) { int s; @@ -131,6 +136,7 @@ int sendRequest(QString host, int port, QString req, QString & ret) return 0; } +/// rest_account get_rest_account(QString host, QString email) { QString req = "GET /rest/accountcreator?email=" + email; @@ -154,33 +160,35 @@ rest_account get_rest_account(QString host, QString email) /*************************************************************************** * Class AccountWizard * * Widget of the wizard for creating an account. * - ***************************************************************************/ + **************************************************************************/ +///Constructor AccountWizard::AccountWizard(QWidget * parent) : QWizard(parent) { - setPage(Page_Intro, new WizardIntroPage); - setPage(Page_AutoMan, new WizardAccountAutoManualPage); - setPage(Page_Type, new WizardAccountTypePage); - setPage(Page_Email, new WizardAccountEmailAddressPage); - setPage(Page_SIPForm, new WizardAccountSIPFormPage); - setPage(Page_IAXForm, new WizardAccountIAXFormPage); - setPage(Page_Stun, new WizardAccountStunPage); - setPage(Page_Conclusion, new WizardAccountConclusionPage); + setPage(Page_Intro , new WizardIntroPage ); + setPage(Page_AutoMan , new WizardAccountAutoManualPage ); + setPage(Page_Type , new WizardAccountTypePage ); + setPage(Page_Email , new WizardAccountEmailAddressPage ); + setPage(Page_SIPForm , new WizardAccountSIPFormPage ); + setPage(Page_IAXForm , new WizardAccountIAXFormPage ); + setPage(Page_Stun , new WizardAccountStunPage ); + setPage(Page_Conclusion , new WizardAccountConclusionPage ); setStartId(Page_Intro); setWindowTitle(i18n("Account creation wizard")); setWindowIcon(QIcon(ICON_SFLPHONE)); - setMinimumHeight(350); - setMinimumWidth(500); + setMinimumHeight ( 350 ); + setMinimumWidth ( 500 ); setPixmap(QWizard::WatermarkPixmap, QPixmap(ICON_SFLPHONE)); } - +///Destructor AccountWizard::~AccountWizard() { } +///The accept button have been pressed void AccountWizard::accept() { ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); @@ -188,33 +196,33 @@ void AccountWizard::accept() QString ret; MapStringString accountDetails; - QString & alias = accountDetails[QString(ACCOUNT_ALIAS)]; - QString & enabled = accountDetails[QString(ACCOUNT_ENABLED)]; - QString & mailbox = accountDetails[QString(ACCOUNT_MAILBOX)]; - QString & protocol = accountDetails[QString(ACCOUNT_TYPE)]; - QString & server = accountDetails[QString(ACCOUNT_HOSTNAME)]; - QString & user = accountDetails[QString(ACCOUNT_USERNAME)]; - QString & password = accountDetails[QString(ACCOUNT_PASSWORD)]; + QString & alias = accountDetails[ QString(ACCOUNT_ALIAS) ]; + QString & enabled = accountDetails[ QString(ACCOUNT_ENABLED) ]; + QString & mailbox = accountDetails[ QString(ACCOUNT_MAILBOX) ]; + QString & protocol = accountDetails[ QString(ACCOUNT_TYPE) ]; + QString & server = accountDetails[ QString(ACCOUNT_HOSTNAME) ]; + QString & user = accountDetails[ QString(ACCOUNT_USERNAME) ]; + QString & password = accountDetails[ QString(ACCOUNT_PASSWORD) ]; // sip only parameters - QString & stun_enabled = accountDetails[QString(ACCOUNT_SIP_STUN_ENABLED)]; - QString & stun_server = accountDetails[QString(ACCOUNT_SIP_STUN_SERVER)]; + QString & stun_enabled = accountDetails[ QString(ACCOUNT_SIP_STUN_ENABLED) ]; + QString & stun_server = accountDetails[ QString(ACCOUNT_SIP_STUN_SERVER) ]; // zrtp only parameters - QString & srtp_enabled = accountDetails[QString(ACCOUNT_SRTP_ENABLED)]; - QString & key_exchange = accountDetails[QString(ACCOUNT_KEY_EXCHANGE)]; - QString & zrtp_display_sas = accountDetails[QString(ACCOUNT_ZRTP_DISPLAY_SAS)]; - QString & zrtp_not_supp_warning = accountDetails[QString(ACCOUNT_ZRTP_NOT_SUPP_WARNING)]; - QString & zrtp_hello_hash = accountDetails[QString(ACCOUNT_ZRTP_HELLO_HASH)]; - QString & display_sas_once = accountDetails[QString(ACCOUNT_DISPLAY_SAS_ONCE)]; + QString & srtp_enabled = accountDetails[ QString(ACCOUNT_SRTP_ENABLED) ]; + QString & key_exchange = accountDetails[ QString(ACCOUNT_KEY_EXCHANGE) ]; + QString & zrtp_display_sas = accountDetails[ QString(ACCOUNT_ZRTP_DISPLAY_SAS) ]; + QString & zrtp_not_supp_warning = accountDetails[ QString(ACCOUNT_ZRTP_NOT_SUPP_WARNING) ]; + QString & zrtp_hello_hash = accountDetails[ QString(ACCOUNT_ZRTP_HELLO_HASH) ]; + QString & display_sas_once = accountDetails[ QString(ACCOUNT_DISPLAY_SAS_ONCE) ]; // interface paramters - QString & locale_interface = accountDetails[QString(LOCAL_INTERFACE)]; - QString & published_address = accountDetails[QString(PUBLISHED_ADDRESS)]; + QString & locale_interface = accountDetails[ QString(LOCAL_INTERFACE) ]; + QString & published_address = accountDetails[ QString(PUBLISHED_ADDRESS) ]; bool is_using_sflphone_org = field(FIELD_SFL_ACCOUNT).toBool(); - bool is_using_sip = false; - bool is_create_account = false; + bool is_using_sip = false; + bool is_create_account = false; // sflphone.org if(is_using_sflphone_org) { @@ -225,20 +233,20 @@ void AccountWizard::accept() if(acc.success) { ret += i18n("This assistant is now finished.") + "\n"; - field(FIELD_SIP_ALIAS) = QString(acc.user) + "@" + SFL_ACCOUNT_HOST; - field(FIELD_SIP_VOICEMAIL) = QString(); - field(FIELD_SIP_SERVER) = QString(SFL_ACCOUNT_HOST); - field(FIELD_SIP_PASSWORD) = QString(acc.passwd); - field(FIELD_SIP_USER) = QString(acc.user); - - protocol = QString(ACCOUNT_TYPE_SIP); - server = QString(SFL_ACCOUNT_HOST); - password = QString(acc.passwd); - user = QString(acc.user); - enabled = QString(ACCOUNT_ENABLED_TRUE); + field( FIELD_SIP_ALIAS ) = QString(acc.user) + "@" + SFL_ACCOUNT_HOST; + field( FIELD_SIP_VOICEMAIL ) = QString(); + field( FIELD_SIP_SERVER ) = QString(SFL_ACCOUNT_HOST); + field( FIELD_SIP_PASSWORD ) = QString(acc.passwd); + field( FIELD_SIP_USER ) = QString(acc.user); + + protocol = QString( ACCOUNT_TYPE_SIP ); + server = QString( SFL_ACCOUNT_HOST ); + password = QString( acc.passwd ); + user = QString( acc.user ); + enabled = QString( ACCOUNT_ENABLED_TRUE ); is_create_account = true; - is_using_sip = true; + is_using_sip = true; } else { ret += i18n("Creation of account has failed for the reason") + " :\n"; @@ -246,15 +254,15 @@ void AccountWizard::accept() } } else if(field(FIELD_SIP_ACCOUNT).toBool()) { //sip - ret += i18n("This assistant is now finished.") + "\n"; + ret += i18n("This assistant is now finished.") + "\n"; - alias = field(FIELD_SIP_ALIAS).toString(); - enabled = QString(ACCOUNT_ENABLED_TRUE); - mailbox = field(FIELD_SIP_VOICEMAIL).toString(); - protocol = QString(ACCOUNT_TYPE_SIP); - server = field(FIELD_SIP_SERVER).toString(); - password = field(FIELD_SIP_PASSWORD).toString(); - user = field(FIELD_SIP_USER).toString(); + alias = field ( FIELD_SIP_ALIAS ).toString(); + enabled = QString ( ACCOUNT_ENABLED_TRUE ); + mailbox = field ( FIELD_SIP_VOICEMAIL ).toString(); + protocol = QString ( ACCOUNT_TYPE_SIP ); + server = field ( FIELD_SIP_SERVER ).toString(); + password = field ( FIELD_SIP_PASSWORD ).toString(); + user = field ( FIELD_SIP_USER ).toString(); is_create_account = true; is_using_sip = true; @@ -263,13 +271,13 @@ void AccountWizard::accept() else { // iax ret += i18n("This assistant is now finished.") + "\n"; - alias = field(FIELD_IAX_ALIAS).toString(); - enabled = QString(ACCOUNT_ENABLED_TRUE); - mailbox = field(FIELD_IAX_VOICEMAIL).toString(); - protocol = QString(ACCOUNT_TYPE_IAX); - server = field(FIELD_IAX_SERVER).toString(); - password = field(FIELD_IAX_PASSWORD).toString(); - user = field(FIELD_IAX_USER).toString(); + alias = field ( FIELD_IAX_ALIAS ).toString(); + enabled = QString ( ACCOUNT_ENABLED_TRUE ); + mailbox = field ( FIELD_IAX_VOICEMAIL ).toString(); + protocol = QString ( ACCOUNT_TYPE_IAX ); + server = field ( FIELD_IAX_SERVER ).toString(); + password = field ( FIELD_IAX_PASSWORD ).toString(); + user = field ( FIELD_IAX_USER ).toString(); is_create_account = true; is_using_sip = false; @@ -280,33 +288,33 @@ void AccountWizard::accept() if(is_using_sip) { if(field(FIELD_SIP_ENABLE_STUN).toBool()) { stun_enabled = QString(ACCOUNT_ENABLED_TRUE); - stun_server = field(FIELD_SIP_STUN_SERVER).toString(); + stun_server = field(FIELD_SIP_STUN_SERVER).toString(); } else { stun_enabled = QString(ACCOUNT_ENABLED_FALSE); - stun_server = QString(); + stun_server = QString(); } if(field(FIELD_ZRTP_ENABLED).toBool()) { - srtp_enabled = QString(ACCOUNT_ENABLED_TRUE); - key_exchange = QString(ZRTP); - zrtp_display_sas = QString(ACCOUNT_ENABLED_TRUE); - zrtp_not_supp_warning = QString(ACCOUNT_ENABLED_TRUE); - zrtp_hello_hash = QString(ACCOUNT_ENABLED_TRUE); - display_sas_once = QString(ACCOUNT_ENABLED_FALSE); + srtp_enabled = QString( ACCOUNT_ENABLED_TRUE ); + key_exchange = QString( ZRTP ); + zrtp_display_sas = QString( ACCOUNT_ENABLED_TRUE ); + zrtp_not_supp_warning = QString( ACCOUNT_ENABLED_TRUE ); + zrtp_hello_hash = QString( ACCOUNT_ENABLED_TRUE ); + display_sas_once = QString( ACCOUNT_ENABLED_FALSE ); } QStringList ifaceList = configurationManager.getAllIpInterface(); - locale_interface = ifaceList.at(0); - published_address = ifaceList.at(0); + locale_interface = ifaceList.at(0); + published_address = ifaceList.at(0); - ret += i18n("Alias") + " : " + alias + "\n"; - ret += i18n("Server") + " : " + server + "\n"; - ret += i18n("Username") + " : " + user + "\n"; - ret += i18n("Password") + " : " + password + "\n"; - ret += i18n("Protocol") + " : " + protocol + "\n"; - ret += i18n("Voicemail number") + " : " + mailbox + "\n"; + ret += i18n( "Alias" ) + " : " + alias + "\n"; + ret += i18n( "Server" ) + " : " + server + "\n"; + ret += i18n( "Username" ) + " : " + user + "\n"; + ret += i18n( "Password" ) + " : " + password + "\n"; + ret += i18n( "Protocol" ) + " : " + protocol + "\n"; + ret += i18n( "Voicemail number" ) + " : " + mailbox + "\n"; } if(is_create_account) { @@ -323,8 +331,9 @@ void AccountWizard::accept() /*************************************************************************** * Class WizardIntroPage * * Widget of the introduction page of the wizard * - ***************************************************************************/ + **************************************************************************/ +///The first page WizardIntroPage::WizardIntroPage(QWidget *parent) : QWizardPage(parent) { @@ -354,34 +363,35 @@ int WizardIntroPage::nextId() const * Class WizardAccountAutoManualPage * * Page in which user choses to create an account on * * sflphone.org or register a new one. * - ***************************************************************************/ - + **************************************************************************/ +///The second page WizardAccountAutoManualPage::WizardAccountAutoManualPage(QWidget *parent) : QWizardPage(parent) { setTitle(i18n("Account")); setSubTitle(i18n("Please select one of the following options")); - radioButton_SFL = new QRadioButton(i18n("Create a free SIP/IAX2 account on sflphone.org")); + radioButton_SFL = new QRadioButton(i18n("Create a free SIP/IAX2 account on sflphone.org")); radioButton_manual = new QRadioButton(i18n("Register an existing SIP or IAX2 account")); radioButton_SFL->setChecked(true); - registerField(FIELD_SFL_ACCOUNT, radioButton_SFL); - registerField(FIELD_OTHER_ACCOUNT, radioButton_manual); + registerField( FIELD_SFL_ACCOUNT , radioButton_SFL ); + registerField( FIELD_OTHER_ACCOUNT , radioButton_manual ); QVBoxLayout *layout = new QVBoxLayout; - layout->addWidget(radioButton_SFL); - layout->addWidget(radioButton_manual); + layout->addWidget( radioButton_SFL ); + layout->addWidget( radioButton_manual ); setLayout(layout); } - +///Second page destructor WizardAccountAutoManualPage::~WizardAccountAutoManualPage() { delete radioButton_SFL; delete radioButton_manual; } +/// int WizardAccountAutoManualPage::nextId() const { if(radioButton_SFL->isChecked()) @@ -394,19 +404,19 @@ int WizardAccountAutoManualPage::nextId() const * Class WizardAccountTypePage * * Page in which user choses between SIP and IAX account. * ***************************************************************************/ - +///The third page WizardAccountTypePage::WizardAccountTypePage(QWidget *parent) : QWizardPage(parent) { - setTitle(i18n("VoIP Protocols")); - setSubTitle(i18n("Select an account type")); + setTitle ( i18n("VoIP Protocols" )); + setSubTitle ( i18n("Select an account type" )); - radioButton_SIP = new QRadioButton(i18n("SIP (Session Initiation Protocol)")); - radioButton_IAX = new QRadioButton(i18n("IAX2 (InterAsterix Exchange)")); + radioButton_SIP = new QRadioButton(i18n("SIP (Session Initiation Protocol)" )); + radioButton_IAX = new QRadioButton(i18n("IAX2 (InterAsterix Exchange)" )); radioButton_SIP->setChecked(true); - registerField(FIELD_SIP_ACCOUNT, radioButton_SIP); - registerField(FIELD_IAX_ACCOUNT, radioButton_IAX); + registerField( FIELD_SIP_ACCOUNT, radioButton_SIP ); + registerField( FIELD_IAX_ACCOUNT, radioButton_IAX ); QVBoxLayout *layout = new QVBoxLayout; layout->addWidget(radioButton_SIP); @@ -414,13 +424,14 @@ WizardAccountTypePage::WizardAccountTypePage(QWidget *parent) setLayout(layout); } - +///Third page destructor WizardAccountTypePage::~WizardAccountTypePage() { delete radioButton_SIP; delete radioButton_IAX; } +/// int WizardAccountTypePage::nextId() const { if(radioButton_SIP->isChecked()) @@ -432,33 +443,34 @@ int WizardAccountTypePage::nextId() const /*************************************************************************** * Class WizardAccountEmailAddressPage * * Page in which user choses between SIP and IAX account. * - ***************************************************************************/ + **************************************************************************/ +///Set your email address WizardAccountEmailAddressPage::WizardAccountEmailAddressPage(QWidget *parent) : QWizardPage(parent) { setTitle(i18n("Optional email address")); setSubTitle(i18n("This email address will be used to send your voicemail messages.")); - label_emailAddress = new QLabel(i18n("Email address")); + label_emailAddress = new QLabel(i18n("Email address")); lineEdit_emailAddress = new QLineEdit(); - label_enableZrtp = new QLabel(i18n("Secure with ZRTP")); - checkBox_enableZrtp = new QCheckBox(); + label_enableZrtp = new QLabel(i18n("Secure with ZRTP")); + checkBox_enableZrtp = new QCheckBox(); - registerField(FIELD_EMAIL_ADDRESS, lineEdit_emailAddress); - registerField(FIELD_ZRTP_ENABLED, checkBox_enableZrtp); + registerField( FIELD_EMAIL_ADDRESS , lineEdit_emailAddress ); + registerField( FIELD_ZRTP_ENABLED , checkBox_enableZrtp ); QFormLayout *layout = new QFormLayout; - layout->setWidget(0, QFormLayout::LabelRole, label_emailAddress); - layout->setWidget(0, QFormLayout::FieldRole, lineEdit_emailAddress); - layout->setWidget(1, QFormLayout::LabelRole, label_enableZrtp); - layout->setWidget(1, QFormLayout::FieldRole, checkBox_enableZrtp); + layout->setWidget(0 , QFormLayout::LabelRole , label_emailAddress ); + layout->setWidget(0 , QFormLayout::FieldRole , lineEdit_emailAddress ); + layout->setWidget(1 , QFormLayout::LabelRole , label_enableZrtp ); + layout->setWidget(1 , QFormLayout::FieldRole , checkBox_enableZrtp ); setLayout(layout); } - +///Email page destructor WizardAccountEmailAddressPage::~WizardAccountEmailAddressPage() { delete label_emailAddress; @@ -467,6 +479,7 @@ WizardAccountEmailAddressPage::~WizardAccountEmailAddressPage() delete checkBox_enableZrtp; } +/// int WizardAccountEmailAddressPage::nextId() const { return AccountWizard::Page_Stun; @@ -475,7 +488,7 @@ int WizardAccountEmailAddressPage::nextId() const /*************************************************************************** * Class WizardAccountFormPage * * Page of account settings. * - ***************************************************************************/ + **************************************************************************/ WizardAccountSIPFormPage::WizardAccountSIPFormPage(QWidget *parent) : QWizardPage(parent) @@ -483,44 +496,44 @@ WizardAccountSIPFormPage::WizardAccountSIPFormPage(QWidget *parent) setTitle(i18n("SIP account settings")); setSubTitle(i18n("Please fill the following information")); - label_alias = new QLabel(i18n("Alias") + " *"); - label_server = new QLabel(i18n("Server") + " *"); - label_user = new QLabel(i18n("Username") + " *"); - label_password = new QLabel(i18n("Password") + " *"); - label_voicemail = new QLabel(i18n("Voicemail number")); - label_enableZrtp = new QLabel(i18n("Secure with ZRTP")); - - lineEdit_alias = new QLineEdit; - lineEdit_server = new QLineEdit; - lineEdit_user = new QLineEdit; - lineEdit_password = new QLineEdit; - lineEdit_voicemail = new QLineEdit; + label_alias = new QLabel( i18n( "Alias" ) + " *" ); + label_server = new QLabel( i18n( "Server" ) + " *" ); + label_user = new QLabel( i18n( "Username" ) + " *" ); + label_password = new QLabel( i18n( "Password" ) + " *" ); + label_voicemail = new QLabel( i18n( "Voicemail number" ) ); + label_enableZrtp = new QLabel( i18n( "Secure with ZRTP" ) ); + + lineEdit_alias = new QLineEdit; + lineEdit_server = new QLineEdit; + lineEdit_user = new QLineEdit; + lineEdit_password = new QLineEdit; + lineEdit_voicemail = new QLineEdit; checkBox_enableZrtp = new QCheckBox; lineEdit_password->setEchoMode(QLineEdit::Password); - registerField(QString(FIELD_SIP_ALIAS) + "*", lineEdit_alias); - registerField(QString(FIELD_SIP_SERVER) + "*", lineEdit_server); - registerField(QString(FIELD_SIP_USER) + "*", lineEdit_user); - registerField(QString(FIELD_SIP_PASSWORD) + "*", lineEdit_password); - registerField(QString(FIELD_SIP_VOICEMAIL), lineEdit_voicemail); - registerField(QString(FIELD_ZRTP_ENABLED), checkBox_enableZrtp); + registerField(QString( FIELD_SIP_ALIAS) + "*" , lineEdit_alias ); + registerField(QString( FIELD_SIP_SERVER) + "*" , lineEdit_server ); + registerField(QString( FIELD_SIP_USER) + "*" , lineEdit_user ); + registerField(QString( FIELD_SIP_PASSWORD) + "*" , lineEdit_password ); + registerField(QString( FIELD_SIP_VOICEMAIL) , lineEdit_voicemail ); + registerField(QString( FIELD_ZRTP_ENABLED) , checkBox_enableZrtp ); QFormLayout *layout = new QFormLayout; - layout->setWidget(0, QFormLayout::LabelRole, label_alias); - layout->setWidget(0, QFormLayout::FieldRole, lineEdit_alias); - layout->setWidget(1, QFormLayout::LabelRole, label_server); - layout->setWidget(1, QFormLayout::FieldRole, lineEdit_server); - layout->setWidget(2, QFormLayout::LabelRole, label_user); - layout->setWidget(2, QFormLayout::FieldRole, lineEdit_user); - layout->setWidget(3, QFormLayout::LabelRole, label_password); - layout->setWidget(3, QFormLayout::FieldRole, lineEdit_password); - layout->setWidget(4, QFormLayout::LabelRole, label_voicemail); - layout->setWidget(4, QFormLayout::FieldRole, lineEdit_voicemail); - layout->setWidget(5, QFormLayout::LabelRole, label_enableZrtp); - layout->setWidget(5, QFormLayout::FieldRole, checkBox_enableZrtp); + layout->setWidget( 0, QFormLayout::LabelRole , label_alias ); + layout->setWidget( 0, QFormLayout::FieldRole , lineEdit_alias ); + layout->setWidget( 1, QFormLayout::LabelRole , label_server ); + layout->setWidget( 1, QFormLayout::FieldRole , lineEdit_server ); + layout->setWidget( 2, QFormLayout::LabelRole , label_user ); + layout->setWidget( 2, QFormLayout::FieldRole , lineEdit_user ); + layout->setWidget( 3, QFormLayout::LabelRole , label_password ); + layout->setWidget( 3, QFormLayout::FieldRole , lineEdit_password ); + layout->setWidget( 4, QFormLayout::LabelRole , label_voicemail ); + layout->setWidget( 4, QFormLayout::FieldRole , lineEdit_voicemail ); + layout->setWidget( 5, QFormLayout::LabelRole , label_enableZrtp ); + layout->setWidget( 5, QFormLayout::FieldRole , checkBox_enableZrtp ); setLayout(layout); } @@ -558,38 +571,38 @@ WizardAccountIAXFormPage::WizardAccountIAXFormPage(QWidget *parent) setTitle(i18n("IAX2 account settings")); setSubTitle(i18n("Please fill the following information")); - label_alias = new QLabel(i18n("Alias") + " *"); - label_server = new QLabel(i18n("Server") + " *"); - label_user = new QLabel(i18n("Username") + " *"); - label_password = new QLabel(i18n("Password") + " *"); - label_voicemail = new QLabel(i18n("Voicemail number")); + label_alias = new QLabel(i18n("Alias") + " *" ); + label_server = new QLabel(i18n("Server") + " *" ); + label_user = new QLabel(i18n("Username") + " *" ); + label_password = new QLabel(i18n("Password") + " *" ); + label_voicemail = new QLabel(i18n("Voicemail number" )); - lineEdit_alias = new QLineEdit; - lineEdit_server = new QLineEdit; - lineEdit_user = new QLineEdit; - lineEdit_password = new QLineEdit; + lineEdit_alias = new QLineEdit; + lineEdit_server = new QLineEdit; + lineEdit_user = new QLineEdit; + lineEdit_password = new QLineEdit; lineEdit_voicemail = new QLineEdit; lineEdit_password->setEchoMode(QLineEdit::Password); - registerField(QString(FIELD_IAX_ALIAS) + "*", lineEdit_alias); - registerField(QString(FIELD_IAX_SERVER) + "*", lineEdit_server); - registerField(QString(FIELD_IAX_USER) + "*", lineEdit_user); - registerField(QString(FIELD_IAX_PASSWORD) + "*", lineEdit_password); - registerField(QString(FIELD_IAX_VOICEMAIL), lineEdit_voicemail); + registerField( QString( FIELD_IAX_ALIAS ) + "*", lineEdit_alias ); + registerField( QString( FIELD_IAX_SERVER ) + "*", lineEdit_server ); + registerField( QString( FIELD_IAX_USER ) + "*", lineEdit_user ); + registerField( QString( FIELD_IAX_PASSWORD ) + "*", lineEdit_password ); + registerField( QString( FIELD_IAX_VOICEMAIL ) , lineEdit_voicemail ); QFormLayout *layout = new QFormLayout; - layout->setWidget(0, QFormLayout::LabelRole, label_alias); - layout->setWidget(0, QFormLayout::FieldRole, lineEdit_alias); - layout->setWidget(1, QFormLayout::LabelRole, label_server); - layout->setWidget(1, QFormLayout::FieldRole, lineEdit_server); - layout->setWidget(2, QFormLayout::LabelRole, label_user); - layout->setWidget(2, QFormLayout::FieldRole, lineEdit_user); - layout->setWidget(3, QFormLayout::LabelRole, label_password); - layout->setWidget(3, QFormLayout::FieldRole, lineEdit_password); - layout->setWidget(4, QFormLayout::LabelRole, label_voicemail); - layout->setWidget(4, QFormLayout::FieldRole, lineEdit_voicemail); + layout->setWidget( 0 , QFormLayout::LabelRole , label_alias ); + layout->setWidget( 0 , QFormLayout::FieldRole , lineEdit_alias ); + layout->setWidget( 1 , QFormLayout::LabelRole , label_server ); + layout->setWidget( 1 , QFormLayout::FieldRole , lineEdit_server ); + layout->setWidget( 2 , QFormLayout::LabelRole , label_user ); + layout->setWidget( 2 , QFormLayout::FieldRole , lineEdit_user ); + layout->setWidget( 3 , QFormLayout::LabelRole , label_password ); + layout->setWidget( 3 , QFormLayout::FieldRole , lineEdit_password ); + layout->setWidget( 4 , QFormLayout::LabelRole , label_voicemail ); + layout->setWidget( 4 , QFormLayout::FieldRole , lineEdit_voicemail ); setLayout(layout); } @@ -626,20 +639,20 @@ WizardAccountStunPage::WizardAccountStunPage(QWidget *parent) setSubTitle(i18n("You should probably enable this if you are behind a firewall.")); checkBox_enableStun = new QCheckBox(i18n("Enable STUN")); - label_StunServer = new QLabel(i18n("Stun Server")); + label_StunServer = new QLabel(i18n("Stun Server")); lineEdit_StunServer = new QLineEdit(); - lineEdit_StunServer->setDisabled(true); + lineEdit_StunServer->setDisabled(true); registerField(FIELD_SIP_ENABLE_STUN, checkBox_enableStun); registerField(FIELD_SIP_STUN_SERVER, lineEdit_StunServer); QFormLayout *layout = new QFormLayout; - layout->addWidget(checkBox_enableStun); - layout->addWidget(label_StunServer); - layout->addWidget(lineEdit_StunServer); + layout->addWidget( checkBox_enableStun ); + layout->addWidget( label_StunServer ); + layout->addWidget( lineEdit_StunServer ); setLayout(layout); - connect(checkBox_enableStun, SIGNAL(toggled(bool)), lineEdit_StunServer, SLOT(setEnabled(bool))); + connect(checkBox_enableStun, SIGNAL(toggled(bool)), lineEdit_StunServer, SLOT(setEnabled(bool))); } diff --git a/kde/src/AccountWizard.h b/kde/src/AccountWizard.h index 8700099317c7b628e0d2d3a45eaa01a2f4367996..f1671b7fdb5c8249194189821f42c79cba62aa4c 100755 --- a/kde/src/AccountWizard.h +++ b/kde/src/AccountWizard.h @@ -22,11 +22,12 @@ #define ACCOUNTWIZARD_H #include <QWizard> -#include <QLabel> -#include <QRadioButton> -#include <QLineEdit> -#include <QCheckBox> +//Qt +class QLabel; +class QRadioButton; +class QLineEdit; +class QCheckBox; /** @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> diff --git a/kde/src/AkonadiBackend.cpp b/kde/src/AkonadiBackend.cpp index 6620e089bd3fc936bc5b494e641ac4e0af8c9daa..5b37a36c45add53b63aa49d1591a069614294ff1 100644 --- a/kde/src/AkonadiBackend.cpp +++ b/kde/src/AkonadiBackend.cpp @@ -2,7 +2,6 @@ #include <QtCore/QTimer> #include <akonadi/control.h> #include <akonadi/collectionfilterproxymodel.h> -#include <akonadi/collectionmodel.h> #include <akonadi/kmime/messagemodel.h> #include <kabc/contactgroup.h> #include <kabc/phonenumber.h> @@ -13,27 +12,37 @@ #include <akonadi/contact/contacteditor.h> #include <kdialog.h> +#include <QObject> +#include <akonadi/session.h> +#include <kabc/addressee.h> +#include <kabc/addresseelist.h> + #include "lib/Contact.h" #include "SFLPhone.h" +#include "SFLPhoneView.h" +///Init static attributes AkonadiBackend* AkonadiBackend::m_pInstance = 0; +///Constructor AkonadiBackend::AkonadiBackend(QObject* parent) : ContactBackend(parent) { //QTimer::singleShot( 0, this, SLOT( delayedInit() ) ); m_pSession = new Akonadi::Session( "SFLPhone::instance" ); - // fetching all collections containing emails recursively, starting at the root collection + // fetching all collections containing emails recursively, starting at the root collection Akonadi::CollectionFetchJob *job = new Akonadi::CollectionFetchJob( Akonadi::Collection::root(), Akonadi::CollectionFetchJob::Recursive, this ); job->fetchScope().setContentMimeTypes( QStringList() << "text/directory" ); connect( job, SIGNAL( collectionsReceived( const Akonadi::Collection::List& ) ), this, SLOT( collectionsReceived( const Akonadi::Collection::List& ) ) ); } +///Destructor AkonadiBackend::~AkonadiBackend() { } +///Singleton ContactBackend* AkonadiBackend::getInstance() { if (m_pInstance == NULL) { @@ -42,6 +51,7 @@ ContactBackend* AkonadiBackend::getInstance() return m_pInstance; } +///Update the contact list when a new Akonadi collection is added ContactList AkonadiBackend::update(Akonadi::Collection collection) { m_pCollection = collection; @@ -95,22 +105,25 @@ ContactList AkonadiBackend::update(Akonadi::Collection collection) return contacts; } +///Update the contact list even without a new collection ContactList AkonadiBackend::update_slot() { return update(m_pCollection); } - +///Find contact using a phone number Contact* AkonadiBackend::getContactByPhone(QString phoneNumber) { return m_pContactByPhone[phoneNumber]; } +///Find contact by UID Contact* AkonadiBackend::getContactByUid(QString uid) { return m_pContactByUid[uid]; } +///Called when a new collection is added void AkonadiBackend::collectionsReceived( const Akonadi::Collection::List& list) { foreach (Akonadi::Collection coll, list) { @@ -119,6 +132,7 @@ void AkonadiBackend::collectionsReceived( const Akonadi::Collection::List& list } } +///Edit backend value using an updated frontend contact void AkonadiBackend::editContact(Contact* contact) { KABC::Addressee ct = m_pAddrHash[contact->getUid()]; @@ -135,6 +149,7 @@ void AkonadiBackend::editContact(Contact* contact) dlg->exec(); } +///Add a new contact void AkonadiBackend::addNewContact(Contact* contact) { KABC::Addressee newContact; @@ -177,8 +192,6 @@ void AkonadiBackend::addNewContact(Contact* contact) dlg->setMainWidget(editor); dlg->exec(); - - if ( !editor->saveContact() ) { qDebug() << "Unable to save new contact to storage"; return; diff --git a/kde/src/AkonadiBackend.h b/kde/src/AkonadiBackend.h index cc2ddb4a24e8f51337fbc9b1ec8dfb663c8f7abb..fdc97e6305c1603608f0002bde74d953c3a4bac3 100644 --- a/kde/src/AkonadiBackend.h +++ b/kde/src/AkonadiBackend.h @@ -1,19 +1,27 @@ #ifndef AKONADI_BACKEND_H #define AKONADI_BACKEND_H -#include <QObject> -#include <akonadi/session.h> -#include <akonadi/collectionmodel.h> -#include <kabc/addressee.h> -#include <kabc/addresseelist.h> #include <lib/ContactBackend.h> +#include <akonadi/collectionmodel.h> -class Contact; +//Qt +class QObject; +//KDE namespace KABC { class Addressee; + class AddresseeList; } +namespace Akonadi { + class Session; + class CollectionModel; + class Collection; +} + +//SFLPhone +class Contact; + typedef QList<Contact*> ContactList; class AkonadiBackend : public ContactBackend { diff --git a/kde/src/CallView.cpp b/kde/src/CallView.cpp index e6d15d7ff8c52cc0313c5505b49ee96456c46e08..a68334add497e93d72e4b47bf83267878a988bad 100644 --- a/kde/src/CallView.cpp +++ b/kde/src/CallView.cpp @@ -1,17 +1,20 @@ #include "CallView.h" #include "AkonadiBackend.h" #include "lib/Contact.h" +#include "lib/sflphone_const.h" +#include "lib/callmanager_interface_singleton.h" +#include "widgets/CallTreeItem.h" + +#include "SFLPhone.h" +#include "SFLPhoneView.h" #include <QtGui/QInputDialog> +#include <QtGui/QTreeWidget> +#include <QtGui/QTreeWidgetItem> ///Retrieve current and older calls from the daemon, fill history and the calls TreeView and enable drag n' drop -CallView::CallView(QWidget* parent, ModelType type) : QTreeWidget(parent), TreeWidgetCallModel(type) +CallView::CallView(QWidget* parent) : QTreeWidget(parent) { - if (type == ActiveCall) - initCall(); - else if (type == History) - initHistory(); - //Widget part setAcceptDrops(true); setDragEnabled(true); @@ -20,8 +23,13 @@ CallView::CallView(QWidget* parent, ModelType type) : QTreeWidget(parent), TreeW setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding)); //User Interface events - connect(this, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*,int))); - connect(this, SIGNAL(itemClicked(QTreeWidgetItem*,int)), this, SLOT(itemClicked(QTreeWidgetItem*,int))); + connect(this , SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int) ) , this, SLOT( itemDoubleClicked(QTreeWidgetItem*,int)) ); + connect(this , SIGNAL(itemClicked(QTreeWidgetItem*,int) ) , this, SLOT( itemClicked(QTreeWidgetItem*,int)) ); + connect(SFLPhone::model() , SIGNAL(conferenceCreated(Call*) ) , this, SLOT( addConference(Call*)) ); + connect(SFLPhone::model() , SIGNAL(conferenceChanged(Call*) ) , this, SLOT( conferenceChanged(Call*)) ); + connect(SFLPhone::model() , SIGNAL(aboutToRemoveConference(Call*) ) , this, SLOT( conferenceRemoved(Call*)) ); + connect(SFLPhone::model() , SIGNAL(callAdded(Call*,Call*) ) , this, SLOT( addCall(Call*,Call*)) ); + } @@ -37,38 +45,39 @@ bool CallView::callToCall(QTreeWidgetItem *parent, int index, const QMimeData *d Q_UNUSED(action) QByteArray encodedCallId = data->data( MIME_CALLID ); if (!QString(encodedCallId).isEmpty()) { - clearArtefact(getIndex(encodedCallId)); + if (SFLPhone::model()->getIndex(encodedCallId)) + clearArtefact(SFLPhone::model()->getIndex(encodedCallId)); if (!parent) { qDebug() << "Call dropped on empty space"; - if (getIndex(encodedCallId)->parent()) { + if (SFLPhone::model()->getIndex(encodedCallId)->parent()) { qDebug() << "Detaching participant"; - detachParticipant(getCall(encodedCallId)); + SFLPhone::model()->detachParticipant(SFLPhone::model()->getCall(encodedCallId)); } else qDebug() << "The call is not in a conversation (doing nothing)"; return true; } - if (getCall(parent)->getCallId() == QString(encodedCallId)) { + if (SFLPhone::model()->getCall(parent)->getCallId() == QString(encodedCallId)) { qDebug() << "Call dropped on itself (doing nothing)"; return true; } - if ((parent->childCount()) && (getIndex(encodedCallId)->childCount())) { + if ((parent->childCount()) && (SFLPhone::model()->getIndex(encodedCallId)->childCount())) { qDebug() << "Merging two conferences"; - mergeConferences(getCall(parent),getCall(encodedCallId)); + SFLPhone::model()->mergeConferences(SFLPhone::model()->getCall(parent),SFLPhone::model()->getCall(encodedCallId)); return true; } else if ((parent->parent()) || (parent->childCount())) { qDebug() << "Call dropped on a conference"; - if ((getIndex(encodedCallId)->childCount()) && (!parent->childCount())) { + if ((SFLPhone::model()->getIndex(encodedCallId)->childCount()) && (!parent->childCount())) { qDebug() << "Conference dropped on a call (doing nothing)"; return true; } - QTreeWidgetItem* call1 = getIndex(encodedCallId); + QTreeWidgetItem* call1 = SFLPhone::model()->getIndex(encodedCallId); QTreeWidgetItem* call2 = (parent->parent())?parent->parent():parent; if (call1->parent()) { @@ -77,28 +86,28 @@ bool CallView::callToCall(QTreeWidgetItem *parent, int index, const QMimeData *d qDebug() << "Call dropped on it's own conference (doing nothing)"; return true; } - else if (getIndex(call1)->childCount()) { + else if (SFLPhone::model()->getIndex(call1)->childCount()) { qDebug() << "Merging two conferences"; - mergeConferences(getCall(call1),getCall(call2)); + SFLPhone::model()->mergeConferences(SFLPhone::model()->getCall(call1),SFLPhone::model()->getCall(call2)); } else if (call1->parent()) { qDebug() << "Moving call from a conference to an other"; - detachParticipant(getCall(encodedCallId)); + SFLPhone::model()->detachParticipant(SFLPhone::model()->getCall(encodedCallId)); } } qDebug() << "Adding participant"; - int state = getCall(call1)->getState(); + int state = SFLPhone::model()->getCall(call1)->getState(); if(state == CALL_STATE_INCOMING || state == CALL_STATE_DIALING || state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD) { - getCall(call1)->actionPerformed(CALL_ACTION_ACCEPT); + SFLPhone::model()->getCall(call1)->actionPerformed(CALL_ACTION_ACCEPT); } - state = getCall(call2)->getState(); + state = SFLPhone::model()->getCall(call2)->getState(); if(state == CALL_STATE_INCOMING || state == CALL_STATE_DIALING || state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD) { - getCall(call2)->actionPerformed(CALL_ACTION_ACCEPT); + SFLPhone::model()->getCall(call2)->actionPerformed(CALL_ACTION_ACCEPT); } - addParticipant(getCall(call1),getCall(call2)); + SFLPhone::model()->addParticipant(SFLPhone::model()->getCall(call1),SFLPhone::model()->getCall(call2)); return true; } - else if ((getIndex(encodedCallId)->childCount()) && (!parent->childCount())) { + else if ((SFLPhone::model()->getIndex(encodedCallId)->childCount()) && (!parent->childCount())) { qDebug() << "Call dropped on it's own conference (doing nothing)"; return true; } @@ -106,7 +115,7 @@ bool CallView::callToCall(QTreeWidgetItem *parent, int index, const QMimeData *d qDebug() << "Call dropped on another call"; - createConferenceFromCall(getCall(encodedCallId),getCall(parent)); + SFLPhone::model()->createConferenceFromCall(SFLPhone::model()->getCall(encodedCallId),SFLPhone::model()->getCall(parent)); return true; } return false; @@ -124,7 +133,7 @@ bool CallView::phoneNumberToCall(QTreeWidgetItem *parent, int index, const QMime name = contact->getFormattedName(); else name = "Unknow"; - Call* call2 = TreeWidgetCallModel::addDialingCall(name, TreeWidgetCallModel::getCurrentAccountId()); + Call* call2 = SFLPhone::model()->addDialingCall(name, SFLPhone::model()->getCurrentAccountId()); call2->appendText(QString(encodedPhoneNumber)); if (!parent) { //Dropped on free space @@ -133,16 +142,16 @@ bool CallView::phoneNumberToCall(QTreeWidgetItem *parent, int index, const QMime else if (parent->childCount() || parent->parent()) { //Dropped on a conversation QTreeWidgetItem* call = (parent->parent())?parent->parent():parent; - addParticipant(getCall(call),call2); + SFLPhone::model()->addParticipant(SFLPhone::model()->getCall(call),call2); } else { //Dropped on call call2->actionPerformed(CALL_ACTION_ACCEPT); - int state = getCall(parent)->getState(); + int state = SFLPhone::model()->getCall(parent)->getState(); if(state == CALL_STATE_INCOMING || state == CALL_STATE_DIALING || state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD) { - getCall(parent)->actionPerformed(CALL_ACTION_ACCEPT); + SFLPhone::model()->getCall(parent)->actionPerformed(CALL_ACTION_ACCEPT); } - createConferenceFromCall(call2,getCall(parent)); + SFLPhone::model()->createConferenceFromCall(call2,SFLPhone::model()->getCall(parent)); } } return false; @@ -151,15 +160,15 @@ bool CallView::phoneNumberToCall(QTreeWidgetItem *parent, int index, const QMime bool CallView::contactToCall(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action) { qDebug() << "contactToCall"; - Q_UNUSED(index) - Q_UNUSED(action) + Q_UNUSED( index ) + Q_UNUSED( action ) QByteArray encodedContact = data->data( MIME_CONTACT ); if (!QString(encodedContact).isEmpty()) { Contact* contact = AkonadiBackend::getInstance()->getContactByUid(encodedContact); if (contact) { Call* call2; if (contact->getPhoneNumbers().count() == 1) { - call2 = TreeWidgetCallModel::addDialingCall(contact->getFormattedName(), TreeWidgetCallModel::getCurrentAccountId()); + call2 = SFLPhone::model()->addDialingCall(contact->getFormattedName(), SFLPhone::model()->getCurrentAccountId()); call2->appendText(contact->getPhoneNumbers()[0]->getNumber()); } else if (contact->getPhoneNumbers().count() > 1) { @@ -172,7 +181,7 @@ bool CallView::contactToCall(QTreeWidgetItem *parent, int index, const QMimeData } QString result = QInputDialog::getItem (this, QString("Select phone number"), QString("This contact have many phone number, please select the one you wish to call"), list, 0, false, &ok); if (ok) { - call2 = TreeWidgetCallModel::addDialingCall(contact->getFormattedName(), TreeWidgetCallModel::getCurrentAccountId()); + call2 = SFLPhone::model()->addDialingCall(contact->getFormattedName(), SFLPhone::model()->getCurrentAccountId()); call2->appendText(map[result]); } else { @@ -191,16 +200,16 @@ bool CallView::contactToCall(QTreeWidgetItem *parent, int index, const QMimeData else if (parent->childCount() || parent->parent()) { //Dropped on a conversation QTreeWidgetItem* call = (parent->parent())?parent->parent():parent; - addParticipant(getCall(call),call2); + SFLPhone::model()->addParticipant(SFLPhone::model()->getCall(call),call2); } else { //Dropped on call call2->actionPerformed(CALL_ACTION_ACCEPT); - int state = getCall(parent)->getState(); + int state = SFLPhone::model()->getCall(parent)->getState(); if(state == CALL_STATE_INCOMING || state == CALL_STATE_DIALING || state == CALL_STATE_TRANSFER || state == CALL_STATE_TRANSF_HOLD) { - getCall(parent)->actionPerformed(CALL_ACTION_ACCEPT); + SFLPhone::model()->getCall(parent)->actionPerformed(CALL_ACTION_ACCEPT); } - createConferenceFromCall(call2,getCall(parent)); + SFLPhone::model()->createConferenceFromCall(call2,SFLPhone::model()->getCall(parent)); } } } @@ -243,18 +252,18 @@ QMimeData* CallView::mimeData( const QList<QTreeWidgetItem *> items) const QMimeData *mimeData = new QMimeData(); //Call ID for internal call merging and spliting - if (getCall(items[0])->isConference()) { - mimeData->setData(MIME_CALLID, getCall(items[0])->getConfId().toAscii()); + if (SFLPhone::model()->getCall(items[0])->isConference()) { + mimeData->setData(MIME_CALLID, SFLPhone::model()->getCall(items[0])->getConfId().toAscii()); } else { - mimeData->setData(MIME_CALLID, getCall(items[0])->getCallId().toAscii()); + mimeData->setData(MIME_CALLID, SFLPhone::model()->getCall(items[0])->getCallId().toAscii()); } //Plain text for other applications - mimeData->setData(MIME_PLAIN_TEXT, QString(getCall(items[0])->getPeerName()+"\n"+getCall(items[0])->getPeerPhoneNumber()).toAscii()); + mimeData->setData(MIME_PLAIN_TEXT, QString(SFLPhone::model()->getCall(items[0])->getPeerName()+"\n"+SFLPhone::model()->getCall(items[0])->getPeerPhoneNumber()).toAscii()); //TODO Comment this line if you don't want to see ugly artefact, but the caller details will not be visible while dragged - items[0]->setText(0, getCall(items[0])->getPeerName() + "\n" + getCall(items[0])->getPeerPhoneNumber()); + items[0]->setText(0, SFLPhone::model()->getCall(items[0])->getPeerName() + "\n" + SFLPhone::model()->getCall(items[0])->getPeerPhoneNumber()); return mimeData; } @@ -269,7 +278,7 @@ QMimeData* CallView::mimeData( const QList<QTreeWidgetItem *> items) const Call* CallView::addCall(Call* call, Call* parent) { QTreeWidgetItem* callItem = new QTreeWidgetItem(); - updateIndex(call,callItem); + SFLPhone::model()->updateIndex(call,callItem); insertItem(callItem,parent); setCurrentItem(callItem); @@ -293,8 +302,8 @@ void CallView::setTitle(QString title) ///Select an item in the TreeView bool CallView::selectItem(Call* item) { - if (getIndex(item)) { - setCurrentItem(getIndex(item)); + if (SFLPhone::model()->getIndex(item)) { + setCurrentItem(SFLPhone::model()->getIndex(item)); return true; } else @@ -304,8 +313,8 @@ bool CallView::selectItem(Call* item) ///Return the current item Call* CallView::getCurrentItem() { - if (currentItem() && getCall(QTreeWidget::currentItem())) - return getCall(QTreeWidget::currentItem()); + if (currentItem() && SFLPhone::model()->getCall(QTreeWidget::currentItem())) + return SFLPhone::model()->getCall(QTreeWidget::currentItem()); else return false; } @@ -313,8 +322,8 @@ Call* CallView::getCurrentItem() ///Remove a TreeView item and delete it bool CallView::removeItem(Call* item) { - if (indexOfTopLevelItem(getIndex(item)) != -1) {//TODO To remove once safe - removeItemWidget(getIndex(item),0); + if (indexOfTopLevelItem(SFLPhone::model()->getIndex(item)) != -1) {//TODO To remove once safe + removeItemWidget(SFLPhone::model()->getIndex(item),0); return true; } else @@ -330,7 +339,7 @@ QWidget* CallView::getWidget() ///Convenience wrapper around extractItem(QTreeWidgetItem*) QTreeWidgetItem* CallView::extractItem(QString callId) { - QTreeWidgetItem* currentItem = getIndex(callId); + QTreeWidgetItem* currentItem = SFLPhone::model()->getIndex(callId); return extractItem(currentItem); } @@ -356,7 +365,7 @@ QTreeWidgetItem* CallView::extractItem(QTreeWidgetItem* item) ///Convenience wrapper around insertItem(QTreeWidgetItem*, QTreeWidgetItem*) CallTreeItem* CallView::insertItem(QTreeWidgetItem* item, Call* parent) { - return insertItem(item,(parent)?getIndex(parent):0); + return insertItem(item,(parent)?SFLPhone::model()->getIndex(parent):0); } ///Insert a TreeView item in the TreeView as child of parent or as a top level item, also restore the item Widget @@ -373,8 +382,8 @@ CallTreeItem* CallView::insertItem(QTreeWidgetItem* item, QTreeWidgetItem* paren parent->addChild(item); CallTreeItem* callItem = new CallTreeItem(); - updateWidget(getCall(item), callItem); - callItem->setCall(getCall(item)); + SFLPhone::model()->updateWidget(SFLPhone::model()->getCall(item), callItem); + callItem->setCall(SFLPhone::model()->getCall(item)); setItemWidget(item,0,callItem); @@ -385,15 +394,15 @@ CallTreeItem* CallView::insertItem(QTreeWidgetItem* item, QTreeWidgetItem* paren ///Remove a call from the interface void CallView::destroyCall(Call* toDestroy) { - if (getIndex(toDestroy) == currentItem()) + if (SFLPhone::model()->getIndex(toDestroy) == currentItem()) setCurrentItem(0); - if (!getIndex(toDestroy)) + if (!SFLPhone::model()->getIndex(toDestroy)) qDebug() << "Call not found"; - else if (indexOfTopLevelItem(getIndex(toDestroy)) != -1) - takeTopLevelItem(indexOfTopLevelItem(getIndex(toDestroy))); - else if (getIndex(toDestroy)->parent()) //May crash here - getIndex(toDestroy)->parent()->removeChild(getIndex(toDestroy)); + else if (indexOfTopLevelItem(SFLPhone::model()->getIndex(toDestroy)) != -1) + takeTopLevelItem(indexOfTopLevelItem(SFLPhone::model()->getIndex(toDestroy))); + else if (SFLPhone::model()->getIndex(toDestroy)->parent()) //May crash here + SFLPhone::model()->getIndex(toDestroy)->parent()->removeChild(SFLPhone::model()->getIndex(toDestroy)); else qDebug() << "Call not found"; } @@ -401,7 +410,8 @@ void CallView::destroyCall(Call* toDestroy) /// @todo Remove the text partially covering the TreeView item widget when it is being dragged, a beter implementation is needed void CallView::clearArtefact(QTreeWidgetItem* item) { - item->setText(0,""); + if (item) + item->setText(0,""); } @@ -413,13 +423,16 @@ void CallView::clearArtefact(QTreeWidgetItem* item) void CallView::itemDoubleClicked(QTreeWidgetItem* item, int column) { Q_UNUSED(column) - qDebug() << "Item doubleclicked"; - switch(getCall(item)->getState()) { + qDebug() << "Item doubleclicked" << SFLPhone::model()->getCall(item)->getState(); + switch(SFLPhone::model()->getCall(item)->getState()) { + case CALL_STATE_INCOMING: + SFLPhone::model()->getCall(item)->actionPerformed(CALL_ACTION_ACCEPT); + break; case CALL_STATE_HOLD: - getCall(item)->actionPerformed(CALL_ACTION_HOLD); + SFLPhone::model()->getCall(item)->actionPerformed(CALL_ACTION_HOLD); break; case CALL_STATE_DIALING: - getCall(item)->actionPerformed(CALL_ACTION_ACCEPT); + SFLPhone::model()->getCall(item)->actionPerformed(CALL_ACTION_ACCEPT); break; default: qDebug() << "Double clicked an item with no action on double click."; @@ -428,7 +441,7 @@ void CallView::itemDoubleClicked(QTreeWidgetItem* item, int column) { void CallView::itemClicked(QTreeWidgetItem* item, int column) { Q_UNUSED(column) - emit itemChanged(getCall(item)); + emit itemChanged(SFLPhone::model()->getCall(item)); qDebug() << "Item clicked"; } @@ -440,13 +453,13 @@ void CallView::itemClicked(QTreeWidgetItem* item, int column) { ****************************************************************************/ ///Add a new conference, get the call list and update the interface as needed -Call* CallView::addConference(const QString & confID) +Call* CallView::addConference(Call* conf) { qDebug() << "Conference created"; - Call* newConf = TreeWidgetCallModel::addConference(confID); + Call* newConf = conf;//SFLPhone::model()->addConference(confID);//TODO ELV? QTreeWidgetItem* confItem = new QTreeWidgetItem(); - updateIndex(newConf,confItem); + SFLPhone::model()->updateIndex(conf,confItem); insertItem(confItem,(QTreeWidgetItem*)0); @@ -454,11 +467,11 @@ Call* CallView::addConference(const QString & confID) setCurrentItem(confItem); CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); - QStringList callList = callManager.getParticipantList(confID); + QStringList callList = callManager.getParticipantList(conf->getConfId()); foreach (QString callId, callList) { qDebug() << "Adding " << callId << "to the conversation"; - insertItem(extractItem(getIndex(callId)),confItem); + insertItem(extractItem(SFLPhone::model()->getIndex(callId)),confItem); } Q_ASSERT_X(confItem->childCount() == 0, "add conference","Conference created, but without any participants"); @@ -466,79 +479,61 @@ Call* CallView::addConference(const QString & confID) } ///Executed when the daemon signal a modification in an existing conference. Update the call list and update the TreeView -bool CallView::conferenceChanged(const QString &confId, const QString &state) +bool CallView::conferenceChanged(Call* conf) { qDebug() << "Conference changed"; - if (!TreeWidgetCallModel::conferenceChanged(confId, state)) - return false; + //if (!SFLPhone::model()->conferenceChanged(confId, state)) + // return false; CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); - QStringList callList = callManager.getParticipantList(confId); + QStringList callList = callManager.getParticipantList(conf->getConfId()); QList<QTreeWidgetItem*> buffer; foreach (QString callId, callList) { - if (getCall(callId)) { - QTreeWidgetItem* item3 = extractItem(getIndex(callId)); - insertItem(item3, getIndex(confId)); - buffer << getIndex(callId); + if (SFLPhone::model()->getCall(callId)) { + QTreeWidgetItem* item3 = extractItem(SFLPhone::model()->getIndex(callId)); + insertItem(item3, SFLPhone::model()->getIndex(conf)); + buffer << SFLPhone::model()->getIndex(callId); } else qDebug() << "Call " << callId << " does not exist"; } - for (int j =0; j < getIndex(confId)->childCount();j++) { - if (buffer.indexOf(getIndex(confId)->child(j)) == -1) - insertItem(extractItem(getIndex(confId)->child(j))); + for (int j =0; j < SFLPhone::model()->getIndex(conf)->childCount();j++) { + if (buffer.indexOf(SFLPhone::model()->getIndex(conf)->child(j)) == -1) + insertItem(extractItem(SFLPhone::model()->getIndex(conf)->child(j))); } - Q_ASSERT_X(getIndex(confId)->childCount() == 0,"changind conference","A conference can't have no participants"); + Q_ASSERT_X(SFLPhone::model()->getIndex(conf)->childCount() == 0,"changind conference","A conference can't have no participants"); return true; } ///Remove a conference from the model and the TreeView -void CallView::conferenceRemoved(const QString &confId) +void CallView::conferenceRemoved(Call* conf) { - while (getIndex(confId)->childCount()) { - insertItem(extractItem(getIndex(confId)->child(0))); + qDebug() << "Attempting to remove conference"; + QTreeWidgetItem* idx = SFLPhone::model()->getIndex(conf); + if (idx) { + while (idx->childCount()) { + insertItem(extractItem(SFLPhone::model()->getIndex(conf)->child(0))); } - takeTopLevelItem(indexOfTopLevelItem(getIndex(confId))); - TreeWidgetCallModel::conferenceRemoved(confId); + takeTopLevelItem(indexOfTopLevelItem(SFLPhone::model()->getIndex(conf))); + //SFLPhone::model()->conferenceRemoved(confId); qDebug() << "Conference removed"; + } + else { + qDebug() << "Conference not found"; + } } ///Clear the list of old calls //TODO Clear them from the daemon void CallView::clearHistory() { - m_pHistoryCalls.clear(); -} - -void CallView::conferenceCreatedSignal(const QString& confId) -{ - addConference(confId); + //SFLPhone::model()->getHistory().clear(); } -void CallView::conferenceChangedSignal(const QString& confId, const QString& state) -{ - qDebug() << "Conf changed signal"; - conferenceChanged(confId, state); -} - -void CallView::conferenceRemovedSignal(const QString& confId) -{ - conferenceRemoved(confId); +///Redirect keypresses to parent +void CallView::keyPressEvent(QKeyEvent* event) { + SFLPhone::app()->view()->keyPressEvent(event); } -// -// void CallView::incomingMessageSignal(const QString& accountId, const QString& message) -// { -// Q_UNUSED(accountId) -// Q_UNUSED(message) -// //TODO -// } -// -// void CallView::voiceMailNotifySignal(const QString& accountId, int count) -// { -// Q_UNUSED(accountId) -// Q_UNUSED(count) -// //TODO -// } \ No newline at end of file diff --git a/kde/src/CallView.h b/kde/src/CallView.h index 5fe2c97f03dd594369fb2e402e62ef02dc639cad..f2fb282935953d19d0453c2115886f15327dfbb7 100644 --- a/kde/src/CallView.h +++ b/kde/src/CallView.h @@ -1,14 +1,15 @@ #ifndef CALL_VIEW #define CALL_VIEW -#include <QTreeWidget> -#include <QTreeWidgetItem> -#include <QItemDelegate> - +#include <QtGui/QItemDelegate> +#include <QtGui/QTreeWidget> #include "lib/CallModel.h" -#include "lib/sflphone_const.h" -#include "lib/callmanager_interface_singleton.h" -#include "widgets/CallTreeItem.h" + +//Qt +class QTreeWidgetItem; + +//SFLPhone +class CallTreeItem; class CallTreeItemDelegate : public QItemDelegate { @@ -24,49 +25,43 @@ class CallTreeItemDelegate : public QItemDelegate typedef CallModel<CallTreeItem*,QTreeWidgetItem*> TreeWidgetCallModel; -class CallView : public QTreeWidget, public TreeWidgetCallModel { +class CallView : public QTreeWidget/*, public TreeWidgetCallModel*/ { Q_OBJECT public: - CallView(QWidget* parent =0,ModelType type = ActiveCall); - bool selectItem(Call* item); - Call* getCurrentItem(); - bool removeItem(Call* item); - QWidget* getWidget(); - void setTitle(QString title); - bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action); - virtual QMimeData* mimeData( const QList<QTreeWidgetItem *> items) const; - virtual Call* addCall(Call* call, Call* parent =0); - virtual Call* addConference(const QString &confID); - virtual bool conferenceChanged(const QString &confId, const QString &state); - virtual void conferenceRemoved(const QString &confId); + CallView ( QWidget* parent = 0 ); + Call* getCurrentItem ( ); + QWidget* getWidget ( ); + void setTitle ( QString title ); + bool selectItem ( Call* item ); + bool removeItem ( Call* item ); + bool dropMimeData ( QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action ); + virtual QMimeData* mimeData ( const QList<QTreeWidgetItem *> items ) const; private: - QTreeWidgetItem* extractItem(QString callId); - QTreeWidgetItem* extractItem(QTreeWidgetItem* item); - CallTreeItem* insertItem(QTreeWidgetItem* item, QTreeWidgetItem* parent=0); - CallTreeItem* insertItem(QTreeWidgetItem* item, Call* parent); - void clearArtefact(QTreeWidgetItem* item); + QTreeWidgetItem* extractItem ( QString callId ); + QTreeWidgetItem* extractItem ( QTreeWidgetItem* item ); + CallTreeItem* insertItem ( QTreeWidgetItem* item, QTreeWidgetItem* parent=0 ); + CallTreeItem* insertItem ( QTreeWidgetItem* item, Call* parent ); + void clearArtefact ( QTreeWidgetItem* item ); protected: - void dragEnterEvent(QDragEnterEvent *e) { e->accept(); } - void dragMoveEvent(QDragMoveEvent *e) { e->accept(); } - bool callToCall(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action); - bool phoneNumberToCall(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action); - bool contactToCall(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action); + void dragEnterEvent( QDragEnterEvent *e) { e->accept(); } + void dragMoveEvent ( QDragMoveEvent *e) { e->accept(); } + bool callToCall ( QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action ); + bool phoneNumberToCall ( QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action ); + bool contactToCall ( QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action ); public slots: - void destroyCall(Call* toDestroy); - void itemDoubleClicked(QTreeWidgetItem* item, int column); - void itemClicked(QTreeWidgetItem* item, int column); - //D-Bus handling -// void callStateChangedSignal(const QString& callId, const QString& state); -// void incomingCallSignal(const QString& accountId, const QString& callId); - void conferenceCreatedSignal(const QString& confId); - void conferenceChangedSignal(const QString& confId, const QString& state); - void conferenceRemovedSignal(const QString& confId); -// void incomingMessageSignal(const QString& accountId, const QString& message); -// void voiceMailNotifySignal(const QString& accountId, int count); - + void destroyCall ( Call* toDestroy); + void itemDoubleClicked ( QTreeWidgetItem* item, int column ); + void itemClicked ( QTreeWidgetItem* item, int column ); + Call* addCall ( Call* call, Call* parent =0 ); + Call* addConference ( Call* conf ); + bool conferenceChanged ( Call* conf ); + void conferenceRemoved ( Call* conf ); + + virtual void keyPressEvent(QKeyEvent* event); + public slots: void clearHistory(); diff --git a/kde/src/Codec.cpp b/kde/src/Codec.cpp index 7ba23343dc51b43ae26934e603a6aa20e0eee9c4..1fa741fe92d353bed3da311aca76b9810dac77b4 100755 --- a/kde/src/Codec.cpp +++ b/kde/src/Codec.cpp @@ -17,79 +17,92 @@ * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ + **************************************************************************/ #include "Codec.h" #include "lib/configurationmanager_interface_singleton.h" #include "lib/sflphone_const.h" +///Constructor Codec::Codec(int payload, bool enabled) { ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); QStringList details = configurationManager.getAudioCodecDetails(payload); - this->payload = QString::number(payload); - this->enabled = enabled; - this->name = details[CODEC_NAME]; + this->payload = QString::number(payload); + this->enabled = enabled; + this->name = details[CODEC_NAME]; this->frequency = details[CODEC_SAMPLE_RATE]; - this->bitrate = details[CODEC_BIT_RATE]; + this->bitrate = details[CODEC_BIT_RATE]; this->bandwidth = details[CODEC_BANDWIDTH]; } +///Return the payload QString Codec::getPayload() const { return payload; } +///Return the codec name QString Codec::getName() const { return name; } +///Return the frequency QString Codec::getFrequency() const { return frequency; } +///Return the bitrate QString Codec::getBitrate() const { return bitrate; } +///Return the bandwidth QString Codec::getBandwidth() const { return bandwidth; } +///Is this codec enabled bool Codec::isEnabled() const { return enabled; } +///Set the payload void Codec::setPayload(QString payload) { this->payload = payload; } +///Set the codec name void Codec::setName(QString name) { this->name = name; } +///Set the frequency void Codec::setFrequency(QString frequency) { this->frequency = frequency; } +///Set the bitrate void Codec::setBitrate(QString bitrate) { this->bitrate = bitrate; } +///Set the bandwidth void Codec::setBandwidth(QString bandwidth) { this->bandwidth = bandwidth; } +///Make this cedec enabled void Codec::setEnabled(bool enabled) { this->enabled = enabled; diff --git a/kde/src/Codec.h b/kde/src/Codec.h index 4bb408d67ff119ebb29d8eda512735c09e1e7c47..e4340f7473f5eca2f82b74e9125164c42f977a70 100755 --- a/kde/src/Codec.h +++ b/kde/src/Codec.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ + **************************************************************************/ #ifndef CODEC_H #define CODEC_H @@ -31,36 +31,31 @@ class Codec : public QObject { Q_OBJECT private: - QString payload; - QString name; - QString frequency; - QString bitrate; - QString bandwidth; + QString payload ; + QString name ; + QString frequency ; + QString bitrate ; + QString bandwidth ; bool enabled; public: Codec(int payload, bool enabled); -// Codec(const Codec & codec); - -// ~Codec(); - QString getPayload() const; - QString getName() const; - QString getFrequency() const; - QString getBitrate() const; - QString getBandwidth() const; - bool isEnabled() const; + QString getPayload () const; + QString getName () const; + QString getFrequency () const; + QString getBitrate () const; + QString getBandwidth () const; + bool isEnabled () const; - void setPayload(QString payload); - void setName(QString name); - void setFrequency(QString frequency); - void setBitrate(QString bitrate); - void setBandwidth(QString bandwidth); - void setEnabled(bool enabled); + void setPayload ( QString payload ); + void setName ( QString name ); + void setFrequency ( QString frequency ); + void setBitrate ( QString bitrate ); + void setBandwidth ( QString bandwidth ); + void setEnabled ( bool enabled ); Codec & operator=(const Codec&); - - }; #endif diff --git a/kde/src/SFLPhone.cpp b/kde/src/SFLPhone.cpp index 4d2e5403d9f1048348a900cb120a2975174c0515..2dbde9b648cec083f71c07352fefb12942cd037e 100755 --- a/kde/src/SFLPhone.cpp +++ b/kde/src/SFLPhone.cpp @@ -1,4 +1,4 @@ -/************************************** ************************************* +/************************************** ************************************ * Copyright (C) 2009-2010 by Savoir-Faire Linux * * Author : Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> * * Emmanuel Lepage Vallee <emmanuel.lepage@savoirfairelinux.com>* @@ -17,7 +17,7 @@ * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ + **************************************************************************/ #include <unistd.h> #include "SFLPhone.h" @@ -31,6 +31,16 @@ #include <QtGui/QStatusBar> #include <QtGui/QCursor> #include <KActionCollection> +#include <QtCore/QString> +#include <QtGui/QListWidgetItem> +#include <QtGui/QKeyEvent> +#include <QErrorMessage> +#include <KSystemTrayIcon> +#include <KNotification> +#include <QActionGroup> +#include <QLabel> +#include <QListWidget> +#include <kshortcutsdialog.h> #include "lib/sflphone_const.h" #include "lib/instance_interface_singleton.h" @@ -38,55 +48,78 @@ #include "lib/Contact.h" #include "AkonadiBackend.h" #include "conf/ConfigurationSkeleton.h" +#include "widgets/ContactDock.h" +#include "AccountWizard.h" +#include "widgets/HistoryDock.h" +#include "widgets/BookmarkDock.h" +#include "lib/Contact.h" +#include "SFLPhoneView.h" +#include "widgets/SFLPhoneTray.h" SFLPhone* SFLPhone::m_sApp = NULL; +TreeWidgetCallModel* SFLPhone::m_pModel = NULL; +///Constructor SFLPhone::SFLPhone(QWidget *parent) : KXmlGuiWindow(parent), - initialized_(false), + m_pInitialized(false), m_pView(new SFLPhoneView(this)) { setupActions(); m_sApp = this; -} +} +///Destructor +SFLPhone::~SFLPhone() +{ + //saveState(); +} + +///Singleton SFLPhone* SFLPhone::app() { return m_sApp; } +///Get the view (to be used with the singleton) SFLPhoneView* SFLPhone::view() { return m_pView; } -CallView* SFLPhone::model() + +///Singleton +TreeWidgetCallModel* SFLPhone::model() { - return m_pView->model(); + if (!m_pModel) { + m_pModel = new TreeWidgetCallModel(TreeWidgetCallModel::ActiveCall); + m_pModel->initCall(); + m_pModel->initContact(AkonadiBackend::getInstance()); + } + return m_pModel; } +///Return the contact dock ContactDock* SFLPhone::contactDock() { return m_pContactCD; } +///Return the history dock HistoryDock* SFLPhone::historyDock() { return m_pHistoryDW; } +///Return the bookmark dock BookmarkDock* SFLPhone::bookmarkDock() { return m_pBookmarkDW; } -SFLPhone::~SFLPhone() -{ - saveState(); -} - +///Init everything bool SFLPhone::initialize() { - if ( initialized_ ) { + if ( m_pInitialized ) { qDebug() << "Already initialized."; return false; } @@ -105,14 +138,14 @@ bool SFLPhone::initialize() addDockWidget(Qt::TopDockWidgetArea,m_pContactCD); // tell the KXmlGuiWindow that this is indeed the main widget - //setCentralWidget(m_pView); m_pCentralDW = new QDockWidget(this); - m_pCentralDW->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); - m_pCentralDW->setWidget(m_pView); - m_pCentralDW->setWindowTitle("Call"); - m_pCentralDW->setFeatures(QDockWidget::NoDockWidgetFeatures); - m_pView->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding); - m_pCentralDW->setStyleSheet("\ + m_pCentralDW->setObjectName ( "callDock" ); + m_pCentralDW->setSizePolicy ( QSizePolicy::Expanding,QSizePolicy::Expanding ); + m_pCentralDW->setWidget ( m_pView ); + m_pCentralDW->setWindowTitle ( i18n("Call") ); + m_pCentralDW->setFeatures ( QDockWidget::NoDockWidgetFeatures ); + m_pView->setSizePolicy ( QSizePolicy::Expanding,QSizePolicy::Expanding ); + m_pCentralDW->setStyleSheet ( "\ QDockWidget::title {\ margin:0px;\ padding:0px;\ @@ -128,56 +161,54 @@ bool SFLPhone::initialize() addDockWidget(Qt::TopDockWidgetArea,m_pCentralDW); - - m_pHistoryDW = new HistoryDock(this); - addDockWidget(Qt::TopDockWidgetArea,m_pHistoryDW); - m_pBookmarkDW = new BookmarkDock(this); - addDockWidget(Qt::TopDockWidgetArea,m_pBookmarkDW); - tabifyDockWidget(m_pBookmarkDW,m_pHistoryDW); + m_pHistoryDW = new HistoryDock(this); + m_pBookmarkDW = new BookmarkDock(this); + addDockWidget( Qt::TopDockWidgetArea,m_pHistoryDW ); + addDockWidget( Qt::TopDockWidgetArea,m_pBookmarkDW ); + tabifyDockWidget(m_pBookmarkDW,m_pHistoryDW); setWindowIcon(QIcon(ICON_SFLPHONE)); setWindowTitle(i18n("SFLphone")); setupActions(); - statusBarWidget = new QLabel(); - statusBar()->addWidget(statusBarWidget); + m_pStatusBarWidget = new QLabel(); + statusBar()->addWidget(m_pStatusBarWidget); - trayIcon = new SFLPhoneTray(this->windowIcon(), this); - trayIcon->show(); + m_pTrayIcon = new SFLPhoneTray(this->windowIcon(), this); + m_pTrayIcon->show(); - iconChanged = false; + m_pIconChanged = false; setObjectNames(); QMetaObject::connectSlotsByName(this); m_pView->loadWindow(); move(QCursor::pos().x() - geometry().width()/2, QCursor::pos().y() - geometry().height()/2); - //if( ! configurationManager.isStartHidden()) { show(); - //} if(configurationManager.getAccountList().value().isEmpty()) { (new AccountWizard())->show(); } - initialized_ = true; + m_pInitialized = true; return true; } +///Set widgets object name void SFLPhone::setObjectNames() { - m_pView->setObjectName("m_pView"); - statusBar()->setObjectName("statusBar"); - trayIcon->setObjectName("trayIcon"); + m_pView->setObjectName ( "m_pView" ); + statusBar()->setObjectName ( "statusBar" ); + m_pTrayIcon->setObjectName ( "trayIcon" ); } +///Setup evry actions void SFLPhone::setupActions() { qDebug() << "setupActions"; - //ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); action_accept = new KAction(this); action_refuse = new KAction(this); @@ -195,9 +226,10 @@ void SFLPhone::setupActions() action_screen = new QActionGroup(this); action_screen->setExclusive(true); + action_main = new KAction(KIcon(QIcon(ICON_SCREEN_MAIN)), i18n("Main screen"), action_screen); - action_main->setCheckable(true); - action_main->setChecked(true); + action_main->setCheckable( true ); + action_main->setChecked ( true ); action_screen->addAction(action_main); action_close = KStandardAction::close(this, SLOT(close()), this); @@ -206,14 +238,18 @@ void SFLPhone::setupActions() action_configureSflPhone = KStandardAction::preferences(m_pView, SLOT(configureSflPhone()), this); action_configureSflPhone->setText(i18n("Configure SFLphone")); - action_displayVolumeControls = new KAction(KIcon(QIcon(ICON_DISPLAY_VOLUME_CONSTROLS)), i18n("Display volume controls"), this); action_displayDialpad = new KAction(KIcon(QIcon(ICON_DISPLAY_DIALPAD)), i18n("Display dialpad"), this); - action_displayDialpad->setCheckable(true); + action_displayDialpad->setCheckable( true ); + action_displayDialpad->setChecked ( ConfigurationSkeleton::displayDialpad() ); - action_displayVolumeControls->setCheckable(true); - action_displayVolumeControls->setChecked(ConfigurationSkeleton::displayVolume()); - action_displayDialpad->setChecked(ConfigurationSkeleton::displayDialpad()); + action_displayVolumeControls = new KAction(KIcon(QIcon(ICON_DISPLAY_VOLUME_CONSTROLS)), i18n("Display volume controls"), this); + action_displayVolumeControls->setCheckable( true ); + action_displayVolumeControls->setChecked ( ConfigurationSkeleton::displayVolume() ); + action_accountCreationWizard = new KAction(i18n("Account creation wizard"), this); + + + action_configureShortcut = new KAction(KIcon(KIcon("configure-shortcuts")), i18n("Configure Shortcut"), this); connect(action_accept, SIGNAL(triggered()), m_pView , SLOT(accept() )); connect(action_refuse, SIGNAL(triggered()), m_pView , SLOT(refuse() )); @@ -225,6 +261,7 @@ void SFLPhone::setupActions() connect(action_displayVolumeControls, SIGNAL(toggled(bool)), m_pView , SLOT(displayVolumeControls(bool) )); connect(action_displayDialpad, SIGNAL(toggled(bool)), m_pView , SLOT(displayDialpad(bool) )); connect(action_accountCreationWizard, SIGNAL(triggered()), m_pView , SLOT(accountCreationWizard() )); + connect(action_configureShortcut, SIGNAL(triggered()), this , SLOT(showShortCutEditor() )); action_screen->addAction(action_main); @@ -241,34 +278,17 @@ void SFLPhone::setupActions() actionCollection()->addAction("action_displayDialpad" , action_displayDialpad ); actionCollection()->addAction("action_configureSflPhone" , action_configureSflPhone ); actionCollection()->addAction("action_accountCreationWizard" , action_accountCreationWizard ); + actionCollection()->addAction("action_configureShortcut" , action_configureShortcut ); - QString rcFilePath = QString(DATA_INSTALL_DIR) + "/sflphone-client-kde/sflphone-client-kdeui.rc"; - - if(! QFile::exists(rcFilePath)) { - QDir dir; - dir.cdUp(); - dir.cd("data"); - rcFilePath = dir.filePath("sflphone-client-kdeui.rc"); - qDebug() << "rcFilePath = " << rcFilePath ; - - if(! QFile::exists(rcFilePath)) { - QDir dir; - dir.cdUp(); - dir.cdUp(); - dir.cd("data"); - rcFilePath = dir.filePath("sflphone-client-kdeui.rc"); - } - } - qDebug() << "rcFilePath = " << rcFilePath ; - createGUI(rcFilePath); - + setAutoSaveSettings(); + createGUI(); } -SFLPhoneView * SFLPhone::getView() -{ - return m_pView; +void SFLPhone::showShortCutEditor() { + KShortcutsDialog::configure( actionCollection() ); } +///[Action]Hide sflphone bool SFLPhone::queryClose() { qDebug() << "queryClose"; @@ -276,37 +296,35 @@ bool SFLPhone::queryClose() return false; } +///[Action] Quit action void SFLPhone::quitButton() { - - //qDebug() << "quitButton : " << m_pView->callTree->count() << " calls open."; - - //if(m_pView->callTree->count() > 0 && instance.getRegistrationCount() <= 1) { - //qDebug() << "Attempting to quit when still having some calls open."; - //} - m_pView->saveState(); qApp->quit(); } +///Called when something happen void SFLPhone::changeEvent(QEvent* event) { - if (event->type() == QEvent::ActivationChange && iconChanged && isActiveWindow()) { - iconChanged = false; + if (event->type() == QEvent::ActivationChange && m_pIconChanged && isActiveWindow()) { + m_pIconChanged = false; } } +///Change status message void SFLPhone::on_m_pView_statusMessageChangeAsked(const QString & message) { qDebug() << "on_m_pView_statusMessageChangeAsked : " + message; - statusBarWidget->setText(message); + m_pStatusBarWidget->setText(message); } +///Change windowtitle void SFLPhone::on_m_pView_windowTitleChangeAsked(const QString & message) { qDebug() << "on_m_pView_windowTitleChangeAsked : " + message; setWindowTitle(message); } +///Enable or disable toolbar items void SFLPhone::on_m_pView_enabledActionsChangeAsked(const bool * enabledActions) { qDebug() << "on_m_pView_enabledActionsChangeAsked"; @@ -318,6 +336,7 @@ void SFLPhone::on_m_pView_enabledActionsChangeAsked(const bool * enabledActions) action_mailBox->setVisible ( enabledActions[SFLPhone::Mailbox ]); } +///Change icons void SFLPhone::on_m_pView_actionIconsChangeAsked(const QString * actionIcons) { qDebug() << "on_m_pView_actionIconsChangeAsked"; @@ -329,6 +348,7 @@ void SFLPhone::on_m_pView_actionIconsChangeAsked(const QString * actionIcons) action_mailBox->setIcon ( QIcon(actionIcons[SFLPhone::Mailbox ])); } +///Change text void SFLPhone::on_m_pView_actionTextsChangeAsked(const QString * actionTexts) { qDebug() << "on_m_pView_actionTextsChangeAsked"; @@ -340,30 +360,35 @@ void SFLPhone::on_m_pView_actionTextsChangeAsked(const QString * actionTexts) action_mailBox->setText ( actionTexts[SFLPhone::Mailbox ]); } - +///Change transfer state void SFLPhone::on_m_pView_transferCheckStateChangeAsked(bool transferCheckState) { qDebug() << "Changing transfer action checkState"; action_transfer->setChecked(transferCheckState); } +///Change record state void SFLPhone::on_m_pView_recordCheckStateChangeAsked(bool recordCheckState) { qDebug() << "Changing record action checkState"; action_record->setChecked(recordCheckState); } +///Update the GUI void SFLPhone::updateScreen(QAction * action) { if(action == action_main) m_pView->changeScreen(SCREEN_MAIN); } +///Do nothing +/// @deprecated This function can be removed void SFLPhone::on_m_pView_screenChanged(int screen) { qDebug() << "on_m_pView_screenChanged"; if(screen == SCREEN_MAIN) action_main->setChecked(true); } +///Produce an actionList for auto CallBack QList<QAction*> SFLPhone::getCallActions() { QList<QAction*> callActions = QList<QAction *>(); @@ -376,19 +401,12 @@ QList<QAction*> SFLPhone::getCallActions() return callActions; } +///Called when a call is coming void SFLPhone::on_m_pView_incomingCall(const Call * call) { - //ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - //trayIconSignal(); - /*if(configurationManager.popupMode()) - { - putForeground(); - }*/ - //if(configurationManager.getNotify()) { Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(call->getPeerPhoneNumber()); if (contact) { KNotification::event(KNotification::Notification, "New incomming call", "New call from: \n" + call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() : call->getPeerName(),*contact->getPhoto()); } KNotification::event(KNotification::Notification, "New incomming call", "New call from: \n" + call->getPeerName().isEmpty() ? call->getPeerPhoneNumber() : call->getPeerName()); - //} } diff --git a/kde/src/SFLPhone.h b/kde/src/SFLPhone.h index d72f9129ae73f49bd3a9d7e419845b0a9dc37335..9efe6cae4f678de18d9bc8fa5c18d171f3ab9501 100755 --- a/kde/src/SFLPhone.h +++ b/kde/src/SFLPhone.h @@ -17,49 +17,48 @@ * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ + **************************************************************************/ #ifndef SFLPHONE_H #define SFLPHONE_H -#include <QtCore/QString> -#include <QtCore/QVector> -#include <QtGui/QListWidgetItem> -#include <QtGui/QKeyEvent> -#include <QErrorMessage> -#include <KSystemTrayIcon> -#include <KNotification> - #include <KXmlGuiWindow> -#include <KAction> -#include "widgets/ContactDock.h" -#include "widgets/HistoryDock.h" -#include "widgets/BookmarkDock.h" -#include <QActionGroup> - -// #include "ui_SFLPhoneView_base.h" -//#include "CallList.h" -#include "AccountWizard.h" -#include "lib/Contact.h" -#include "SFLPhoneView.h" -#include "widgets/SFLPhoneTray.h" - +#include <QtCore/QVector> +#include <lib/CallModel.h> + +//Qt +class QString; +class QLabel; +class QTreeWidgetItem; +class QActionGroup; + +//KDE +class KAction; + +//SFLPhone +class Call; +class ContactDock; +class BookmarkDock; +class SFLPhoneTray; class SFLPhoneView; -class CallView; - -/** - * This class represents the SFLphone main window - * It implements the methods relative to windowing - * (status, menus, toolbars, notifications...). - * It uses a view which implements the real functionning - * and features of the phone. - * The display of the window is according to the state of the view, - * so the view sends some signals to ask for changes on the window - * that the window has to take into account. - * - * @short Main window - * @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> - * @version 0.9.6 +class HistoryDock; +class CallTreeItem; + +typedef CallModel<CallTreeItem*,QTreeWidgetItem*> TreeWidgetCallModel; + +/** + * This class represents the SFLphone main window + * It implements the methods relative to windowing + * (status, menus, toolbars, notifications...). + * It uses a view which implements the real functionning + * and features of the phone. + * The display of the window is according to the state of the view, + * so the view sends some signals to ask for changes on the window + * that the window has to take into account. + * + * @short Main window + * @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> + * @version 0.9.6 **/ class SFLPhone : public KXmlGuiWindow { @@ -67,45 +66,46 @@ Q_OBJECT public: enum CallAction { - Accept, - Refuse, - Hold, - Transfer, - Record, - Mailbox, - NumberOfCallActions}; + Accept , + Refuse , + Hold , + Transfer , + Record , + Mailbox , + NumberOfCallActions +}; private: // Whether or not the object has been initialized - bool initialized_; - KAction * action_accept; - KAction * action_refuse; - KAction * action_hold; - KAction * action_transfer; - KAction * action_record; + bool m_pInitialized; + KAction* action_accept ; + KAction* action_refuse ; + KAction* action_hold ; + KAction* action_transfer ; + KAction* action_record ; + KAction* action_main ; + KAction* action_mailBox ; + KAction* action_close ; + KAction* action_quit ; + KAction* action_displayVolumeControls ; + KAction* action_displayDialpad ; + KAction* action_configureSflPhone ; + KAction* action_configureShortcut ; + KAction* action_accountCreationWizard ; + QActionGroup * action_screen; - KAction * action_main; - KAction * action_mailBox; - KAction * action_close; - KAction * action_quit; - KAction * action_displayVolumeControls; - KAction * action_displayDialpad; - KAction * action_configureSflPhone; - KAction * action_accountCreationWizard; - - SFLPhoneView * m_pView; - QMenu *trayIconMenu; - bool iconChanged; - SFLPhoneTray *trayIcon; - KNotification *notification; - QLabel* statusBarWidget; - ContactDock* m_pContactCD; - QDockWidget* m_pCentralDW; - HistoryDock* m_pHistoryDW; - BookmarkDock* m_pBookmarkDW; + + SFLPhoneView* m_pView ; + bool m_pIconChanged ; + SFLPhoneTray* m_pTrayIcon ; + QLabel* m_pStatusBarWidget ; + ContactDock* m_pContactCD ; + QDockWidget* m_pCentralDW ; + HistoryDock* m_pHistoryDW ; + BookmarkDock* m_pBookmarkDW ; static SFLPhone* m_sApp; - + static TreeWidgetCallModel* m_pModel; private: void setObjectNames(); @@ -116,34 +116,33 @@ protected: public: SFLPhone(QWidget *parent = 0); - ~SFLPhone(); - bool initialize(); - void setupActions(); - void trayIconSignal(); - SFLPhoneView * getView(); - QList<QAction *> getCallActions(); + ~SFLPhone (); + bool initialize (); + void setupActions (); + void trayIconSignal (); + QList<QAction *> getCallActions (); friend class SFLPhoneView; - static SFLPhone* app(); - SFLPhoneView* view(); - CallView* model(); + static SFLPhone* app (); + static TreeWidgetCallModel* model (); + SFLPhoneView* view (); ContactDock* contactDock(); HistoryDock* historyDock(); BookmarkDock* bookmarkDock(); private slots: - void on_m_pView_statusMessageChangeAsked(const QString & message); - void on_m_pView_windowTitleChangeAsked(const QString & message); - void on_m_pView_enabledActionsChangeAsked(const bool * enabledActions); - void on_m_pView_actionIconsChangeAsked(const QString * actionIcons); - void on_m_pView_actionTextsChangeAsked(const QString * actionTexts); - void on_m_pView_transferCheckStateChangeAsked(bool transferCheckState); - void on_m_pView_recordCheckStateChangeAsked(bool recordCheckState); - void on_m_pView_screenChanged(int screen); - void on_m_pView_incomingCall(const Call * call); - + void on_m_pView_statusMessageChangeAsked ( const QString& message ); + void on_m_pView_windowTitleChangeAsked ( const QString& message ); + void on_m_pView_enabledActionsChangeAsked ( const bool* enabledActions ); + void on_m_pView_actionIconsChangeAsked ( const QString* actionIcons ); + void on_m_pView_actionTextsChangeAsked ( const QString* actionTexts ); + void on_m_pView_transferCheckStateChangeAsked ( bool transferCheckState ); + void on_m_pView_recordCheckStateChangeAsked ( bool recordCheckState ); + void on_m_pView_screenChanged ( int screen ); + void on_m_pView_incomingCall ( const Call * call ); + void showShortCutEditor ( ); void updateScreen(QAction * action); void quitButton(); diff --git a/kde/src/SFLPhoneView.cpp b/kde/src/SFLPhoneView.cpp index 2779a7bbec02b1fc2b304992476c6ff1838bd5e1..fd2bf1a3b39bafaf06ca8ec57fe343bf226665ba 100755 --- a/kde/src/SFLPhoneView.cpp +++ b/kde/src/SFLPhoneView.cpp @@ -26,6 +26,17 @@ #include <QtGui/QBrush> #include <QtGui/QPalette> #include <QtGui/QInputDialog> +#include <QtGui/QWidget> +#include <QtCore/QString> +#include <QtGui/QKeyEvent> +#include <QErrorMessage> +#include <KXmlGuiWindow> + +#include "conf/ConfigurationDialog.h" +#include "AccountWizard.h" +#include "lib/Contact.h" +#include "lib/AccountList.h" +#include "CallView.h" #include <klocale.h> #include <kstandardaction.h> @@ -61,45 +72,23 @@ SFLPhoneView::SFLPhoneView(QWidget *parent) setupUi(this); ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); errorWindow = new QErrorMessage(this); - callTreeModel->setTitle("Calls"); + callTreeModel->setTitle(i18n("Calls")); QPalette pal = QPalette(palette()); pal.setColor(QPalette::AlternateBase, Qt::lightGray); setPalette(pal); - //BEGIN Port to CallModel - connect(&callManager, SIGNAL(callStateChanged(const QString &, const QString &)), - this, SLOT(on1_callStateChanged(const QString &, const QString &))); - connect(&callManager, SIGNAL(incomingCall(const QString &, const QString &, const QString &)), - this, SLOT(on1_incomingCall(const QString &, const QString &))); - connect(&callManager, SIGNAL(conferenceCreated(const QString &)), - this, SLOT(on1_incomingConference(const QString &))); - connect(&callManager, SIGNAL(conferenceChanged(const QString &, const QString &)), - this, SLOT(on1_changingConference(const QString &, const QString &))); - connect(&callManager, SIGNAL(conferenceRemoved(const QString &)), - this, SLOT(on1_conferenceRemoved(const QString &))); - connect(&callManager, SIGNAL(voiceMailNotify(const QString &, int)), - this, SLOT(on1_voiceMailNotify(const QString &, int))); - - connect(&callManager, SIGNAL(volumeChanged(const QString &, double)), - this, SLOT(on1_volumeChanged(const QString &, double))); - - connect(&configurationManager, SIGNAL(accountsChanged()), - CallView::getAccountList(), SLOT(updateAccounts())); - //END Port to Call Model - - //connect(configDialog, SIGNAL(changesApplied()), - //this, SLOT(loadWindow())); - - connect(CallView::getAccountList(), SIGNAL(accountListUpdated()), - this, SLOT(updateStatusMessage())); - connect(CallView::getAccountList(), SIGNAL(accountListUpdated()), - this, SLOT(updateWindowCallState())); + connect(SFLPhone::model() , SIGNAL(incomingCall(Call*)) , this , SLOT(on1_incomingCall(Call*) )); + connect(SFLPhone::model() , SIGNAL(voiceMailNotify(const QString &, int)) , this , SLOT(on1_voiceMailNotify(const QString &, int) )); + connect(SFLPhone::model() , SIGNAL(volumeChanged(const QString &, double)), this , SLOT(on1_volumeChanged(const QString &, double) )); + connect(SFLPhone::model() , SIGNAL(callStateChanged(Call*)) , this , SLOT(updateWindowCallState() )); + connect(TreeWidgetCallModel::getAccountList() , SIGNAL(accountListUpdated()) , this , SLOT(updateStatusMessage() )); + connect(TreeWidgetCallModel::getAccountList() , SIGNAL(accountListUpdated()) , this , SLOT(updateWindowCallState() )); + connect(&configurationManager , SIGNAL(accountsChanged()) , TreeWidgetCallModel::getAccountList() , SLOT(updateAccounts() )); - CallView::getAccountList()->updateAccounts(); + TreeWidgetCallModel::getAccountList()->updateAccounts(); } @@ -108,22 +97,16 @@ SFLPhoneView::~SFLPhoneView() { } -void SFLPhoneView::saveState() -{ - //ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - //configurationManager.setHistory(callTreeModel->getHistoryCallId()); -} - void SFLPhoneView::loadWindow() { - updateWindowCallState(); - updateRecordButton(); - updateVolumeButton(); - updateRecordBar(); - updateVolumeBar(); - updateVolumeControls(); - updateDialpad(); - updateStatusMessage(); + updateWindowCallState (); + updateRecordButton (); + updateVolumeButton (); + updateRecordBar (); + updateVolumeBar (); + updateVolumeControls (); + updateDialpad (); + updateStatusMessage (); } QErrorMessage * SFLPhoneView::getErrorWindow() @@ -131,11 +114,6 @@ QErrorMessage * SFLPhoneView::getErrorWindow() return errorWindow; } -CallView* SFLPhoneView::model() -{ - return callTreeModel; -} - void SFLPhoneView::typeString(QString str) { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); @@ -151,7 +129,7 @@ void SFLPhoneView::typeString(QString str) } } - foreach (Call* call2, callTreeModel->getCallList()) { + foreach (Call* call2, SFLPhone::model()->getCallList()) { if(currentCall != call2 && call2->getState() == CALL_STATE_CURRENT) { action(call2, CALL_ACTION_HOLD); } @@ -162,7 +140,7 @@ void SFLPhoneView::typeString(QString str) if(!currentCall && !candidate) { qDebug() << "Typing when no item is selected. Opening an item."; - candidate = callTreeModel->addDialingCall(); + candidate = SFLPhone::model()->addDialingCall(); } if(!currentCall && candidate) { @@ -183,11 +161,6 @@ void SFLPhoneView::backspace() if(call->getState() == CALL_STATE_OVER) { if (callTreeModel->getCurrentItem()) callTreeModel->removeItem(callTreeModel->getCurrentItem()); - -// if(call->getHistoryState() != NONE) { -// //historyTree->insert(call); -// historyTreeModel->addCall(call); -// } } } } @@ -195,10 +168,9 @@ void SFLPhoneView::backspace() void SFLPhoneView::escape() { qDebug() << "escape"; - qDebug() << "In call list."; Call* call = callTreeModel->getCurrentItem(); if(!call) { - //qDebug() << "Escape when no item is selected. Doing nothing."; + qDebug() << "Escape when no item is selected. Doing nothing."; } else { if(call->getState() == CALL_STATE_TRANSFER || call->getState() == CALL_STATE_TRANSF_HOLD) { @@ -213,7 +185,6 @@ void SFLPhoneView::escape() void SFLPhoneView::enter() { qDebug() << "enter"; - qDebug() << "In call list."; Call* call = callTreeModel->getCurrentItem(); if(!call) { qDebug() << "Error : Enter on unexisting call."; @@ -258,119 +229,100 @@ void SFLPhoneView::updateWindowCallState() QString buttonIconFiles[6] = {ICON_CALL, ICON_HANGUP, ICON_HOLD, ICON_TRANSFER, ICON_REC_DEL_OFF, ICON_MAILBOX}; QString actionTexts[6] = {ACTION_LABEL_CALL, ACTION_LABEL_HANG_UP, ACTION_LABEL_HOLD, ACTION_LABEL_TRANSFER, ACTION_LABEL_RECORD, ACTION_LABEL_MAILBOX}; - Call* call; + Call* call = 0; bool transfer = false; bool recordActivated = false; //tells whether the call is in recording position - enabledActions[SFLPhone::Mailbox] = CallView::getCurrentAccount() && ! CallView::getCurrentAccount()->getAccountDetail(ACCOUNT_MAILBOX).isEmpty(); + enabledActions[SFLPhone::Mailbox] = SFLPhone::model()->getCurrentAccount() && ! SFLPhone::model()->getCurrentAccount()->getAccountDetail(ACCOUNT_MAILBOX).isEmpty(); call = callTreeModel->getCurrentItem(); if (!call) { qDebug() << "No item selected."; - enabledActions[SFLPhone::Refuse] = false; - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; - enabledActions[SFLPhone::Record] = false; + enabledActions[ SFLPhone::Refuse ] = false; + enabledActions[ SFLPhone::Hold ] = false; + enabledActions[ SFLPhone::Transfer ] = false; + enabledActions[ SFLPhone::Record ] = false; } else { call_state state = call->getState(); recordActivated = call->getRecording(); + qDebug() << "Reached State" << state << " with call" << call->getCallId(); + switch (state) { case CALL_STATE_INCOMING: - qDebug() << "Reached CALL_STATE_INCOMING with call " << call->getCallId(); - buttonIconFiles[SFLPhone::Accept] = ICON_ACCEPT; - buttonIconFiles[SFLPhone::Refuse] = ICON_REFUSE; - actionTexts[SFLPhone::Accept] = ACTION_LABEL_ACCEPT; - actionTexts[SFLPhone::Refuse] = ACTION_LABEL_REFUSE; + buttonIconFiles [ SFLPhone::Accept ] = ICON_ACCEPT ; + buttonIconFiles [ SFLPhone::Refuse ] = ICON_REFUSE ; + actionTexts [ SFLPhone::Accept ] = ACTION_LABEL_ACCEPT ; + actionTexts [ SFLPhone::Refuse ] = ACTION_LABEL_REFUSE ; break; case CALL_STATE_RINGING: - qDebug() << "Reached CALL_STATE_RINGING with call " << call->getCallId(); - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; + enabledActions [ SFLPhone::Hold ] = false ; + enabledActions [ SFLPhone::Transfer ] = false ; break; case CALL_STATE_CURRENT: - qDebug() << "details = " << CallManagerInterfaceSingleton::getInstance().getCallDetails(call->getCallId()).value(); - qDebug() << "Reached CALL_STATE_CURRENT with call " << call->getCallId(); - buttonIconFiles[SFLPhone::Record] = ICON_REC_DEL_ON; + buttonIconFiles [ SFLPhone::Record ] = ICON_REC_DEL_ON ; break; case CALL_STATE_DIALING: - qDebug() << "Reached CALL_STATE_DIALING with call " << call->getCallId(); - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; - enabledActions[SFLPhone::Record] = false; - actionTexts[SFLPhone::Accept] = ACTION_LABEL_ACCEPT; - buttonIconFiles[SFLPhone::Accept] = ICON_ACCEPT; + enabledActions [ SFLPhone::Hold ] = false ; + enabledActions [ SFLPhone::Transfer ] = false ; + enabledActions [ SFLPhone::Record ] = false ; + actionTexts [ SFLPhone::Accept ] = ACTION_LABEL_ACCEPT ; + buttonIconFiles [ SFLPhone::Accept ] = ICON_ACCEPT ; break; case CALL_STATE_HOLD: - qDebug() << "Reached CALL_STATE_HOLD with call " << call->getCallId(); - buttonIconFiles[SFLPhone::Hold] = ICON_UNHOLD; - actionTexts[SFLPhone::Hold] = ACTION_LABEL_UNHOLD; + buttonIconFiles [ SFLPhone::Hold ] = ICON_UNHOLD ; + actionTexts [ SFLPhone::Hold ] = ACTION_LABEL_UNHOLD ; break; case CALL_STATE_FAILURE: - qDebug() << "Reached CALL_STATE_FAILURE with call " << call->getCallId(); - enabledActions[SFLPhone::Accept] = false; - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; - enabledActions[SFLPhone::Record] = false; + enabledActions [ SFLPhone::Accept ] = false ; + enabledActions [ SFLPhone::Hold ] = false ; + enabledActions [ SFLPhone::Transfer ] = false ; + enabledActions [ SFLPhone::Record ] = false ; break; case CALL_STATE_BUSY: - qDebug() << "Reached CALL_STATE_BUSY with call " << call->getCallId(); - enabledActions[SFLPhone::Accept] = false; - enabledActions[SFLPhone::Hold] = false; - enabledActions[SFLPhone::Transfer] = false; - enabledActions[SFLPhone::Record] = false; + enabledActions [ SFLPhone::Accept ] = false ; + enabledActions [ SFLPhone::Hold ] = false ; + enabledActions [ SFLPhone::Transfer ] = false ; + enabledActions [ SFLPhone::Record ] = false ; break; case CALL_STATE_TRANSFER: - qDebug() << "Reached CALL_STATE_TRANSFER with call " << call->getCallId(); - buttonIconFiles[SFLPhone::Accept] = ICON_EXEC_TRANSF; - actionTexts[SFLPhone::Transfer] = ACTION_LABEL_GIVE_UP_TRANSF; + buttonIconFiles [ SFLPhone::Accept ] = ICON_EXEC_TRANSF ; + actionTexts [ SFLPhone::Transfer ] = ACTION_LABEL_GIVE_UP_TRANSF ; + buttonIconFiles [ SFLPhone::Record ] = ICON_REC_DEL_ON ; transfer = true; - buttonIconFiles[SFLPhone::Record] = ICON_REC_DEL_ON; break; case CALL_STATE_TRANSF_HOLD: - qDebug() << "Reached CALL_STATE_TRANSF_HOLD with call " << call->getCallId(); - buttonIconFiles[SFLPhone::Accept] = ICON_EXEC_TRANSF; - buttonIconFiles[SFLPhone::Hold] = ICON_UNHOLD; - actionTexts[SFLPhone::Transfer] = ACTION_LABEL_GIVE_UP_TRANSF; - actionTexts[SFLPhone::Hold] = ACTION_LABEL_UNHOLD; + buttonIconFiles [ SFLPhone::Accept ] = ICON_EXEC_TRANSF ; + buttonIconFiles [ SFLPhone::Hold ] = ICON_UNHOLD ; + actionTexts [ SFLPhone::Transfer ] = ACTION_LABEL_GIVE_UP_TRANSF ; + actionTexts [ SFLPhone::Hold ] = ACTION_LABEL_UNHOLD ; transfer = true; break; case CALL_STATE_OVER: - qDebug() << "Error : Reached CALL_STATE_OVER with call " << call->getCallId() << "!"; + qDebug() << "Error : Reached CALL_STATE_OVER with call " << call->getCallId() << "!"; break; case CALL_STATE_ERROR: qDebug() << "Error : Reached CALL_STATE_ERROR with call " << call->getCallId() << "!"; break; default: - qDebug() << "Error : Reached unexisting state for call " << call->getCallId() << "!"; + qDebug() << "Error : Reached unexisting state for call " << call->getCallId() << "!"; break; } } qDebug() << "Updating Window."; - emit enabledActionsChangeAsked(enabledActions); - emit actionIconsChangeAsked(buttonIconFiles); - emit actionTextsChangeAsked(actionTexts); - emit transferCheckStateChangeAsked(transfer); - emit recordCheckStateChangeAsked(recordActivated); + emit enabledActionsChangeAsked ( enabledActions ); + emit actionIconsChangeAsked ( buttonIconFiles ); + emit actionTextsChangeAsked ( actionTexts ); + emit transferCheckStateChangeAsked ( transfer ); + emit recordCheckStateChangeAsked ( recordActivated ); qDebug() << "Window updated."; } -void SFLPhoneView::alternateColors(QListWidget * listWidget) -{ - for(int i = 0 ; i < listWidget->count(); i++) { - QListWidgetItem* item = listWidget->item(i); - QBrush c = (i % 2 == 1) ? palette().base() : palette().alternateBase(); - item->setBackground( c ); - } - listWidget->setUpdatesEnabled( true ); - -} - int SFLPhoneView::phoneNumberTypesDisplayed() { ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); @@ -457,25 +409,15 @@ void SFLPhoneView::updateVolumeBar() void SFLPhoneView::updateVolumeControls() { + ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - int display = false; - - if(QString(configurationManager.getAudioManager()) == "alsa") { - display = true; - - SFLPhone::app()->action_displayVolumeControls->setEnabled(true); - } - else { - SFLPhone::app()->action_displayVolumeControls->setEnabled(false); - } - - SFLPhone::app()->action_displayVolumeControls->setChecked(display); + //SFLPhone::app()->action_displayVolumeControls->setChecked(display); //widget_recVol->setVisible(display); //widget_sndVol->setVisible(display); - toolButton_recVol->setVisible(display && ConfigurationSkeleton::displayVolume()); - toolButton_sndVol->setVisible(display && ConfigurationSkeleton::displayVolume()); - slider_recVol->setVisible(display && ConfigurationSkeleton::displayVolume()); - slider_sndVol->setVisible(display && ConfigurationSkeleton::displayVolume()); + toolButton_recVol->setVisible ( SFLPhone::app()->action_displayVolumeControls->isChecked() && ConfigurationSkeleton::displayVolume() ); + toolButton_sndVol->setVisible ( SFLPhone::app()->action_displayVolumeControls->isChecked() && ConfigurationSkeleton::displayVolume() ); + slider_recVol->setVisible ( SFLPhone::app()->action_displayVolumeControls->isChecked() && ConfigurationSkeleton::displayVolume() ); + slider_sndVol->setVisible ( SFLPhone::app()->action_displayVolumeControls->isChecked() && ConfigurationSkeleton::displayVolume() ); } @@ -488,7 +430,7 @@ void SFLPhoneView::updateDialpad() void SFLPhoneView::updateStatusMessage() { qDebug() << "updateStatusMessage"; - Account * account = CallView::getCurrentAccount(); + Account * account = SFLPhone::model()->getCurrentAccount(); if(account == NULL) { emit statusMessageChangeAsked(i18n("No registered accounts")); @@ -515,7 +457,7 @@ void SFLPhoneView::displayVolumeControls(bool checked) void SFLPhoneView::displayDialpad(bool checked) { - qDebug() << "Max res2: " << ConfigurationSkeleton::displayDialpad() << "\n\n\n\n\n\n"; + qDebug() << "Max res2: " << ConfigurationSkeleton::displayDialpad(); ConfigurationSkeleton::setDisplayDialpad(checked); updateDialpad(); } @@ -618,26 +560,25 @@ void SFLPhoneView::contextMenuEvent(QContextMenuEvent *event) SFLPhone * window = SFLPhone::app(); QList<QAction *> callActions = window->getCallActions(); - menu.addAction(callActions.at((int) SFLPhone::Accept)); - menu.addAction(callActions[SFLPhone::Refuse]); - menu.addAction(callActions[SFLPhone::Hold]); - menu.addAction(callActions[SFLPhone::Transfer]); - menu.addAction(callActions[SFLPhone::Record]); + + menu.addAction ( callActions.at((int) SFLPhone::Accept) ); + menu.addAction ( callActions[ SFLPhone::Refuse ] ); + menu.addAction ( callActions[ SFLPhone::Hold ] ); + menu.addAction ( callActions[ SFLPhone::Transfer ] ); + menu.addAction ( callActions[ SFLPhone::Record ] ); menu.addSeparator(); - QAction * action = new ActionSetAccountFirst(NULL, &menu); - action->setChecked(CallView::getPriorAccoundId().isEmpty()); - connect(action, SIGNAL(setFirst(Account *)), - this , SLOT(setAccountFirst(Account *))); + QAction* action = new ActionSetAccountFirst(NULL, &menu); + action->setChecked(SFLPhone::model()->getPriorAccoundId().isEmpty()); + connect(action, SIGNAL(setFirst(Account *)), this , SLOT(setAccountFirst(Account *))); menu.addAction(action); - QVector<Account *> accounts = CallView::getAccountList()->registeredAccounts(); + QVector<Account *> accounts = SFLPhone::model()->getAccountList()->registeredAccounts(); for (int i = 0 ; i < accounts.size() ; i++) { - Account * account = accounts.at(i); - QAction * action = new ActionSetAccountFirst(account, &menu); - action->setChecked(account->getAccountId() == CallView::getPriorAccoundId()); - connect(action, SIGNAL(setFirst(Account *)), - this , SLOT(setAccountFirst(Account *))); + Account* account = accounts.at(i); + QAction* action = new ActionSetAccountFirst(account, &menu); + action->setChecked(account->getAccountId() == SFLPhone::model()->getPriorAccoundId()); + connect(action, SIGNAL(setFirst(Account *)), this , SLOT(setAccountFirst(Account *))); menu.addAction(action); } menu.exec(event->globalPos()); @@ -653,7 +594,7 @@ void SFLPhoneView::editBeforeCall() QString newNumber = QInputDialog::getText(this, i18n("Edit before call"), QString(), QLineEdit::Normal, number, &ok); if(ok) { changeScreen(SCREEN_MAIN); - Call* call = callTreeModel->addDialingCall(name); + Call* call = SFLPhone::model()->addDialingCall(name); call->appendText(newNumber); //callTreeModel->selectItem(addCallToCallList(call)); action(call, CALL_ACTION_ACCEPT); @@ -664,12 +605,12 @@ void SFLPhoneView::setAccountFirst(Account * account) { qDebug() << "setAccountFirst : " << (account ? account->getAlias() : QString()) << (account ? account->getAccountId() : QString()); if(account) { - CallView::setPriorAccountId(account->getAccountId()); + SFLPhone::model()->setPriorAccountId(account->getAccountId()); } else { - CallView::setPriorAccountId(QString()); + SFLPhone::model()->setPriorAccountId(QString()); } - qDebug() << "Current account id" << CallView::getCurrentAccountId(); + qDebug() << "Current account id" << SFLPhone::model()->getCurrentAccountId(); updateStatusMessage(); } @@ -700,14 +641,14 @@ void SFLPhoneView::accept() Call* call = callTreeModel->getCurrentItem(); if(!call) { qDebug() << "Calling when no item is selected. Opening an item."; - callTreeModel->addDialingCall(); + SFLPhone::model()->addDialingCall(); } else { int state = call->getState(); if(state == CALL_STATE_RINGING || state == CALL_STATE_CURRENT || state == CALL_STATE_HOLD || state == CALL_STATE_BUSY) { qDebug() << "Calling when item currently ringing, current, hold or busy. Opening an item."; - callTreeModel->addDialingCall(); + SFLPhone::model()->addDialingCall(); } else { action(call, CALL_ACTION_ACCEPT); @@ -761,66 +702,34 @@ void SFLPhoneView::record() void SFLPhoneView::mailBox() { - Account * account = CallView::getCurrentAccount(); + Account * account = SFLPhone::model()->getCurrentAccount(); QString mailBoxNumber = account->getAccountDetail(ACCOUNT_MAILBOX); - Call * call = callTreeModel->addDialingCall(); + Call * call = SFLPhone::model()->addDialingCall(); call->appendText(mailBoxNumber); action(call, CALL_ACTION_ACCEPT); } -void SFLPhoneView::on1_callStateChanged(const QString &callID, const QString &state) -{ - //This code is part of the CallModel iterface too - qDebug() << "Signal : Call State Changed for call " << callID << " . New state : " << state; - Call* call = callTreeModel->findCallByCallId(callID); - if(!call) { - if(state == CALL_STATE_CHANGE_RINGING) { - call = callTreeModel->addRingingCall(callID); - } - else { - qDebug() << "Call doesn't exist in this client. Might have been initialized by another client instance before this one started."; - return; - } - } - else { - call->stateChanged(state); - } - updateWindowCallState(); //NEED_PORT -} - void SFLPhoneView::on1_error(MapStringString details) { qDebug() << "Signal : Daemon error : " << details; } -void SFLPhoneView::on1_incomingCall(const QString & /*accountID*/, const QString & callID) +void SFLPhoneView::on1_incomingCall(Call* call) { - qDebug() << "Signal : Incoming Call ! ID = " << callID; - Call* call = callTreeModel->addIncomingCall(callID); - + qDebug() << "Signal : Incoming Call ! ID = " << call->getCallId(); + //Call* call = SFLPhone::model()->addIncomingCall(callID); + //NEED_PORT changeScreen(SCREEN_MAIN); - SFLPhone::app()->activateWindow(); - SFLPhone::app()->raise(); - SFLPhone::app()->setVisible(true); + SFLPhone::app()->activateWindow ( ); + SFLPhone::app()->raise ( ); + SFLPhone::app()->setVisible ( true ); emit incomingCall(call); } -void SFLPhoneView::on1_incomingConference(const QString &confID) { - callTreeModel->conferenceCreatedSignal(confID); -} - -void SFLPhoneView::on1_changingConference(const QString &confID, const QString &state) { - callTreeModel->conferenceChangedSignal(confID, state); -} - -void SFLPhoneView::on1_conferenceRemoved(const QString &confId) { - callTreeModel->conferenceRemovedSignal(confId); -} - void SFLPhoneView::on1_voiceMailNotify(const QString &accountID, int count) { qDebug() << "Signal : VoiceMail Notify ! " << count << " new voice mails for account " << accountID; diff --git a/kde/src/SFLPhoneView.h b/kde/src/SFLPhoneView.h index 799111193cdf6e913d95f7d75b2471a8b80db169..393cbfd596a18be19557a2f70f645242f864f92f 100755 --- a/kde/src/SFLPhoneView.h +++ b/kde/src/SFLPhoneView.h @@ -17,55 +17,47 @@ * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ + **************************************************************************/ #ifndef SFLPHONEVIEW_H #define SFLPHONEVIEW_H -#include <QtGui/QWidget> -#include <QtCore/QString> +#include "ui_SFLPhoneView_base.h" #include <QtCore/QVector> #include <QtCore/QList> -#include <QtGui/QKeyEvent> -#include <QErrorMessage> -#include <KXmlGuiWindow> +#include <QtGui/QWidget> -#include "ui_SFLPhoneView_base.h" -#include "conf/ConfigurationDialog.h" -#include "widgets/CallTreeItem.h" -#include "AccountWizard.h" -#include "lib/Contact.h" -#include "lib/AccountList.h" -#include "CallView.h" +//Qt +class QString; +class QKeyEvent; +class QErrorMessage; +class QListWidget; +//SFLPhone class ConfigurationDialog; - - -/** - * This is the main view class for sflphone-client-kde. Most of the non-menu, - * non-toolbar, and non-statusbar (e.g., non frame) GUI code should go - * here. - * As the state of the view has effects on the window, - * it emits some signals to ask for changes that the window has - * to treat. - * - * @short Main view - * @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> - * @version 0.9.6 +class AccountWizard; +class CallView; + + +/** + * This is the main view class for sflphone-client-kde. Most of the non-menu, + * non-toolbar, and non-statusbar (e.g., non frame) GUI code should go + * here. + * As the state of the view has effects on the window, + * it emits some signals to ask for changes that the window has + * to treat. + * + * @short Main view + * @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> + * @version 0.9.6 */ class SFLPhoneView : public QWidget, public Ui::SFLPhone_view { Q_OBJECT private: - - //static ConfigurationDialog * configDialog; AccountWizard * wizard; - //List of calls in the window, and past ones. - //Handles both current calls (dialing, ringing...) and history. - //CallList * callList; QErrorMessage * errorWindow; - //Account used prioritary if defined and registered. If not, the first registered account in accountList is used. protected: @@ -103,19 +95,6 @@ public: * chosen to be displayed in SFLphone configuration. */ int phoneNumberTypesDisplayed(); - - /** - * - * @return true if the address book is enabled in config - */ - //bool isAddressBookEnabled(); - - //QVector<Contact *> findContactsInKAddressBook(QString textSearched, bool & full); - - /** - * Save the settings to save in the daemon before exit - */ - void saveState(); private slots: /** @@ -174,13 +153,6 @@ private slots: */ void editBeforeCall(); - /** - * Alternates colors of the list widget with the application's palettes's - * base and alternateBase colors. - * @param listWidget the list widget to which we alternate colors - */ - void alternateColors(QListWidget * listWidget); - /** * Updates the toolbar's actions' display according to the selected * item's state. @@ -192,12 +164,12 @@ private slots: * text searched. * If empty, hide the search bar. */ - void updateRecordButton(); - void updateVolumeButton(); - void updateRecordBar(); - void updateVolumeBar(); - void updateVolumeControls(); - void updateDialpad(); + void updateRecordButton (); + void updateVolumeButton (); + void updateRecordBar (); + void updateVolumeBar (); + void updateVolumeControls (); + void updateDialpad (); public slots: @@ -223,7 +195,7 @@ public slots: else { QString text = event->text(); - if(! event->text().isEmpty()) + if(! text.isEmpty()) { typeString(text); } @@ -234,46 +206,35 @@ public slots: void displayDialpad(bool checked = true); void configureSflPhone(); void accountCreationWizard(); - void accept(); - void refuse(); - void hold(); - void transfer(); - void record(); - void mailBox(); + void accept (); + void refuse (); + void hold (); + void transfer (); + void record (); + void mailBox (); void on_widget_dialpad_typed(QString text); - void on_slider_recVol_valueChanged(int value); - void on_slider_sndVol_valueChanged(int value); - - void on_toolButton_recVol_clicked(bool checked); - void on_toolButton_sndVol_clicked(bool checked); - - //void on_callTree_currentItemChanged(); - //void on_callTree_itemChanged(); - //void on_callTree_itemDoubleClicked(QTreeWidgetItem* item, int column); + void on_slider_recVol_valueChanged ( int value ); + void on_slider_sndVol_valueChanged ( int value ); + void on_toolButton_recVol_clicked ( bool checked ); + void on_toolButton_sndVol_clicked ( bool checked ); - void on1_callStateChanged(const QString &callID, const QString &state); void on1_error(MapStringString details); - void on1_incomingCall(const QString &accountID, const QString &callID/*, const QString &from*/); - //void on1_incomingMessage(const QString &accountID, const QString &message); + void on1_incomingCall(Call* call); void on1_voiceMailNotify(const QString &accountID, int count); void on1_volumeChanged(const QString &device, double value); - //void on1_audioManagerChanged(); - void on1_incomingConference(const QString &confID); - void on1_changingConference(const QString &confID, const QString &state); - void on1_conferenceRemoved(const QString &confId); void changeScreen(int screen); signals: - void statusMessageChangeAsked(const QString & message); - void windowTitleChangeAsked(const QString & title); - void enabledActionsChangeAsked(const bool * enabledActions); - void actionIconsChangeAsked(const QString * actionIcons); - void actionTextsChangeAsked(const QString * actionTexts); - void transferCheckStateChangeAsked(bool transferCheckState); - void recordCheckStateChangeAsked(bool recordCheckState); - void addressBookEnableAsked(bool enableAddressBook); + void statusMessageChangeAsked ( const QString& message ); + void windowTitleChangeAsked ( const QString& title ); + void enabledActionsChangeAsked ( const bool* enabledActions ); + void actionIconsChangeAsked ( const QString* actionIcons ); + void actionTextsChangeAsked ( const QString* actionTexts ); + void transferCheckStateChangeAsked ( bool transferCheckState ); + void recordCheckStateChangeAsked ( bool recordCheckState ); + void addressBookEnableAsked ( bool enableAddressBook ); void screenChanged(int screen); void incomingCall(const Call * call); diff --git a/kde/src/SFLPhoneapplication.cpp b/kde/src/SFLPhoneapplication.cpp index f7c4e8cb4adfc97991a4eebcfc690bcff295f3b6..786df12a2cdd49cac728af56ab8fedd40d4bfcb3 100755 --- a/kde/src/SFLPhoneapplication.cpp +++ b/kde/src/SFLPhoneapplication.cpp @@ -102,10 +102,10 @@ void SFLPhoneApplication::initializePaths() qDebug() << "KGlobal::dirs" << QString(DATA_INSTALL_DIR); // Test whether the prefix is correct. - if( KGlobal::dirs()->findResource( "appdata", "icons/hi128-apps-sflphone-client-kde.png" ).isNull() ) { - kWarning() << "SFLPhone could not find resources in the search paths: " - << KGlobal::dirs()->findDirs( "appdata", QString::null ).join(", ") << endl; - } +// if( KGlobal::dirs()->findResource( "appdata", "icons/hi128-apps-sflphone-client-kde.png" ).isNull() ) { +// kWarning() << "SFLPhone could not find resources in the search paths: " +// << KGlobal::dirs()->findDirs( "appdata", QString::null ).join(", ") << endl; + //} } Q_NOREPLY void SFLPhoneApplication::quit2() diff --git a/kde/src/conf/dlgaccounts.cpp b/kde/src/conf/dlgaccounts.cpp index d7ce422edc10a33cbc20965b6902cf0b760a1f9b..e928183f275e529f3bcbec536b30fb194b95890b 100755 --- a/kde/src/conf/dlgaccounts.cpp +++ b/kde/src/conf/dlgaccounts.cpp @@ -24,6 +24,7 @@ #include "lib/configurationmanager_interface_singleton.h" #include "SFLPhoneView.h" +#include "../AccountView.h" #include "lib/sflphone_const.h" #include "conf/ConfigurationDialog.h" #include <vector> @@ -33,7 +34,7 @@ DlgAccounts::DlgAccounts(KConfigDialog* parent) : QWidget(parent) { setupUi(this); - + disconnect(keditlistbox_codec->addButton(),SIGNAL(clicked())); ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); button_accountUp->setIcon (KIcon("go-up") ); button_accountDown->setIcon (KIcon("go-down") ); @@ -45,47 +46,50 @@ DlgAccounts::DlgAccounts(KConfigDialog* parent) accountListHasChanged = false; //toolButton_accountsApply->setEnabled(false); + QRadioButton* rbloc = radioButton_pa_same_as_local; + QRadioButton* rbcus = radioButton_pa_custom; + //SLOTS - // SENDER SIGNAL RECEIVER SLOT / - /**/connect(edit1_alias, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); - /**/connect(edit2_protocol, SIGNAL(activated(int)) , this , SLOT(changedAccountList() )); - /**/connect(edit3_server, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); - /**/connect(edit4_user, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); - /**/connect(edit5_password, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); - /**/connect(edit6_mailbox, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); - /**/connect(spinbox_regExpire, SIGNAL(editingFinished()) , this , SLOT(changedAccountList() )); - /**/connect(comboBox_ni_local_address, SIGNAL(currentIndexChanged (int)) , this , SLOT(changedAccountList() )); - /**/connect(checkBox_conformRFC, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); - /**/connect(button_accountUp, SIGNAL(clicked()) , this , SLOT(changedAccountList() )); - /**/connect(button_accountDown, SIGNAL(clicked()) , this , SLOT(changedAccountList() )); - /**/connect(button_accountAdd, SIGNAL(clicked()) , this , SLOT(changedAccountList() )); - /**/connect(button_accountRemove, SIGNAL(clicked()) , this , SLOT(changedAccountList() )); - /**/connect(edit_tls_private_key_password, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); - /**/connect(spinbox_tls_listener, SIGNAL(editingFinished()) , this , SLOT(changedAccountList() )); - /**/connect(file_tls_authority, SIGNAL(textChanged(const QString &)), this , SLOT(changedAccountList() )); - /**/connect(file_tls_endpoint, SIGNAL(textChanged(const QString &)), this , SLOT(changedAccountList() )); - /**/connect(file_tls_private_key, SIGNAL(textChanged(const QString &)), this , SLOT(changedAccountList() )); - /**/connect(combo_tls_method, SIGNAL(currentIndexChanged(int)) , this , SLOT(changedAccountList() )); - /**/connect(edit_tls_cipher, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); - /**/connect(edit_tls_outgoing, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); - /**/connect(spinbox_tls_timeout_sec, SIGNAL(editingFinished()) , this , SLOT(changedAccountList() )); - /**/connect(spinbox_tls_timeout_msec, SIGNAL(editingFinished()) , this , SLOT(changedAccountList() )); - /**/connect(check_tls_incoming, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); - /**/connect(check_tls_answer, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); - /**/connect(check_tls_requier_cert, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); - /**/connect(group_security_tls, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); - /**/connect(radioButton_pa_same_as_local, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); - /**/connect(radioButton_pa_custom, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); - /**/connect(&configurationManager, SIGNAL(accountsChanged()) , this , SLOT(updateAccountStates() )); - /**/connect(edit_tls_private_key_password, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); - /**/connect(this, SIGNAL(updateButtons()) , parent , SLOT(updateButtons() )); - /**/connect(keditlistbox_codec->listView(), SIGNAL(clicked(QModelIndex)) , this , SLOT(codecClicked(QModelIndex) )); - /**/connect(keditlistbox_codec->addButton(),SIGNAL(clicked()) , this , SLOT(addCodec() )); - /**/connect(keditlistbox_codec, SIGNAL(changed()) , this , SLOT(codecChanged() )); - /**/connect(combo_security_STRP, SIGNAL(currentIndexChanged(int)) , this , SLOT(updateCombo(int) )); - /**/connect(button_add_credential, SIGNAL(clicked()) , this , SLOT(addCredential() )); - /**/connect(button_remove_credential, SIGNAL(clicked()) , this , SLOT(removeCredential() )); - /* */ + // SENDER SIGNAL RECEIVER SLOT / + /**/connect(edit1_alias, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); + /**/connect(edit2_protocol, SIGNAL(activated(int)) , this , SLOT(changedAccountList() )); + /**/connect(edit3_server, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); + /**/connect(edit4_user, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); + /**/connect(edit5_password, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); + /**/connect(edit6_mailbox, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); + /**/connect(spinbox_regExpire, SIGNAL(editingFinished()) , this , SLOT(changedAccountList() )); + /**/connect(comboBox_ni_local_address, SIGNAL(currentIndexChanged (int)) , this , SLOT(changedAccountList() )); + /**/connect(checkBox_conformRFC, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); + /**/connect(button_accountUp, SIGNAL(clicked()) , this , SLOT(changedAccountList() )); + /**/connect(button_accountDown, SIGNAL(clicked()) , this , SLOT(changedAccountList() )); + /**/connect(button_accountAdd, SIGNAL(clicked()) , this , SLOT(changedAccountList() )); + /**/connect(button_accountRemove, SIGNAL(clicked()) , this , SLOT(changedAccountList() )); + /**/connect(edit_tls_private_key_password, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); + /**/connect(spinbox_tls_listener, SIGNAL(editingFinished()) , this , SLOT(changedAccountList() )); + /**/connect(file_tls_authority, SIGNAL(textChanged(const QString &)), this , SLOT(changedAccountList() )); + /**/connect(file_tls_endpoint, SIGNAL(textChanged(const QString &)), this , SLOT(changedAccountList() )); + /**/connect(file_tls_private_key, SIGNAL(textChanged(const QString &)), this , SLOT(changedAccountList() )); + /**/connect(combo_tls_method, SIGNAL(currentIndexChanged(int)) , this , SLOT(changedAccountList() )); + /**/connect(edit_tls_cipher, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); + /**/connect(edit_tls_outgoing, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); + /**/connect(spinbox_tls_timeout_sec, SIGNAL(editingFinished()) , this , SLOT(changedAccountList() )); + /**/connect(spinbox_tls_timeout_msec, SIGNAL(editingFinished()) , this , SLOT(changedAccountList() )); + /**/connect(check_tls_incoming, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); + /**/connect(check_tls_answer, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); + /**/connect(check_tls_requier_cert, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); + /**/connect(group_security_tls, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); + /**/connect(radioButton_pa_same_as_local, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); + /**/connect(radioButton_pa_custom, SIGNAL(clicked(bool)) , this , SLOT(changedAccountList() )); + /**/connect(&configurationManager, SIGNAL(accountsChanged()) , this , SLOT(updateAccountStates() )); + /**/connect(edit_tls_private_key_password, SIGNAL(textEdited(const QString &)) , this , SLOT(changedAccountList() )); + /**/connect(this, SIGNAL(updateButtons()) , parent , SLOT(updateButtons() )); + /**/connect(keditlistbox_codec->listView(), SIGNAL(clicked(QModelIndex)) , this , SLOT(codecClicked(QModelIndex) )); + /**/connect(keditlistbox_codec->addButton(),SIGNAL(clicked()) , this , SLOT(addCodec() )); + /**/connect(keditlistbox_codec, SIGNAL(changed()) , this , SLOT(codecChanged() )); + /**/connect(combo_security_STRP, SIGNAL(currentIndexChanged(int)) , this , SLOT(updateCombo(int) )); + /**/connect(button_add_credential, SIGNAL(clicked()) , this , SLOT(addCredential() )); + /**/connect(button_remove_credential, SIGNAL(clicked()) , this , SLOT(removeCredential() )); + /* */ connect(list_credential, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), this,SLOT( selectCredential(QListWidgetItem*, QListWidgetItem*))); @@ -350,6 +354,8 @@ void DlgAccounts::loadAccount(QListWidgetItem * item) tab_advanced->setEnabled(true); line_stun->setEnabled(checkbox_stun->isChecked()); + radioButton_pa_same_as_local->setDisabled(checkbox_stun->isChecked()); + radioButton_pa_custom->setDisabled(checkbox_stun->isChecked()); } else { checkbox_stun->setChecked(false); @@ -650,12 +656,12 @@ void DlgAccounts::loadCredentails(QString accountId) { VectorMapStringString credentials = configurationManager.getCredentials(accountId); for (int i=0; i < credentials.size(); i++) { QListWidgetItem* newItem = new QListWidgetItem(); - newItem->setText(credentials[i]["username"]); + newItem->setText(credentials[i][ "username" ]); CredentialData data; - data.pointer = newItem ; - data.name = credentials[i]["username"] ; - data.password = credentials[i]["password"] ; - data.realm = credentials[i]["realm"] ; + data.pointer = newItem ; + data.name = credentials[i][ "username" ] ; + data.password = credentials[i][ "password" ] ; + data.realm = credentials[i][ "realm" ] ; credentialInfo[newItem] = data; credentialList << data; list_credential->addItem(newItem); diff --git a/kde/src/conf/dlgaccounts.h b/kde/src/conf/dlgaccounts.h index 48125a3edf0783e5190e9b2fe1d5dc02d62664d1..93784f26987cd4861478b4f51dca7111df609852 100755 --- a/kde/src/conf/dlgaccounts.h +++ b/kde/src/conf/dlgaccounts.h @@ -49,8 +49,18 @@ class Private_AddCodecDialog : public KDialog { Private_AddCodecDialog(QList< StringHash > itemList, QStringList currentItems ,QWidget* parent = 0) : KDialog(parent) { codecTable = new QTableWidget(this); codecTable->verticalHeader()->setVisible(false); - codecTable->setColumnCount(5); + codecTable->setColumnCount(4); + for (int i=0;i<4;i++) { + codecTable->setHorizontalHeaderItem( i, new QTableWidgetItem(0)); + codecTable->horizontalHeader()->setResizeMode(i,QHeaderView::ResizeToContents); + } + codecTable->setSelectionBehavior(QAbstractItemView::SelectRows); + codecTable->horizontalHeaderItem(0)->setText("Name"); + codecTable->horizontalHeaderItem(1)->setText("Bitrate"); + codecTable->horizontalHeaderItem(2)->setText("Frequency"); + codecTable->horizontalHeaderItem(3)->setText("Alias"); + codecTable->horizontalHeader()->setResizeMode(0,QHeaderView::Stretch); int i =0; foreach (StringHash aCodec, itemList) { if ( currentItems.indexOf(aCodec["alias"]) == -1) { @@ -62,12 +72,12 @@ class Private_AddCodecDialog : public KDialog { QTableWidgetItem* cFrequency = new QTableWidgetItem(aCodec["frequency"]); codecTable->setItem(i,2,cFrequency); QTableWidgetItem* cAlias = new QTableWidgetItem(aCodec["alias"]); - codecTable->setItem(i,4,cAlias); + codecTable->setItem(i,3,cAlias); i++; } } setMainWidget(codecTable); - resize(400,300); + resize(550,300); connect(this, SIGNAL(okClicked()), this, SLOT(emitNewCodec())); } @@ -75,7 +85,8 @@ class Private_AddCodecDialog : public KDialog { QTableWidget* codecTable; private slots: void emitNewCodec() { - emit addCodec(codecTable->item(codecTable->currentRow(),4)->text()); + if (codecTable->currentRow() >= 0) + emit addCodec(codecTable->item(codecTable->currentRow(),3)->text()); } signals: void addCodec(QString alias); diff --git a/kde/src/conf/dlgaccountsbase.ui b/kde/src/conf/dlgaccountsbase.ui index 29a0fe63ba81f9fac639d7fb3bbd140104f29b36..94f5f4c68cb83d067708c9d301ba76ca53571ccc 100755 --- a/kde/src/conf/dlgaccountsbase.ui +++ b/kde/src/conf/dlgaccountsbase.ui @@ -539,65 +539,54 @@ </widget> </item> <item> - <spacer name="verticalSpacer_3"> - <property name="orientation"> - <enum>Qt::Vertical</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>138</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - <widget class="QWidget" name="tab_stun"> - <attribute name="title"> - <string>Stun</string> - </attribute> - <layout class="QGridLayout" name="gridLayout_6"> - <item row="0" column="0" colspan="2"> - <widget class="QLabel" name="label_commonSettings"> - <property name="text"> - <string>Stun parameters will be applied on each SIP account created.</string> - </property> - <property name="wordWrap"> - <bool>true</bool> + <widget class="QGroupBox" name="groupBox_4"> + <property name="title"> + <string>Stun</string> </property> + <layout class="QGridLayout" name="gridLayout_11"> + <item row="0" column="0" colspan="2"> + <widget class="QLabel" name="label_commonSettings"> + <property name="text"> + <string>Stun parameters will be applied on each SIP account created.</string> + </property> + <property name="wordWrap"> + <bool>true</bool> + </property> + </widget> + </item> + <item row="1" column="0"> + <widget class="QCheckBox" name="checkbox_stun"> + <property name="text"> + <string>Enable Stun</string> + </property> + </widget> + </item> + <item row="1" column="1"> + <widget class="KLineEdit" name="line_stun"> + <property name="enabled"> + <bool>false</bool> + </property> + <property name="clickMessage"> + <string>choose Stun server (example : stunserver.org)</string> + </property> + </widget> + </item> + </layout> </widget> </item> - <item row="2" column="0"> - <spacer name="verticalSpacer_2"> + <item> + <spacer name="verticalSpacer_3"> <property name="orientation"> <enum>Qt::Vertical</enum> </property> <property name="sizeHint" stdset="0"> <size> <width>20</width> - <height>40</height> + <height>138</height> </size> </property> </spacer> </item> - <item row="1" column="0"> - <widget class="QCheckBox" name="checkbox_stun"> - <property name="text"> - <string>Enable Stun</string> - </property> - </widget> - </item> - <item row="1" column="1"> - <widget class="KLineEdit" name="line_stun"> - <property name="enabled"> - <bool>false</bool> - </property> - <property name="clickMessage"> - <string>choose Stun server (example : stunserver.org)</string> - </property> - </widget> - </item> </layout> </widget> <widget class="QWidget" name="tab_codec"> @@ -1196,12 +1185,44 @@ <slot>setEnabled(bool)</slot> <hints> <hint type="sourcelabel"> - <x>324</x> - <y>74</y> + <x>320</x> + <y>415</y> + </hint> + <hint type="destinationlabel"> + <x>448</x> + <y>419</y> + </hint> + </hints> + </connection> + <connection> + <sender>checkbox_stun</sender> + <signal>toggled(bool)</signal> + <receiver>radioButton_pa_same_as_local</receiver> + <slot>setDisabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>307</x> + <y>412</y> + </hint> + <hint type="destinationlabel"> + <x>372</x> + <y>248</y> + </hint> + </hints> + </connection> + <connection> + <sender>checkbox_stun</sender> + <signal>toggled(bool)</signal> + <receiver>radioButton_pa_custom</receiver> + <slot>setDisabled(bool)</slot> + <hints> + <hint type="sourcelabel"> + <x>300</x> + <y>412</y> </hint> <hint type="destinationlabel"> - <x>429</x> - <y>77</y> + <x>341</x> + <y>278</y> </hint> </hints> </connection> diff --git a/kde/src/lib/Account.cpp b/kde/src/lib/Account.cpp index c9c415866817db2ce11a0738498344cf147d7e6a..bf978941af455c5527e6d822b7c2af868e17cc09 100644 --- a/kde/src/lib/Account.cpp +++ b/kde/src/lib/Account.cpp @@ -23,6 +23,8 @@ #include <QtGui/QApplication> #include <QDebug> +#include <QtCore/QString> +#include <QtGui/QColor> #include "sflphone_const.h" #include "configurationmanager_interface_singleton.h" diff --git a/kde/src/lib/Account.h b/kde/src/lib/Account.h index b4c235ac25045fe774f776bb6619cbdea0e88ee5..f393a13fde8b92d6b0e912c57cb4466f45db8c77 100644 --- a/kde/src/lib/Account.h +++ b/kde/src/lib/Account.h @@ -22,8 +22,8 @@ #ifndef ACCOUNT_H #define ACCOUNT_H -#include <QtCore/QString> -#include <QtGui/QColor> +//Qt +class QString; #include "typedefs.h" diff --git a/kde/src/lib/AccountList.cpp b/kde/src/lib/AccountList.cpp index 14212427c1146938857da1eed45c30c2f88adec6..be54288e7e3948e8209b2a5416f04acef6b7da52 100644 --- a/kde/src/lib/AccountList.cpp +++ b/kde/src/lib/AccountList.cpp @@ -166,7 +166,7 @@ Account* AccountList::firstRegisteredAccount() const Account* current; for (int i = 0; i < m_pAccounts->count(); ++i) { current = (*m_pAccounts)[i]; - if(current->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) { + if(current && current->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED) { return current; } else { diff --git a/kde/src/lib/Call.cpp b/kde/src/lib/Call.cpp index 628fdd52bd2cb31852216a53831c7e3ffa126c5c..54533d8b97cf22eb9fb5f70e7b9a46ac6f65c6d0 100644 --- a/kde/src/lib/Call.cpp +++ b/kde/src/lib/Call.cpp @@ -24,6 +24,8 @@ #include "callmanager_interface_singleton.h" #include "configurationmanager_interface_singleton.h" +#include "ContactBackend.h" +#include "Contact.h" const call_state Call::actionPerformedStateMap [11][5] = @@ -94,6 +96,13 @@ const function Call::stateChangedFunctionMap[11][6] = const char * Call::historyIcons[3] = {ICON_HISTORY_INCOMING, ICON_HISTORY_OUTGOING, ICON_HISTORY_MISSED}; +ContactBackend* Call::m_pContactBackend = 0; + +void Call::setContactBackend(ContactBackend* be) +{ + m_pContactBackend = be; +} + ///Constructor Call::Call(call_state startState, QString callId, QString peerName, QString peerNumber, QString account) : conference(false) @@ -318,13 +327,13 @@ QString Call::getStartTimeStamp() const ///Get the number where the call have been transferred QString Call::getTransferNumber() const { - return transferNumber; + return m_pTransferNumber; } ///Get the call / peer number QString Call::getCallNumber() const { - return callNumber; + return m_pCallNumber; } ///Return the call id @@ -416,13 +425,13 @@ bool Call::isSecure() const { ///Set the transfer number void Call::setTransferNumber(QString number) { - transferNumber = number; + m_pTransferNumber = number; } ///Set the call number void Call::setCallNumber(QString number) { - callNumber = number; + m_pCallNumber = number; emit changed(); } @@ -472,8 +481,9 @@ call_state Call::stateChanged(const QString& newStateName) call_state Call::actionPerformed(call_action action) { call_state previousState = currentState; - Q_ASSERT_X((previousState>10) || (previousState<0),"perform action","Invalid previous state ("+QString::number(previousState)+")"); - Q_ASSERT_X((state>4) || (state < 0),"perform action","Invalid action ("+QString::number(actuon)+")"); + Q_ASSERT_X((previousState>10) || (previousState<0),"perform action","Invalid previous state ("+QString::number(previousState)+")"); + Q_ASSERT_X((state>4) || (state < 0),"perform action","Invalid action ("+QString::number(action)+")"); + Q_ASSERT_X((action>5) || (action < 0),"perform action","Invalid action ("+QString::number(action)+")"); //update the state changeCurrentState(actionPerformedStateMap[previousState][action]); //execute the action associated with this transition @@ -543,9 +553,9 @@ void Call::refuse() void Call::acceptTransf() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Accepting call and transfering it to number : " << transferNumber << ". callId : " << m_pCallId; + qDebug() << "Accepting call and transfering it to number : " << m_pTransferNumber << ". callId : " << m_pCallId; callManager.accept(m_pCallId); - callManager.transfer(m_pCallId, transferNumber); + callManager.transfer(m_pCallId, m_pTransferNumber); // m_pHistoryState = TRANSFERED; } @@ -594,17 +604,20 @@ void Call::call() this->m_pAccount = CallModelConvenience::getCurrentAccountId(); } if(!m_pAccount.isEmpty()) { - qDebug() << "Calling " << callNumber << " with account " << m_pAccount << ". callId : " << m_pCallId; - callManager.placeCall(m_pAccount, m_pCallId, callNumber); + qDebug() << "Calling " << m_pCallNumber << " with account " << m_pAccount << ". callId : " << m_pCallId; + callManager.placeCall(m_pAccount, m_pCallId, m_pCallNumber); this->m_pAccount = m_pAccount; - this->m_pPeerPhoneNumber = callNumber; -// Contact * contact = findContactForNumberInKAddressBook(peerPhoneNumber); //TODO port -// if(contact) this->m_pPeerName = contact->getNickName(); + this->m_pPeerPhoneNumber = m_pCallNumber; + if (m_pContactBackend) { + Contact* contact = m_pContactBackend->getContactByPhone(m_pPeerPhoneNumber); + if (contact) + m_pPeerName = contact->getFormattedName(); + } this->m_pStartTime = new QDateTime(QDateTime::currentDateTime()); this->m_pHistoryState = OUTGOING; } else { - qDebug() << "Trying to call " << transferNumber << " with no account registered . callId : " << m_pCallId; + qDebug() << "Trying to call " << m_pTransferNumber << " with no account registered . callId : " << m_pCallId; this->m_pHistoryState = NONE; throw "No account registered!"; } @@ -614,8 +627,8 @@ void Call::call() void Call::transfer() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Transfering call to number : " << transferNumber << ". callId : " << m_pCallId; - callManager.transfer(m_pCallId, transferNumber); + qDebug() << "Transfering call to number : " << m_pTransferNumber << ". callId : " << m_pCallId; + callManager.transfer(m_pCallId, m_pTransferNumber); this->m_pStopTime = new QDateTime(QDateTime::currentDateTime()); } @@ -693,10 +706,10 @@ void Call::appendText(QString str) switch (currentState) { case CALL_STATE_TRANSFER : case CALL_STATE_TRANSF_HOLD : - editNumber = &transferNumber; + editNumber = &m_pTransferNumber; break; case CALL_STATE_DIALING : - editNumber = &callNumber; + editNumber = &m_pCallNumber; break; default : qDebug() << "Backspace on call not editable. Doing nothing."; @@ -716,10 +729,10 @@ void Call::backspaceItemText() switch (currentState) { case CALL_STATE_TRANSFER : case CALL_STATE_TRANSF_HOLD : - editNumber = &transferNumber; + editNumber = &m_pTransferNumber; break; case CALL_STATE_DIALING : - editNumber = &callNumber; + editNumber = &m_pCallNumber; break; default : qDebug() << "Backspace on call not editable. Doing nothing."; diff --git a/kde/src/lib/Call.h b/kde/src/lib/Call.h index 97caa2625042e8afed9e6e235205063931bffe2a..e8769151504d672e72d84e72e787b0b5e5d9a9b7 100644 --- a/kde/src/lib/Call.h +++ b/kde/src/lib/Call.h @@ -17,20 +17,23 @@ * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ + **************************************************************************/ #ifndef CALL_H #define CALL_H -#include <QtCore/QString> -#include <QtCore/QDateTime> -#include <QtGui/QLabel> -#include <QtGui/QWidget> +//Qt +class QString; +class QDateTime; +class QLabel; +class QWidget; #include "sflphone_const.h" #include "typedefs.h" +class ContactBackend; + /** @enum daemon_call_state_t * This enum have all the states a call can take for the daemon. @@ -134,8 +137,9 @@ private: QLabel * labelHistoryTime; */ - QString transferNumber; - QString callNumber; + QString m_pTransferNumber; + QString m_pCallNumber; + static ContactBackend* m_pContactBackend; bool conference; @@ -212,6 +216,7 @@ public: static Call* buildRingingCall (const QString & callId ); static Call* buildHistoryCall (const QString & callId, uint startTimeStamp, uint stopTimeStamp, QString account, QString name, QString number, QString type ); static Call* buildExistingCall (QString callId ); + static void setContactBackend (ContactBackend* be ); //Static getters static history_state getHistoryStateFromType ( QString type ); diff --git a/kde/src/lib/CallModel.cpp b/kde/src/lib/CallModel.cpp index d3746dd489e0ebdb4b68e3d57d5611a119c27a17..e74ca594d8fd051967e6cbd5e12b05a302f63abd 100644 --- a/kde/src/lib/CallModel.cpp +++ b/kde/src/lib/CallModel.cpp @@ -19,3 +19,112 @@ **************************************************************************/ #include <CallModel.h> +bool CallModelBase::dbusInit = false; + +CallModelBase::CallModelBase(QObject* parent) : QObject(parent) +{ + if (!dbusInit) { + CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); + connect(&callManager, SIGNAL( callStateChanged (const QString &, const QString & ) ), this , SLOT( on1_callStateChanged ( const QString &, const QString & ) ) ); + connect(&callManager, SIGNAL( incomingCall (const QString &, const QString &, const QString & ) ), this , SLOT( on1_incomingCall ( const QString &, const QString & ) ) ); + connect(&callManager, SIGNAL( conferenceCreated (const QString & ) ), this , SLOT( on1_incomingConference( const QString & ) ) ); + connect(&callManager, SIGNAL( conferenceChanged (const QString &, const QString & ) ), this , SLOT( on1_changingConference( const QString &, const QString & ) ) ); + connect(&callManager, SIGNAL( conferenceRemoved (const QString & ) ), this , SLOT( on1_conferenceRemoved ( const QString & ) ) ); + connect(&callManager, SIGNAL( voiceMailNotify (const QString &, int ) ), this , SLOT( on1_voiceMailNotify ( const QString &, int ) ) ); + connect(&callManager, SIGNAL( volumeChanged (const QString &, double ) ), this , SLOT( on1_volumeChanged ( const QString &, double ) ) ); + dbusInit = true; + } +} + +void CallModelBase::on1_callStateChanged(const QString &callID, const QString &state) +{ + //This code is part of the CallModel iterface too + qDebug() << "Signal : Call State Changed for call " << callID << " . New state : " << state; + Call* call = findCallByCallId(callID); + if(!call) { + qDebug() << "Call not found"; + if(state == CALL_STATE_CHANGE_RINGING) { + call = addRingingCall(callID); + } + else { + qDebug() << "Call doesn't exist in this client. Might have been initialized by another client instance before this one started."; + return; + } + } + else { + qDebug() << "Call found" << call; + call->stateChanged(state); + } + //updateWindowCallState(); //NEED_PORT + emit callStateChanged(call); + +} + +void CallModelBase::on1_incomingCall(const QString & accountID, const QString & callID) +{ + Q_UNUSED(accountID) + qDebug() << "Signal : Incoming Call ! ID = " << callID; + Call* call = addIncomingCall(callID); + + //NEED_PORT +// changeScreen(SCREEN_MAIN); +// +// SFLPhone::app()->activateWindow(); +// SFLPhone::app()->raise(); +// SFLPhone::app()->setVisible(true); + + //emit incomingCall(call); + emit incomingCall(call); +} + +void CallModelBase::on1_incomingConference(const QString &confID) +{ + Call* conf = addConference(confID); + qDebug() << "---------------Adding conference" << conf << confID << "---------------"; + emit conferenceCreated(conf); +} + +void CallModelBase::on1_changingConference(const QString &confID, const QString &state) +{ + Call* conf = getCall(confID); + qDebug() << "Changing conference state" << conf << confID; + if (conf) { + changeConference(confID, state); + emit conferenceChanged(conf); + } + else { + qDebug() << "Trying to affect a conference that does not exist (anymore)"; + } +} + +void CallModelBase::on1_conferenceRemoved(const QString &confId) +{ + Call* conf = getCall(confId); + emit aboutToRemoveConference(conf); + removeConference(confId); + emit conferenceRemoved(confId); +} + +void CallModelBase::on1_voiceMailNotify(const QString &accountID, int count) +{ + qDebug() << "Signal : VoiceMail Notify ! " << count << " new voice mails for account " << accountID; + emit voiceMailNotify(accountID,count); +} + +void CallModelBase::on1_volumeChanged(const QString & device, double value) +{ +// qDebug() << "Signal : Volume Changed !"; +// if(! (toolButton_recVol->isChecked() && value == 0.0)) +// updateRecordBar(); +// if(! (toolButton_sndVol->isChecked() && value == 0.0)) +// updateVolumeBar(); + emit volumeChanged(device,value); +} + +Call* CallModelBase::addCall(Call* call, Call* parent) +{ + emit callAdded(call,parent); + return call; +} + +//More code in CallModel.hpp \ No newline at end of file diff --git a/kde/src/lib/CallModel.h b/kde/src/lib/CallModel.h index aee51aef13c99c766b89635251bb1ef14ff66081..6262751177a2e0c000388c645cd4aba7d2831e7a 100644 --- a/kde/src/lib/CallModel.h +++ b/kde/src/lib/CallModel.h @@ -22,32 +22,68 @@ #define CALL_MODEL_H #include <QObject> -#include <QHash> #include <QVector> -#include <QDragEnterEvent> -#include <QDebug> - -#include "Call.h" -#include "AccountList.h" -#include "dbus/metatypes.h" -#include "callmanager_interface_singleton.h" -#include "configurationmanager_interface_singleton.h" -#include "instance_interface_singleton.h" -#include "sflphone_const.h" -#include "unistd.h" +#include <QHash> #include "typedefs.h" +//Qt +class QDragEnterEvent; +class QDebug; +class QModelIndex; + +//SFLPhone +class Call; +class AccountList; +class Account; +class ContactBackend; + typedef QHash<QString, Call*> CallHash; typedef QList<Call*> CallList; +///This class need to exist because template classes can't have signals ans +///slots because Qt MOC generator can't guess the type at precompilation +class LIB_EXPORT CallModelBase : public QObject +{ + Q_OBJECT +public: + CallModelBase(QObject* parent = 0); + virtual bool changeConference ( const QString &confId, const QString &state ) = 0; + virtual void removeConference ( const QString &confId ) = 0; + virtual Call* addConference ( const QString &confID ) = 0; + virtual Call* findCallByCallId ( QString callId ) = 0; + virtual Call* addRingingCall ( const QString& callId ) = 0; + virtual Call* addIncomingCall ( const QString& callId ) = 0; + virtual Call* addCall ( Call* call , Call* parent =0 ); + virtual Call* getCall ( const QString callId ) const = 0; +public slots: + void on1_callStateChanged ( const QString& callID , const QString &state ); + void on1_incomingCall ( const QString& accountID , const QString & callID ); + void on1_incomingConference ( const QString& confID ); + void on1_changingConference ( const QString& confID , const QString &state ); + void on1_conferenceRemoved ( const QString& confId ); + void on1_voiceMailNotify ( const QString& accountID , int count ); + void on1_volumeChanged ( const QString& device , double value ); +private: + static bool dbusInit; +signals: + void callStateChanged (Call* call ); + void incomingCall (Call* call ); + void conferenceCreated (Call* conf ); + void conferenceChanged (Call* conf ); + void conferenceRemoved (const QString& confId ); + void aboutToRemoveConference (Call* conf ); + void voiceMailNotify (const QString& accountID , int count ); + void volumeChanged (const QString& device , double value ); + void callAdded (Call* call , Call* parent ); +}; + /** * Note from the author: It was previously done by a QAbstractModel + QTreeView, but the sip-call use case is incompatible * with the MVC model. The MVC never got to a point were it was bug-free and the code was getting dirty. The Mirror model * solution may be less "clean" than MVC, but is 3 time smaller and easier to improve (in fact, possible to improve). */ template <typename CallWidget, typename Index> -class LIB_EXPORT CallModel { - //Q_OBJECT +class LIB_EXPORT CallModel : public CallModelBase { public: enum ModelType { ActiveCall, @@ -56,10 +92,11 @@ class LIB_EXPORT CallModel { }; //Constructors, initializer and destructors - CallModel ( ModelType type ); - virtual ~CallModel ( ) {} - virtual bool initCall ( ); - virtual bool initHistory ( ); + CallModel ( ModelType type ); + virtual ~CallModel ( ) {} + virtual bool initCall ( ); + virtual bool initHistory ( ); + virtual void initContact ( ContactBackend* be ); //Call related virtual Call* addCall ( Call* call , Call* parent =0 ); @@ -76,8 +113,8 @@ class LIB_EXPORT CallModel { bool mergeConferences ( Call* conf1, Call* conf2 ); bool addParticipant ( Call* call2, Call* conference ); bool detachParticipant ( Call* call ); - virtual bool conferenceChanged ( const QString &confId, const QString &state ); - virtual void conferenceRemoved ( const QString &confId ); + virtual bool changeConference ( const QString &confId, const QString &state ); + virtual void removeConference ( const QString &confId ); virtual Call* addConference ( const QString &confID ); void removeConference ( Call* call ); diff --git a/kde/src/lib/CallModel.hpp b/kde/src/lib/CallModel.hpp index ef6bec6f7a7992636d9c611cac68b86625bdf49c..371a4853982b495d9eed291fd91503f3c0763f80 100644 --- a/kde/src/lib/CallModel.hpp +++ b/kde/src/lib/CallModel.hpp @@ -1,3 +1,18 @@ +#include <QHash> +#include <QVector> +#include <QDragEnterEvent> +#include <QDebug> +#include "Call.h" +#include "AccountList.h" +#include "dbus/metatypes.h" +#include "callmanager_interface_singleton.h" +#include "configurationmanager_interface_singleton.h" +#include "instance_interface_singleton.h" +#include "sflphone_const.h" +#include "unistd.h" +#include "typedefs.h" +#include "ContactBackend.h" + //Static member template <typename CallWidget, typename Index> QString CallModel<CallWidget,Index>::m_pPriorAccountId = "" ; template <typename CallWidget, typename Index> AccountList* CallModel<CallWidget,Index>::m_pAccountList = 0 ; @@ -20,7 +35,7 @@ template <typename CallWidget, typename Index> typename CallModel<CallWidget,In ****************************************************************************/ ///Retrieve current and older calls from the daemon, fill history and the calls TreeView and enable drag n' drop -template<typename CallWidget, typename Index> CallModel<CallWidget,Index>::CallModel(ModelType type) +template<typename CallWidget, typename Index> CallModel<CallWidget,Index>::CallModel(ModelType type) : CallModelBase(0) { Q_UNUSED(type) init(); @@ -65,6 +80,12 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: return true; } +///Set how the call can find more informations about the call it receive +template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::initContact ( ContactBackend* be ) +{ + Call::setContactBackend(be); +} + ///Fill the history list ///@warning This solution wont scale to multiple call or history model implementation. Some static addCall + foreach for each call would be needed if this case ever become unavoidable template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::initHistory() @@ -143,7 +164,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: m_pPrivateCallList_callId[call->getCallId()] = aNewStruct; //setCurrentItem(callItem); - + CallModelBase::addCall(call,parent); return call; } @@ -245,9 +266,10 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: InternalStruct* aNewStruct = new InternalStruct; aNewStruct->call_real = newConf; + aNewStruct->conference = true; - m_pPrivateCallList_call[newConf] = aNewStruct; - m_pPrivateCallList_callId[newConf->getConfId()] = aNewStruct; //WARNING It may break something is it is done wrong + m_pPrivateCallList_call[newConf] = aNewStruct; + m_pPrivateCallList_callId[confID] = aNewStruct; return newConf; } @@ -292,7 +314,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Executed when the daemon signal a modification in an existing conference. Update the call list and update the TreeView -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::conferenceChanged(const QString& confId, const QString& state) +template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::changeConference(const QString& confId, const QString& state) { qDebug() << "Conf changed2"; Q_UNUSED(state) @@ -310,7 +332,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Remove a conference from the model and the TreeView -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::conferenceRemoved(const QString &confId) +template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::removeConference(const QString &confId) { qDebug() << "Ending conversation containing " << m_pPrivateCallList_callId[confId]->children.size() << " participants"; removeConference(getCall(confId)); @@ -539,7 +561,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, ///Update the index associated with this call template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateIndex (Call* call, Index value ) -{ +{ if (!m_pPrivateCallList_call[call]) { m_pPrivateCallList_call[call] = new InternalStruct; m_pPrivateCallList_call[call]->call_real = call; diff --git a/kde/src/lib/Contact.cpp b/kde/src/lib/Contact.cpp index 11551f750cdc0aa29e1bcf1c16ab500605e4d13d..84eee4a9203d960cc2bf9ff6d5d9e4befa1b794c 100644 --- a/kde/src/lib/Contact.cpp +++ b/kde/src/lib/Contact.cpp @@ -21,6 +21,12 @@ #include "Contact.h" #include <QtCore/QDebug> +#include <kabc/addressee.h> +#include <kabc/picture.h> +#include <kabc/phonenumber.h> +#include <QtGui/QListWidgetItem> +#include <QtGui/QWidget> +#include <QPixmap> #include "sflphone_const.h" diff --git a/kde/src/lib/Contact.h b/kde/src/lib/Contact.h index 68e133acf11c383e5a56c4eeb184c39e4a4088c6..5e03a500a70cc0c171e62f50f1e53be9d2747713 100644 --- a/kde/src/lib/Contact.h +++ b/kde/src/lib/Contact.h @@ -21,20 +21,25 @@ #ifndef CONTACT_H #define CONTACT_H -#include <QtGui/QListWidgetItem> -#include <QtGui/QWidget> +#include <QObject> -#include <QPixmap> +//Qt +class QListWidgetItem; +class QWidget; +class QPixmap; -#include <kabc/addressee.h> -#include <kabc/picture.h> -#include <kabc/phonenumber.h> +//KDE +namespace KABC { + class Addressee ; + class Picture ; + class PhoneNumber ; +} #include "typedefs.h" /** @author Jérémy Quentin <jeremy.quentin@savoirfairelinux.com> - @author Jérémy Quentin <emmanuel.lepage@savoirfairelinux.com> + @author Emmanuel Lepage <emmanuel.lepage@savoirfairelinux.com> */ class LIB_EXPORT Contact : public QObject{ Q_OBJECT @@ -85,6 +90,7 @@ public: virtual QString getType() const; virtual void initItem(); + //Setters virtual void setPhoneNumbers (PhoneNumbers ); virtual void setFormattedName (QString name ); virtual void setNickName (QString name ); diff --git a/kde/src/lib/ContactBackend.h b/kde/src/lib/ContactBackend.h index 72584f8c52f51b3294b6eae5261f428589534348..1a3cc57a0c92c5f950b4d929d1117262c779ddb4 100644 --- a/kde/src/lib/ContactBackend.h +++ b/kde/src/lib/ContactBackend.h @@ -6,6 +6,7 @@ #include "typedefs.h" +//SFLPhone class Contact; typedef QList<Contact*> ContactList; diff --git a/kde/src/lib/sflphone_const.h b/kde/src/lib/sflphone_const.h index 71b65a2837c5a8c67a9d6988cd092b2dda3ff514..4475f5a67c3ec0c3a62632cb7c1988e8230c3464 100644 --- a/kde/src/lib/sflphone_const.h +++ b/kde/src/lib/sflphone_const.h @@ -282,27 +282,27 @@ typedef enum { /** Ringing incoming call */ - CALL_STATE_INCOMING, + CALL_STATE_INCOMING = 0, /** Ringing outgoing call */ - CALL_STATE_RINGING, + CALL_STATE_RINGING = 1, /** Call to which the user can speak and hear */ - CALL_STATE_CURRENT, + CALL_STATE_CURRENT = 2, /** Call which numbers are being added by the user */ - CALL_STATE_DIALING, + CALL_STATE_DIALING = 3, /** Call is on hold */ - CALL_STATE_HOLD, + CALL_STATE_HOLD = 4, /** Call has failed */ - CALL_STATE_FAILURE, + CALL_STATE_FAILURE = 5, /** Call is busy */ - CALL_STATE_BUSY, + CALL_STATE_BUSY = 6, /** Call is being transfered. During this state, the user can enter the new number. */ - CALL_STATE_TRANSFER, + CALL_STATE_TRANSFER = 7, /** Call is on hold for transfer */ - CALL_STATE_TRANSF_HOLD, + CALL_STATE_TRANSF_HOLD = 8, /** Call is over and should not be used */ - CALL_STATE_OVER, + CALL_STATE_OVER = 9, /** This state should never be reached */ - CALL_STATE_ERROR + CALL_STATE_ERROR = 10 } call_state; /** MIME API */ diff --git a/kde/src/main.cpp b/kde/src/main.cpp index ef17f9df259621d81c28acc4e25268c058c486f1..606a1f59362508ef8e8ff948548ec0806a93b370 100755 --- a/kde/src/main.cpp +++ b/kde/src/main.cpp @@ -26,7 +26,7 @@ static const char description[] = "A KDE 4 Client for SFLphone"; -static const char version[] = "0.9.6"; +static const char version[] = "1.0.0"; int main(int argc, char **argv) { @@ -36,25 +36,26 @@ int main(int argc, char **argv) KLocale::setMainCatalog("sflphone-client-kde"); KAboutData about( - "sflphone-client-kde", - "sflphone-client-kde", - ki18n("SFLphone KDE Client"), - version, - ki18n(description), - KAboutData::License_GPL_V3, - ki18n("(C) 2009-2010 Savoir-faire Linux"), - KLocalizedString(), - "http://www.sflphone.org.", - "sflphone@lists.savoirfairelinux.net"); - about.addAuthor( ki18n("Jérémy Quentin"), KLocalizedString(), "jeremy.quentin@savoirfairelinux.com" ); - about.addAuthor( ki18n("Emmanuel Lepage Vallee"), KLocalizedString(), "emmanuel.lepage@savoirfairelinux.com" ); - about.setTranslator( ki18nc("NAME OF TRANSLATORS","Your names"), ki18nc("EMAIL OF TRANSLATORS","Your emails") ); + "sflphone-client-kde" , + "sflphone-client-kde" , + ki18n("SFLphone KDE Client") , + version , + ki18n(description) , + KAboutData::License_GPL_V3 , + ki18n("(C) 2009-2010 Savoir-faire Linux") , + KLocalizedString() , + "http://www.sflphone.org." , + "sflphone@lists.savoirfairelinux.net" + ); + about.addAuthor( ki18n( "Jérémy Quentin" ), KLocalizedString(), "jeremy.quentin@savoirfairelinux.com" ); + about.addAuthor( ki18n( "Emmanuel Lepage Vallee" ), KLocalizedString(), "emmanuel.lepage@savoirfairelinux.com" ); + //about.setTranslator( ki18nc("NAME OF TRANSLATORS","Your names"), ki18nc("EMAIL OF TRANSLATORS","Your emails") ); KCmdLineArgs::init(argc, argv, &about); KCmdLineOptions options; KCmdLineArgs::addCmdLineOptions(options); //configuration dbus - CallView::init(); + TreeWidgetCallModel::init(); SFLPhoneApplication app; @@ -69,6 +70,7 @@ int main(int argc, char **argv) ConfigurationSkeleton* conf = ConfigurationSkeleton::self(); conf->writeConfig(); + delete sflphoneWindow_; return retVal; } catch(const char * msg) diff --git a/kde/src/widgets/BookmarkDock.cpp b/kde/src/widgets/BookmarkDock.cpp index b08365a1ca5b0a417b1358ad691a3a2fb2bdbda4..550c152052aa9cd84d3e3d76b71c2543b93bda04 100644 --- a/kde/src/widgets/BookmarkDock.cpp +++ b/kde/src/widgets/BookmarkDock.cpp @@ -2,6 +2,7 @@ #include <QtGui/QVBoxLayout> #include <QtGui/QTreeWidgetItem> +#include <KLocalizedString> #include <kicon.h> #include <klineedit.h> #include <QtGui/QTreeWidget> @@ -30,6 +31,7 @@ class QNumericTreeWidgetItem : public QTreeWidgetItem { BookmarkDock::BookmarkDock(QWidget* parent) : QDockWidget(parent) { + setObjectName("bookmarkDock"); setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); setMinimumSize(250,0); @@ -49,8 +51,8 @@ BookmarkDock::BookmarkDock(QWidget* parent) : QDockWidget(parent) m_pSplitter->setChildrenCollapsible(true); m_pSplitter->setStretchFactor(0,7); - setWindowTitle("Bookmark"); - m_pItemView->headerItem()->setText(0,"Bookmark" ); + setWindowTitle(i18n("Bookmark")); + m_pItemView->headerItem()->setText(0,i18n("Bookmark") ); foreach (QString nb, ConfigurationSkeleton::bookmarkList()) { addBookmark_internal(nb); diff --git a/kde/src/widgets/BookmarkDock.h b/kde/src/widgets/BookmarkDock.h index b5e9bb0584bb3057d430de57aec246e5fb0d427b..7c91b8099767c900c86e08b143a9c01edb2e76fc 100644 --- a/kde/src/widgets/BookmarkDock.h +++ b/kde/src/widgets/BookmarkDock.h @@ -3,10 +3,16 @@ #include <QtGui/QDockWidget> +//Qt class QTreeWidget; -class KLineEdit; class QSplitter; + +//KDE +class KLineEdit; + +//SFLPhonr class HistoryTreeItem; + typedef QList<HistoryTreeItem*> BookmarkList; class BookmarkDock : public QDockWidget { Q_OBJECT diff --git a/kde/src/widgets/CallTreeItem.cpp b/kde/src/widgets/CallTreeItem.cpp index 71c2d131840eed771b34faaf4e996c01e054ff5e..64f452e0b46062477fc46531b306606bcd6af3dc 100644 --- a/kde/src/widgets/CallTreeItem.cpp +++ b/kde/src/widgets/CallTreeItem.cpp @@ -27,41 +27,58 @@ #include "lib/sflphone_const.h" #include "CallTreeItem.h" #include "lib/Contact.h" +#include "lib/Call.h" #include "AkonadiBackend.h" +#include <QtCore/QList> +#include <QtCore/QVariant> +#include <QtCore/QVector> + +#include <QtGui/QWidget> +#include <QtGui/QLabel> +#include <QtGui/QSpacerItem> +#include <QtGui/QHBoxLayout> +#include <QtGui/QVBoxLayout> +#include <KIcon> + +///Constant const char * CallTreeItem::callStateIcons[12] = {ICON_INCOMING, ICON_RINGING, ICON_CURRENT, ICON_DIALING, ICON_HOLD, ICON_FAILURE, ICON_BUSY, ICON_TRANSFER, ICON_TRANSF_HOLD, "", "", ICON_CONFERENCE}; +///Constructor CallTreeItem::CallTreeItem(QWidget *parent) : QWidget(parent), itemCall(0), init(false) { setMaximumSize(99999,50); } +///Destructor CallTreeItem::~CallTreeItem() { } +///Return the call item Call* CallTreeItem::call() const { return itemCall; } +///Set the call item void CallTreeItem::setCall(Call *call) { itemCall = call; if (itemCall->isConference()) { if (!init) { - labelHistoryPeerName = new QLabel("Conference",this); - labelIcon = new QLabel("Icn",this); + labelHistoryPeerName = new QLabel(i18n("Conference"),this); + labelIcon = new QLabel("",this); QHBoxLayout* mainLayout = new QHBoxLayout(); mainLayout->addWidget(labelIcon); mainLayout->addWidget(labelHistoryPeerName); setLayout(mainLayout); init = true; } - labelIcon->setPixmap(QPixmap(ICON_CONFERENCE)); + labelIcon->setPixmap(QPixmap(ICON_CONFERENCE).scaled(QSize(48,48))); labelIcon->setVisible(true); labelHistoryPeerName->setVisible(true); return; @@ -113,8 +130,10 @@ void CallTreeItem::setCall(Call *call) updated(); } +///Update data void CallTreeItem::updated() { + qDebug() << "Updating tree item"; Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(itemCall->getPeerPhoneNumber()); if (contact) { labelIcon->setPixmap(*contact->getPhoto()); @@ -127,7 +146,7 @@ void CallTreeItem::updated() labelPeerName->setText("<b>"+itemCall->getPeerName()+"</b>"); } else { - labelPeerName->setText("<b>Unknow</b>"); + labelPeerName->setText(i18n("<b>Unknow</b>")); } } @@ -165,4 +184,3 @@ void CallTreeItem::updated() } } - diff --git a/kde/src/widgets/CallTreeItem.h b/kde/src/widgets/CallTreeItem.h index 02672737ffeea7e0a774bc538691a080f3f843fd..7908979bdf5cb12615ddc6b0641535702c6b0a5d 100644 --- a/kde/src/widgets/CallTreeItem.h +++ b/kde/src/widgets/CallTreeItem.h @@ -19,27 +19,22 @@ * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -/** - * http://doc.trolltech.com/4.5/itemviews-editabletreemodel.html - */ - + **************************************************************************/ #ifndef CALLTREE_ITEM_H #define CALLTREE_ITEM_H -#include <QtCore/QList> -#include <QtCore/QVariant> #include <QtCore/QVector> - +#include <QtCore/QList> #include <QtGui/QWidget> -#include <QtGui/QLabel> -#include <QtGui/QSpacerItem> -#include <QtGui/QHBoxLayout> -#include <QtGui/QVBoxLayout> -#include <KIcon> -#include "lib/Call.h" +//Qt +class QLabel; + +//KDE +class KIcon; + +//SFLPhone +class Call; class CallTreeItem : public QWidget { diff --git a/kde/src/widgets/ContactDock.cpp b/kde/src/widgets/ContactDock.cpp index 16647a4e0d307bb2ecfe2c9371bac6a545ad219a..625ca83b115186f05b4f58ba2289281d8d993d95 100644 --- a/kde/src/widgets/ContactDock.cpp +++ b/kde/src/widgets/ContactDock.cpp @@ -7,6 +7,10 @@ #include <QtGui/QHeaderView> #include <QtGui/QCheckBox> #include <QtCore/QDateTime> +#include <QSplitter> +#include <klineedit.h> +#include <KLocalizedString> +#include <QtGui/QLabel> #include <akonadi/collectionfilterproxymodel.h> #include <akonadi/contact/contactstreemodel.h> @@ -16,22 +20,25 @@ #include <kabc/picture.h> #include <kabc/phonenumber.h> #include <kabc/vcard.h> -#include <kabc/addressee.h> #include <kabc/field.h> #include <kabc/vcardline.h> #include <kabc/contactgroup.h> -#include <kabc/phonenumber.h> #include <akonadi/itemfetchscope.h> #include <akonadi/entitydisplayattribute.h> #include <akonadi/recursiveitemfetchjob.h> #include <kicon.h> +#include <akonadi/entitytreeview.h> +#include <akonadi/itemview.h> +#include <akonadi/collectioncombobox.h> #include "AkonadiBackend.h" #include "ContactItemWidget.h" #include "conf/ConfigurationSkeleton.h" #include "lib/Call.h" #include "SFLPhone.h" +#include "lib/Contact.h" +///Hack around Qt sorting limitation class QNumericTreeWidgetItem_hist : public QTreeWidgetItem { public: QNumericTreeWidgetItem_hist(QTreeWidget* parent):QTreeWidgetItem(parent),widget(0),weight(-1){} @@ -52,8 +59,22 @@ class QNumericTreeWidgetItem_hist : public QTreeWidgetItem { } }; +///Forward keypresses to the filter line edit +bool KeyPressEaterC::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyPress) { + m_pDock->keyPressEvent((QKeyEvent*)event); + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } +} + +///Constructor ContactDock::ContactDock(QWidget* parent) : QDockWidget(parent) { + setObjectName("contactDock"); m_pFilterLE = new KLineEdit ( ); m_pSplitter = new QSplitter ( Qt::Vertical,this ); m_pSortByCBB = new QComboBox ( this ); @@ -69,19 +90,21 @@ ContactDock::ContactDock(QWidget* parent) : QDockWidget(parent) QWidget* mainWidget = new QWidget(this); setWidget(mainWidget); - m_pContactView->headerItem()->setText(0,"Contacts"); + m_pContactView->headerItem()->setText(0,i18n("Contacts")); m_pContactView->header()->setClickable(true); m_pContactView->header()->setSortIndicatorShown(true); m_pContactView->setAcceptDrops(true); m_pContactView->setDragEnabled(true); + KeyPressEaterC *keyPressEater = new KeyPressEaterC(this); + m_pContactView->installEventFilter(keyPressEater); m_pContactView->setAlternatingRowColors(true); - m_pFilterLE->setPlaceholderText("Filter"); + m_pFilterLE->setPlaceholderText(i18n("Filter")); m_pFilterLE->setClearButtonShown(true); m_pShowHistoCK->setChecked(ConfigurationSkeleton::displayContactCallHistory()); - m_pShowHistoCK->setText("Display history"); + m_pShowHistoCK->setText(i18n("Display history")); setHistoryVisible(ConfigurationSkeleton::displayContactCallHistory()); @@ -101,14 +124,16 @@ ContactDock::ContactDock(QWidget* parent) : QDockWidget(parent) connect (m_pContactView, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)),this, SLOT(loadContactHistory(QTreeWidgetItem*) )); connect (m_pFilterLE, SIGNAL(textChanged(QString)), this, SLOT(filter(QString) )); connect (m_pShowHistoCK, SIGNAL(toggled(bool)), this, SLOT(setHistoryVisible(bool) )); - setWindowTitle("Contact"); + setWindowTitle(i18n("Contact")); } +///Destructor ContactDock::~ContactDock() { } +///Reload the contact void ContactDock::reloadContact() { ContactList list = AkonadiBackend::getInstance()->update(); @@ -139,6 +164,7 @@ void ContactDock::reloadContact() } } +///Query the call history for all items related to this contact void ContactDock::loadContactHistory(QTreeWidgetItem* item) { if (m_pShowHistoCK->isChecked()) { @@ -158,6 +184,7 @@ void ContactDock::loadContactHistory(QTreeWidgetItem* item) } } +///Filter contact void ContactDock::filter(QString text) { foreach(ContactItemWidget* item, m_pContacts) { @@ -174,6 +201,7 @@ void ContactDock::filter(QString text) m_pContactView->expandAll(); } +///Serialize informations to be used for drag and drop QMimeData* ContactTree::mimeData( const QList<QTreeWidgetItem *> items) const { qDebug() << "An history call is being dragged"; @@ -199,6 +227,7 @@ QMimeData* ContactTree::mimeData( const QList<QTreeWidgetItem *> items) const return mimeData; } +///Handle data being dropped on the widget bool ContactTree::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action) { Q_UNUSED(index) @@ -212,9 +241,22 @@ bool ContactTree::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeDa return false; } +///Show or hide the history list void ContactDock::setHistoryVisible(bool visible) { qDebug() << "Toggling history visibility"; m_pCallView->setVisible(visible); ConfigurationSkeleton::setDisplayContactCallHistory(visible); +} + +///Handle keypresses ont the dock +void ContactDock::keyPressEvent(QKeyEvent* event) { + int key = event->key(); + if(key == Qt::Key_Escape) + m_pFilterLE->setText(QString()); + else if(key == Qt::Key_Return || key == Qt::Key_Enter) {} + else if((key == Qt::Key_Backspace) && (m_pFilterLE->text().size())) + m_pFilterLE->setText(m_pFilterLE->text().left( m_pFilterLE->text().size()-1 )); + else if (!event->text().isEmpty() && !(key == Qt::Key_Backspace)) + m_pFilterLE->setText(m_pFilterLE->text()+event->text()); } \ No newline at end of file diff --git a/kde/src/widgets/ContactDock.h b/kde/src/widgets/ContactDock.h index b0f6051b0bfd2c2010adbc8374032b5856071895..c470a1d09389d2b3ff7c16a8cf313f2d6e8a44d9 100644 --- a/kde/src/widgets/ContactDock.h +++ b/kde/src/widgets/ContactDock.h @@ -3,21 +3,33 @@ #include <QtGui/QDockWidget> #include <QtGui/QTreeWidget> -#include <QSplitter> - -#include <akonadi/entitytreeview.h> -#include <akonadi/itemview.h> -#include <klineedit.h> -#include <kabc/addressee.h> -#include <akonadi/contact/contactstreemodel.h> -#include <akonadi/collectioncombobox.h> +//Qt +class QSplitter; class QListWidget; class QComboBox; class QTreeWidgetItem; class QCheckBox; -class ContactItemWidget; + +//KDE +class KLineEdit; + +namespace Akonadi { + class EntityTreeView; + class ItemView; + class CollectionCombobox; + namespace Contact { + class ContactsTreeModel; + } +} + +namespace KABC { + class Addressee; +} + +///SFLPhone class ContactTree; +class ContactItemWidget; class ContactDock : public QDockWidget { Q_OBJECT @@ -33,7 +45,8 @@ private: QComboBox* m_pSortByCBB; QCheckBox* m_pShowHistoCK; QList<ContactItemWidget*> m_pContacts; - +public slots: + virtual void keyPressEvent(QKeyEvent* event); private slots: void reloadContact(); void loadContactHistory(QTreeWidgetItem* item); @@ -49,4 +62,17 @@ public: bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action); }; +class KeyPressEaterC : public QObject +{ + Q_OBJECT +public: + KeyPressEaterC(ContactDock* parent) : QObject(parent) { + m_pDock = parent; + } +protected: + bool eventFilter(QObject *obj, QEvent *event); +private: + ContactDock* m_pDock; +}; + #endif \ No newline at end of file diff --git a/kde/src/widgets/ContactItemWidget.cpp b/kde/src/widgets/ContactItemWidget.cpp index 0a47d370ea1dc16ed52ca11be4656aab0553d9e3..8bed3b30ec822157a5b45456fb25229a9adb1afe 100644 --- a/kde/src/widgets/ContactItemWidget.cpp +++ b/kde/src/widgets/ContactItemWidget.cpp @@ -25,6 +25,17 @@ #include <QtGui/QGridLayout> #include <QtGui/QMenu> +#include <QtGui/QLabel> +#include <QtGui/QSpacerItem> +#include <QtGui/QHBoxLayout> +#include <QtGui/QVBoxLayout> +#include <KIcon> +#include <kabc/addressee.h> +#include <kabc/picture.h> +#include <kabc/phonenumber.h> + +#include <lib/Contact.h> + #include <klocale.h> #include <kdebug.h> #include <unistd.h> @@ -33,42 +44,44 @@ #include "lib/sflphone_const.h" #include "ContactItemWidget.h" #include "AkonadiBackend.h" +#include "widgets/BookmarkDock.h" #include "SFLPhone.h" #include "conf/ConfigurationSkeleton.h" +///Constructor ContactItemWidget::ContactItemWidget(QWidget *parent) : QWidget(parent), m_pMenu(0),init(false) { setContextMenuPolicy(Qt::CustomContextMenu); m_pCallAgain = new KAction(this); - m_pCallAgain->setShortcut(Qt::CTRL + Qt::Key_Enter); - m_pCallAgain->setText("Call Again"); - m_pCallAgain->setIcon(KIcon(ICON_DIALING)); + m_pCallAgain->setShortcut ( Qt::CTRL + Qt::Key_Enter ); + m_pCallAgain->setText ( i18n("Call Again") ); + m_pCallAgain->setIcon ( KIcon(ICON_DIALING) ); m_pEditContact = new KAction(this); - m_pEditContact->setShortcut(Qt::CTRL + Qt::Key_E); - m_pEditContact->setText("Edit contact"); - m_pEditContact->setIcon(KIcon("contact-new")); + m_pEditContact->setShortcut ( Qt::CTRL + Qt::Key_E ); + m_pEditContact->setText ( i18n("Edit contact") ); + m_pEditContact->setIcon ( KIcon("contact-new") ); m_pCopy = new KAction(this); - m_pCopy->setShortcut(Qt::CTRL + Qt::Key_C); - m_pCopy->setText("Copy"); - m_pCopy->setIcon(KIcon("edit-copy")); + m_pCopy->setShortcut ( Qt::CTRL + Qt::Key_C ); + m_pCopy->setText ( i18n("Copy") ); + m_pCopy->setIcon ( KIcon("edit-copy") ); m_pEmail = new KAction(this); - m_pEmail->setShortcut(Qt::CTRL + Qt::Key_M); - m_pEmail->setText("Send Email"); - m_pEmail->setIcon(KIcon("mail-message-new")); + m_pEmail->setShortcut ( Qt::CTRL + Qt::Key_M ); + m_pEmail->setText ( i18n("Send Email") ); + m_pEmail->setIcon ( KIcon("mail-message-new") ); m_pAddPhone = new KAction(this); - m_pAddPhone->setShortcut(Qt::CTRL + Qt::Key_N); - m_pAddPhone->setText("Add Phone Number"); - m_pAddPhone->setIcon(KIcon("list-resource-add")); + m_pAddPhone->setShortcut ( Qt::CTRL + Qt::Key_N ); + m_pAddPhone->setText ( i18n("Add Phone Number") ); + m_pAddPhone->setIcon ( KIcon("list-resource-add") ); m_pBookmark = new KAction(this); - m_pBookmark->setShortcut(Qt::CTRL + Qt::Key_D); - m_pBookmark->setText("Bookmark"); - m_pBookmark->setIcon(KIcon("bookmarks")); + m_pBookmark->setShortcut ( Qt::CTRL + Qt::Key_D ); + m_pBookmark->setText ( i18n("Bookmark") ); + m_pBookmark->setIcon ( KIcon("bookmarks") ); connect(m_pCallAgain , SIGNAL(triggered()) , this,SLOT(callAgain() )); connect(m_pEditContact , SIGNAL(triggered()) , this,SLOT(editContact() )); @@ -78,19 +91,21 @@ ContactItemWidget::ContactItemWidget(QWidget *parent) connect(m_pBookmark , SIGNAL(triggered()) , this,SLOT(bookmark() )); } +///Destructor ContactItemWidget::~ContactItemWidget() { } +///Set the contact void ContactItemWidget::setContact(Contact* contact) { - m_pContactKA = contact; - m_pIconL = new QLabel(this); - m_pContactNameL = new QLabel(); - m_pOrganizationL = new QLabel(this); - m_pEmailL = new QLabel(); - m_pCallNumberL = new QLabel(this); + m_pContactKA = contact; + m_pIconL = new QLabel ( this ); + m_pContactNameL = new QLabel ( ); + m_pOrganizationL = new QLabel ( this ); + m_pEmailL = new QLabel ( ); + m_pCallNumberL = new QLabel ( this ); m_pIconL->setMinimumSize(70,48); m_pIconL->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Fixed); @@ -104,12 +119,12 @@ void ContactItemWidget::setContact(Contact* contact) QGridLayout* mainLayout = new QGridLayout(this); mainLayout->setContentsMargins(0,0,0,0); - mainLayout->addWidget(m_pIconL,0,0,4,1); - mainLayout->addWidget(m_pContactNameL,0,1); - mainLayout->addWidget(m_pOrganizationL,1,1); - mainLayout->addWidget(m_pCallNumberL,2,1); - mainLayout->addWidget(m_pEmailL,3,1); - mainLayout->addItem(verticalSpacer,4,1); + mainLayout->addWidget( m_pIconL , 0 , 0 , 4 , 1 ); + mainLayout->addWidget( m_pContactNameL , 0 , 1 ); + mainLayout->addWidget( m_pOrganizationL, 1 , 1 ); + mainLayout->addWidget( m_pCallNumberL , 2 , 1 ); + mainLayout->addWidget( m_pEmailL , 3 , 1 ); + mainLayout->addItem(verticalSpacer , 4 , 1 ); setLayout(mainLayout); setMinimumSize(QSize(50, 30)); @@ -118,6 +133,7 @@ void ContactItemWidget::setContact(Contact* contact) connect(this,SIGNAL(customContextMenuRequested(QPoint)),this,SLOT(showContext(QPoint))); } +///The contact need to be updated void ContactItemWidget::updated() { m_pContactNameL->setText("<b>"+m_pContactKA->getFormattedName()+"</b>"); @@ -143,7 +159,7 @@ void ContactItemWidget::updated() if (getCallNumbers().count() == 1) m_pCallNumberL->setText(getCallNumbers()[0]->getNumber()); else - m_pCallNumberL->setText(QString::number(getCallNumbers().count())+" numbers"); + m_pCallNumberL->setText(QString::number(getCallNumbers().count())+i18n(" numbers")); if (!m_pContactKA->getPhoto()) m_pIconL->setPixmap(QPixmap(KIcon("user-identity").pixmap(QSize(48,48)))); @@ -151,11 +167,6 @@ void ContactItemWidget::updated() m_pIconL->setPixmap(*m_pContactKA->getPhoto()); } -// QPixmap* ContactItemWidget::getIcon() -// { -// return new QPixmap(); -// } - QString ContactItemWidget::getContactName() const { return m_pContactKA->getFormattedName(); @@ -199,13 +210,13 @@ Contact* ContactItemWidget::getContact() void ContactItemWidget::showContext(const QPoint& pos) { if (!m_pMenu) { - m_pMenu = new QMenu(this); - m_pMenu->addAction(m_pCallAgain); - m_pMenu->addAction(m_pEditContact); - m_pMenu->addAction(m_pAddPhone); - m_pMenu->addAction(m_pCopy); - m_pMenu->addAction(m_pEmail); - m_pMenu->addAction(m_pBookmark); + m_pMenu = new QMenu( this ); + m_pMenu->addAction( m_pCallAgain ); + m_pMenu->addAction( m_pEditContact ); + m_pMenu->addAction( m_pAddPhone ); + m_pMenu->addAction( m_pCopy ); + m_pMenu->addAction( m_pEmail ); + m_pMenu->addAction( m_pBookmark ); } PhoneNumbers numbers = m_pContactKA->getPhoneNumbers(); m_pBookmark->setEnabled(numbers.count() == 1); diff --git a/kde/src/widgets/ContactItemWidget.h b/kde/src/widgets/ContactItemWidget.h index b3430a67d4f51bde0cf1a4a44c2b7fce92c57b41..9c5151bab362d048ee24272bd2d2864d57b6ea57 100644 --- a/kde/src/widgets/ContactItemWidget.h +++ b/kde/src/widgets/ContactItemWidget.h @@ -21,26 +21,28 @@ #ifndef CONTACTITEMWIDGET_H #define CONTACTITEMWIDGET_H +#include <QtGui/QWidget> #include <QtCore/QList> #include <QtCore/QVariant> #include <QtCore/QVector> +#include "lib/Contact.h" -#include <QtGui/QWidget> -#include <QtGui/QLabel> -#include <QtGui/QSpacerItem> -#include <QtGui/QHBoxLayout> -#include <QtGui/QVBoxLayout> -#include <KIcon> -#include <kabc/addressee.h> -#include <kabc/picture.h> -#include <kabc/phonenumber.h> - -#include <lib/Contact.h> - +//Qt +class QLabel; class QTreeWidgetItem; -class KAction; class QMenu; +//KDE +class KAction; +class KIcon; + +namespace KABC { + class Addressee; +} + +//SFLPhone +class Contact; + class ContactItemWidget : public QWidget { Q_OBJECT diff --git a/kde/src/widgets/Dialpad.cpp b/kde/src/widgets/Dialpad.cpp index f0f4514e1494b2f035c8a244a241b611cd8949e4..a23bf72978f38934e6fb58cce81bd46c2835048c 100755 --- a/kde/src/widgets/Dialpad.cpp +++ b/kde/src/widgets/Dialpad.cpp @@ -22,7 +22,10 @@ #include <QLabel> #include <QDebug> +#include <QPushButton> +#include <QGridLayout> +///Constructor Dialpad::Dialpad(QWidget *parent) : QWidget(parent) { @@ -55,33 +58,33 @@ Dialpad::Dialpad(QWidget *parent) pushButton_diese->setObjectName(QString::fromUtf8("pushButton_diese")); pushButton_etoile->setObjectName(QString::fromUtf8("pushButton_etoile")); - gridLayout->addWidget(pushButton_1, 0, 0); - gridLayout->addWidget(pushButton_2, 0, 1); - gridLayout->addWidget(pushButton_3, 0, 2); - gridLayout->addWidget(pushButton_4, 1, 0); - gridLayout->addWidget(pushButton_5, 1, 1); - gridLayout->addWidget(pushButton_6, 1, 2); - gridLayout->addWidget(pushButton_7, 2, 0); - gridLayout->addWidget(pushButton_8, 2, 1); - gridLayout->addWidget(pushButton_9, 2, 2); - gridLayout->addWidget(pushButton_etoile, 3, 0); - gridLayout->addWidget(pushButton_0, 3, 1); - gridLayout->addWidget(pushButton_diese, 3, 2); + gridLayout->addWidget(pushButton_1 , 0, 0 ); + gridLayout->addWidget(pushButton_2 , 0, 1 ); + gridLayout->addWidget(pushButton_3 , 0, 2 ); + gridLayout->addWidget(pushButton_4 , 1, 0 ); + gridLayout->addWidget(pushButton_5 , 1, 1 ); + gridLayout->addWidget(pushButton_6 , 1, 2 ); + gridLayout->addWidget(pushButton_7 , 2, 0 ); + gridLayout->addWidget(pushButton_8 , 2, 1 ); + gridLayout->addWidget(pushButton_9 , 2, 2 ); + gridLayout->addWidget(pushButton_etoile , 3, 0 ); + gridLayout->addWidget(pushButton_0 , 3, 1 ); + gridLayout->addWidget(pushButton_diese , 3, 2 ); fillButtons(); QMetaObject::connectSlotsByName(this); } - +///Make the buttons void Dialpad::fillButtons() { QHBoxLayout * layout; QLabel * number; QLabel * text; - int spacing = 5; - int numberSize = 14; - int textSize = 8; + int spacing = 5 ; + int numberSize = 14 ; + int textSize = 8 ; QPushButton * buttons[12] = {pushButton_1, pushButton_2, pushButton_3, @@ -117,6 +120,7 @@ void Dialpad::fillButtons() } } +///Slots void Dialpad::on_pushButton_1_clicked() { emit typed("1"); } void Dialpad::on_pushButton_2_clicked() { emit typed("2"); } void Dialpad::on_pushButton_3_clicked() { emit typed("3"); } diff --git a/kde/src/widgets/Dialpad.h b/kde/src/widgets/Dialpad.h index e93478a5174227fc4a8fbc06e6383d53c106c8f1..5a4d1c60318ba00f32823b7e351aa287ce89a4ff 100755 --- a/kde/src/widgets/Dialpad.h +++ b/kde/src/widgets/Dialpad.h @@ -22,8 +22,10 @@ #define DIALPAD_H #include <QWidget> -#include <QPushButton> -#include <QGridLayout> + +//Qt +class QPushButton; +class QGridLayout; /** A widget that represents a phone dialpad, with numbers and letters associated. @@ -35,19 +37,19 @@ class Dialpad : public QWidget Q_OBJECT private: - QGridLayout * gridLayout; - QPushButton * pushButton_0; - QPushButton * pushButton_1; - QPushButton * pushButton_2; - QPushButton * pushButton_3; - QPushButton * pushButton_4; - QPushButton * pushButton_5; - QPushButton * pushButton_6; - QPushButton * pushButton_7; - QPushButton * pushButton_8; - QPushButton * pushButton_9; - QPushButton * pushButton_diese; - QPushButton * pushButton_etoile; + QGridLayout* gridLayout; + QPushButton* pushButton_0; + QPushButton* pushButton_1; + QPushButton* pushButton_2; + QPushButton* pushButton_3; + QPushButton* pushButton_4; + QPushButton* pushButton_5; + QPushButton* pushButton_6; + QPushButton* pushButton_7; + QPushButton* pushButton_8; + QPushButton* pushButton_9; + QPushButton* pushButton_diese; + QPushButton* pushButton_etoile; public: Dialpad(QWidget *parent = 0); diff --git a/kde/src/widgets/HistoryDock.cpp b/kde/src/widgets/HistoryDock.cpp index 2d53ae398f153d6074be42f73fb2d8170f8ef572..b31e8df3286fbca081bb7196a69d1865052d914f 100644 --- a/kde/src/widgets/HistoryDock.cpp +++ b/kde/src/widgets/HistoryDock.cpp @@ -7,6 +7,10 @@ #include <QtGui/QComboBox> #include <QtGui/QPushButton> #include <QtGui/QLabel> +#include <QDebug> +#include <QDate> +#include <QtGui/QTreeWidgetItem> +#include <QtCore/QString> #include <kdatewidget.h> #include <QHeaderView> #include <QtGui/QCheckBox> @@ -17,6 +21,7 @@ #include "AkonadiBackend.h" #include "lib/sflphone_const.h" +///Qt lack official functional sorting algo, so this hack around it class QNumericTreeWidgetItem : public QTreeWidgetItem { public: QNumericTreeWidgetItem(QTreeWidget* parent):QTreeWidgetItem(parent),widget(0),weight(-1){} @@ -36,19 +41,33 @@ class QNumericTreeWidgetItem : public QTreeWidgetItem { } }; +///Event filter allowing to write text on the Tree widget to filter it. +bool KeyPressEater::eventFilter(QObject *obj, QEvent *event) +{ + if (event->type() == QEvent::KeyPress) { + m_pDock->keyPressEvent((QKeyEvent*)event); + return true; + } else { + // standard event processing + return QObject::eventFilter(obj, event); + } +} + +///Constructor HistoryDock::HistoryDock(QWidget* parent) : QDockWidget(parent) { + setObjectName("historyDock"); setMinimumSize(250,0); setSizePolicy(QSizePolicy::Minimum,QSizePolicy::Minimum); m_pFilterLE = new KLineEdit(); m_pItemView = new HistoryTree(this); m_pSortByCBB = new QComboBox(); - m_pSortByL = new QLabel("Sort by:"); - m_pFromL = new QLabel("From:"); - m_pToL = new QLabel("To:"); + m_pSortByL = new QLabel(i18n("Sort by:")); + m_pFromL = new QLabel(i18n("From:")); + m_pToL = new QLabel(i18n("To:")); m_pFromDW = new KDateWidget(); m_pToDW = new KDateWidget(); - m_pAllTimeCB = new QCheckBox("Display all"); + m_pAllTimeCB = new QCheckBox(i18n("Display all")); m_pLinkPB = new QPushButton(this); m_pAllTimeCB->setChecked(ConfigurationSkeleton::displayDataRange()); @@ -60,14 +79,16 @@ HistoryDock::HistoryDock(QWidget* parent) : QDockWidget(parent) m_pLinkPB->setSizePolicy(QSizePolicy::Fixed,QSizePolicy::Expanding); m_pLinkPB->setCheckable(true); - m_pItemView->headerItem()->setText(0,"Calls" ); + m_pItemView->headerItem()->setText(0,i18n("Calls") ); m_pItemView->header ()->setClickable(true ); m_pItemView->header ()->setSortIndicatorShown(true ); m_pItemView->setAlternatingRowColors(true ); m_pItemView->setAcceptDrops( true ); m_pItemView->setDragEnabled( true ); + KeyPressEater *keyPressEater = new KeyPressEater(this); + m_pItemView->installEventFilter(keyPressEater); - m_pFilterLE->setPlaceholderText("Filter"); + m_pFilterLE->setPlaceholderText(i18n("Filter")); m_pFilterLE->setClearButtonShown(true); QStringList sortBy; @@ -90,7 +111,7 @@ HistoryDock::HistoryDock(QWidget* parent) : QDockWidget(parent) mainLayout->addWidget(m_pItemView ,6,0,1,3 ); mainLayout->addWidget(m_pFilterLE ,7,0,1,3 ); - setWindowTitle("History"); + setWindowTitle(i18n("History")); QDate date(2000,1,1); m_pFromDW->setDate(date); @@ -107,10 +128,12 @@ HistoryDock::HistoryDock(QWidget* parent) : QDockWidget(parent) connect(AkonadiBackend::getInstance(), SIGNAL(collectionChanged()), this, SLOT(updateContactInfo() )); } +///Destructor HistoryDock::~HistoryDock() { } +///Return the identity of the call caller QString HistoryDock::getIdentity(HistoryTreeItem* item) { if (item->getName().trimmed().isEmpty()) @@ -119,6 +142,7 @@ QString HistoryDock::getIdentity(HistoryTreeItem* item) return item->getName(); } +///Update informations void HistoryDock::updateContactInfo() { foreach(HistoryTreeItem* hitem, m_pHistory) { @@ -126,6 +150,7 @@ void HistoryDock::updateContactInfo() } } +///Reload the history list void HistoryDock::reload() { m_pItemView->clear(); @@ -195,6 +220,7 @@ void HistoryDock::reload() m_pItemView->sortItems(0,Qt::AscendingOrder); } +///Enable the ability to set a date range like 1 month to limit history void HistoryDock::enableDateRange(bool enable) { m_pFromL->setVisible(enable); @@ -206,6 +232,7 @@ void HistoryDock::enableDateRange(bool enable) ConfigurationSkeleton::setDisplayDataRange(enable); } +///Filter the history void HistoryDock::filter(QString text) { foreach(HistoryTreeItem* item, m_pHistory) { @@ -215,6 +242,7 @@ void HistoryDock::filter(QString text) m_pItemView->expandAll(); } +///When the data range is linked, change the opposite value when editing the first void HistoryDock::updateLinkedDate(KDateWidget* item, QDate& prevDate, QDate& newDate) { if (m_pLinkPB->isChecked()) { @@ -237,20 +265,23 @@ void HistoryDock::updateLinkedDate(KDateWidget* item, QDate& prevDate, QDate& ne prevDate = newDate; } +///The signals have to be disabled to prevent an ifinite loop void HistoryDock::updateLinkedFromDate(QDate date) { - disconnect(m_pToDW , SIGNAL(changed(QDate)), this, SLOT(updateLinkedToDate(QDate))); + disconnect (m_pToDW , SIGNAL(changed(QDate)), this, SLOT(updateLinkedToDate(QDate))); updateLinkedDate(m_pToDW,m_pCurrentFromDate,date); - connect(m_pToDW , SIGNAL(changed(QDate)), this, SLOT(updateLinkedToDate(QDate))); + connect (m_pToDW , SIGNAL(changed(QDate)), this, SLOT(updateLinkedToDate(QDate))); } +///The signals have to be disabled to prevent an ifinite loop void HistoryDock::updateLinkedToDate(QDate date) { disconnect(m_pFromDW , SIGNAL(changed(QDate)), this, SLOT(updateLinkedFromDate(QDate))); updateLinkedDate(m_pFromDW,m_pCurrentToDate,date); - connect(m_pFromDW , SIGNAL(changed(QDate)), this, SLOT(updateLinkedFromDate(QDate))); + connect (m_pFromDW , SIGNAL(changed(QDate)), this, SLOT(updateLinkedFromDate(QDate))); } +///Generate serializerd version of the content QMimeData* HistoryTree::mimeData( const QList<QTreeWidgetItem *> items) const { qDebug() << "An history call is being dragged"; @@ -273,6 +304,7 @@ QMimeData* HistoryTree::mimeData( const QList<QTreeWidgetItem *> items) const return mimeData; } +///Handle what happen when serialized data is dropped bool HistoryTree::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action) { Q_UNUSED(index) @@ -284,4 +316,16 @@ bool HistoryTree::dropMimeData(QTreeWidgetItem *parent, int index, const QMimeDa qDebug() << "In history import"<< QString(encodedData); return false; +} + +///Handle keyboard input and redirect them to the filterbox +void HistoryDock::keyPressEvent(QKeyEvent* event) { + int key = event->key(); + if(key == Qt::Key_Escape) + m_pFilterLE->setText(QString()); + else if(key == Qt::Key_Return || key == Qt::Key_Enter) {} + else if((key == Qt::Key_Backspace) && (m_pFilterLE->text().size())) + m_pFilterLE->setText(m_pFilterLE->text().left( m_pFilterLE->text().size()-1 )); + else if (!event->text().isEmpty() && !(key == Qt::Key_Backspace)) + m_pFilterLE->setText(m_pFilterLE->text()+event->text()); } \ No newline at end of file diff --git a/kde/src/widgets/HistoryDock.h b/kde/src/widgets/HistoryDock.h index 466f798d95c1216b57a7ff4de5374676a99c3263..3c1b20e68b88719fdfda2068881dd9de1380951d 100644 --- a/kde/src/widgets/HistoryDock.h +++ b/kde/src/widgets/HistoryDock.h @@ -2,19 +2,23 @@ #define HISTORY_DOCK_H #include <QtGui/QDockWidget> -#include <QDebug> -#include <QDate> -#include <QtGui/QTreeWidgetItem> -#include <QtCore/QString> +#include <QtGui/QTreeWidget> +#include <QtCore/QDate> +//Qt +class QTreeWidgetItem; +class QString; class QTreeWidget; -class KLineEdit; class QComboBox; class QLabel; -class KDateWidget; class QCheckBox; class QPushButton; -class QDate; + +//KDE +class KLineEdit; +class KDateWidget; + +//SFLPhone class HistoryTreeItem; class HistoryTree; @@ -23,6 +27,7 @@ typedef QList<HistoryTreeItem*> HistoryList; class HistoryDock : public QDockWidget { Q_OBJECT public: + friend class KeyPressEater; HistoryDock(QWidget* parent); virtual ~HistoryDock(); private: @@ -50,6 +55,7 @@ private: QDate m_pCurrentToDate; public slots: void enableDateRange(bool enable); + virtual void keyPressEvent(QKeyEvent* event); private slots: void filter(QString text); void updateLinkedFromDate(QDate date); @@ -66,4 +72,17 @@ public: bool dropMimeData(QTreeWidgetItem *parent, int index, const QMimeData *data, Qt::DropAction action); }; +class KeyPressEater : public QObject +{ + Q_OBJECT +public: + KeyPressEater(HistoryDock* parent) : QObject(parent) { + m_pDock = parent; + } +protected: + bool eventFilter(QObject *obj, QEvent *event); +private: + HistoryDock* m_pDock; +}; + #endif \ No newline at end of file diff --git a/kde/src/widgets/HistoryTreeItem.cpp b/kde/src/widgets/HistoryTreeItem.cpp index 856c7c87a7d4d03984e3eb39a14dd01668750865..f27c8c8793c03d0dd458fbba0dc0262f3bc355ba 100644 --- a/kde/src/widgets/HistoryTreeItem.cpp +++ b/kde/src/widgets/HistoryTreeItem.cpp @@ -26,17 +26,25 @@ #include <kdebug.h> #include <unistd.h> #include <kaction.h> -#include <kicon.h> +#include <QtGui/QLabel> +#include <QtGui/QSpacerItem> +#include <QtGui/QHBoxLayout> +#include <QtGui/QVBoxLayout> +#include <KIcon> +#include <QLabel> #include "lib/sflphone_const.h" #include "HistoryTreeItem.h" #include "AkonadiBackend.h" #include "lib/Contact.h" #include "SFLPhone.h" +#include "widgets/BookmarkDock.h" #include "conf/ConfigurationSkeleton.h" +#include "lib/Call.h" const char * HistoryTreeItem::callStateIcons[12] = {ICON_INCOMING, ICON_RINGING, ICON_CURRENT, ICON_DIALING, ICON_HOLD, ICON_FAILURE, ICON_BUSY, ICON_TRANSFER, ICON_TRANSF_HOLD, "", "", ICON_CONFERENCE}; +///Constructor HistoryTreeItem::HistoryTreeItem(QWidget *parent ,QString phone) : QWidget(parent), itemCall(0),m_pMenu(0), init(false) { @@ -49,29 +57,32 @@ HistoryTreeItem::HistoryTreeItem(QWidget *parent ,QString phone) m_pAddToContact = new KAction(this); m_pBookmark = new KAction(this); - m_pCallAgain->setShortcut ( Qt::CTRL + Qt::Key_Enter ); - m_pCallAgain->setText ( "Call Again" ); - m_pCallAgain->setIcon ( KIcon(ICON_DIALING) ); - - m_pAddToContact->setShortcut ( Qt::CTRL + Qt::Key_E ); - m_pAddToContact->setText ( "Add Number to Contact" ); - m_pAddToContact->setIcon ( KIcon("list-resource-add") ); + m_pCallAgain->setShortcut ( Qt::CTRL + Qt::Key_Enter ); + m_pCallAgain->setText ( i18n("Call Again") ); + m_pCallAgain->setIcon ( KIcon(ICON_DIALING) ); + + m_pAddToContact->setShortcut ( Qt::CTRL + Qt::Key_E ); + m_pAddToContact->setText ( i18n("Add Number to Contact") ); + m_pAddToContact->setIcon ( KIcon("list-resource-add") ); + m_pAddToContact->setDisabled ( true ); - m_pAddContact->setShortcut ( Qt::CTRL + Qt::Key_E ); - m_pAddContact->setText ( "Add Contact" ); - m_pAddContact->setIcon ( KIcon("contact-new") ); + m_pAddContact->setShortcut ( Qt::CTRL + Qt::Key_E ); + m_pAddContact->setText ( i18n("Add Contact") ); + m_pAddContact->setIcon ( KIcon("contact-new") ); - m_pCopy->setShortcut ( Qt::CTRL + Qt::Key_C ); - m_pCopy->setText ( "Copy" ); - m_pCopy->setIcon ( KIcon("edit-copy") ); + m_pCopy->setShortcut ( Qt::CTRL + Qt::Key_C ); + m_pCopy->setText ( i18n("Copy") ); + m_pCopy->setIcon ( KIcon("edit-copy") ); + m_pCopy->setDisabled ( true ); - m_pEmail->setShortcut ( Qt::CTRL + Qt::Key_M ); - m_pEmail->setText ( "Send Email" ); - m_pEmail->setIcon ( KIcon("mail-message-new") ); + m_pEmail->setShortcut ( Qt::CTRL + Qt::Key_M ); + m_pEmail->setText ( i18n("Send Email") ); + m_pEmail->setIcon ( KIcon("mail-message-new") ); + m_pEmail->setDisabled ( true ); - m_pBookmark->setShortcut ( Qt::CTRL + Qt::Key_D ); - m_pBookmark->setText ( "Bookmark" ); - m_pBookmark->setIcon ( KIcon("bookmarks") ); + m_pBookmark->setShortcut ( Qt::CTRL + Qt::Key_D ); + m_pBookmark->setText ( i18n("Bookmark") ); + m_pBookmark->setIcon ( KIcon("bookmarks") ); connect(m_pCallAgain , SIGNAL(triggered()) , this , SLOT(callAgain() )); connect(m_pAddContact , SIGNAL(triggered()) , this , SLOT(addContact() )); @@ -108,16 +119,19 @@ HistoryTreeItem::HistoryTreeItem(QWidget *parent ,QString phone) } } +///Destructor HistoryTreeItem::~HistoryTreeItem() { } +///Return the call item Call* HistoryTreeItem::call() const { return itemCall; } +///Set the call to be handled by this item void HistoryTreeItem::setCall(Call *call) { itemCall = call; @@ -143,6 +157,7 @@ void HistoryTreeItem::setCall(Call *call) m_pPhoneNumber = itemCall->getPeerPhoneNumber(); } +///Can a contact be associed with this call? bool HistoryTreeItem::getContactInfo(QString phoneNumber) { Contact* contact = AkonadiBackend::getInstance()->getContactByPhone(phoneNumber); @@ -153,12 +168,13 @@ bool HistoryTreeItem::getContactInfo(QString phoneNumber) } else { labelIcon->setPixmap(QPixmap(KIcon("user-identity").pixmap(QSize(48,48)))); - labelPeerName->setText("<b>Unknow</b>"); + labelPeerName->setText(i18n("<b>Unknow</b>")); return false; } return true; } +///The item have to be updated void HistoryTreeItem::updated() { if (!getContactInfo(itemCall->getPeerPhoneNumber())) { @@ -185,37 +201,43 @@ void HistoryTreeItem::updated() } +///Return the time stamp uint HistoryTreeItem::getTimeStamp() { return m_pTimeStamp; } +///Return the duration uint HistoryTreeItem::getDuration() { return m_pDuration; } +///Return the caller name QString HistoryTreeItem::getName() { return m_pName; } +///Return the caller peer number QString HistoryTreeItem::getPhoneNumber() { return m_pPhoneNumber; } - +///Get the index item assiciated with this widget QTreeWidgetItem* HistoryTreeItem::getItem() { return m_pItem; } +///Set the index associed with this widget void HistoryTreeItem::setItem(QTreeWidgetItem* item) { m_pItem = item; } +///Show the context menu void HistoryTreeItem::showContext(const QPoint& pos) { if (!m_pMenu) { @@ -230,24 +252,30 @@ void HistoryTreeItem::showContext(const QPoint& pos) m_pMenu->exec(mapToGlobal(pos)); } - +///Send an email void HistoryTreeItem::sendEmail() { + //TODO qDebug() << "Sending email"; } +///Call the caller again void HistoryTreeItem::callAgain() { - qDebug() << "Calling "<< itemCall->getPeerPhoneNumber(); - SFLPhone::app()->model()->addDialingCall(m_pName, SFLPhone::app()->model()->getCurrentAccountId())->setCallNumber(m_pPhoneNumber); - + if (itemCall) { + qDebug() << "Calling "<< itemCall->getPeerPhoneNumber(); + } + SFLPhone::model()->addDialingCall(m_pName, SFLPhone::app()->model()->getCurrentAccountId())->setCallNumber(m_pPhoneNumber); } +///Copy the call void HistoryTreeItem::copy() { + //TODO qDebug() << "Copying contact"; } +///Create a contact from those informations void HistoryTreeItem::addContact() { qDebug() << "Adding contact"; @@ -257,10 +285,14 @@ void HistoryTreeItem::addContact() AkonadiBackend::getInstance()->addNewContact(aContact); } +///Add this call number to an existing contact void HistoryTreeItem::addToContact() { + //TODO qDebug() << "Adding to contact"; } + +///Bookmark this contact void HistoryTreeItem::bookmark() { qDebug() << "bookmark"; diff --git a/kde/src/widgets/HistoryTreeItem.h b/kde/src/widgets/HistoryTreeItem.h index abe24eabfa609e3797e37edbb70733823ab8671d..28eb710bc80637f6e46e47d80a0c9a06abf3f0e2 100644 --- a/kde/src/widgets/HistoryTreeItem.h +++ b/kde/src/widgets/HistoryTreeItem.h @@ -28,22 +28,21 @@ #ifndef HISTORYTREE_ITEM_H #define HISTORYTREE_ITEM_H +#include <QtGui/QWidget> #include <QtCore/QList> #include <QtCore/QVariant> #include <QtCore/QVector> -#include <QtGui/QWidget> -#include <QtGui/QLabel> -#include <QtGui/QSpacerItem> -#include <QtGui/QHBoxLayout> -#include <QtGui/QVBoxLayout> -#include <KIcon> - -#include "lib/Call.h" +//SFLPhone +class Call; +//Qt class QTreeWidgetItem; -class KAction; class QMenu; +class QLabel; + +//KDE +class KAction; class HistoryTreeItem : public QWidget { diff --git a/kde/src/widgets/SFLPhoneTray.cpp b/kde/src/widgets/SFLPhoneTray.cpp index 662506892df20baa91f8aae1379f0e94f205bd00..88e924df435cd29769794fce01e164ce59b213a9 100755 --- a/kde/src/widgets/SFLPhoneTray.cpp +++ b/kde/src/widgets/SFLPhoneTray.cpp @@ -20,6 +20,9 @@ ***************************************************************************/ #include <QDebug> +#include <KAction> +#include <QMenu> +#include <QIcon> #include "SFLPhoneTray.h" diff --git a/kde/src/widgets/SFLPhoneTray.h b/kde/src/widgets/SFLPhoneTray.h index 537e147b6ceacc2db9dd0ef5b9f4ae1256f837eb..9c4d730fcb8bf0b6952069783a0b45f7613b4613 100755 --- a/kde/src/widgets/SFLPhoneTray.h +++ b/kde/src/widgets/SFLPhoneTray.h @@ -23,9 +23,13 @@ #define SFLPHONETRAY_H #include <KSystemTrayIcon> -#include <KAction> -#include <QMenu> -#include <QIcon> + +//KDE +class KAction; + +//Qt +class QMenu; +class QIcon; class SFLPhoneTray : public KSystemTrayIcon {