diff --git a/src/Call.cpp b/src/Call.cpp index 223bb0706ee3ea48dc282718db565aabb10b2257..b1683e4b4a22008fbb906172fff0a4d936f755f6 100644 --- a/src/Call.cpp +++ b/src/Call.cpp @@ -471,6 +471,12 @@ void Call::setRecordingPath(const QString& path) m_RecordingPath = path; } +///Set peer name +void Call::setPeerName(const QString& name) +{ + m_PeerName = name; +} + /***************************************************************************** * * * Mutator * diff --git a/src/Call.h b/src/Call.h index 4d763bf472382627dd873f99db678a8a7d3891f5..ad2fbdc004fedf5bd57fa8549ee36db4b2183bde 100644 --- a/src/Call.h +++ b/src/Call.h @@ -158,11 +158,12 @@ public: call_state actionPerformed(call_action action); //Setters - void setConference(bool value); - void setConfId(QString value); - void setTransferNumber(const QString& number); - void setCallNumber(const QString& number); - void setRecordingPath(const QString& path); + void setConference ( bool value ); + void setConfId ( QString value ); + void setTransferNumber ( const QString& number ); + void setCallNumber ( const QString& number ); + void setRecordingPath ( const QString& path ); + void setPeerName ( const QString& name ); //Mutators void appendText(const QString& str); diff --git a/src/CallModel.h b/src/CallModel.h index ae19567b0c0fafd667a57f5cc60d959daff8309f..d5654546c3c3fae720be34358874229956e48e23 100644 --- a/src/CallModel.h +++ b/src/CallModel.h @@ -128,11 +128,11 @@ class LIB_EXPORT CallModel : public CallModelBase { void removeConference ( Call* call ); //Getters - int size (); - CallList getCallList (); - static const CallMap& getHistory (); - static const QStringList getNumbersByPopularity (); - static const QStringList getHistoryCallId (); + int size (); + CallList getCallList (); + static const CallMap& getHistory (); + static const QStringList getNumbersByPopularity (); + static const QStringList getHistoryCallId (); //Account related static Account* getCurrentAccount ( ); diff --git a/src/CallModel.hpp b/src/CallModel.hpp index cff7ce9808ea661e696bac41aa5885e1b15e86b6..43b667221cb0dcd8f1337a302d0f05f2346fa080 100644 --- a/src/CallModel.hpp +++ b/src/CallModel.hpp @@ -38,20 +38,24 @@ //System #include "unistd.h" +//Define +#define CALLMODEL_TEMPLATE template<typename CallWidget, typename Index> +#define CALLMODEL_T CallModel<CallWidget,Index> + //Static member -template <typename CallWidget, typename Index> QString CallModel<CallWidget,Index>::m_sPriorAccountId = "" ; -template <typename CallWidget, typename Index> AccountList* CallModel<CallWidget,Index>::m_spAccountList = 0 ; -template <typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::m_sInstanceInit = false ; -template <typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::m_sCallInit = false ; -template <typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::m_sHistoryInit = false ; +CALLMODEL_TEMPLATE QString CALLMODEL_T::m_sPriorAccountId = "" ; +CALLMODEL_TEMPLATE AccountList* CALLMODEL_T::m_spAccountList = 0 ; +CALLMODEL_TEMPLATE bool CALLMODEL_T::m_sInstanceInit = false ; +CALLMODEL_TEMPLATE bool CALLMODEL_T::m_sCallInit = false ; +CALLMODEL_TEMPLATE bool CALLMODEL_T::m_sHistoryInit = false ; -template <typename CallWidget, typename Index> CallMap CallModel<CallWidget,Index>::m_sActiveCalls ; -template <typename CallWidget, typename Index> CallMap CallModel<CallWidget,Index>::m_sHistoryCalls ; +CALLMODEL_TEMPLATE CallMap CALLMODEL_T::m_sActiveCalls ; +CALLMODEL_TEMPLATE CallMap CALLMODEL_T::m_sHistoryCalls ; -template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalCall CallModel<CallWidget,Index>::m_sPrivateCallList_call ; -template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalCallId CallModel<CallWidget,Index>::m_sPrivateCallList_callId ; -template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalIndex CallModel<CallWidget,Index>::m_sPrivateCallList_index ; -template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalWidget CallModel<CallWidget,Index>::m_sPrivateCallList_widget ; +CALLMODEL_TEMPLATE typename CALLMODEL_T::InternalCall CALLMODEL_T::m_sPrivateCallList_call ; +CALLMODEL_TEMPLATE typename CALLMODEL_T::InternalCallId CALLMODEL_T::m_sPrivateCallList_callId ; +CALLMODEL_TEMPLATE typename CALLMODEL_T::InternalIndex CALLMODEL_T::m_sPrivateCallList_index ; +CALLMODEL_TEMPLATE typename CALLMODEL_T::InternalWidget CALLMODEL_T::m_sPrivateCallList_widget ; /***************************************************************************** * * @@ -81,7 +85,7 @@ inline bool operator< (const SortableCallSource & s1, const SortableCallSource & ****************************************************************************/ ///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) : CallModelBase(0) +CALLMODEL_TEMPLATE CALLMODEL_T::CallModel(ModelType type) : CallModelBase(0) { Q_UNUSED(type) init(); @@ -89,7 +93,7 @@ template<typename CallWidget, typename Index> CallModel<CallWidget,Index>::CallM } ///Open the connection to the daemon and register this client -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::init() +CALLMODEL_TEMPLATE bool CALLMODEL_T::init() { if (!m_sInstanceInit) { registerCommTypes(); @@ -106,7 +110,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: ///Fill the call 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>::initCall() +CALLMODEL_TEMPLATE bool CALLMODEL_T::initCall() { if (!m_sCallInit) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); @@ -127,14 +131,14 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///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 ) +CALLMODEL_TEMPLATE void CALLMODEL_T::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() +CALLMODEL_TEMPLATE bool CALLMODEL_T::initHistory() { if (!m_sHistoryInit) { ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); @@ -149,6 +153,9 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: hc[ PEER_NUMBER_KEY ] , hc[ STATE_KEY ] ); + if (pastCall->getPeerName().isEmpty()) { + pastCall->setPeerName("Unknow"); + } pastCall->setRecordingPath(hc[ RECORDING_PATH_KEY ]); m_sHistoryCalls[ hc[TIMESTAMP_START_KEY ]] = pastCall; addCall(pastCall); @@ -167,19 +174,19 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: ****************************************************************************/ ///Return the active call count -template<typename CallWidget, typename Index> int CallModel<CallWidget,Index>::size() +CALLMODEL_TEMPLATE int CALLMODEL_T::size() { return m_sActiveCalls.size(); } ///Return a call corresponding to this ID or NULL -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::findCallByCallId(const QString& callId) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::findCallByCallId(const QString& callId) { return m_sActiveCalls[callId]; } ///Return the action call list -template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCallList() +CALLMODEL_TEMPLATE QList<Call*> CALLMODEL_T::getCallList() { QList<Call*> callList; foreach(Call* call, m_sActiveCalls) { @@ -196,7 +203,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, ****************************************************************************/ ///Add a call in the model structure, the call must exist before being added to the model -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addCall(Call* call, Call* parent) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::addCall(Call* call, Call* parent) { Q_UNUSED(parent) if (!call) @@ -215,7 +222,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///Common set of instruction shared by all call adder -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addCallCommon(Call* call) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::addCallCommon(Call* call) { m_sActiveCalls[call->getCallId()] = call; addCall(call); @@ -224,7 +231,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///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) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::addDialingCall(const QString& peerName, QString account) { QString account2 = account; if (account2.isEmpty()) { @@ -236,21 +243,21 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///Create a new incomming call when the daemon is being called -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addIncomingCall(const QString& callId) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::addIncomingCall(const QString& callId) { Call* call = Call::buildIncomingCall(callId); return addCallCommon(call); } ///Create a ringing call -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addRingingCall(const QString& callId) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::addRingingCall(const QString& callId) { Call* call = Call::buildRingingCall(callId); return addCallCommon(call); } ///Generate a new random call unique identifier (callId) -template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index>::generateCallId() +CALLMODEL_TEMPLATE QString CALLMODEL_T::generateCallId() { int id = qrand(); QString res = QString::number(id); @@ -258,7 +265,7 @@ template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index } ///Remove a call and update the internal structure -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::removeCall(Call* call) +CALLMODEL_TEMPLATE void CALLMODEL_T::removeCall(Call* call) { InternalStruct* internal = m_sPrivateCallList_call[call]; @@ -285,7 +292,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: } ///Transfer "toTransfer" to "target" and wait to see it it succeeded -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::attendedTransfer(Call* toTransfer, Call* target) +CALLMODEL_TEMPLATE void CALLMODEL_T::attendedTransfer(Call* toTransfer, Call* target) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); callManager.attendedTransfer(toTransfer->getCallId(),target->getCallId()); @@ -296,7 +303,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: } ///Transfer this call to "target" number -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::transfer(Call* toTransfer, QString target) +CALLMODEL_TEMPLATE void CALLMODEL_T::transfer(Call* toTransfer, QString target) { qDebug() << "Transferring call " << toTransfer->getCallId() << "to" << target; toTransfer->setTransferNumber(target); @@ -312,7 +319,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: ****************************************************************************/ ///Add a new conference, get the call list and update the interface as needed -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::addConference(const QString & confID) +CALLMODEL_TEMPLATE Call* CALLMODEL_T::addConference(const QString & confID) { qDebug() << "Notified of a new conference " << confID; CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); @@ -341,7 +348,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///Join two call to create a conference, the conference will be created later (see addConference) -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::createConferenceFromCall(Call* call1, Call* call2) +CALLMODEL_TEMPLATE bool CALLMODEL_T::createConferenceFromCall(Call* call1, Call* call2) { qDebug() << "Joining call: " << call1->getCallId() << " and " << call2->getCallId(); CallManagerInterface &callManager = CallManagerInterfaceSingleton::getInstance(); @@ -350,7 +357,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Add a new participant to a conference -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::addParticipant(Call* call2, Call* conference) +CALLMODEL_TEMPLATE bool CALLMODEL_T::addParticipant(Call* call2, Call* conference) { if (conference->isConference()) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); @@ -364,7 +371,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Remove a participant from a conference -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::detachParticipant(Call* call) +CALLMODEL_TEMPLATE bool CALLMODEL_T::detachParticipant(Call* call) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); callManager.detachParticipant(call->getCallId()); @@ -372,7 +379,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Merge two conferences -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::mergeConferences(Call* conf1, Call* conf2) +CALLMODEL_TEMPLATE bool CALLMODEL_T::mergeConferences(Call* conf1, Call* conf2) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); callManager.joinConference(conf1->getConfId(),conf2->getConfId()); @@ -380,7 +387,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>::changeConference(const QString& confId, const QString& state) +CALLMODEL_TEMPLATE bool CALLMODEL_T::changeConference(const QString& confId, const QString& state) { qDebug() << "Conf changed"; Q_UNUSED(state) @@ -398,14 +405,14 @@ 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>::removeConference(const QString &confId) +CALLMODEL_TEMPLATE void CALLMODEL_T::removeConference(const QString &confId) { qDebug() << "Ending conversation containing " << m_sPrivateCallList_callId[confId]->children.size() << " participants"; removeConference(getCall(confId)); } ///Remove a conference using it's call object -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::removeConference(Call* call) +CALLMODEL_TEMPLATE void CALLMODEL_T::removeConference(Call* call) { InternalStruct* internal = m_sPrivateCallList_call[call]; @@ -424,7 +431,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: ****************************************************************************/ ///Return a list of all previous calls -template<typename CallWidget, typename Index> const QStringList CallModel<CallWidget,Index>::getHistoryCallId() +CALLMODEL_TEMPLATE const QStringList CALLMODEL_T::getHistoryCallId() { QStringList toReturn; foreach(Call* call, m_sHistoryCalls) { @@ -434,13 +441,13 @@ template<typename CallWidget, typename Index> const QStringList CallModel<CallWi } ///Return the history list -template<typename CallWidget, typename Index> const CallMap& CallModel<CallWidget,Index>::getHistory() +CALLMODEL_TEMPLATE const CallMap& CALLMODEL_T::getHistory() { return m_sHistoryCalls; } ///Add to history -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::addToHistory(Call* call) +CALLMODEL_TEMPLATE void CALLMODEL_T::addToHistory(Call* call) { if (call) { m_sHistoryCalls[call->getStartTimeStamp()] = call; @@ -448,7 +455,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: } ///Sort all history call by popularity and return the result (most popular first) -template<typename CallWidget, typename Index> const QStringList CallModel<CallWidget,Index>::getNumbersByPopularity() +CALLMODEL_TEMPLATE const QStringList CALLMODEL_T::getNumbersByPopularity() { QHash<QString,SortableCallSource*> hc; foreach (Call* call, getHistory()) { @@ -481,7 +488,7 @@ template<typename CallWidget, typename Index> const QStringList CallModel<CallWi ****************************************************************************/ ///Return the current account id (do not put in the cpp file) -template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index>::getCurrentAccountId() +CALLMODEL_TEMPLATE QString CALLMODEL_T::getCurrentAccountId() { Account* firstRegistered = getCurrentAccount(); if(firstRegistered == NULL) { @@ -494,7 +501,7 @@ template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index ///Return the current account -template<typename CallWidget, typename Index> Account* CallModel<CallWidget,Index>::getCurrentAccount() +CALLMODEL_TEMPLATE Account* CALLMODEL_T::getCurrentAccount() { Account* priorAccount = getAccountList()->getAccountById(m_sPriorAccountId); if(priorAccount && priorAccount->getAccountDetail(ACCOUNT_REGISTRATION_STATUS) == ACCOUNT_STATE_REGISTERED ) { @@ -507,7 +514,7 @@ template<typename CallWidget, typename Index> Account* CallModel<CallWidget,Inde } ///Return a list of registered accounts -template<typename CallWidget, typename Index> AccountList* CallModel<CallWidget,Index>::getAccountList() +CALLMODEL_TEMPLATE AccountList* CALLMODEL_T::getAccountList() { if (m_spAccountList == NULL) { m_spAccountList = new AccountList(true); @@ -516,13 +523,13 @@ template<typename CallWidget, typename Index> AccountList* CallModel<CallWidget, } ///Return the previously used account ID -template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index>::getPriorAccoundId() +CALLMODEL_TEMPLATE QString CALLMODEL_T::getPriorAccoundId() { return m_sPriorAccountId; } ///Set the previous account used -template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::setPriorAccountId(const QString& value) { +CALLMODEL_TEMPLATE void CALLMODEL_T::setPriorAccountId(const QString& value) { m_sPriorAccountId = value; } @@ -533,7 +540,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: ****************************************************************************/ ///Get a call from it's widget -template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::getCall ( const CallWidget widget ) const +CALLMODEL_TEMPLATE Call* CALLMODEL_T::getCall ( const CallWidget widget ) const { if (m_sPrivateCallList_widget[widget]) { return m_sPrivateCallList_widget[widget]->call_real; @@ -542,7 +549,7 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: } ///Get a call list from a conference -template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( const CallWidget widget ) const +CALLMODEL_TEMPLATE QList<Call*> CALLMODEL_T::getCalls ( const CallWidget widget ) const { QList<Call*> toReturn; if (m_sPrivateCallList_widget[widget] && m_sPrivateCallList_widget[widget]->conference) { @@ -554,7 +561,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, } ///Get a list of every call -template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( ) +CALLMODEL_TEMPLATE QList<Call*> CALLMODEL_T::getCalls ( ) { QList<Call*> toReturn; foreach (InternalStruct* child, m_sPrivateCallList_call) { @@ -564,7 +571,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 +CALLMODEL_TEMPLATE bool CALLMODEL_T::isConference ( const CallWidget widget ) const { if (m_sPrivateCallList_widget[widget]) { return m_sPrivateCallList_widget[widget]->conference; @@ -573,7 +580,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 +CALLMODEL_TEMPLATE bool CALLMODEL_T::isConference ( const Call* call ) const { if (m_sPrivateCallList_call[(Call*)call]) { return m_sPrivateCallList_call[(Call*)call]->conference; @@ -582,13 +589,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 +CALLMODEL_TEMPLATE Call* CALLMODEL_T::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 +CALLMODEL_TEMPLATE QList<Call*> CALLMODEL_T::getCalls ( const Call* call ) const { QList<Call*> toReturn; if (m_sPrivateCallList_call[call] && m_sPrivateCallList_call[call]->conference) { @@ -600,7 +607,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 +CALLMODEL_TEMPLATE bool CALLMODEL_T::isConference ( const Index idx ) const { if (m_sPrivateCallList_index[idx]) { return m_sPrivateCallList_index[idx]->conference; @@ -609,7 +616,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 +CALLMODEL_TEMPLATE Call* CALLMODEL_T::getCall ( const Index idx ) const { if (m_sPrivateCallList_index[idx]) { return m_sPrivateCallList_index[idx]->call_real; @@ -619,7 +626,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 +CALLMODEL_TEMPLATE QList<Call*> CALLMODEL_T::getCalls ( const Index idx ) const { QList<Call*> toReturn; if (m_sPrivateCallList_index[idx] && m_sPrivateCallList_index[idx]->conference) { @@ -631,7 +638,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 +CALLMODEL_TEMPLATE bool CALLMODEL_T::isConference ( const QString& callId ) const { if (m_sPrivateCallList_callId[callId]) { return m_sPrivateCallList_callId[callId]->conference; @@ -640,7 +647,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 +CALLMODEL_TEMPLATE Call* CALLMODEL_T::getCall ( const QString& callId ) const { if (m_sPrivateCallList_callId[callId]) { return m_sPrivateCallList_callId[callId]->call_real; @@ -649,7 +656,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 +CALLMODEL_TEMPLATE QList<Call*> CALLMODEL_T::getCalls ( const QString& callId ) const { QList<Call*> toReturn; if (m_sPrivateCallList_callId[callId] && m_sPrivateCallList_callId[callId]->conference) { @@ -661,7 +668,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, } ///Get the index associated with this call -template<typename CallWidget, typename Index> Index CallModel<CallWidget,Index>::getIndex ( const Call* call ) const +CALLMODEL_TEMPLATE Index CALLMODEL_T::getIndex ( const Call* call ) const { if (m_sPrivateCallList_call[(Call*)call]) { return m_sPrivateCallList_call[(Call*)call]->index; @@ -670,7 +677,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 +CALLMODEL_TEMPLATE Index CALLMODEL_T::getIndex ( const Index idx ) const { if (m_sPrivateCallList_index[idx]) { return m_sPrivateCallList_index[idx]->index; @@ -679,7 +686,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 +CALLMODEL_TEMPLATE Index CALLMODEL_T::getIndex ( const CallWidget widget ) const { if (m_sPrivateCallList_widget[widget]) { return m_sPrivateCallList_widget[widget]->index; @@ -688,7 +695,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 +CALLMODEL_TEMPLATE Index CALLMODEL_T::getIndex ( const QString& callId ) const { if (m_sPrivateCallList_callId[callId]) { return m_sPrivateCallList_callId[callId]->index; @@ -697,7 +704,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 +CALLMODEL_TEMPLATE CallWidget CALLMODEL_T::getWidget ( const Call* call ) const { if (m_sPrivateCallList_call[call]) { return m_sPrivateCallList_call[call]->call; @@ -706,7 +713,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 +CALLMODEL_TEMPLATE CallWidget CALLMODEL_T::getWidget ( const Index idx ) const { if (m_sPrivateCallList_index[idx]) { return m_sPrivateCallList_index[idx]->call; @@ -715,7 +722,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 +CALLMODEL_TEMPLATE CallWidget CALLMODEL_T::getWidget ( const CallWidget widget ) const { if (m_sPrivateCallList_widget[widget]) { return m_sPrivateCallList_widget[widget]->call; @@ -724,7 +731,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 +CALLMODEL_TEMPLATE CallWidget CALLMODEL_T::getWidget ( const QString& widget ) const { if (m_sPrivateCallList_widget[widget]) { return m_sPrivateCallList_widget[widget]->call; @@ -733,7 +740,7 @@ template<typename CallWidget, typename Index> CallWidget CallModel<CallWidget,In } ///Common set of instruction shared by all gui updater -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateCommon(Call* call) +CALLMODEL_TEMPLATE bool CALLMODEL_T::updateCommon(Call* call) { if (!m_sPrivateCallList_call[call] && dynamic_cast<Call*>(call)) { m_sPrivateCallList_call [ call ] = new InternalStruct ; @@ -747,7 +754,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Update the widget associated with this call -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateWidget (Call* call, CallWidget value ) +CALLMODEL_TEMPLATE bool CALLMODEL_T::updateWidget (Call* call, CallWidget value ) { if (!updateCommon(call)) return false; m_sPrivateCallList_call[call]->call = value ; @@ -756,7 +763,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: } ///Update the index associated with this call -template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::updateIndex (Call* call, Index value ) +CALLMODEL_TEMPLATE bool CALLMODEL_T::updateIndex (Call* call, Index value ) { updateCommon(call); m_sPrivateCallList_call[call]->index = value ; diff --git a/src/Contact.cpp b/src/Contact.cpp index bc64c91e69fffad8b49cef54460f5efd63ac1067..ce53582cb4a15610822ae89fdeea38205fc087f2 100644 --- a/src/Contact.cpp +++ b/src/Contact.cpp @@ -187,4 +187,23 @@ void Contact::setGroup(const QString& name) void Contact::setDepartment(const QString& name) { m_Department = name; +} + +///Turn the contact into QString-QString hash +QHash<QString,QVariant> Contact::toHash() +{ + QHash<QString,QVariant> aContact; + //aContact[""] = PhoneNumbers getPhoneNumbers() const; + aContact[ "nickName" ] = getNickName(); + aContact[ "firstName" ] = getFirstName(); + aContact[ "secondName" ] = getSecondName(); + aContact[ "formattedName" ] = getFormattedName(); + aContact[ "organization" ] = getOrganization(); + aContact[ "Uid" ] = getUid(); + aContact[ "preferredEmail" ] = getPreferredEmail(); + //aContact["Photo"] = getPhoto( const; + aContact[ "type" ] = getType(); + aContact[ "group" ] = getGroup(); + aContact[ "department" ] = getDepartment(); + return aContact; } \ No newline at end of file diff --git a/src/Contact.h b/src/Contact.h index 0e23260292183429759f88788e3bab275335e4be..c13a6e0d01b25b5191564fccfda7c8a497960d79 100644 --- a/src/Contact.h +++ b/src/Contact.h @@ -21,7 +21,8 @@ #ifndef CONTACT_H #define CONTACT_H -#include <QObject> +#include <QtCore/QObject> +#include <QtCore/QVariant> //Qt class QListWidgetItem; @@ -106,6 +107,9 @@ public: virtual void setDepartment ( const QString& name ); virtual void setUid ( const QString& id ); virtual void setPhoto ( QPixmap* photo ); + + //Mutator + QHash<QString,QVariant> toHash(); protected: virtual void initItemWidget(); diff --git a/src/ContactBackend.h b/src/ContactBackend.h index 66d65cd8dae12ed87942f5bc46c2daab109e9995..64ad72cca992066de42adf718fc3d821d7bbdfc7 100644 --- a/src/ContactBackend.h +++ b/src/ContactBackend.h @@ -24,12 +24,16 @@ #include <QObject> #include <QHash> +#include <QStringList> +#include <QVariant> #include "typedefs.h" +#include "Contact.h" //SFLPhone class Contact; +//Typedef typedef QList<Contact*> ContactList; ///@class ContactBackend Allow different way to handle contact without poluting the library