diff --git a/src/Account.h b/src/Account.h index deda48be2fa70ac9e6c0e4e2626dc193e072028c..fa0b619685432d98c14544b4a20db19a4dc678b2 100644 --- a/src/Account.h +++ b/src/Account.h @@ -61,8 +61,11 @@ class LIB_EXPORT Account : public QObject { bool operator==(const Account&)const; protected: + //Constructors Account(); - QString* m_pAccountId; + + //Attributes + QString* m_pAccountId; MapStringString* m_pAccountDetails; public slots: diff --git a/src/AccountList.cpp b/src/AccountList.cpp index 561b1c8fb277aa77e9d96cfd1cd402f0bb2f8cfc..dc5211b887b5c5ead95cfd1e6d472beda39f724d 100644 --- a/src/AccountList.cpp +++ b/src/AccountList.cpp @@ -39,6 +39,7 @@ AccountList::AccountList(QStringList & _accountIds) } ///Constructors +///@param fill Whether to fill the list with accounts from configurationManager or not. AccountList::AccountList(bool fill) { m_pAccounts = new QVector<Account *>(); diff --git a/src/AccountList.h b/src/AccountList.h index ca3f0f15e3c29eba1412273b191dfc67ff065891..c3f26744ecf710d371c7373de478c504bf005e95 100644 --- a/src/AccountList.h +++ b/src/AccountList.h @@ -30,54 +30,40 @@ ///@class AccountList List of all daemon accounts class LIB_EXPORT AccountList : public QObject{ - Q_OBJECT - -private: - - QVector<Account*>* m_pAccounts; public: //Constructors & Destructors AccountList(QStringList & _accountIds); - /** - * Constructs a new accountList, empty if fill = false - * filled with accounts from configurationManager.getAccountList() if true - * @param fill Whether to fill the list with accounts from configurationManager or not. - */ AccountList(bool fill = true); ~AccountList(); //Getters - QVector<Account*> & getAccounts(); - Account* getAccountAt (int i); - const Account* getAccountAt (int i) const; - Account* getAccountById(const QString & id) const; - QVector<Account*> getAccountsByState(QString & state); - int size() const; - Account* firstRegisteredAccount() const; - QString getOrderedList() const; + QVector<Account*>& getAccounts ( ); + QVector<Account*> getAccountsByState ( QString & state ); + QString getOrderedList ( ) const; + Account* getAccountById ( const QString& id ) const; + Account* getAccountAt ( int i ); + const Account* getAccountAt ( int i ) const; + int size ( ) const; + Account* firstRegisteredAccount ( ) const; - //Setters - virtual Account* addAccount(QString & alias); - void removeAccount(Account* account); - //void upAccount(int index); - //void downAccount(int index); + //Mutators + virtual Account* addAccount ( QString & alias ) ; + void removeAccount ( Account* account ) ; + QVector<Account*> registeredAccounts( ) const; //Operators - Account* operator[] (int i); + Account* operator[] (int i) ; const Account* operator[] (int i) const; - QVector<Account*> registeredAccounts() const; -public slots: - /** - * updates the list of accounts (removed, added, order...) with the configurationManager's list - */ +private: + //Attributes + QVector<Account*>* m_pAccounts; + +public slots: void update(); - /** - * updates the list and the details of accounts with the configurationManager's list - */ void updateAccounts(); signals: diff --git a/src/Call.cpp b/src/Call.cpp index 5c44275c016f65d139af02b8f14c74e5a298488e..93cbe28c22ab980113985829c7eedabedbdb7457 100644 --- a/src/Call.cpp +++ b/src/Call.cpp @@ -107,16 +107,16 @@ void Call::setContactBackend(ContactBackend* be) ///Constructor Call::Call(call_state startState, QString callId, QString peerName, QString peerNumber, QString account) - : conference(false) -{ - this->m_pCallId = callId ; - this->m_pPeerPhoneNumber = peerNumber ; - this->m_pPeerName = peerName ; - changeCurrentState(startState) ; - this->m_pAccount = account ; - this->recording = false ; - this->m_pStartTime = NULL ; - this->m_pStopTime = NULL ; + : m_isConference(false) +{ + this->m_CallId = callId ; + this->m_PeerPhoneNumber = peerNumber ; + this->m_PeerName = peerName ; + changeCurrentState(startState) ; + this->m_Account = account ; + this->m_Recording = false ; + this->m_pStartTime = NULL ; + this->m_pStopTime = NULL ; emit changed(); } @@ -129,10 +129,10 @@ Call::~Call() ///Constructor Call::Call(QString confId, QString account) - : conference(true) + : m_isConference(true) { - this->m_pConfId = confId ; - this->m_pAccount = account ; + this->m_ConfId = confId ; + this->m_Account = account ; } /***************************************************************************** @@ -156,8 +156,8 @@ Call* Call::buildExistingCall(QString callId) Call* call = new Call(startState, callId, peerName, peerNumber, account) ; call->m_pStartTime = new QDateTime(QDateTime::currentDateTime()) ; - call->recording = callManager.getIsRecording(callId) ; - call->m_pHistoryState = getHistoryStateFromDaemonCallState(details[CALL_STATE], details[CALL_TYPE]) ; + call->m_Recording = callManager.getIsRecording(callId) ; + call->m_HistoryState = getHistoryStateFromDaemonCallState(details[CALL_STATE], details[CALL_TYPE]) ; return call; } @@ -166,7 +166,7 @@ Call* Call::buildExistingCall(QString callId) Call* Call::buildDialingCall(QString callId, const QString & peerName, QString account) { Call* call = new Call(CALL_STATE_DIALING, callId, peerName, "", account); - call->m_pHistoryState = NONE; + call->m_HistoryState = NONE; return call; } @@ -183,7 +183,7 @@ Call* Call::buildIncomingCall(const QString & callId) QString peerName = details[ CALL_PEER_NAME ]; Call* call = new Call(CALL_STATE_INCOMING, callId, peerName, from, account); - call->m_pHistoryState = MISSED; + call->m_HistoryState = MISSED; return call; } @@ -198,7 +198,7 @@ Call* Call::buildRingingCall(const QString & callId) QString peerName = details[ CALL_PEER_NAME ]; Call* call = new Call(CALL_STATE_RINGING, callId, peerName, from, account); - call->m_pHistoryState = OUTGOING; + call->m_HistoryState = OUTGOING; return call; } @@ -215,7 +215,7 @@ Call* Call::buildHistoryCall(const QString & callId, uint startTimeStamp, uint s Call* call = new Call(CALL_STATE_OVER, callId, name, number, account ); call->m_pStartTime = new QDateTime(QDateTime::fromTime_t(startTimeStamp) ); call->m_pStopTime = new QDateTime(QDateTime::fromTime_t(stopTimeStamp) ); - call->m_pHistoryState = getHistoryStateFromType(type ); + call->m_HistoryState = getHistoryStateFromType(type ); return call; } @@ -330,80 +330,80 @@ QString Call::getStartTimeStamp() const ///Get the number where the call have been transferred QString Call::getTransferNumber() const { - return m_pTransferNumber; + return m_TransferNumber; } ///Get the call / peer number QString Call::getCallNumber() const { - return m_pCallNumber; + return m_CallNumber; } ///Return the call id QString Call::getCallId() const { - return m_pCallId; + return m_CallId; } ///Return the peer phone number QString Call::getPeerPhoneNumber() const { - return m_pPeerPhoneNumber; + return m_PeerPhoneNumber; } ///Get the peer name QString Call::getPeerName() const { - return m_pPeerName; + return m_PeerName; } ///Get the current state call_state Call::getCurrentState() const { - return currentState; + return m_CurrentState; } ///Get the call recording bool Call::getRecording() const { - return recording; + return m_Recording; } ///Get the call account id QString Call::getAccountId() const { - return m_pAccount; + return m_Account; } ///Is this call a conference bool Call::isConference() const { - return conference; + return m_isConference; } ///Get the conference ID QString Call::getConfId() const { - return m_pConfId; + return m_ConfId; } ///Get the current codec QString Call::getCurrentCodecName() const { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - return callManager.getCurrentAudioCodecName(m_pCallId); + return callManager.getCurrentAudioCodecName(m_CallId); } ///Get the state call_state Call::getState() const { - return currentState; + return m_CurrentState; } ///Get the history state history_state Call::getHistoryState() const { - return m_pHistoryState; + return m_HistoryState; } ///Is this call over? @@ -415,13 +415,13 @@ bool Call::isHistory() const ///This function could also be called mayBeSecure or haveChancesToBeEncryptedButWeCantTell. bool Call::isSecure() const { - if (m_pAccount.isEmpty()) { + if (m_Account.isEmpty()) { qDebug() << "Account not set, can't check security"; return false; } AccountList accountList(true); - Account* currentAccount = accountList.getAccountById(m_pAccount); + Account* currentAccount = accountList.getAccountById(m_Account); if ((currentAccount->getAccountDetail(TLS_ENABLE ) == "true") || (currentAccount->getAccountDetail(TLS_METHOD).toInt())) { return true; @@ -439,26 +439,26 @@ bool Call::isSecure() const { ///Set the transfer number void Call::setTransferNumber(QString number) { - m_pTransferNumber = number; + m_TransferNumber = number; } ///This call is a conference void Call::setConference(bool value) { - conference = value; + m_isConference = value; } ///Set the call number void Call::setCallNumber(QString number) { - m_pCallNumber = number; + m_CallNumber = number; emit changed(); } ///Set the conference ID void Call::setConfId(QString value) { - m_pConfId = value; + m_ConfId = value; } /***************************************************************************** @@ -470,13 +470,13 @@ void Call::setConfId(QString value) ///The call state just changed call_state Call::stateChanged(const QString& newStateName) { - if (!conference) { - call_state previousState = currentState; + if (!m_isConference) { + call_state previousState = m_CurrentState; daemon_call_state dcs = toDaemonCallState(newStateName); - changeCurrentState(stateChangedStateMap[currentState][dcs]); + changeCurrentState(stateChangedStateMap[m_CurrentState][dcs]); (this->*(stateChangedFunctionMap[previousState][dcs]))(); - qDebug() << "Calling stateChanged " << newStateName << " -> " << toDaemonCallState(newStateName) << " on call with state " << previousState << ". Become " << currentState; - return currentState; + qDebug() << "Calling stateChanged " << newStateName << " -> " << toDaemonCallState(newStateName) << " on call with state " << previousState << ". Become " << m_CurrentState; + return m_CurrentState; } else { qDebug() << "A conference have no call state"; @@ -487,7 +487,7 @@ call_state Call::stateChanged(const QString& newStateName) ///An acount have been performed call_state Call::actionPerformed(call_action action) { - call_state previousState = currentState; + call_state previousState = m_CurrentState; Q_ASSERT_X((previousState>10) || (previousState<0),"perform action","Invalid previous state ("+QString::number(previousState)+")"); Q_ASSERT_X((state>4) || (state < 0),"perform action","Invalid action ("+QString::number(action)+")"); Q_ASSERT_X((action>5) || (action < 0),"perform action","Invalid action ("+QString::number(action)+")"); @@ -495,19 +495,19 @@ call_state Call::actionPerformed(call_action action) changeCurrentState(actionPerformedStateMap[previousState][action]); //execute the action associated with this transition (this->*(actionPerformedFunctionMap[previousState][action]))(); //WARNING BUG //WARNING SEGFAULT //TODO remove this node, it was not a good idea, it is not stable - qDebug() << "Calling action " << action << " on call with state " << previousState << ". Become " << currentState; + qDebug() << "Calling action " << action << " on call with state " << previousState << ". Become " << m_CurrentState; //return the new state - return currentState; + return m_CurrentState; } /* void Call::putRecording() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - bool daemonRecording = callManager.getIsRecording(this -> m_pCallId); - if(daemonRecording != recording) + bool daemonRecording = callManager.getIsRecording(this -> m_CallId); + if(daemonRecording != m_Recording) { - callManager.setRecording(this->m_pCallId); + callManager.setRecording(this->m_CallId); } } */ @@ -515,11 +515,11 @@ void Call::putRecording() void Call::changeCurrentState(call_state newState) { //qDebug() << "Call state changed to: " << newState; - currentState = newState; + m_CurrentState = newState; emit changed(); - if (currentState == CALL_STATE_OVER) + if (m_CurrentState == CALL_STATE_OVER) emit isOver(this); } @@ -540,40 +540,40 @@ void Call::nothing() void Call::accept() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Accepting call. callId : " << m_pCallId; - callManager.accept(m_pCallId); + qDebug() << "Accepting call. callId : " << m_CallId; + callManager.accept(m_CallId); this->m_pStartTime = new QDateTime(QDateTime::currentDateTime()); - this->m_pHistoryState = INCOMING; + this->m_HistoryState = INCOMING; } ///Refuse the call void Call::refuse() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Refusing call. callId : " << m_pCallId; - callManager.refuse(m_pCallId); + qDebug() << "Refusing call. callId : " << m_CallId; + callManager.refuse(m_CallId); this->m_pStartTime = new QDateTime(QDateTime::currentDateTime()); - this->m_pHistoryState = MISSED; + this->m_HistoryState = MISSED; } ///Accept the transfer void Call::acceptTransf() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Accepting call and transfering it to number : " << m_pTransferNumber << ". callId : " << m_pCallId; - callManager.accept(m_pCallId); - callManager.transfer(m_pCallId, m_pTransferNumber); -// m_pHistoryState = TRANSFERED; + qDebug() << "Accepting call and transfering it to number : " << m_TransferNumber << ". callId : " << m_CallId; + callManager.accept(m_CallId); + callManager.transfer(m_CallId, m_TransferNumber); +// m_HistoryState = TRANSFERED; } ///Put the call on hold void Call::acceptHold() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Accepting call and holding it. callId : " << m_pCallId; - callManager.accept(m_pCallId); - callManager.hold(m_pCallId); - this->m_pHistoryState = INCOMING; + qDebug() << "Accepting call and holding it. callId : " << m_CallId; + callManager.accept(m_CallId); + callManager.hold(m_CallId); + this->m_HistoryState = INCOMING; } ///Hang up @@ -581,51 +581,51 @@ void Call::hangUp() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); this->m_pStopTime = new QDateTime(QDateTime::currentDateTime()); - qDebug() << "Hanging up call. callId : " << m_pCallId; - callManager.hangUp(m_pCallId); + qDebug() << "Hanging up call. callId : " << m_CallId; + callManager.hangUp(m_CallId); } ///Cancel this call void Call::cancel() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Canceling call. callId : " << m_pCallId; - callManager.hangUp(m_pCallId); + qDebug() << "Canceling call. callId : " << m_CallId; + callManager.hangUp(m_CallId); } ///Put on hold void Call::hold() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Holding call. callId : " << m_pCallId; - callManager.hold(m_pCallId); + qDebug() << "Holding call. callId : " << m_CallId; + callManager.hold(m_CallId); } ///Start the call void Call::call() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "account = " << m_pAccount; - if(m_pAccount.isEmpty()) { + qDebug() << "account = " << m_Account; + if(m_Account.isEmpty()) { qDebug() << "account is not set, taking the first registered."; - this->m_pAccount = CallModelConvenience::getCurrentAccountId(); + this->m_Account = CallModelConvenience::getCurrentAccountId(); } - if(!m_pAccount.isEmpty()) { - qDebug() << "Calling " << m_pCallNumber << " with account " << m_pAccount << ". callId : " << m_pCallId; - callManager.placeCall(m_pAccount, m_pCallId, m_pCallNumber); - this->m_pAccount = m_pAccount; - this->m_pPeerPhoneNumber = m_pCallNumber; + if(!m_Account.isEmpty()) { + qDebug() << "Calling " << m_CallNumber << " with account " << m_Account << ". callId : " << m_CallId; + callManager.placeCall(m_Account, m_CallId, m_CallNumber); + this->m_Account = m_Account; + this->m_PeerPhoneNumber = m_CallNumber; if (m_pContactBackend) { - Contact* contact = m_pContactBackend->getContactByPhone(m_pPeerPhoneNumber); + Contact* contact = m_pContactBackend->getContactByPhone(m_PeerPhoneNumber); if (contact) - m_pPeerName = contact->getFormattedName(); + m_PeerName = contact->getFormattedName(); } this->m_pStartTime = new QDateTime(QDateTime::currentDateTime()); - this->m_pHistoryState = OUTGOING; + this->m_HistoryState = OUTGOING; } else { - qDebug() << "Trying to call " << m_pTransferNumber << " with no account registered . callId : " << m_pCallId; - this->m_pHistoryState = NONE; + qDebug() << "Trying to call " << m_TransferNumber << " with no account registered . callId : " << m_CallId; + this->m_HistoryState = NONE; throw "No account registered!"; } } @@ -634,23 +634,23 @@ void Call::call() void Call::transfer() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Transfering call to number : " << m_pTransferNumber << ". callId : " << m_pCallId; - callManager.transfer(m_pCallId, m_pTransferNumber); + qDebug() << "Transfering call to number : " << m_TransferNumber << ". callId : " << m_CallId; + callManager.transfer(m_CallId, m_TransferNumber); this->m_pStopTime = new QDateTime(QDateTime::currentDateTime()); } void Call::unhold() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Unholding call. callId : " << m_pCallId; - callManager.unhold(m_pCallId); + qDebug() << "Unholding call. callId : " << m_CallId; + callManager.unhold(m_CallId); } /* void Call::switchRecord() { qDebug() << "Switching record state for call automate. callId : " << callId; - recording = !recording; + m_Recording = !m_Recording; } */ @@ -658,22 +658,22 @@ void Call::switchRecord() void Call::setRecord() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - qDebug() << "Setting record " << !recording << " for call. callId : " << m_pCallId; - callManager.setRecording(m_pCallId); - recording = !recording; + qDebug() << "Setting record " << !m_Recording << " for call. callId : " << m_CallId; + callManager.setRecording(m_CallId); + m_Recording = !m_Recording; } ///Start the timer void Call::start() { - qDebug() << "Starting call. callId : " << m_pCallId; + qDebug() << "Starting call. callId : " << m_CallId; this->m_pStartTime = new QDateTime(QDateTime::currentDateTime()); } ///Toggle the timer void Call::startStop() { - qDebug() << "Starting and stoping call. callId : " << m_pCallId; + qDebug() << "Starting and stoping call. callId : " << m_CallId; this->m_pStartTime = new QDateTime(QDateTime::currentDateTime()); this->m_pStopTime = new QDateTime(QDateTime::currentDateTime()); } @@ -681,22 +681,22 @@ void Call::startStop() ///Stop the timer void Call::stop() { - qDebug() << "Stoping call. callId : " << m_pCallId; + qDebug() << "Stoping call. callId : " << m_CallId; this->m_pStopTime = new QDateTime(QDateTime::currentDateTime()); } ///Handle error instead of crashing void Call::startWeird() { - qDebug() << "Starting call. callId : " << m_pCallId; + qDebug() << "Starting call. callId : " << m_CallId; this->m_pStartTime = new QDateTime(QDateTime::currentDateTime()); - qDebug() << "Warning : call " << m_pCallId << " had an unexpected transition of state at its start."; + qDebug() << "Warning : call " << m_CallId << " had an unexpected transition of state at its start."; } ///Print a warning void Call::warning() { - qDebug() << "Warning : call " << m_pCallId << " had an unexpected transition of state."; + qDebug() << "Warning : call " << m_CallId << " had an unexpected transition of state."; } /***************************************************************************** @@ -710,13 +710,13 @@ void Call::appendText(QString str) { QString * editNumber; - switch (currentState) { + switch (m_CurrentState) { case CALL_STATE_TRANSFER : case CALL_STATE_TRANSF_HOLD : - editNumber = &m_pTransferNumber; + editNumber = &m_TransferNumber; break; case CALL_STATE_DIALING : - editNumber = &m_pCallNumber; + editNumber = &m_CallNumber; break; default : qDebug() << "Backspace on call not editable. Doing nothing."; @@ -733,15 +733,15 @@ void Call::backspaceItemText() { QString * editNumber; - switch (currentState) { - case CALL_STATE_TRANSFER : - case CALL_STATE_TRANSF_HOLD : - editNumber = &m_pTransferNumber; + switch (m_CurrentState) { + case CALL_STATE_TRANSFER : + case CALL_STATE_TRANSF_HOLD : + editNumber = &m_TransferNumber; break; - case CALL_STATE_DIALING : - editNumber = &m_pCallNumber; + case CALL_STATE_DIALING : + editNumber = &m_CallNumber; break; - default : + default : qDebug() << "Backspace on call not editable. Doing nothing."; return; } diff --git a/src/Call.h b/src/Call.h index 97f79dd4f815d14b8cc25b1baa84f883f64988db..7016eab4a84eea0b829a4419d2cfef2b8ca7e6e1 100644 --- a/src/Call.h +++ b/src/Call.h @@ -116,32 +116,74 @@ typedef void (Call::*function)(); class LIB_EXPORT Call : public QObject { Q_OBJECT -private: +public: + //Constructors & Destructors + Call(QString confId, QString account); + ~Call(); + static Call* buildDialingCall (QString callId, const QString & peerName, QString account = "" ); + static Call* buildIncomingCall (const QString & callId ); + static Call* buildRingingCall (const QString & callId ); + static Call* buildHistoryCall (const QString & callId, uint startTimeStamp, uint stopTimeStamp, QString account, QString name, QString number, QString type ); + static Call* buildExistingCall (QString callId ); + static void setContactBackend (ContactBackend* be ); + + //Static getters + static history_state getHistoryStateFromType ( QString type ); + static QString getTypeFromHistoryState ( history_state historyState ); + static call_state getStartStateFromDaemonCallState ( QString daemonCallState, QString daemonCallType ); + static history_state getHistoryStateFromDaemonCallState ( QString daemonCallState, QString daemonCallType ); + + //Getters + call_state getState () const; + QString getCallId () const; + QString getPeerPhoneNumber () const; + QString getPeerName () const; + call_state getCurrentState () const; + history_state getHistoryState () const; + bool getRecording () const; + QString getAccountId () const; + bool isHistory () const; + QString getStopTimeStamp () const; + QString getStartTimeStamp () const; + QString getCurrentCodecName () const; + bool isSecure () const; + bool isConference () const; + QString getConfId () const; + QString getTransferNumber () const; + QString getCallNumber () const; - //Call attributes + //Automated function + call_state stateChanged(const QString & newState); + call_state actionPerformed(call_action action); - QString m_pAccount; - QString m_pCallId; - QString m_pConfId; - QString m_pPeerPhoneNumber; - QString m_pPeerName; - history_state m_pHistoryState; - QDateTime* m_pStartTime; - QDateTime* m_pStopTime; + //Setters + void setConference(bool value); + void setConfId(QString value); + void setTransferNumber(QString number); + void setCallNumber(QString number); - /* - QWidget * historyItemWidget; - QLabel * labelHistoryIcon; - QLabel * labelHistoryPeerName; - QLabel * labelHistoryCallNumber; - QLabel * labelHistoryTime; - */ + //Mutotors + void appendText(QString str); + void backspaceItemText(); + void changeCurrentState(call_state newState); + +private: - QString m_pTransferNumber; - QString m_pCallNumber; + //Attributes + QString m_Account; + QString m_CallId; + QString m_ConfId; + QString m_PeerPhoneNumber; + QString m_PeerName; + history_state m_HistoryState; + QDateTime* m_pStartTime; + QDateTime* m_pStopTime; + QString m_TransferNumber; + QString m_CallNumber; static ContactBackend* m_pContactBackend; - - bool conference; + bool m_isConference; + call_state m_CurrentState; + bool m_Recording; //Automate attributes /** @@ -176,9 +218,6 @@ private: static const char * historyIcons[3]; - call_state currentState; - bool recording; - static const char * callStateIcons[11]; Call(call_state startState, QString callId, QString peerNumber = "", QString account = "", QString peerName = ""); @@ -207,57 +246,6 @@ private: void startWeird (); void warning (); -public: - //Constructors & Destructors - Call(QString confId, QString account); - ~Call(); - static Call* buildDialingCall (QString callId, const QString & peerName, QString account = "" ); - static Call* buildIncomingCall (const QString & callId ); - static Call* buildRingingCall (const QString & callId ); - static Call* buildHistoryCall (const QString & callId, uint startTimeStamp, uint stopTimeStamp, QString account, QString name, QString number, QString type ); - static Call* buildExistingCall (QString callId ); - static void setContactBackend (ContactBackend* be ); - - //Static getters - static history_state getHistoryStateFromType ( QString type ); - static QString getTypeFromHistoryState ( history_state historyState ); - static call_state getStartStateFromDaemonCallState ( QString daemonCallState, QString daemonCallType ); - static history_state getHistoryStateFromDaemonCallState ( QString daemonCallState, QString daemonCallType ); - - //Getters - call_state getState () const; - QString getCallId () const; - QString getPeerPhoneNumber () const; - QString getPeerName () const; - call_state getCurrentState () const; - history_state getHistoryState () const; - bool getRecording () const; - QString getAccountId () const; - bool isHistory () const; - QString getStopTimeStamp () const; - QString getStartTimeStamp () const; - QString getCurrentCodecName () const; - bool isSecure () const; - bool isConference () const; - QString getConfId () const; - QString getTransferNumber () const; - QString getCallNumber () const; - - //Automated function - call_state stateChanged(const QString & newState); - call_state actionPerformed(call_action action); - - //Setters - void setConference(bool value); - void setConfId(QString value); - void setTransferNumber(QString number); - void setCallNumber(QString number); - - //Mutotors - void appendText(QString str); - void backspaceItemText(); - void changeCurrentState(call_state newState); - signals: void changed(); void isOver(Call*); diff --git a/src/CallModel.h b/src/CallModel.h index a7bc8630945eb86237cec43d146017b558ca06e1..b72a82939bbfe9cdc38a8aa8d81cb3f93bf6d63d 100644 --- a/src/CallModel.h +++ b/src/CallModel.h @@ -115,8 +115,8 @@ class LIB_EXPORT CallModel : public CallModelBase { bool mergeConferences ( Call* conf1, Call* conf2 ); bool addParticipant ( Call* call2, Call* conference ); bool detachParticipant ( Call* call ); - virtual bool changeConference ( const QString &confId, const QString &state ); - virtual void removeConference ( const QString &confId ); + virtual bool changeConference ( const QString &confId, const QString &state ); + virtual void removeConference ( const QString &confId ); virtual Call* addConference ( const QString &confID ); void removeConference ( Call* call ); @@ -169,6 +169,7 @@ class LIB_EXPORT CallModel : public CallModelBase { protected: + //Struct struct InternalStruct; typedef QList<InternalStruct*> InternalCallList; struct InternalStruct { @@ -182,28 +183,27 @@ class LIB_EXPORT CallModel : public CallModelBase { typedef QHash< QString , InternalStruct* > InternalCallId; typedef QHash< CallWidget , InternalStruct* > InternalWidget; typedef QHash< Index , InternalStruct* > InternalIndex ; + + //Static attributes + static CallHash m_sActiveCalls ; + static CallHash m_sHistoryCalls; - static CallHash m_pActiveCalls ; - static CallHash m_pHistoryCalls; - - static InternalCall m_pPrivateCallList_call ; - static InternalCallId m_pPrivateCallList_callId; - static InternalWidget m_pPrivateCallList_widget; - static InternalIndex m_pPrivateCallList_index ; + static InternalCall m_sPrivateCallList_call ; + static InternalCallId m_sPrivateCallList_callId; + static InternalWidget m_sPrivateCallList_widget; + static InternalIndex m_sPrivateCallList_index ; - static QString m_pPriorAccountId; - static AccountList* m_pAccountList ; - static bool m_pCallInit ; - static bool m_pHistoryInit ; + static QString m_sPriorAccountId; + static AccountList* m_spAccountList ; + static bool m_sCallInit ; + static bool m_sHistoryInit ; private: - static bool m_pInstanceInit; + static bool m_sInstanceInit; //Helpers Call* addCallCommon(Call* call); - bool updateCommon(Call* call); - //public slots: - //void clearHistory(); + bool updateCommon (Call* call); }; class CallModelConvenience : public CallModel<QWidget*,QModelIndex*> diff --git a/src/CallModel.hpp b/src/CallModel.hpp index 973c8dac9707290d95f92a5f579369baa7699cba..b212c5e170b72d31a12ba417d8b1618e0acb7288 100644 --- a/src/CallModel.hpp +++ b/src/CallModel.hpp @@ -39,19 +39,19 @@ #include "unistd.h" //Static member -template <typename CallWidget, typename Index> QString CallModel<CallWidget,Index>::m_pPriorAccountId = "" ; -template <typename CallWidget, typename Index> AccountList* CallModel<CallWidget,Index>::m_pAccountList = 0 ; -template <typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::m_pInstanceInit = false ; -template <typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::m_pCallInit = false ; -template <typename CallWidget, typename Index> bool CallModel<CallWidget,Index>::m_pHistoryInit = false ; +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 ; -template <typename CallWidget, typename Index> QHash<QString, Call*> CallModel<CallWidget,Index>::m_pActiveCalls ; -template <typename CallWidget, typename Index> QHash<QString, Call*> CallModel<CallWidget,Index>::m_pHistoryCalls ; +template <typename CallWidget, typename Index> QHash<QString, Call*> CallModel<CallWidget,Index>::m_sActiveCalls ; +template <typename CallWidget, typename Index> QHash<QString, Call*> CallModel<CallWidget,Index>::m_sHistoryCalls ; -template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalCall CallModel<CallWidget,Index>::m_pPrivateCallList_call ; -template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalCallId CallModel<CallWidget,Index>::m_pPrivateCallList_callId ; -template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalIndex CallModel<CallWidget,Index>::m_pPrivateCallList_index ; -template <typename CallWidget, typename Index> typename CallModel<CallWidget,Index>::InternalWidget CallModel<CallWidget,Index>::m_pPrivateCallList_widget ; +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 ; /***************************************************************************** * * @@ -70,16 +70,16 @@ 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() { - if (!m_pInstanceInit) { + if (!m_sInstanceInit) { registerCommTypes(); InstanceInterface& instance = InstanceInterfaceSingleton::getInstance(); instance.Register(getpid(), APP_NAME); //Setup accounts - if (m_pAccountList == NULL) - m_pAccountList = new AccountList(true); + if (m_spAccountList == NULL) + m_spAccountList = new AccountList(true); } - m_pInstanceInit = true; + m_sInstanceInit = true; return true; } @@ -87,12 +87,12 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: ///@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() { - if (!m_pCallInit) { + if (!m_sCallInit) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); QStringList callList = callManager.getCallList(); foreach (QString callId, callList) { Call* tmpCall = Call::buildExistingCall(callId); - m_pActiveCalls[tmpCall->getCallId()] = tmpCall; + m_sActiveCalls[tmpCall->getCallId()] = tmpCall; addCall(tmpCall); } @@ -101,7 +101,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: addConference(confId); } } - m_pCallInit = true; + m_sCallInit = true; return true; } @@ -115,7 +115,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: ///@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() { - if (!m_pHistoryInit) { + if (!m_sHistoryInit) { ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); QStringList historyMap = configurationManager.getHistory().value(); foreach (QString historyCallId, historyMap) { @@ -132,12 +132,12 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: QString recordfile = param[7]; QString confID = param[8]; QString time_added = param[9]; - m_pHistoryCalls[time_start] = Call::buildHistoryCall(callID, time_start.toUInt(), time_stop.toUInt(), accountID, peer_name, peer_number, history_state); - addCall(m_pHistoryCalls[time_start]); + m_sHistoryCalls[time_start] = Call::buildHistoryCall(callID, time_start.toUInt(), time_stop.toUInt(), accountID, peer_name, peer_number, history_state); + addCall(m_sHistoryCalls[time_start]); } } } - m_pHistoryInit = true; + m_sHistoryInit = true; return true; } @@ -151,20 +151,20 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: ///Return the active call count template<typename CallWidget, typename Index> int CallModel<CallWidget,Index>::size() { - return m_pActiveCalls.size(); + return m_sActiveCalls.size(); } ///Return a call corresponding to this ID or NULL template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>::findCallByCallId(QString callId) { - return m_pActiveCalls[callId]; + return m_sActiveCalls[callId]; } ///Return the action call list template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCallList() { QList<Call*> callList; - foreach(Call* call, m_pActiveCalls) { + foreach(Call* call, m_sActiveCalls) { callList.push_back(call); } return callList; @@ -185,8 +185,8 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: aNewStruct->call_real = call; aNewStruct->conference = false; - m_pPrivateCallList_call[call] = aNewStruct; - m_pPrivateCallList_callId[call->getCallId()] = aNewStruct; + m_sPrivateCallList_call[call] = aNewStruct; + m_sPrivateCallList_callId[call->getCallId()] = aNewStruct; //setCurrentItem(callItem); CallModelBase::addCall(call,parent); @@ -196,7 +196,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) { - m_pActiveCalls[call->getCallId()] = call; + m_sActiveCalls[call->getCallId()] = call; addCall(call); selectItem(call); return call; @@ -239,27 +239,27 @@ 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) { - InternalStruct* internal = m_pPrivateCallList_call[call]; + InternalStruct* internal = m_sPrivateCallList_call[call]; if (!internal) { qDebug() << "Cannot remove call: call not found"; return; } - if (m_pPrivateCallList_call[call] != NULL) { - m_pPrivateCallList_call.remove(call); + if (m_sPrivateCallList_call[call] != NULL) { + m_sPrivateCallList_call.remove(call); } - if (m_pPrivateCallList_callId[m_pPrivateCallList_callId.key(internal)] == internal) { - m_pPrivateCallList_callId.remove(m_pPrivateCallList_callId.key(internal)); + if (m_sPrivateCallList_callId[m_sPrivateCallList_callId.key(internal)] == internal) { + m_sPrivateCallList_callId.remove(m_sPrivateCallList_callId.key(internal)); } - if (m_pPrivateCallList_widget[m_pPrivateCallList_widget.key(internal)] == internal) { - m_pPrivateCallList_widget.remove(m_pPrivateCallList_widget.key(internal)); + if (m_sPrivateCallList_widget[m_sPrivateCallList_widget.key(internal)] == internal) { + m_sPrivateCallList_widget.remove(m_sPrivateCallList_widget.key(internal)); } - if (m_pPrivateCallList_index[m_pPrivateCallList_index.key(internal)] == internal) { - m_pPrivateCallList_index.remove(m_pPrivateCallList_index.key(internal)); + if (m_sPrivateCallList_index[m_sPrivateCallList_index.key(internal)] == internal) { + m_sPrivateCallList_index.remove(m_sPrivateCallList_index.key(internal)); } } @@ -283,18 +283,18 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: return 0; } - if (!m_pPrivateCallList_callId[callList[0]]) { + if (!m_sPrivateCallList_callId[callList[0]]) { qDebug() << "Invalid call"; return 0; } - Call* newConf = new Call(confID, m_pPrivateCallList_callId[callList[0]]->call_real->getAccountId()); + Call* newConf = new Call(confID, m_sPrivateCallList_callId[callList[0]]->call_real->getAccountId()); InternalStruct* aNewStruct = new InternalStruct; aNewStruct->call_real = newConf; aNewStruct->conference = true; - m_pPrivateCallList_call[newConf] = aNewStruct; - m_pPrivateCallList_callId[confID] = aNewStruct; + m_sPrivateCallList_call[newConf] = aNewStruct; + m_sPrivateCallList_callId[confID] = aNewStruct; return newConf; } @@ -344,12 +344,12 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: qDebug() << "Conf changed2"; Q_UNUSED(state) - if (!m_pPrivateCallList_callId[confId]) { + if (!m_sPrivateCallList_callId[confId]) { qDebug() << "The conference does not exist"; return false; } - if (!m_pPrivateCallList_callId[confId]->index) { + if (!m_sPrivateCallList_callId[confId]->index) { qDebug() << "The conference item does not exist"; return false; } @@ -359,14 +359,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) { - qDebug() << "Ending conversation containing " << m_pPrivateCallList_callId[confId]->children.size() << " participants"; + 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) { - InternalStruct* internal = m_pPrivateCallList_call[call]; + InternalStruct* internal = m_sPrivateCallList_call[call]; if (!internal) { qDebug() << "Cannot remove conference: call not found"; @@ -386,7 +386,7 @@ template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>:: template<typename CallWidget, typename Index> const QStringList CallModel<CallWidget,Index>::getHistoryCallId() { QStringList toReturn; - foreach(Call* call, m_pHistoryCalls) { + foreach(Call* call, m_sHistoryCalls) { toReturn << call->getCallId(); } return toReturn; @@ -395,7 +395,7 @@ template<typename CallWidget, typename Index> const QStringList CallModel<CallWi ///Return the history list template<typename CallWidget, typename Index> const CallHash& CallModel<CallWidget,Index>::getHistory() { - return m_pHistoryCalls; + return m_sHistoryCalls; } /***************************************************************************** @@ -420,7 +420,7 @@ template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index ///Return the current account template<typename CallWidget, typename Index> Account* CallModel<CallWidget,Index>::getCurrentAccount() { - Account* priorAccount = getAccountList()->getAccountById(m_pPriorAccountId); + Account* priorAccount = getAccountList()->getAccountById(m_sPriorAccountId); if(priorAccount && priorAccount->getAccountDetail(ACCOUNT_STATUS) == ACCOUNT_STATE_REGISTERED ) { return priorAccount; } @@ -433,21 +433,21 @@ 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() { - if (m_pAccountList == NULL) { - m_pAccountList = new AccountList(true); + if (m_spAccountList == NULL) { + m_spAccountList = new AccountList(true); } - return m_pAccountList; + return m_spAccountList; } ///Return the previously used account ID template<typename CallWidget, typename Index> QString CallModel<CallWidget,Index>::getPriorAccoundId() { - return m_pPriorAccountId; + return m_sPriorAccountId; } ///Set the previous account used template<typename CallWidget, typename Index> void CallModel<CallWidget,Index>::setPriorAccountId(QString value) { - m_pPriorAccountId = value; + m_sPriorAccountId = value; } /***************************************************************************** @@ -459,8 +459,8 @@ 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 { - if (m_pPrivateCallList_widget[widget]) { - return m_pPrivateCallList_widget[widget]->call_real; + if (m_sPrivateCallList_widget[widget]) { + return m_sPrivateCallList_widget[widget]->call_real; } return NULL; } @@ -469,8 +469,8 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( const CallWidget widget ) const { QList<Call*> toReturn; - if (m_pPrivateCallList_widget[widget] && m_pPrivateCallList_widget[widget]->conference) { - foreach (InternalStruct* child, m_pPrivateCallList_widget[widget]->children) { + if (m_sPrivateCallList_widget[widget] && m_sPrivateCallList_widget[widget]->conference) { + foreach (InternalStruct* child, m_sPrivateCallList_widget[widget]->children) { toReturn << child.call_real; } } @@ -481,7 +481,7 @@ template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget, template<typename CallWidget, typename Index> QList<Call*> CallModel<CallWidget,Index>::getCalls ( ) { QList<Call*> toReturn; - foreach (InternalStruct* child, m_pPrivateCallList_call) { + foreach (InternalStruct* child, m_sPrivateCallList_call) { toReturn << child->call_real; } return toReturn; @@ -490,8 +490,8 @@ 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 { - if (m_pPrivateCallList_widget[widget]) { - return m_pPrivateCallList_widget[widget]->conference; + if (m_sPrivateCallList_widget[widget]) { + return m_sPrivateCallList_widget[widget]->conference; } return false; } @@ -499,8 +499,8 @@ 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 { - if (m_pPrivateCallList_call[(Call*)call]) { - return m_pPrivateCallList_call[(Call*)call]->conference; + if (m_sPrivateCallList_call[(Call*)call]) { + return m_sPrivateCallList_call[(Call*)call]->conference; } return false; } @@ -515,8 +515,8 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: 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) { - foreach (InternalStruct* child, m_pPrivateCallList_call[call]->children) { + if (m_sPrivateCallList_call[call] && m_sPrivateCallList_call[call]->conference) { + foreach (InternalStruct* child, m_sPrivateCallList_call[call]->children) { toReturn << child.call_real; } } @@ -526,8 +526,8 @@ 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 { - if (m_pPrivateCallList_index[idx]) { - return m_pPrivateCallList_index[idx]->conference; + if (m_sPrivateCallList_index[idx]) { + return m_sPrivateCallList_index[idx]->conference; } return false; } @@ -535,8 +535,8 @@ 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 { - if (m_pPrivateCallList_index[idx]) { - return m_pPrivateCallList_index[idx]->call_real; + if (m_sPrivateCallList_index[idx]) { + return m_sPrivateCallList_index[idx]->call_real; } qDebug() << "Call not found"; return NULL; @@ -546,8 +546,8 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: 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) { - foreach (InternalStruct* child, m_pPrivateCallList_index[idx]->children) { + if (m_sPrivateCallList_index[idx] && m_sPrivateCallList_index[idx]->conference) { + foreach (InternalStruct* child, m_sPrivateCallList_index[idx]->children) { toReturn << child.call_real; } } @@ -557,8 +557,8 @@ 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 { - if (m_pPrivateCallList_callId[callId]) { - return m_pPrivateCallList_callId[callId]->conference; + if (m_sPrivateCallList_callId[callId]) { + return m_sPrivateCallList_callId[callId]->conference; } return false; } @@ -566,8 +566,8 @@ 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 { - if (m_pPrivateCallList_callId[callId]) { - return m_pPrivateCallList_callId[callId]->call_real; + if (m_sPrivateCallList_callId[callId]) { + return m_sPrivateCallList_callId[callId]->call_real; } return NULL; } @@ -576,8 +576,8 @@ template<typename CallWidget, typename Index> Call* CallModel<CallWidget,Index>: 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) { - foreach (InternalStruct* child, m_pPrivateCallList_callId[callId]->children) { + if (m_sPrivateCallList_callId[callId] && m_sPrivateCallList_callId[callId]->conference) { + foreach (InternalStruct* child, m_sPrivateCallList_callId[callId]->children) { toReturn << child.callId_real; } } @@ -587,8 +587,8 @@ 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 { - if (m_pPrivateCallList_call[(Call*)call]) { - return m_pPrivateCallList_call[(Call*)call]->index; + if (m_sPrivateCallList_call[(Call*)call]) { + return m_sPrivateCallList_call[(Call*)call]->index; } return NULL; } @@ -596,8 +596,8 @@ 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 { - if (m_pPrivateCallList_index[idx]) { - return m_pPrivateCallList_index[idx]->index; + if (m_sPrivateCallList_index[idx]) { + return m_sPrivateCallList_index[idx]->index; } return NULL; } @@ -605,8 +605,8 @@ 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 { - if (m_pPrivateCallList_widget[widget]) { - return m_pPrivateCallList_widget[widget]->index; + if (m_sPrivateCallList_widget[widget]) { + return m_sPrivateCallList_widget[widget]->index; } return NULL; } @@ -614,8 +614,8 @@ 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 { - if (m_pPrivateCallList_callId[callId]) { - return m_pPrivateCallList_callId[callId]->index; + if (m_sPrivateCallList_callId[callId]) { + return m_sPrivateCallList_callId[callId]->index; } return NULL; } @@ -623,8 +623,8 @@ 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 { - if (m_pPrivateCallList_call[call]) { - return m_pPrivateCallList_call[call]->call; + if (m_sPrivateCallList_call[call]) { + return m_sPrivateCallList_call[call]->call; } return NULL; } @@ -632,8 +632,8 @@ 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 { - if (m_pPrivateCallList_index[idx]) { - return m_pPrivateCallList_index[idx]->call; + if (m_sPrivateCallList_index[idx]) { + return m_sPrivateCallList_index[idx]->call; } return NULL; } @@ -641,8 +641,8 @@ 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 { - if (m_pPrivateCallList_widget[widget]) { - return m_pPrivateCallList_widget[widget]->call; + if (m_sPrivateCallList_widget[widget]) { + return m_sPrivateCallList_widget[widget]->call; } return NULL; } @@ -650,8 +650,8 @@ 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 { - if (m_pPrivateCallList_widget[widget]) { - return m_pPrivateCallList_widget[widget]->call; + if (m_sPrivateCallList_widget[widget]) { + return m_sPrivateCallList_widget[widget]->call; } return NULL; } @@ -659,11 +659,11 @@ 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) { - 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] ; + if (!m_sPrivateCallList_call[call]) { + m_sPrivateCallList_call [ call ] = new InternalStruct ; + m_sPrivateCallList_call [ call ]->call_real = call ; + m_sPrivateCallList_call [ call ]->conference = false ; + m_sPrivateCallList_callId [ call->getCallId() ] = m_sPrivateCallList_call[call] ; } return true; } @@ -672,8 +672,8 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: 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] ; + m_sPrivateCallList_call[call]->call = value ; + m_sPrivateCallList_widget[value] = m_sPrivateCallList_call[call] ; return true; } @@ -682,7 +682,7 @@ template<typename CallWidget, typename Index> bool CallModel<CallWidget,Index>:: 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] ; + m_sPrivateCallList_call[call]->index = value ; + m_sPrivateCallList_index[value] = m_sPrivateCallList_call[call] ; return true; } \ No newline at end of file diff --git a/src/Contact.cpp b/src/Contact.cpp index 90d472aab7badb9a51f4bace26f6c9f44cc9d8a7..fd45d1b193a55411c75b76c23159e785039d0e16 100644 --- a/src/Contact.cpp +++ b/src/Contact.cpp @@ -56,25 +56,25 @@ void Contact::initItemWidget() ///Get the phone number list PhoneNumbers Contact::getPhoneNumbers() const { - return m_pNumbers; + return m_Numbers; } ///Get the nickname QString Contact::getNickName() const { - return m_pNickName; + return m_NickName; } ///Get the firstname QString Contact::getFirstName() const { - return m_pFirstName; + return m_FirstName; } ///Get the second/family name QString Contact::getSecondName() const { - return m_pSecondName; + return m_SecondName; } ///Get the photo @@ -86,55 +86,55 @@ const QPixmap* Contact::getPhoto() const ///Get the formatted name QString Contact::getFormattedName() const { - return m_pFormattedName; + return m_FormattedName; } ///Get the organisation QString Contact::getOrganization() const { - return m_pOrganization; + return m_Organization; } ///Get the preferred email QString Contact::getPreferredEmail() const { - return m_pPreferredEmail; + return m_PreferredEmail; } ///Get the unique identifier (used for drag and drop) QString Contact::getUid() const { - return m_pUid; + return m_Uid; } ///Get the contact type QString Contact::getType() const { - return m_pType; + return m_Type; } ///Set the phone number (type and number) void Contact::setPhoneNumbers(PhoneNumbers numbers) { - m_pNumbers = numbers; + m_Numbers = numbers; } ///Set the nickname void Contact::setNickName(QString name) { - m_pNickName = name; + m_NickName = name; } ///Set the first name void Contact::setFirstName(QString name) { - m_pFirstName = name; + m_FirstName = name; } ///Set the family name void Contact::setFamilyName(QString name) { - m_pSecondName = name; + m_SecondName = name; } ///Set the Photo/Avatar @@ -146,23 +146,23 @@ void Contact::setPhoto(QPixmap* photo) ///Set the formatted name (display name) void Contact::setFormattedName(QString name) { - m_pFormattedName = name; + m_FormattedName = name; } ///Set the organisation / business void Contact::setOrganization(QString name) { - m_pOrganization = name; + m_Organization = name; } ///Set the default email void Contact::setPreferredEmail(QString name) { - m_pPreferredEmail = name; + m_PreferredEmail = name; } ///Set UID void Contact::setUid(QString id) { - m_pUid = id; + m_Uid = id; } \ No newline at end of file diff --git a/src/Contact.h b/src/Contact.h index 24cd3c571cb4e3abea67082e763c525aec7d5ed2..133b466a1e29cf88b682ed1f353cb7b068408a43 100644 --- a/src/Contact.h +++ b/src/Contact.h @@ -48,38 +48,39 @@ public: class PhoneNumber { public: PhoneNumber(QString number, QString type) - : m_pNumber(number),m_pType(type){} + : m_Number(number),m_Type(type){} QString& getNumber() { - return m_pNumber ; + return m_Number ; } QString& getType() { - return m_pType ; + return m_Type ; } private: - QString m_pNumber ; - QString m_pType ; + QString m_Number ; + QString m_Type ; }; typedef QList<Contact::PhoneNumber*> PhoneNumbers; private: - QString m_pFirstName ; - QString m_pSecondName ; - QString m_pNickName ; - QPixmap* m_pPhoto ; - QString m_pType ; - QString m_pFormattedName ; - QString m_pPreferredEmail ; - QString m_pOrganization ; - QString m_pUid ; - bool displayPhoto ; - PhoneNumbers m_pNumbers ; + QString m_FirstName ; + QString m_SecondName ; + QString m_NickName ; + QPixmap* m_pPhoto ; + QString m_Type ; + QString m_FormattedName ; + QString m_PreferredEmail ; + QString m_Organization ; + QString m_Uid ; + bool m_DisplayPhoto ; + PhoneNumbers m_Numbers ; public: //Constructors & Destructors explicit Contact(); virtual ~Contact(); + virtual void initItem(); //Getters virtual PhoneNumbers getPhoneNumbers() const; @@ -92,7 +93,6 @@ public: virtual QString getPreferredEmail() const; virtual const QPixmap* getPhoto() const; virtual QString getType() const; - virtual void initItem(); //Setters virtual void setPhoneNumbers (PhoneNumbers ); diff --git a/src/ContactBackend.h b/src/ContactBackend.h index cb5b3560850693b1c165ecab08d0c86de4821f04..518bb7282b5d28898c25f6a7db63777f5f15bba7 100644 --- a/src/ContactBackend.h +++ b/src/ContactBackend.h @@ -43,8 +43,8 @@ public: virtual void addNewContact ( Contact* contact ) = 0; protected: virtual ContactList update_slot ( ) = 0; - QHash<QString,Contact*> m_pContactByPhone ; - QHash<QString,Contact*> m_pContactByUid ; + QHash<QString,Contact*> m_ContactByPhone ; + QHash<QString,Contact*> m_ContactByUid ; public slots: ContactList update();