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

[ #50191 ] Remove some redundancy between calls and conference

This change will reduce some risks when using the wrong id()
parent c5293804
No related branches found
No related tags found
No related merge requests found
...@@ -191,11 +191,11 @@ QDebug LIB_EXPORT operator<<(QDebug dbg, const Call::Action& c) ...@@ -191,11 +191,11 @@ QDebug LIB_EXPORT operator<<(QDebug dbg, const Call::Action& c)
///Constructor ///Constructor
Call::Call(Call::State startState, const QString& callId, const QString& peerName, PhoneNumber* number, Account* account) Call::Call(Call::State startState, const QString& callId, const QString& peerName, PhoneNumber* number, Account* account)
: QObject(CallModel::instance()), m_isConference(false),m_pStopTimeStamp(0), : QObject(CallModel::instance()),m_pStopTimeStamp(0),
m_pImModel(nullptr),m_pTimer(nullptr),m_Recording(false),m_Account(nullptr), m_pImModel(nullptr),m_pTimer(nullptr),m_Recording(false),m_Account(nullptr),
m_PeerName(peerName),m_pPeerPhoneNumber(number),m_HistoryConst(HistoryTimeCategoryModel::HistoryConst::Never), m_PeerName(peerName),m_pPeerPhoneNumber(number),m_HistoryConst(HistoryTimeCategoryModel::HistoryConst::Never),
m_CallId(callId),m_CurrentState(startState),m_pStartTimeStamp(0),m_pDialNumber(nullptr),m_pTransferNumber(nullptr), m_CallId(callId),m_CurrentState(startState),m_pStartTimeStamp(0),m_pDialNumber(nullptr),m_pTransferNumber(nullptr),
m_History(false),m_Missed(false),m_Direction(Call::Direction::OUTGOING),m_pBackend(nullptr) m_History(false),m_Missed(false),m_Direction(Call::Direction::OUTGOING),m_pBackend(nullptr),m_Type(Call::Type::CALL)
{ {
m_Account = account; m_Account = account;
Q_ASSERT(!callId.isEmpty()); Q_ASSERT(!callId.isEmpty());
...@@ -218,23 +218,23 @@ Call::~Call() ...@@ -218,23 +218,23 @@ Call::~Call()
///Constructor ///Constructor
Call::Call(const QString& confId, const QString& account): QObject(CallModel::instance()), Call::Call(const QString& confId, const QString& account): QObject(CallModel::instance()),
m_pStopTimeStamp(0),m_pStartTimeStamp(0),m_pImModel(nullptr),m_ConfId(confId), m_pStopTimeStamp(0),m_pStartTimeStamp(0),m_pImModel(nullptr),
m_Account(AccountListModel::instance()->getAccountById(account)),m_CurrentState(Call::State::CONFERENCE), m_Account(AccountListModel::instance()->getAccountById(account)),m_CurrentState(Call::State::CONFERENCE),
m_pTimer(nullptr), m_isConference(false),m_pPeerPhoneNumber(nullptr),m_pDialNumber(nullptr),m_pTransferNumber(nullptr), m_pTimer(nullptr),m_pPeerPhoneNumber(nullptr),m_pDialNumber(nullptr),m_pTransferNumber(nullptr),
m_HistoryConst(HistoryTimeCategoryModel::HistoryConst::Never),m_History(false),m_Missed(false), m_HistoryConst(HistoryTimeCategoryModel::HistoryConst::Never),m_History(false),m_Missed(false),
m_Direction(Call::Direction::OUTGOING),m_pBackend(nullptr) m_Direction(Call::Direction::OUTGOING),m_pBackend(nullptr), m_CallId(confId),
m_Type((!confId.isEmpty())?Call::Type::CONFERENCE:Call::Type::CALL)
{ {
setObjectName("Conf:"+confId); setObjectName("Conf:"+confId);
m_isConference = !m_ConfId.isEmpty();
m_pUserActionModel = new UserActionModel(this); m_pUserActionModel = new UserActionModel(this);
if (m_isConference) { if (type() == Call::Type::CONFERENCE) {
time_t curTime; time_t curTime;
::time(&curTime); ::time(&curTime);
setStartTimeStamp(curTime); setStartTimeStamp(curTime);
initTimer(); initTimer();
CallManagerInterface& callManager = DBus::CallManager::instance(); CallManagerInterface& callManager = DBus::CallManager::instance();
MapStringString details = callManager.getConferenceDetails(m_ConfId) ; MapStringString details = callManager.getConferenceDetails(id()) ;
m_CurrentState = confStatetoCallState(details[ConfDetailsMapFields::CONF_STATE]); m_CurrentState = confStatetoCallState(details[ConfDetailsMapFields::CONF_STATE]);
emit stateChanged(); emit stateChanged();
} }
...@@ -435,9 +435,9 @@ Call::State Call::startStateFromDaemonCallState(const QString& daemonCallState, ...@@ -435,9 +435,9 @@ Call::State Call::startStateFromDaemonCallState(const QString& daemonCallState,
return Call::State::HOLD ; return Call::State::HOLD ;
else if(daemonCallState == Call::DaemonStateInit::BUSY ) else if(daemonCallState == Call::DaemonStateInit::BUSY )
return Call::State::BUSY ; return Call::State::BUSY ;
else if(daemonCallState == Call::DaemonStateInit::INACTIVE && daemonCallType == Call::CallType::INCOMING ) else if(daemonCallState == Call::DaemonStateInit::INACTIVE && daemonCallType == Call::CallDirection::INCOMING )
return Call::State::INCOMING ; return Call::State::INCOMING ;
else if(daemonCallState == Call::DaemonStateInit::INACTIVE && daemonCallType == Call::CallType::OUTGOING ) else if(daemonCallState == Call::DaemonStateInit::INACTIVE && daemonCallType == Call::CallDirection::OUTGOING )
return Call::State::RINGING ; return Call::State::RINGING ;
else if(daemonCallState == Call::DaemonStateInit::INCOMING ) else if(daemonCallState == Call::DaemonStateInit::INCOMING )
return Call::State::INCOMING ; return Call::State::INCOMING ;
...@@ -599,7 +599,7 @@ const QString Call::peerName() const ...@@ -599,7 +599,7 @@ const QString Call::peerName() const
///Generate the best possible peer name ///Generate the best possible peer name
const QString Call::formattedName() const const QString Call::formattedName() const
{ {
if (isConference()) if (type() == Call::Type::CONFERENCE)
return tr("Conference"); return tr("Conference");
else if (!peerPhoneNumber()) else if (!peerPhoneNumber())
return "Error"; return "Error";
...@@ -657,6 +657,12 @@ Call::Direction Call::direction() const ...@@ -657,6 +657,12 @@ Call::Direction Call::direction() const
return m_Direction; return m_Direction;
} }
///Is the call a conference or something else
Call::Type Call::type() const
{
return m_Type;
}
///Return the backend used to serialize this call ///Return the backend used to serialize this call
AbstractHistoryBackend* Call::backend() const AbstractHistoryBackend* Call::backend() const
{ {
...@@ -699,18 +705,6 @@ Account* Call::account() const ...@@ -699,18 +705,6 @@ Account* Call::account() const
return m_Account; return m_Account;
} }
///Is this call a conference
bool Call::isConference() const
{
return m_isConference;
}
///Get the conference ID
const QString Call::confId() const
{
return m_ConfId;
}
///Get the recording path ///Get the recording path
const QString Call::recordingPath() const const QString Call::recordingPath() const
{ {
...@@ -761,12 +755,6 @@ void Call::setTransferNumber(const QString& number) ...@@ -761,12 +755,6 @@ void Call::setTransferNumber(const QString& number)
m_pTransferNumber->setUri(number); m_pTransferNumber->setUri(number);
} }
///This call is a conference
void Call::setConference(bool value)
{
m_isConference = value;
}
///Set the call number ///Set the call number
void Call::setDialNumber(const QString& number) void Call::setDialNumber(const QString& number)
{ {
...@@ -799,12 +787,6 @@ void Call::setDialNumber(const PhoneNumber* number) ...@@ -799,12 +787,6 @@ void Call::setDialNumber(const PhoneNumber* number)
emit changed(this); emit changed(this);
} }
///Set the conference ID
void Call::setConfId(const QString& value)
{
m_ConfId = value;
}
///Set the recording path ///Set the recording path
void Call::setRecordingPath(const QString& path) void Call::setRecordingPath(const QString& path)
{ {
...@@ -845,7 +827,7 @@ void Call::setBackend(AbstractHistoryBackend* backend) ...@@ -845,7 +827,7 @@ void Call::setBackend(AbstractHistoryBackend* backend)
Call::State Call::stateChanged(const QString& newStateName) Call::State Call::stateChanged(const QString& newStateName)
{ {
const Call::State previousState = m_CurrentState; const Call::State previousState = m_CurrentState;
if (!m_isConference) { if (type() != Call::Type::CONFERENCE) {
Call::DaemonState dcs = toDaemonCallState(newStateName); Call::DaemonState dcs = toDaemonCallState(newStateName);
if (dcs == Call::DaemonState::__COUNT || m_CurrentState == Call::State::__COUNT) { if (dcs == Call::DaemonState::__COUNT || m_CurrentState == Call::State::__COUNT) {
qDebug() << "Error: Invalid state change"; qDebug() << "Error: Invalid state change";
...@@ -1008,7 +990,7 @@ void Call::setStartTimeStamp(time_t stamp) ...@@ -1008,7 +990,7 @@ void Call::setStartTimeStamp(time_t stamp)
void Call::sendTextMessage(const QString& message) void Call::sendTextMessage(const QString& message)
{ {
CallManagerInterface& callManager = DBus::CallManager::instance(); CallManagerInterface& callManager = DBus::CallManager::instance();
Q_NOREPLY callManager.sendTextMessage(isConference()?m_ConfId:m_CallId,message); Q_NOREPLY callManager.sendTextMessage(m_CallId,message);
if (!m_pImModel) { if (!m_pImModel) {
m_pImModel = InstantMessagingModelManager::instance()->getModel(this); m_pImModel = InstantMessagingModelManager::instance()->getModel(this);
} }
...@@ -1046,7 +1028,7 @@ void Call::accept() ...@@ -1046,7 +1028,7 @@ void Call::accept()
Q_ASSERT_IS_IN_PROGRESS Q_ASSERT_IS_IN_PROGRESS
CallManagerInterface & callManager = DBus::CallManager::instance(); CallManagerInterface & callManager = DBus::CallManager::instance();
qDebug() << "Accepting call. callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Accepting call. callId : " << m_CallId << "ConfId:" << id();
Q_NOREPLY callManager.accept(m_CallId); Q_NOREPLY callManager.accept(m_CallId);
time_t curTime; time_t curTime;
::time(&curTime); ::time(&curTime);
...@@ -1059,7 +1041,7 @@ void Call::accept() ...@@ -1059,7 +1041,7 @@ void Call::accept()
void Call::refuse() void Call::refuse()
{ {
CallManagerInterface & callManager = DBus::CallManager::instance(); CallManagerInterface & callManager = DBus::CallManager::instance();
qDebug() << "Refusing call. callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Refusing call. callId : " << m_CallId << "ConfId:" << id();
const bool ret = callManager.refuse(m_CallId); const bool ret = callManager.refuse(m_CallId);
time_t curTime; time_t curTime;
::time(&curTime); ::time(&curTime);
...@@ -1082,7 +1064,7 @@ void Call::acceptTransf() ...@@ -1082,7 +1064,7 @@ void Call::acceptTransf()
return; return;
} }
CallManagerInterface & callManager = DBus::CallManager::instance(); CallManagerInterface & callManager = DBus::CallManager::instance();
qDebug() << "Accepting call and transferring it to number : " << m_pTransferNumber->uri() << ". callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Accepting call and transferring it to number : " << m_pTransferNumber->uri() << ". callId : " << m_CallId << "ConfId:" << id();
callManager.accept(m_CallId); callManager.accept(m_CallId);
Q_NOREPLY callManager.transfer(m_CallId, m_pTransferNumber->uri()); Q_NOREPLY callManager.transfer(m_CallId, m_pTransferNumber->uri());
} }
...@@ -1093,7 +1075,7 @@ void Call::acceptHold() ...@@ -1093,7 +1075,7 @@ void Call::acceptHold()
Q_ASSERT_IS_IN_PROGRESS Q_ASSERT_IS_IN_PROGRESS
CallManagerInterface & callManager = DBus::CallManager::instance(); CallManagerInterface & callManager = DBus::CallManager::instance();
qDebug() << "Accepting call and holding it. callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Accepting call and holding it. callId : " << m_CallId << "ConfId:" << id();
callManager.accept(m_CallId); callManager.accept(m_CallId);
Q_NOREPLY callManager.hold(m_CallId); Q_NOREPLY callManager.hold(m_CallId);
this->m_HistoryState = LegacyHistoryState::INCOMING; this->m_HistoryState = LegacyHistoryState::INCOMING;
...@@ -1109,15 +1091,15 @@ void Call::hangUp() ...@@ -1109,15 +1091,15 @@ void Call::hangUp()
time_t curTime; time_t curTime;
::time(&curTime); ::time(&curTime);
m_pStopTimeStamp = curTime; m_pStopTimeStamp = curTime;
qDebug() << "Hanging up call. callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Hanging up call. callId : " << m_CallId << "ConfId:" << id();
bool ret; bool ret;
if (videoRenderer()) { //TODO remove, cheap hack if (videoRenderer()) { //TODO remove, cheap hack
videoRenderer()->stopRendering(); videoRenderer()->stopRendering();
} }
if (!isConference()) if (type() != Call::Type::CONFERENCE)
ret = callManager.hangUp(m_CallId); ret = callManager.hangUp(m_CallId);
else else
ret = callManager.hangUpConference(m_ConfId); ret = callManager.hangUpConference(id());
if (!ret) { //Can happen if the daemon crash and open again if (!ret) { //Can happen if the daemon crash and open again
qDebug() << "Error: Invalid call, the daemon may have crashed"; qDebug() << "Error: Invalid call, the daemon may have crashed";
changeCurrentState(Call::State::OVER); changeCurrentState(Call::State::OVER);
...@@ -1142,7 +1124,7 @@ void Call::cancel() ...@@ -1142,7 +1124,7 @@ void Call::cancel()
{ {
//This one can be over if the peer server failed to comply with the correct sequence //This one can be over if the peer server failed to comply with the correct sequence
CallManagerInterface & callManager = DBus::CallManager::instance(); CallManagerInterface & callManager = DBus::CallManager::instance();
qDebug() << "Canceling call. callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Canceling call. callId : " << m_CallId << "ConfId:" << id();
emit dialNumberChanged(QString()); emit dialNumberChanged(QString());
// Q_NOREPLY callManager.hangUp(m_CallId); // Q_NOREPLY callManager.hangUp(m_CallId);
if (!callManager.hangUp(m_CallId)) { if (!callManager.hangUp(m_CallId)) {
...@@ -1157,11 +1139,11 @@ void Call::hold() ...@@ -1157,11 +1139,11 @@ void Call::hold()
Q_ASSERT_IS_IN_PROGRESS Q_ASSERT_IS_IN_PROGRESS
CallManagerInterface & callManager = DBus::CallManager::instance(); CallManagerInterface & callManager = DBus::CallManager::instance();
qDebug() << "Holding call. callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Holding call. callId : " << m_CallId << "ConfId:" << id();
if (!isConference()) if (type() != Call::Type::CONFERENCE)
Q_NOREPLY callManager.hold(m_CallId); Q_NOREPLY callManager.hold(m_CallId);
else else
Q_NOREPLY callManager.holdConference(m_ConfId); Q_NOREPLY callManager.holdConference(id());
} }
///Start the call ///Start the call
...@@ -1192,7 +1174,7 @@ void Call::call() ...@@ -1192,7 +1174,7 @@ void Call::call()
} }
//Normal case //Normal case
else if(m_Account) { else if(m_Account) {
qDebug() << "Calling " << peerPhoneNumber()->uri() << " with account " << m_Account << ". callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Calling " << peerPhoneNumber()->uri() << " with account " << m_Account << ". callId : " << m_CallId << "ConfId:" << id();
callManager.placeCall(m_Account->id(), m_CallId, m_pDialNumber->uri()); callManager.placeCall(m_Account->id(), m_CallId, m_pDialNumber->uri());
this->m_pPeerPhoneNumber = PhoneDirectoryModel::instance()->getNumber(m_pDialNumber->uri(),account()); this->m_pPeerPhoneNumber = PhoneDirectoryModel::instance()->getNumber(m_pDialNumber->uri(),account());
if (ContactModel::instance()->hasBackends()) { if (ContactModel::instance()->hasBackends()) {
...@@ -1215,7 +1197,7 @@ void Call::call() ...@@ -1215,7 +1197,7 @@ void Call::call()
} }
else { else {
qDebug() << "Trying to call " << (m_pTransferNumber?m_pTransferNumber->uri():"ERROR") qDebug() << "Trying to call " << (m_pTransferNumber?m_pTransferNumber->uri():"ERROR")
<< " with no account registered . callId : " << m_CallId << "ConfId:" << m_ConfId; << " with no account registered . callId : " << m_CallId << "ConfId:" << id();
this->m_HistoryState = LegacyHistoryState::NONE; this->m_HistoryState = LegacyHistoryState::NONE;
throw tr("No account registered!"); throw tr("No account registered!");
} }
...@@ -1242,25 +1224,25 @@ void Call::unhold() ...@@ -1242,25 +1224,25 @@ void Call::unhold()
Q_ASSERT_IS_IN_PROGRESS Q_ASSERT_IS_IN_PROGRESS
CallManagerInterface & callManager = DBus::CallManager::instance(); CallManagerInterface & callManager = DBus::CallManager::instance();
qDebug() << "Unholding call. callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Unholding call. callId : " << m_CallId << "ConfId:" << id();
if (!isConference()) if (type() != Call::Type::CONFERENCE)
Q_NOREPLY callManager.unhold(m_CallId); Q_NOREPLY callManager.unhold(m_CallId);
else else
Q_NOREPLY callManager.unholdConference(m_ConfId); Q_NOREPLY callManager.unholdConference(id());
} }
///Record the call ///Record the call
void Call::setRecord() void Call::setRecord()
{ {
CallManagerInterface & callManager = DBus::CallManager::instance(); CallManagerInterface & callManager = DBus::CallManager::instance();
qDebug() << "Setting record " << !m_Recording << " for call. callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Setting record " << !m_Recording << " for call. callId : " << m_CallId << "ConfId:" << id();
callManager.toggleRecording((!m_isConference)?m_CallId:m_ConfId); callManager.toggleRecording(id());
} }
///Start the timer ///Start the timer
void Call::start() void Call::start()
{ {
qDebug() << "Starting call. callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Starting call. callId : " << m_CallId << "ConfId:" << id();
time_t curTime; time_t curTime;
::time(&curTime); ::time(&curTime);
emit changed(); emit changed();
...@@ -1277,7 +1259,7 @@ void Call::start() ...@@ -1277,7 +1259,7 @@ void Call::start()
///Toggle the timer ///Toggle the timer
void Call::startStop() void Call::startStop()
{ {
qDebug() << "Starting and stoping call. callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Starting and stoping call. callId : " << m_CallId << "ConfId:" << id();
time_t curTime; time_t curTime;
::time(&curTime); ::time(&curTime);
setStartTimeStamp(curTime); setStartTimeStamp(curTime);
...@@ -1287,7 +1269,7 @@ void Call::startStop() ...@@ -1287,7 +1269,7 @@ void Call::startStop()
///Stop the timer ///Stop the timer
void Call::stop() void Call::stop()
{ {
qDebug() << "Stoping call. callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Stoping call. callId : " << m_CallId << "ConfId:" << id();
if (videoRenderer()) { //TODO remove, cheap hack if (videoRenderer()) { //TODO remove, cheap hack
videoRenderer()->stopRendering(); videoRenderer()->stopRendering();
} }
...@@ -1299,7 +1281,7 @@ void Call::stop() ...@@ -1299,7 +1281,7 @@ void Call::stop()
///Handle error instead of crashing ///Handle error instead of crashing
void Call::startWeird() void Call::startWeird()
{ {
qDebug() << "Starting call. callId : " << m_CallId << "ConfId:" << m_ConfId; qDebug() << "Starting call. callId : " << m_CallId << "ConfId:" << id();
time_t curTime; time_t curTime;
::time(&curTime); ::time(&curTime);
setStartTimeStamp(curTime); setStartTimeStamp(curTime);
...@@ -1548,7 +1530,7 @@ QVariant Call::roleData(int role) const ...@@ -1548,7 +1530,7 @@ QVariant Call::roleData(int role) const
switch (role) { switch (role) {
case Call::Role::Name: case Call::Role::Name:
case Qt::DisplayRole: case Qt::DisplayRole:
if (isConference()) if (type() == Call::Type::CONFERENCE)
return tr("Conference"); return tr("Conference");
else if (state() == Call::State::DIALING) else if (state() == Call::State::DIALING)
return dialNumber(); return dialNumber();
...@@ -1608,9 +1590,6 @@ QVariant Call::roleData(int role) const ...@@ -1608,9 +1590,6 @@ QVariant Call::roleData(int role) const
case Call::Role::Organisation: case Call::Role::Organisation:
return ct?ct->organization():QVariant(); return ct?ct->organization():QVariant();
break; break;
case Call::Role::IsConference:
return isConference();
break;
case Call::Role::Object: case Call::Role::Object:
return QVariant::fromValue(const_cast<Call*>(this)); return QVariant::fromValue(const_cast<Call*>(this));
break; break;
...@@ -1624,7 +1603,7 @@ QVariant Call::roleData(int role) const ...@@ -1624,7 +1603,7 @@ QVariant Call::roleData(int role) const
return static_cast<int>(state()); //TODO Qt5, use the Q_ENUM return static_cast<int>(state()); //TODO Qt5, use the Q_ENUM
break; break;
case Call::Role::Id: case Call::Role::Id:
return ((m_isConference)?confId():id()); return id();
break; break;
case Call::Role::StartTime: case Call::Role::StartTime:
return (int) m_pStartTimeStamp; return (int) m_pStartTimeStamp;
......
...@@ -94,7 +94,6 @@ public: ...@@ -94,7 +94,6 @@ public:
Department = 112, Department = 112,
Email = 113, Email = 113,
Organisation = 114, Organisation = 114,
IsConference = 116,
Object = 117, Object = 117,
PhotoPtr = 118, PhotoPtr = 118,
CallState = 119, CallState = 119,
...@@ -235,12 +234,19 @@ public: ...@@ -235,12 +234,19 @@ public:
}; };
///If the call is incoming or outgoing ///If the call is incoming or outgoing
class CallType { class CallDirection {
public: public:
constexpr static const char* INCOMING = "0"; constexpr static const char* INCOMING = "0";
constexpr static const char* OUTGOING = "1"; constexpr static const char* OUTGOING = "1";
}; };
///Is the call between one or more participants
enum class Type {
CALL , /** A simple call */
CONFERENCE, /** A composition of other calls */
HISTORY , /** A call from a previous session */
};
/** @enum Call::DaemonState /** @enum Call::DaemonState
* This enum have all the states a call can take for the daemon. * This enum have all the states a call can take for the daemon.
*/ */
...@@ -286,8 +292,6 @@ public: ...@@ -286,8 +292,6 @@ public:
Q_PROPERTY( uint stopTimeStamp READ stopTimeStamp ) Q_PROPERTY( uint stopTimeStamp READ stopTimeStamp )
Q_PROPERTY( uint startTimeStamp READ startTimeStamp ) Q_PROPERTY( uint startTimeStamp READ startTimeStamp )
Q_PROPERTY( bool isSecure READ isSecure ) Q_PROPERTY( bool isSecure READ isSecure )
Q_PROPERTY( bool isConference READ isConference )
Q_PROPERTY( QString confId READ confId )
Q_PROPERTY( VideoRenderer* videoRenderer READ videoRenderer ) Q_PROPERTY( VideoRenderer* videoRenderer READ videoRenderer )
Q_PROPERTY( QString formattedName READ formattedName ) Q_PROPERTY( QString formattedName READ formattedName )
Q_PROPERTY( QString length READ length ) Q_PROPERTY( QString length READ length )
...@@ -332,8 +336,6 @@ public: ...@@ -332,8 +336,6 @@ public:
time_t stopTimeStamp () const; time_t stopTimeStamp () const;
time_t startTimeStamp () const; time_t startTimeStamp () const;
bool isSecure () const; bool isSecure () const;
bool isConference () const;
const QString confId () const;
const QString transferNumber () const; const QString transferNumber () const;
const QString dialNumber () const; const QString dialNumber () const;
const QString recordingPath () const; const QString recordingPath () const;
...@@ -350,14 +352,13 @@ public: ...@@ -350,14 +352,13 @@ public:
AbstractHistoryBackend* backend () const; AbstractHistoryBackend* backend () const;
bool hasVideo () const; bool hasVideo () const;
Call::LifeCycleState lifeCycleState () const; Call::LifeCycleState lifeCycleState () const;
Call::Type type () const;
//Automated function //Automated function
Call::State stateChanged(const QString & newState); Call::State stateChanged(const QString & newState);
Call::State performAction(Call::Action action); Call::State performAction(Call::Action action);
//Setters //Setters
void setConference ( bool value );
void setConfId ( const QString& value );
void setTransferNumber ( const QString& number ); void setTransferNumber ( const QString& number );
void setDialNumber ( const QString& number ); void setDialNumber ( const QString& number );
void setDialNumber ( const PhoneNumber* number ); void setDialNumber ( const PhoneNumber* number );
...@@ -380,7 +381,6 @@ private: ...@@ -380,7 +381,6 @@ private:
//Attributes //Attributes
Account* m_Account ; Account* m_Account ;
QString m_CallId ; QString m_CallId ;
QString m_ConfId ;
PhoneNumber* m_pPeerPhoneNumber; PhoneNumber* m_pPeerPhoneNumber;
QString m_PeerName ; QString m_PeerName ;
QString m_RecordingPath ; QString m_RecordingPath ;
...@@ -389,7 +389,6 @@ private: ...@@ -389,7 +389,6 @@ private:
time_t m_pStopTimeStamp ; time_t m_pStopTimeStamp ;
TemporaryPhoneNumber* m_pTransferNumber ; TemporaryPhoneNumber* m_pTransferNumber ;
TemporaryPhoneNumber* m_pDialNumber ; TemporaryPhoneNumber* m_pDialNumber ;
bool m_isConference ;
Call::State m_CurrentState ; Call::State m_CurrentState ;
bool m_Recording ; bool m_Recording ;
InstantMessagingModel* m_pImModel ; InstantMessagingModel* m_pImModel ;
...@@ -398,6 +397,7 @@ private: ...@@ -398,6 +397,7 @@ private:
bool m_History ; bool m_History ;
bool m_Missed ; bool m_Missed ;
Call::Direction m_Direction ; Call::Direction m_Direction ;
Call::Type m_Type ;
AbstractHistoryBackend* m_pBackend ; AbstractHistoryBackend* m_pBackend ;
//Cache //Cache
......
...@@ -160,7 +160,6 @@ void CallModel::initRoles() ...@@ -160,7 +160,6 @@ void CallModel::initRoles()
roles.insert(Call::Role::Department ,QByteArray("department")); roles.insert(Call::Role::Department ,QByteArray("department"));
roles.insert(Call::Role::Email ,QByteArray("email")); roles.insert(Call::Role::Email ,QByteArray("email"));
roles.insert(Call::Role::Organisation ,QByteArray("organisation")); roles.insert(Call::Role::Organisation ,QByteArray("organisation"));
roles.insert(Call::Role::IsConference ,QByteArray("isConference"));
roles.insert(Call::Role::Object ,QByteArray("object")); roles.insert(Call::Role::Object ,QByteArray("object"));
roles.insert(Call::Role::PhotoPtr ,QByteArray("photoPtr")); roles.insert(Call::Role::PhotoPtr ,QByteArray("photoPtr"));
roles.insert(Call::Role::CallState ,QByteArray("callState")); roles.insert(Call::Role::CallState ,QByteArray("callState"));
...@@ -401,7 +400,7 @@ void CallModel::removeCall(Call* call, bool noEmit) ...@@ -401,7 +400,7 @@ void CallModel::removeCall(Call* call, bool noEmit)
//The daemon often fail to emit the right signal, cleanup manually //The daemon often fail to emit the right signal, cleanup manually
foreach(InternalStruct* topLevel, m_lInternalModel) { foreach(InternalStruct* topLevel, m_lInternalModel) {
if (topLevel->call_real->isConference() && if (topLevel->call_real->type() == Call::Type::CONFERENCE &&
(!topLevel->m_lChildren.size() (!topLevel->m_lChildren.size()
//HACK Make a simple validation to prevent ERROR->ERROR->ERROR state loop for conferences //HACK Make a simple validation to prevent ERROR->ERROR->ERROR state loop for conferences
|| topLevel->m_lChildren.first()->call_real->state() == Call::State::ERROR || topLevel->m_lChildren.first()->call_real->state() == Call::State::ERROR
...@@ -528,8 +527,8 @@ bool CallModel::createConferenceFromCall(Call* call1, Call* call2) ...@@ -528,8 +527,8 @@ bool CallModel::createConferenceFromCall(Call* call1, Call* call2)
///Add a new participant to a conference ///Add a new participant to a conference
bool CallModel::addParticipant(Call* call2, Call* conference) bool CallModel::addParticipant(Call* call2, Call* conference)
{ {
if (conference->isConference()) { if (conference->type() == Call::Type::CONFERENCE) {
Q_NOREPLY DBus::CallManager::instance().addParticipant(call2->id(), conference->confId()); Q_NOREPLY DBus::CallManager::instance().addParticipant(call2->id(), conference->id());
return true; return true;
} }
else { else {
...@@ -548,7 +547,7 @@ bool CallModel::detachParticipant(Call* call) ...@@ -548,7 +547,7 @@ bool CallModel::detachParticipant(Call* call)
///Merge two conferences ///Merge two conferences
bool CallModel::mergeConferences(Call* conf1, Call* conf2) bool CallModel::mergeConferences(Call* conf1, Call* conf2)
{ {
Q_NOREPLY DBus::CallManager::instance().joinConference(conf1->confId(),conf2->confId()); Q_NOREPLY DBus::CallManager::instance().joinConference(conf1->id(),conf2->id());
return true; return true;
} }
...@@ -669,12 +668,12 @@ int CallModel::rowCount( const QModelIndex& parentIdx ) const ...@@ -669,12 +668,12 @@ int CallModel::rowCount( const QModelIndex& parentIdx ) const
const InternalStruct* modelItem = static_cast<InternalStruct*>(parentIdx.internalPointer()); const InternalStruct* modelItem = static_cast<InternalStruct*>(parentIdx.internalPointer());
if (modelItem) { if (modelItem) {
if (modelItem->call_real->isConference() && modelItem->m_lChildren.size() > 0) if (modelItem->call_real->type() == Call::Type::CONFERENCE && modelItem->m_lChildren.size() > 0)
return modelItem->m_lChildren.size(); return modelItem->m_lChildren.size();
else if (modelItem->call_real->isConference()) else if (modelItem->call_real->type() == Call::Type::CONFERENCE)
qWarning() << modelItem->call_real << "have" qWarning() << modelItem->call_real << "have"
<< modelItem->m_lChildren.size() << "and" << modelItem->m_lChildren.size() << "and"
<< (modelItem->call_real->isConference()?"is":"is not") << "a conference"; << ((modelItem->call_real->type() == Call::Type::CONFERENCE)?"is":"is not") << "a conference";
} }
return 0; return 0;
} }
...@@ -684,10 +683,16 @@ Qt::ItemFlags CallModel::flags( const QModelIndex& idx ) const ...@@ -684,10 +683,16 @@ Qt::ItemFlags CallModel::flags( const QModelIndex& idx ) const
{ {
if (!idx.isValid()) if (!idx.isValid())
return Qt::NoItemFlags; return Qt::NoItemFlags;
const InternalStruct* modelItem = static_cast<InternalStruct*>(idx.internalPointer());
if (modelItem ) {
const Call* c = modelItem->call_real;
return Qt::ItemIsEnabled|Qt::ItemIsSelectable return Qt::ItemIsEnabled|Qt::ItemIsSelectable
| Qt::ItemIsDragEnabled | Qt::ItemIsDragEnabled
| ((!idx.data(Call::Role::IsConference).toBool())?(Qt::ItemIsDropEnabled):Qt::ItemIsEnabled) | ((c->type() != Call::Type::CONFERENCE)?(Qt::ItemIsDropEnabled):Qt::ItemIsEnabled)
| ((idx.data(Call::Role::CallState) == static_cast<int>(Call::State::DIALING))?Qt::ItemIsEditable:Qt::NoItemFlags); | ((c->state() == Call::State::DIALING)?Qt::ItemIsEditable:Qt::NoItemFlags);
}
return Qt::NoItemFlags;
} }
///Return valid payload types ///Return valid payload types
...@@ -701,7 +706,7 @@ int CallModel::columnCount ( const QModelIndex& parentIdx) const ...@@ -701,7 +706,7 @@ int CallModel::columnCount ( const QModelIndex& parentIdx) const
{ {
const InternalStruct* modelItem = static_cast<InternalStruct*>(parentIdx.internalPointer()); const InternalStruct* modelItem = static_cast<InternalStruct*>(parentIdx.internalPointer());
if (modelItem) { if (modelItem) {
return modelItem->call_real->isConference()?1:0; return (modelItem->call_real->type() == Call::Type::CONFERENCE)?1:0;
} }
else if (parentIdx.isValid()) else if (parentIdx.isValid())
return 0; return 0;
...@@ -803,22 +808,22 @@ bool CallModel::dropMimeData(const QMimeData* mimedata, Qt::DropAction action, i ...@@ -803,22 +808,22 @@ bool CallModel::dropMimeData(const QMimeData* mimedata, Qt::DropAction action, i
return false; return false;
} }
//Conference dropped on a conference -> merge both conferences //Conference dropped on a conference -> merge both conferences
else if (call && target && call->isConference() && target->isConference()) { else if (call && target && call->type() == Call::Type::CONFERENCE && target->type() == Call::Type::CONFERENCE) {
qDebug() << "Merge conferences" << call->confId() << "and" << target->confId(); qDebug() << "Merge conferences" << call->id() << "and" << target->id();
mergeConferences(call,target); mergeConferences(call,target);
return true; return true;
} }
//Conference dropped on a call part of a conference -> merge both conferences //Conference dropped on a call part of a conference -> merge both conferences
else if (call && call->isConference() && targetIdx.parent().isValid()) { else if (call && call->type() == Call::Type::CONFERENCE && targetIdx.parent().isValid()) {
qDebug() << "Merge conferences" << call->confId() << "and" << targetIdx.parent().data(Call::Role::Id).toString(); qDebug() << "Merge conferences" << call->id() << "and" << targetIdx.parent().data(Call::Role::Id).toString();
mergeConferences(call,getCall(targetIdx.parent())); mergeConferences(call,getCall(targetIdx.parent()));
return true; return true;
} }
//Drop a call on a conference -> add it to the conference //Drop a call on a conference -> add it to the conference
else if (target && (targetIdx.parent().isValid() || target->isConference())) { else if (target && (targetIdx.parent().isValid() || target->type() == Call::Type::CONFERENCE)) {
Call* conf = target->isConference()?target:qvariant_cast<Call*>(targetIdx.parent().data(Call::Role::Object)); Call* conf = target->type() == Call::Type::CONFERENCE?target:qvariant_cast<Call*>(targetIdx.parent().data(Call::Role::Object));
if (conf) { if (conf) {
qDebug() << "Adding call " << call->id() << "to conference" << conf->confId(); qDebug() << "Adding call " << call->id() << "to conference" << conf->id();
addParticipant(call,conf); addParticipant(call,conf);
return true; return true;
} }
...@@ -994,7 +999,7 @@ void CallModel::slotChangingConference(const QString &confID, const QString& sta ...@@ -994,7 +999,7 @@ void CallModel::slotChangingConference(const QString &confID, const QString& sta
//The daemon often fail to emit the right signal, cleanup manually //The daemon often fail to emit the right signal, cleanup manually
foreach(InternalStruct* topLevel, m_lInternalModel) { foreach(InternalStruct* topLevel, m_lInternalModel) {
if (topLevel->call_real->isConference() && !topLevel->m_lChildren.size()) { if (topLevel->call_real->type() == Call::Type::CONFERENCE && !topLevel->m_lChildren.size()) {
removeConference(topLevel->call_real); removeConference(topLevel->call_real);
} }
} }
...@@ -1007,7 +1012,7 @@ void CallModel::slotChangingConference(const QString &confID, const QString& sta ...@@ -1007,7 +1012,7 @@ void CallModel::slotChangingConference(const QString &confID, const QString& sta
if (callInt) { if (callInt) {
const QString confId = callDetails[Call::DetailsMapFields::CONF_ID]; const QString confId = callDetails[Call::DetailsMapFields::CONF_ID];
if (callInt->m_pParent) { if (callInt->m_pParent) {
if (!confId.isEmpty() && callInt->m_pParent->call_real->confId() != confId) { if (!confId.isEmpty() && callInt->m_pParent->call_real->id() != confId) {
qWarning() << "Conference parent mismatch"; qWarning() << "Conference parent mismatch";
} }
else if (confId.isEmpty() ){ else if (confId.isEmpty() ){
...@@ -1018,7 +1023,8 @@ void CallModel::slotChangingConference(const QString &confID, const QString& sta ...@@ -1018,7 +1023,8 @@ void CallModel::slotChangingConference(const QString &confID, const QString& sta
else if (!confId.isEmpty()) { else if (!confId.isEmpty()) {
qWarning() << "Found an orphan call"; qWarning() << "Found an orphan call";
InternalStruct* confInt2 = m_sPrivateCallList_callId[confId]; InternalStruct* confInt2 = m_sPrivateCallList_callId[confId];
if (confInt2 && confInt2->call_real->isConference() && !callInt->call_real->isConference()) { if (confInt2 && confInt2->call_real->type() == Call::Type::CONFERENCE
&& (callInt->call_real->type() != Call::Type::CONFERENCE)) {
removeInternal(callInt); removeInternal(callInt);
if (confInt2->m_lChildren.indexOf(callInt) == -1) if (confInt2->m_lChildren.indexOf(callInt) == -1)
confInt2->m_lChildren << callInt; confInt2->m_lChildren << callInt;
......
...@@ -120,7 +120,6 @@ HistoryModel::HistoryModel():QAbstractItemModel(QCoreApplication::instance()),m_ ...@@ -120,7 +120,6 @@ HistoryModel::HistoryModel():QAbstractItemModel(QCoreApplication::instance()),m_
roles.insert(Call::Role::Department ,QByteArray("department" )); roles.insert(Call::Role::Department ,QByteArray("department" ));
roles.insert(Call::Role::Email ,QByteArray("email" )); roles.insert(Call::Role::Email ,QByteArray("email" ));
roles.insert(Call::Role::Organisation ,QByteArray("organisation" )); roles.insert(Call::Role::Organisation ,QByteArray("organisation" ));
roles.insert(Call::Role::IsConference ,QByteArray("isConference" ));
roles.insert(Call::Role::Object ,QByteArray("object" )); roles.insert(Call::Role::Object ,QByteArray("object" ));
roles.insert(Call::Role::PhotoPtr ,QByteArray("photoPtr" )); roles.insert(Call::Role::PhotoPtr ,QByteArray("photoPtr" ));
roles.insert(Call::Role::CallState ,QByteArray("callState" )); roles.insert(Call::Role::CallState ,QByteArray("callState" ));
......
...@@ -64,7 +64,7 @@ void InstantMessagingModelManager::newMessage(QString callId, QString from, QStr ...@@ -64,7 +64,7 @@ void InstantMessagingModelManager::newMessage(QString callId, QString from, QStr
///Singleton ///Singleton
InstantMessagingModel* InstantMessagingModelManager::getModel(Call* call) { InstantMessagingModel* InstantMessagingModelManager::getModel(Call* call) {
const QString key = call->isConference()?call->confId():call->id(); const QString key = call->id();
if (!m_lModels[key]) { if (!m_lModels[key]) {
m_lModels[key] = new InstantMessagingModel(call); m_lModels[key] = new InstantMessagingModel(call);
emit newMessagingModel(call,m_lModels[key]); emit newMessagingModel(call,m_lModels[key]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment