diff --git a/src/Account.h b/src/Account.h index f393a13fde8b92d6b0e912c57cb4466f45db8c77..e70c39f796ffe513eedf657864f2b23cd654871d 100644 --- a/src/Account.h +++ b/src/Account.h @@ -39,19 +39,19 @@ class LIB_EXPORT Account : public QObject { static Account* buildNewAccountFromAlias(QString alias); //Getters - bool isNew() const; - const QString & getAccountId() const; - MapStringString & getAccountDetails() const; - QString getStateName(QString & state); - QString getAccountDetail(QString param) const; - QString getAlias() const; - bool isEnabled() const; - bool isRegistered() const; + bool isNew() const; + const QString& getAccountId() const; + MapStringString& getAccountDetails() const; + QString getStateName(QString & state) ; + QString getAccountDetail(QString param) const; + QString getAlias() const; + bool isEnabled() const; + bool isRegistered() const; //Setters - void setAccountId(QString id); - void setAccountDetails(MapStringString m); - void setAccountDetail(QString param, QString val); + void setAccountId (QString id ); + void setAccountDetails (MapStringString m ); + void setAccountDetail (QString param, QString val ); //Updates virtual void updateState(); diff --git a/src/Call.cpp b/src/Call.cpp index 54533d8b97cf22eb9fb5f70e7b9a46ac6f65c6d0..eaf51ffdfd44883bfef395d40cec3dabf0e3fb5a 100644 --- a/src/Call.cpp +++ b/src/Call.cpp @@ -244,15 +244,15 @@ QString Call::getTypeFromHistoryState(history_state historyState) ///Get history state from daemon history_state Call::getHistoryStateFromDaemonCallState(QString daemonCallState, QString daemonCallType) { - if((daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT || daemonCallState == DAEMON_CALL_STATE_INIT_HOLD) && daemonCallType == DAEMON_CALL_TYPE_INCOMING) + if((daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT || daemonCallState == DAEMON_CALL_STATE_INIT_HOLD) && daemonCallType == DAEMON_CALL_TYPE_INCOMING ) return INCOMING ; - else if((daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT || daemonCallState == DAEMON_CALL_STATE_INIT_HOLD) && daemonCallType == DAEMON_CALL_TYPE_OUTGOING) + else if((daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT || daemonCallState == DAEMON_CALL_STATE_INIT_HOLD) && daemonCallType == DAEMON_CALL_TYPE_OUTGOING ) return OUTGOING ; - else if(daemonCallState == DAEMON_CALL_STATE_INIT_BUSY) + else if(daemonCallState == DAEMON_CALL_STATE_INIT_BUSY ) return OUTGOING ; - else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_INCOMING) + else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_INCOMING ) return INCOMING ; - else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_OUTGOING) + else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_OUTGOING ) return MISSED ; else return NONE ; @@ -261,15 +261,15 @@ history_state Call::getHistoryStateFromDaemonCallState(QString daemonCallState, ///Get the start sate from the daemon state call_state Call::getStartStateFromDaemonCallState(QString daemonCallState, QString daemonCallType) { - if(daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT ) + if(daemonCallState == DAEMON_CALL_STATE_INIT_CURRENT ) return CALL_STATE_CURRENT ; else if(daemonCallState == DAEMON_CALL_STATE_INIT_HOLD ) return CALL_STATE_HOLD ; else if(daemonCallState == DAEMON_CALL_STATE_INIT_BUSY ) return CALL_STATE_BUSY ; - else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_INCOMING) + else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_INCOMING ) return CALL_STATE_INCOMING ; - else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_OUTGOING) + else if(daemonCallState == DAEMON_CALL_STATE_INIT_INACTIVE && daemonCallType == DAEMON_CALL_TYPE_OUTGOING ) return CALL_STATE_RINGING ; else if(daemonCallState == DAEMON_CALL_STATE_INIT_INCOMING ) return CALL_STATE_INCOMING ; @@ -304,12 +304,13 @@ daemon_call_state Call::toDaemonCallState(const QString & stateName) return DAEMON_CALL_STATE_BUSY ; if(stateName == QString(CALL_STATE_CHANGE_FAILURE) ) return DAEMON_CALL_STATE_FAILURE ; + qDebug() << "stateChanged signal received with unknown state."; return DAEMON_CALL_STATE_FAILURE ; } ///Get the time (second from 1 jan 1970) when the call ended -QString Call::getStopTimeStamp() const +QString Call::getStopTimeStamp() const { if (m_pStopTime == NULL) return QString(); @@ -317,7 +318,7 @@ QString Call::getStopTimeStamp() const } ///Get the time (second from 1 jan 1970) when the call started -QString Call::getStartTimeStamp() const +QString Call::getStartTimeStamp() const { if (m_pStartTime == NULL) return QString(); @@ -325,79 +326,90 @@ QString Call::getStartTimeStamp() const } ///Get the number where the call have been transferred -QString Call::getTransferNumber() const +QString Call::getTransferNumber() const { return m_pTransferNumber; } ///Get the call / peer number -QString Call::getCallNumber() const +QString Call::getCallNumber() const { return m_pCallNumber; } ///Return the call id -QString Call::getCallId() const +QString Call::getCallId() const { return m_pCallId; } ///Return the peer phone number -QString Call::getPeerPhoneNumber() const +QString Call::getPeerPhoneNumber() const { return m_pPeerPhoneNumber; } ///Get the peer name -QString Call::getPeerName() const +QString Call::getPeerName() const { return m_pPeerName; } ///Get the current state -call_state Call::getCurrentState() const +call_state Call::getCurrentState() const { return currentState; } ///Get the call recording -bool Call::getRecording() const +bool Call::getRecording() const { return recording; } ///Get the call account id -QString Call::getAccountId() const +QString Call::getAccountId() const { return m_pAccount; } ///Is this call a conference -bool Call::isConference() const { +bool Call::isConference() const +{ return conference; } -///This call is a conference -void Call::setConference(bool value) { - conference = value; -} - ///Get the conference ID -QString Call::getConfId() const { +QString Call::getConfId() const +{ return m_pConfId; } -///Set the conference ID -void Call::setConfId(QString value) { - m_pConfId = value; -} - ///Get the current codec -QString Call::getCurrentCodecName() const { +QString Call::getCurrentCodecName() const +{ CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); return callManager.getCurrentAudioCodecName(m_pCallId); } +///Get the state +call_state Call::getState() const +{ + return currentState; +} + +///Get the history state +history_state Call::getHistoryState() const +{ + return m_pHistoryState; +} + +///Is this call over? +bool Call::isHistory() const +{ + return (getState() == CALL_STATE_OVER); +} + ///This function could also be called mayBeSecure or haveChancesToBeEncryptedButWeCantTell. bool Call::isSecure() const { @@ -428,6 +440,12 @@ void Call::setTransferNumber(QString number) m_pTransferNumber = number; } +///This call is a conference +void Call::setConference(bool value) +{ + conference = value; +} + ///Set the call number void Call::setCallNumber(QString number) { @@ -435,22 +453,10 @@ void Call::setCallNumber(QString number) emit changed(); } -///Get the state -call_state Call::getState() const -{ - return currentState; -} - -///Get the history state -history_state Call::getHistoryState() const -{ - return m_pHistoryState; -} - -///Is this call over? -bool Call::isHistory() const +///Set the conference ID +void Call::setConfId(QString value) { - return (getState() == CALL_STATE_OVER); + m_pConfId = value; } /***************************************************************************** @@ -465,7 +471,6 @@ call_state Call::stateChanged(const QString& newStateName) if (!conference) { call_state previousState = currentState; daemon_call_state dcs = toDaemonCallState(newStateName); - //(this->*(stateChangedFunctionMap[currentState][dcs]))(); changeCurrentState(stateChangedStateMap[currentState][dcs]); (this->*(stateChangedFunctionMap[previousState][dcs]))(); qDebug() << "Calling stateChanged " << newStateName << " -> " << toDaemonCallState(newStateName) << " on call with state " << previousState << ". Become " << currentState; diff --git a/src/CallModel.cpp b/src/CallModel.cpp index e74ca594d8fd051967e6cbd5e12b05a302f63abd..39c87e3395e206d2b07105d980a0c5ab3cdfbd37 100644 --- a/src/CallModel.cpp +++ b/src/CallModel.cpp @@ -25,13 +25,17 @@ 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 ) ) ); + + //SLOTS + // SENDER SIGNAL RECEIVER SLOT / + /**/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; } } @@ -67,8 +71,6 @@ void CallModelBase::on1_incomingCall(const QString & accountID, const QString & Call* call = addIncomingCall(callID); //NEED_PORT -// changeScreen(SCREEN_MAIN); -// // SFLPhone::app()->activateWindow(); // SFLPhone::app()->raise(); // SFLPhone::app()->setVisible(true); diff --git a/src/CallModel.h b/src/CallModel.h index 6262751177a2e0c000388c645cd4aba7d2831e7a..7bcbb27a10926e036d1d96be1809a5fb5f789bf8 100644 --- a/src/CallModel.h +++ b/src/CallModel.h @@ -196,6 +196,10 @@ class LIB_EXPORT CallModel : public CallModelBase { private: static bool m_pInstanceInit; + + //Helpers + Call* addCallCommon(Call* call); + bool updateCommon(Call* call); //public slots: //void clearHistory(); }; diff --git a/src/CallModel.hpp b/src/CallModel.hpp index 371a4853982b495d9eed291fd91503f3c0763f80..5ade85b1ab1004cb5f861a2b6bc319ada47c7531 100644 --- a/src/CallModel.hpp +++ b/src/CallModel.hpp @@ -157,10 +157,10 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: { Q_UNUSED(parent) InternalStruct* aNewStruct = new InternalStruct; - aNewStruct->call_real = call; + aNewStruct->call_real = call; aNewStruct->conference = false; - m_pPrivateCallList_call[call] = aNewStruct; + m_pPrivateCallList_call[call] = aNewStruct; m_pPrivateCallList_callId[call->getCallId()] = aNewStruct; //setCurrentItem(callItem); @@ -168,8 +168,17 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: return call; } +///Common set of instruction shared by all call adder +template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addCallCommon(Call* call) +{ + m_pActiveCalls[call->getCallId()] = call; + addCall(call); + selectItem(call); + return call; +} + ///Create a new dialing call from peer name and the account ID -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addDialingCall(const QString & peerName, QString account) +template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addDialingCall(const QString& peerName, QString account) { QString account2 = account; if (account2.isEmpty()) { @@ -177,30 +186,21 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } Call* call = Call::buildDialingCall(generateCallId(), peerName, account2); - m_pActiveCalls[call->getCallId()] = call; - addCall(call); - selectItem(call); - return call; + return addCallCommon(call); } ///Create a new incomming call when the daemon is being called -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addIncomingCall(const QString & callId) +template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addIncomingCall(const QString& callId) { Call* call = Call::buildIncomingCall(callId); - m_pActiveCalls[call->getCallId()] = call; - addCall(call); - selectItem(call); - return call; + return addCallCommon(call); } ///Create a ringing call -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addRingingCall(const QString & callId) +template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addRingingCall(const QString& callId) { Call* call = Call::buildRingingCall(callId); - m_pActiveCalls[call->getCallId()] = call; - addCall(call); - selectItem(call); - return call; + return addCallCommon(call); } ///Generate a new random call unique identifier (callId) @@ -265,7 +265,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: Call* newConf = new Call(confID, m_pPrivateCallList_callId[callList[0]]->call_real->getAccountId()); InternalStruct* aNewStruct = new InternalStruct; - aNewStruct->call_real = newConf; + aNewStruct->call_real = newConf; aNewStruct->conference = true; m_pPrivateCallList_call[newConf] = aNewStruct; @@ -463,7 +463,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, } ///Is the call associated with that widget a conference -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference (const CallWidget widget ) const +template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference ( const CallWidget widget ) const { if (m_pPrivateCallList_widget[widget]) { return m_pPrivateCallList_widget[widget]->conference; @@ -472,7 +472,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Is that call a conference -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference (const Call* call ) const +template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference ( const Call* call ) const { if (m_pPrivateCallList_call[(Call*)call]) { return m_pPrivateCallList_call[(Call*)call]->conference; @@ -481,13 +481,13 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Do nothing, provided for API consistency -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::getCall (const Call* call ) const +template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::getCall ( const Call* call ) const { return call; } ///Return the calls from the "call" conference -template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls (const Call* call ) const +template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( const Call* call ) const { QList<Call*> toReturn; if (m_pPrivateCallList_call[call] && m_pPrivateCallList_call[call]->conference) { @@ -499,7 +499,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, } ///Is the call associated with that Index a conference -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference (const Index idx ) const +template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference ( const Index idx ) const { if (m_pPrivateCallList_index[idx]) { return m_pPrivateCallList_index[idx]->conference; @@ -508,7 +508,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Get the call associated with this index -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::getCall (const Index idx ) const +template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::getCall ( const Index idx ) const { if (m_pPrivateCallList_index[idx]) { return m_pPrivateCallList_index[idx]->call_real; @@ -518,7 +518,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///Get the call associated with that conference index -template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls (const Index idx ) const +template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( const Index idx ) const { QList<Call*> toReturn; if (m_pPrivateCallList_index[idx] && m_pPrivateCallList_index[idx]->conference) { @@ -530,7 +530,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, } ///Is the call associated with that ID a conference -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference (const QString callId ) const +template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::isConference ( const QString callId ) const { if (m_pPrivateCallList_callId[callId]) { return m_pPrivateCallList_callId[callId]->conference; @@ -539,7 +539,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Get the call associated with this ID -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::getCall (const QString callId ) const +template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::getCall ( const QString callId ) const { if (m_pPrivateCallList_callId[callId]) { return m_pPrivateCallList_callId[callId]->call_real; @@ -548,7 +548,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///Get the calls associated with this ID -template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls (const QString callId ) const +template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( const QString callId ) const { QList<Call*> toReturn; if (m_pPrivateCallList_callId[callId] && m_pPrivateCallList_callId[callId]->conference) { @@ -559,22 +559,8 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, return toReturn; } -///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; - m_pPrivateCallList_call[call]->conference = false; - m_pPrivateCallList_callId[call->getCallId()] = m_pPrivateCallList_call[call]; - } - m_pPrivateCallList_call[call]->index = value; - m_pPrivateCallList_index[value] = m_pPrivateCallList_call[call]; - return true; -} - ///Get the index associated with this call -template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex (const Call* call ) const +template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex ( const Call* call ) const { if (m_pPrivateCallList_call[(Call*)call]) { return m_pPrivateCallList_call[(Call*)call]->index; @@ -583,7 +569,7 @@ template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>: } ///Get the index associated with this index (dummy implementation) -template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex (const Index idx ) const +template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex ( const Index idx ) const { if (m_pPrivateCallList_index[idx]) { return m_pPrivateCallList_index[idx]->index; @@ -592,7 +578,7 @@ template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>: } ///Get the index associated with this call -template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex (const CallWidget widget ) const +template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex ( const CallWidget widget ) const { if (m_pPrivateCallList_widget[widget]) { return m_pPrivateCallList_widget[widget]->index; @@ -601,7 +587,7 @@ template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>: } ///Get the index associated with this ID -template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex (const QString callId ) const +template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex ( const QString callId ) const { if (m_pPrivateCallList_callId[callId]) { return m_pPrivateCallList_callId[callId]->index; @@ -610,7 +596,7 @@ template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>: } ///Get the widget associated with this call -template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget (const Call* call ) const +template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget ( const Call* call ) const { if (m_pPrivateCallList_call[call]) { return m_pPrivateCallList_call[call]->call; @@ -619,7 +605,7 @@ template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,In } ///Get the widget associated with this ID -template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget (const Index idx ) const +template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget ( const Index idx ) const { if (m_pPrivateCallList_index[idx]) { return m_pPrivateCallList_index[idx]->call; @@ -628,7 +614,7 @@ template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,In } ///Get the widget associated with this widget (dummy) -template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget (const CallWidget widget ) const +template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget ( const CallWidget widget ) const { if (m_pPrivateCallList_widget[widget]) { return m_pPrivateCallList_widget[widget]->call; @@ -637,7 +623,7 @@ template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,In } ///Get the widget associated with this ID -template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget (const QString widget ) const +template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,Index>::getWidget ( const QString widget ) const { if (m_pPrivateCallList_widget[widget]) { return m_pPrivateCallList_widget[widget]->call; @@ -645,16 +631,33 @@ template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,In return NULL; } -///Update the widget associated with this call -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateWidget (Call* call, CallWidget value ) +///Common set of instruction shared by all gui updater +template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateCommon(Call* call) { if (!m_pPrivateCallList_call[call]) { - m_pPrivateCallList_call[call] = new InternalStruct; - m_pPrivateCallList_call[call]->call_real = call; - m_pPrivateCallList_call[call]->conference = false; - m_pPrivateCallList_callId[call->getCallId()] = m_pPrivateCallList_call[call]; + m_pPrivateCallList_call [ call ] = new InternalStruct ; + m_pPrivateCallList_call [ call ]->call_real = call ; + m_pPrivateCallList_call [ call ]->conference = false ; + m_pPrivateCallList_callId [ call->getCallId() ] = m_pPrivateCallList_call[call] ; } - m_pPrivateCallList_call[call]->call = value; - m_pPrivateCallList_widget[value] = m_pPrivateCallList_call[call]; + return true; +} + +///Update the widget associated with this call +template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateWidget (Call* call, CallWidget value ) +{ + updateCommon(call); + m_pPrivateCallList_call[call]->call = value ; + m_pPrivateCallList_widget[value] = m_pPrivateCallList_call[call] ; + return true; +} + + +///Update the index associated with this call +template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateIndex (Call* call, Index value ) +{ + updateCommon(call); + m_pPrivateCallList_call[call]->index = value ; + m_pPrivateCallList_index[value] = m_pPrivateCallList_call[call] ; return true; } \ No newline at end of file diff --git a/src/Item.cpp b/src/Item.cpp index 705cb2948c4eefbf44912f1b598ed4c4cf23c8d9..7f2b2a40a87872591c03ee333d5f8744297eba2e 100644 --- a/src/Item.cpp +++ b/src/Item.cpp @@ -19,4 +19,5 @@ * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "Item.h" +#include <QListWidgetItem> diff --git a/src/Item.h b/src/Item.h index b01f796cb6f835910f3931beb8474ae4a345f14c..24238fa5c4e34f318efd4916f6226e3e107979dd 100644 --- a/src/Item.h +++ b/src/Item.h @@ -17,24 +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 ITEM_H #define ITEM_H -#include <QObject> -#include <QListWidgetItem> -#include <QWidget> #include "typedefs.h" +class QListWidgetItem; + /** - @author Jérémy Quentin <jeremy.quentin@gmail.com> - Represents an item of a list, that is displayed - by an QListWidgetItem with a QWidget inside. - The two objects are contained in this class, but their - initializations are pure virtual. - The template class WIDGET_TYPE should be derived from - QWidget. - The implementation of initItem should call initItemWidget + @author Jérémy Quentin <jeremy.quentin@gmail.com> + Represents an item of a list, that is displayed + by an QListWidgetItem with a QWidget inside. + The two objects are contained in this class, but their + initializations are pure virtual. + The template class WIDGET_TYPE should be derived from + QWidget. + The implementation of initItem should call initItemWidget */ template<class WIDGET_TYPE>class LIB_EXPORT Item { @@ -45,9 +44,9 @@ protected: public: /** - * Would be great to take the QListWidget as attribute - * to be able to add the itemWidget to the item in the list. - * For the moment, we have to do it from outside. + * Would be great to take the QListWidget as attribute + * to be able to add the itemWidget to the item in the list. + * For the moment, we have to do it from outside. */ Item(/*QListWidget *list=0*/) { item = NULL; @@ -55,8 +54,8 @@ public: } /** - * Be careful that it is not already deleted by QObject - * Commented for safety reasons... + * Be careful that it is not already deleted by QObject + * Commented for safety reasons... */ virtual ~Item() { // delete item; @@ -79,8 +78,8 @@ public: } /** - * Initializes the item and widget - * Implementation should call initItemWidget! + * Initializes the item and widget + * Implementation should call initItemWidget! */ virtual void initItem() = 0; diff --git a/src/callmanager_interface_singleton.cpp b/src/callmanager_interface_singleton.cpp index edeb420c70e6402df47fdf313d191be731bb3635..c6718aa19a1f53a0a5c6361f13af6fd4f1b8a97f 100644 --- a/src/callmanager_interface_singleton.cpp +++ b/src/callmanager_interface_singleton.cpp @@ -21,17 +21,11 @@ #include "callmanager_interface_singleton.h" -CallManagerInterface * CallManagerInterfaceSingleton::interface - = new CallManagerInterface( - "org.sflphone.SFLphone", - "/org/sflphone/SFLphone/CallManager", - QDBusConnection::sessionBus()); +CallManagerInterface * CallManagerInterfaceSingleton::interface = new CallManagerInterface( "org.sflphone.SFLphone", "/org/sflphone/SFLphone/CallManager", QDBusConnection::sessionBus()); CallManagerInterface & CallManagerInterfaceSingleton::getInstance(){ - if(!interface->connection().isConnected()) - { - throw "Error : sflphoned not connected. Service " + interface->service() + " not connected. From call manager interface."; - } - return *interface; + if(!interface->connection().isConnected()) + throw "Error : sflphoned not connected. Service " + interface->service() + " not connected. From call manager interface."; + return *interface; } diff --git a/src/callmanager_interface_singleton.h b/src/callmanager_interface_singleton.h index 25897d98f0364bdd2f48e15defe8ded8157bf169..85dbee954d6b2b1bf46d32c49a731fa5d7e9dacd 100644 --- a/src/callmanager_interface_singleton.h +++ b/src/callmanager_interface_singleton.h @@ -28,12 +28,10 @@ class LIB_EXPORT CallManagerInterfaceSingleton { private: - - static CallManagerInterface * interface; + static CallManagerInterface* interface; public: - - static CallManagerInterface & getInstance(); + static CallManagerInterface& getInstance(); }; diff --git a/src/instance_interface_singleton.h b/src/instance_interface_singleton.h index c5987dde84440a7ba18d15722f9f6e30bd8393bc..1b29e058d21005f9b589456a6aac04ccb64761d6 100644 --- a/src/instance_interface_singleton.h +++ b/src/instance_interface_singleton.h @@ -32,12 +32,10 @@ class LIB_EXPORT InstanceInterfaceSingleton { private: - - static InstanceInterface* interface; + static InstanceInterface* interface; public: - - static InstanceInterface& getInstance(); + static InstanceInterface& getInstance(); };