Skip to content
Snippets Groups Projects
Commit 46d43295 authored by Emmanuel Lepage's avatar Emmanuel Lepage
Browse files

[#7021] Refactor KDE client dbus handling, add a missing call in daemon and...

[#7021] Refactor KDE client dbus handling, add a missing call in daemon and port the DataEngine to the new API
parent 74ac68f5
Branches
Tags
No related merge requests found
...@@ -473,7 +473,8 @@ call_state Call::actionPerformed(call_action action) ...@@ -473,7 +473,8 @@ call_state Call::actionPerformed(call_action action)
{ {
call_state previousState = currentState; call_state previousState = currentState;
Q_ASSERT_X((previousState>10) || (previousState<0),"perform action","Invalid previous state ("+QString::number(previousState)+")"); 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((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 //update the state
changeCurrentState(actionPerformedStateMap[previousState][action]); changeCurrentState(actionPerformedStateMap[previousState][action]);
//execute the action associated with this transition //execute the action associated with this transition
......
...@@ -19,3 +19,111 @@ ...@@ -19,3 +19,111 @@
**************************************************************************/ **************************************************************************/
#include <CallModel.h> #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)
{
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
...@@ -40,14 +40,48 @@ ...@@ -40,14 +40,48 @@
typedef QHash<QString, Call*> CallHash; typedef QHash<QString, Call*> CallHash;
typedef QList<Call*> CallList; typedef QList<Call*> CallList;
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 * 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 * 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). * 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> template <typename CallWidget, typename Index>
class LIB_EXPORT CallModel { class LIB_EXPORT CallModel : public CallModelBase {
//Q_OBJECT
public: public:
enum ModelType { enum ModelType {
ActiveCall, ActiveCall,
...@@ -76,8 +110,8 @@ class LIB_EXPORT CallModel { ...@@ -76,8 +110,8 @@ class LIB_EXPORT CallModel {
bool mergeConferences ( Call* conf1, Call* conf2 ); bool mergeConferences ( Call* conf1, Call* conf2 );
bool addParticipant ( Call* call2, Call* conference ); bool addParticipant ( Call* call2, Call* conference );
bool detachParticipant ( Call* call ); bool detachParticipant ( Call* call );
virtual bool conferenceChanged ( const QString &confId, const QString &state ); virtual bool changeConference ( const QString &confId, const QString &state );
virtual void conferenceRemoved ( const QString &confId ); virtual void removeConference ( const QString &confId );
virtual Call* addConference ( const QString &confID ); virtual Call* addConference ( const QString &confID );
void removeConference ( Call* call ); void removeConference ( Call* call );
......
...@@ -20,7 +20,7 @@ template <typename CallWidget, typename Index> typename CallModel<CallWidget,In ...@@ -20,7 +20,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 ///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) Q_UNUSED(type)
init(); init();
...@@ -135,6 +135,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, ...@@ -135,6 +135,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,
template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addCall(Call* call, Call* parent) template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addCall(Call* call, Call* parent)
{ {
Q_UNUSED(parent) Q_UNUSED(parent)
qDebug() << "-------------------Adding call" << call << "-------------------";
InternalStruct* aNewStruct = new InternalStruct; InternalStruct* aNewStruct = new InternalStruct;
aNewStruct->call_real = call; aNewStruct->call_real = call;
aNewStruct->conference = false; aNewStruct->conference = false;
...@@ -143,7 +144,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: ...@@ -143,7 +144,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>:
m_pPrivateCallList_callId[call->getCallId()] = aNewStruct; m_pPrivateCallList_callId[call->getCallId()] = aNewStruct;
//setCurrentItem(callItem); //setCurrentItem(callItem);
CallModelBase::addCall(call,parent);
return call; return call;
} }
...@@ -245,9 +246,10 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: ...@@ -245,9 +246,10 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>:
InternalStruct* aNewStruct = new InternalStruct; InternalStruct* aNewStruct = new InternalStruct;
aNewStruct->call_real = newConf; aNewStruct->call_real = newConf;
aNewStruct->conference = true;
m_pPrivateCallList_call[newConf] = aNewStruct; m_pPrivateCallList_call[newConf] = aNewStruct;
m_pPrivateCallList_callId[newConf->getConfId()] = aNewStruct; //WARNING It may break something is it is done wrong m_pPrivateCallList_callId[confID] = aNewStruct;
return newConf; return newConf;
} }
...@@ -292,7 +294,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: ...@@ -292,7 +294,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 ///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"; qDebug() << "Conf changed2";
Q_UNUSED(state) Q_UNUSED(state)
...@@ -310,7 +312,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: ...@@ -310,7 +312,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::
} }
///Remove a conference from the model and the TreeView ///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"; qDebug() << "Ending conversation containing " << m_pPrivateCallList_callId[confId]->children.size() << " participants";
removeConference(getCall(confId)); removeConference(getCall(confId));
......
...@@ -282,27 +282,27 @@ ...@@ -282,27 +282,27 @@
typedef enum typedef enum
{ {
/** Ringing incoming call */ /** Ringing incoming call */
CALL_STATE_INCOMING, CALL_STATE_INCOMING =0,
/** Ringing outgoing call */ /** Ringing outgoing call */
CALL_STATE_RINGING, CALL_STATE_RINGING=1,
/** Call to which the user can speak and hear */ /** 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 which numbers are being added by the user */
CALL_STATE_DIALING, CALL_STATE_DIALING=3,
/** Call is on hold */ /** Call is on hold */
CALL_STATE_HOLD, CALL_STATE_HOLD=4,
/** Call has failed */ /** Call has failed */
CALL_STATE_FAILURE, CALL_STATE_FAILURE=5,
/** Call is busy */ /** 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 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 is on hold for transfer */
CALL_STATE_TRANSF_HOLD, CALL_STATE_TRANSF_HOLD=8,
/** Call is over and should not be used */ /** Call is over and should not be used */
CALL_STATE_OVER, CALL_STATE_OVER=9,
/** This state should never be reached */ /** This state should never be reached */
CALL_STATE_ERROR CALL_STATE_ERROR=10
} call_state; } call_state;
/** MIME API */ /** MIME API */
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment