diff --git a/src/Account.cpp b/src/Account.cpp index 8b5061779d68b18e7d55ea10ed532c6be84e8986..4a851b325d257b8e96cee4b923ac28f37371f553 100644 --- a/src/Account.cpp +++ b/src/Account.cpp @@ -106,7 +106,7 @@ Account* Account::buildExistingAccountFromId(const QString& _accountId) Account* Account::buildNewAccountFromAlias(const QString& alias) { qDebug() << "Building an account from alias: " << alias; - Account* a = new Account(); + Account* a = new Account (); a->m_pAccountDetails = new MapStringString(); a->setAccountDetail(ACCOUNT_ALIAS,alias); return a; @@ -117,7 +117,7 @@ Account::~Account() { disconnect(); delete m_pAccountId; - if (m_pCredentials) delete m_pCredentials; + if (m_pCredentials) delete m_pCredentials ; if (m_pAccountDetails) delete m_pAccountDetails; } @@ -228,9 +228,9 @@ QModelIndex Account::getIndex() QString Account::getStateColorName() const { if(getAccountRegistrationStatus() == ACCOUNT_STATE_UNREGISTERED) - return "black"; + return "black"; if(getAccountRegistrationStatus() == ACCOUNT_STATE_REGISTERED || getAccountRegistrationStatus() == ACCOUNT_STATE_READY) - return "darkGreen"; + return "darkGreen"; return "red"; } @@ -238,38 +238,35 @@ QString Account::getStateColorName() const Qt::GlobalColor Account::getStateColor() const { if(getAccountRegistrationStatus() == ACCOUNT_STATE_UNREGISTERED) - return Qt::darkGray; + return Qt::darkGray ; if(getAccountRegistrationStatus() == ACCOUNT_STATE_REGISTERED || getAccountRegistrationStatus() == ACCOUNT_STATE_READY) - return Qt::darkGreen; + return Qt::darkGreen ; if(getAccountRegistrationStatus() == ACCOUNT_STATE_TRYING) - return Qt::darkYellow; + return Qt::darkYellow; return Qt::darkRed; } ///Create and return the credential model CredentialModel* Account::getCredentialsModel() { - if (!m_pCredentials) { + if (!m_pCredentials) reloadCredentials(); - } return m_pCredentials; } ///Create and return the audio codec model AudioCodecModel* Account::getAudioCodecModel() { - if (!m_pAudioCodecs) { + if (!m_pAudioCodecs) reloadAudioCodecs(); - } return m_pAudioCodecs; } ///Create and return the video codec model VideoCodecModel* Account::getVideoCodecModel() { - if (!m_pVideoCodecs) { + if (!m_pVideoCodecs) m_pVideoCodecs = new VideoCodecModel(this); - } return m_pVideoCodecs; } @@ -333,9 +330,9 @@ bool Account::updateState() { if(! isNew()) { ConfigurationManagerInterface & configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - MapStringString details = configurationManager.getAccountDetails(getAccountId()).value(); - QString status = details[ACCOUNT_REGISTRATION_STATUS]; - QString currentStatus = getAccountRegistrationStatus(); + MapStringString details = configurationManager.getAccountDetails(getAccountId()).value(); + QString status = details[ACCOUNT_REGISTRATION_STATUS]; + QString currentStatus = getAccountRegistrationStatus(); setAccountDetail(ACCOUNT_REGISTRATION_STATUS, status); //Update -internal- object state return status == currentStatus; } @@ -350,7 +347,6 @@ void Account::save() MapStringString details = getAccountDetails(); QString currentId = configurationManager.addAccount(details); setAccountId(currentId); - qDebug() << "NEW ID" << currentId; } else { configurationManager.setAccountDetails(getAccountId(), getAccountDetails()); @@ -363,7 +359,7 @@ void Account::save() if (acc != this) { (*AccountList::getInstance()->m_pAccounts) << this; } - + performAction(AccountEditAction::RELOAD); updateState(); m_CurrentState = READY; @@ -392,6 +388,7 @@ void Account::reload() m_CurrentState = READY; } +///Reload credentials from DBUS void Account::reloadCredentials() { if (!m_pCredentials) { @@ -408,6 +405,7 @@ void Account::reloadCredentials() } } +///Save all credentials void Account::saveCredentials() { if (m_pCredentials) { ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); @@ -426,6 +424,7 @@ void Account::saveCredentials() { } } +///Reload all audio codecs void Account::reloadAudioCodecs() { if (!m_pAudioCodecs) { @@ -461,6 +460,7 @@ void Account::reloadAudioCodecs() } } +///Save audio codecs void Account::saveAudioCodecs() { QStringList _codecList; for (int i=0; i < m_pAudioCodecs->rowCount();i++) { @@ -493,6 +493,7 @@ bool Account::operator==(const Account& a)const * * ****************************************************************************/ #ifdef ENABLE_VIDEO +///Save active video codecs void Account::setActiveVideoCodecList(const QList<VideoCodec*>& codecs) { QStringList codecs2; @@ -503,6 +504,7 @@ void Account::setActiveVideoCodecList(const QList<VideoCodec*>& codecs) interface.setActiveCodecList(codecs2,m_pAccountId); } +///Return the list of active video dodecs QList<VideoCodec*> Account::getActiveVideoCodecList() { QList<VideoCodec*> codecs; diff --git a/src/Account.h b/src/Account.h index 0071dc45ed90a9787ebada45fbdc2415e416dc8c..7fb44f94020ea89a805c5f1d90823845c25a6f96 100644 --- a/src/Account.h +++ b/src/Account.h @@ -48,7 +48,7 @@ enum AccountEditState { REMOVED =5 }; -///@enum AccountEditAction +///@enum AccountEditAction Actions that can be performed on the Account state enum AccountEditAction { NOTHING =0, EDIT =1, @@ -67,7 +67,7 @@ class LIB_EXPORT Account : public QObject { ~Account(); //Constructors static Account* buildExistingAccountFromId(const QString& _accountId); - static Account* buildNewAccountFromAlias(const QString& alias); + static Account* buildNewAccountFromAlias (const QString& alias ); /** *Perform an action @@ -251,8 +251,8 @@ class LIB_EXPORT Account : public QObject { bool operator==(const Account&)const; //Mutator - void saveCredentials(); - void saveAudioCodecs(); + void saveCredentials (); + void saveAudioCodecs (); void reloadCredentials(); void reloadAudioCodecs(); @@ -261,7 +261,7 @@ class LIB_EXPORT Account : public QObject { Account(); //Attributes - QString* m_pAccountId; + QString* m_pAccountId ; MapStringString* m_pAccountDetails; public slots: diff --git a/src/AccountList.cpp b/src/AccountList.cpp index 854fff4dfb932ee1e29fc26030bb29abd9a66660..55456d4e639ae1d615e2715b5959153c6c6dee38 100644 --- a/src/AccountList.cpp +++ b/src/AccountList.cpp @@ -40,11 +40,11 @@ AccountList::AccountList(QStringList & _accountIds) : m_pColorVisitor(nullptr) emit dataChanged(index(size()-1,0),index(size()-1,0)); connect(a,SIGNAL(changed(Account*)),this,SLOT(accountChanged(Account*))); } - CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); - connect(&callManager, SIGNAL(registrationStateChanged(QString,QString,int)),this,SLOT(accountChanged(QString,QString,int))); - + CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - connect(&configurationManager,SIGNAL(accountsChanged()),this,SLOT(updateAccounts())); + + connect(&callManager , SIGNAL(registrationStateChanged(QString,QString,int)) ,this,SLOT(accountChanged(QString,QString,int))); + connect(&configurationManager, SIGNAL(accountsChanged()) ,this,SLOT(updateAccounts()) ); } ///Constructors @@ -55,10 +55,10 @@ AccountList::AccountList(bool fill) : m_pColorVisitor(nullptr) if(fill) updateAccounts(); CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); - connect(&callManager, SIGNAL(registrationStateChanged(QString,QString,int)),this,SLOT(accountChanged(QString,QString,int))); - ConfigurationManagerInterface& configurationManager = ConfigurationManagerInterfaceSingleton::getInstance(); - connect(&configurationManager,SIGNAL(accountsChanged()),this,SLOT(updateAccounts())); + + connect(&callManager , SIGNAL(registrationStateChanged(QString,QString,int)),this,SLOT(accountChanged(QString,QString,int))); + connect(&configurationManager, SIGNAL(accountsChanged()) ,this,SLOT(updateAccounts()) ); } ///Destructor diff --git a/src/AccountList.h b/src/AccountList.h index 20936d7019816d37dde82de0163d81ad8fa2e61d..45337968b2cb71242a41bf67992013629cfa603b 100644 --- a/src/AccountList.h +++ b/src/AccountList.h @@ -52,19 +52,19 @@ public: Account* getDefaultAccount ( ); static Account* getCurrentAccount ( ); static QString getPriorAccoundId ( ); + Account* getAccountByModelIndex ( QModelIndex item ) const; - //Getters + //Abstract model accessors QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const; int rowCount ( const QModelIndex& parent = QModelIndex() ) const; Qt::ItemFlags flags ( const QModelIndex& index ) const; - Account* getAccountByModelIndex(QModelIndex item) const; - void setDefaultAccount(Account* a); //Setters static void setPriorAccountId( const QString& value ); virtual bool setData ( const QModelIndex& index, const QVariant &value, int role); void setColorVisitor ( AccountListColorVisitor* visitor ); - + void setDefaultAccount(Account* a); + //Mutators virtual Account* addAccount ( QString & alias ) ; void removeAccount ( Account* account ) ; @@ -85,14 +85,14 @@ private: ~AccountList(); //Attributes - QVector<Account*>* m_pAccounts; - static AccountList* m_spAccountList; - static QString m_sPriorAccountId; - Account* m_pDefaultAccount; - AccountListColorVisitor* m_pColorVisitor; + QVector<Account*>* m_pAccounts ; + static AccountList* m_spAccountList ; + static QString m_sPriorAccountId; + Account* m_pDefaultAccount; + AccountListColorVisitor* m_pColorVisitor ; public slots: - void update(); + void update (); void updateAccounts(); private slots: @@ -103,9 +103,11 @@ signals: ///The account list changed void accountListUpdated(); ///Emitted when an account state change - void accountStateChanged( Account* account, QString state); - void accountEnabledChanged(Account* source); - void defaultAccountChanged(Account* a); + void accountStateChanged ( Account* account, QString state); + ///Emitted when an account enable attribute change + void accountEnabledChanged( Account* source ); + ///Emitted when the default account change + void defaultAccountChanged( Account* a ); }; ///SFLPhonelib Qt does not link to QtGui, and does not need to, this allow to add runtime Gui support diff --git a/src/AudioCodecModel.cpp b/src/AudioCodecModel.cpp index 80c6b23df1ae6c57f858c11f65ff69fab61dc4cb..5d739387f1c0b0e6c795ac0ef4d453c7fd5d56de 100644 --- a/src/AudioCodecModel.cpp +++ b/src/AudioCodecModel.cpp @@ -17,6 +17,7 @@ ***************************************************************************/ #include "AudioCodecModel.h" +//Qt #include <QtCore/QDebug> ///Constructor @@ -26,20 +27,22 @@ AudioCodecModel::AudioCodecModel(QObject* parent) : QAbstractListModel(parent) { ///Model data QVariant AudioCodecModel::data(const QModelIndex& index, int role) const { - if(index.column() == 0 && role == Qt::DisplayRole) + if(index.column() == 0 && role == Qt::DisplayRole ) { return QVariant(m_lAudioCodecs[index.row()]->name); - else if(index.column() == 0 && role == Qt::CheckStateRole) - return QVariant(m_lEnabledCodecs[m_lAudioCodecs[index.row()]->id] ? Qt::Checked : Qt::Unchecked); - else if (index.column() == 0 && role == AudioCodecModel::NAME_ROLE) { + } + else if(index.column() == 0 && role == Qt::CheckStateRole ) { + return QVariant(m_lEnabledCodecs[m_lAudioCodecs[index.row()]->id] ? Qt::Checked : Qt::Unchecked); + } + else if (index.column() == 0 && role == AudioCodecModel::NAME_ROLE ) { return m_lAudioCodecs[index.row()]->name; } - else if (index.column() == 0 && role == AudioCodecModel::BITRATE_ROLE) { + else if (index.column() == 0 && role == AudioCodecModel::BITRATE_ROLE ) { return m_lAudioCodecs[index.row()]->bitrate; } - else if (index.column() == 0 && role == AudioCodecModel::SAMPLERATE_ROLE) { + else if (index.column() == 0 && role == AudioCodecModel::SAMPLERATE_ROLE ) { return m_lAudioCodecs[index.row()]->samplerate; } - else if (index.column() == 0 && role == AudioCodecModel::ID_ROLE) { + else if (index.column() == 0 && role == AudioCodecModel::ID_ROLE ) { return m_lAudioCodecs[index.row()]->id; } return QVariant(); @@ -114,7 +117,7 @@ void AudioCodecModel::clear() foreach(AudioCodecData* data, m_lAudioCodecs) { delete data; } - m_lAudioCodecs.clear(); + m_lAudioCodecs.clear (); m_lEnabledCodecs.clear(); } diff --git a/src/AudioCodecModel.h b/src/AudioCodecModel.h index 5ff16cbfb0c2d318f7e19e15cf3120128a3a6928..7bc77e7bdc34f1557eecd01ab799469c0804446b 100644 --- a/src/AudioCodecModel.h +++ b/src/AudioCodecModel.h @@ -37,17 +37,17 @@ public: AudioCodecModel(QObject* parent =nullptr); //Abstract model member - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole ) const; - int rowCount(const QModelIndex& parent = QModelIndex() ) const; - Qt::ItemFlags flags(const QModelIndex& index ) const; - virtual bool setData(const QModelIndex& index, const QVariant &value, int role); + QVariant data (const QModelIndex& index, int role = Qt::DisplayRole ) const; + int rowCount (const QModelIndex& parent = QModelIndex() ) const; + Qt::ItemFlags flags (const QModelIndex& index ) const; + virtual bool setData (const QModelIndex& index, const QVariant &value, int role ); //Mutator QModelIndex addAudioCodec(); - void removeAudioCodec(QModelIndex idx); - void clear(); - bool moveUp(QModelIndex idx); - bool moveDown(QModelIndex idx); + void removeAudioCodec ( QModelIndex idx ); + bool moveUp ( QModelIndex idx ); + bool moveDown ( QModelIndex idx ); + void clear ( ); private: ///@struct AudioCodecData store audio codec information @@ -57,11 +57,10 @@ private: QString bitrate ; QString samplerate; }; - - //Attributes - QList<AudioCodecData*> m_lAudioCodecs; - QMap<int,bool> m_lEnabledCodecs; + //Attributes + QList<AudioCodecData*> m_lAudioCodecs ; + QMap<int,bool> m_lEnabledCodecs; }; #endif diff --git a/src/Call.cpp b/src/Call.cpp index f9a2f1872408876d6f99943806915d18edc8f5db..3627c981eb2965b57a63d4f44825c89cdbc59494 100644 --- a/src/Call.cpp +++ b/src/Call.cpp @@ -123,11 +123,11 @@ Call::Call(call_state startState, QString callId, QString peerName, QString peer 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 = nullptr ; this->m_pStopTime = nullptr ; + changeCurrentState(startState) ; m_ContactChanged = true; CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); @@ -156,8 +156,8 @@ Call::Call(QString confId, QString account): m_isConference(false),m_pStopTime(n this->m_Account = account ; if (m_isConference) { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - MapStringString details = callManager.getConferenceDetails(m_ConfId); + CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); + MapStringString details = callManager.getConferenceDetails(m_ConfId) ; m_CurrentState = confStatetoCallState(details["CONF_STATE"]); } } @@ -171,26 +171,26 @@ Call::Call(QString confId, QString account): m_isConference(false),m_pStopTime(n ///Build a call from its ID Call* Call::buildExistingCall(QString callId) { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - MapStringString details = callManager.getCallDetails(callId).value(); - + CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); + MapStringString details = callManager.getCallDetails(callId).value(); + qDebug() << "Constructing existing call with details : " << details; - + QString peerNumber = details[ CALL_PEER_NUMBER ]; QString peerName = details[ CALL_PEER_NAME ]; QString account = details[ CALL_ACCOUNTID ]; call_state startState = getStartStateFromDaemonCallState(details[CALL_STATE], details[CALL_TYPE]); - + Call* call = new Call(startState, callId, peerName, peerNumber, account) ; - + if (!details[ CALL_TIMESTAMP_START ].isEmpty()) call->m_pStartTime = new QDateTime(QDateTime::fromTime_t(details[ CALL_TIMESTAMP_START ].toInt())) ; else call->m_pStartTime = new QDateTime(QDateTime::currentDateTime()) ; - + call->m_Recording = callManager.getIsRecording(callId) ; call->m_HistoryState = getHistoryStateFromType(details[STATE_KEY]); - + return call; } //buildExistingCall @@ -207,7 +207,7 @@ Call* Call::buildIncomingCall(const QString & callId) { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); MapStringString details = callManager.getCallDetails(callId).value(); - + QString from = details[ CALL_PEER_NUMBER ]; QString account = details[ CALL_ACCOUNTID ]; QString peerName = details[ CALL_PEER_NAME ]; @@ -248,8 +248,8 @@ Call* Call::buildHistoryCall(const QString & callId, uint startTimeStamp, uint s QDateTime* stop = new QDateTime(QDateTime::fromTime_t(stopTimeStamp)); if (start){ - call->m_pStartTime = start; - call->m_pStopTime = stop; + call->m_pStartTime = start; + call->m_pStopTime = stop; } call->m_HistoryState = getHistoryStateFromType(type); @@ -318,6 +318,7 @@ daemon_call_state Call::toDaemonCallState(const QString& stateName) return DAEMON_CALL_STATE_FAILURE ; } //toDaemonCallState +///Transform a conference call state to a proper call state call_state Call::confStatetoCallState(const QString& stateName) { if ( stateName == CONF_STATE_CHANGE_HOLD ) @@ -444,7 +445,7 @@ call_state Call::getCurrentState() const bool Call::getRecording() const { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); - ((Call*) this)->m_Recording = callManager.getIsRecording(m_CallId); + ((Call*) this)->m_Recording = callManager.getIsRecording(m_CallId); return m_Recording; } @@ -475,7 +476,7 @@ const QString& Call::getRecordingPath() const ///Get the current codec QString Call::getCurrentCodecName() const { - CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); + CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); return callManager.getCurrentAudioCodecName(m_CallId); } @@ -512,11 +513,7 @@ bool Call::isSecure() const { } Account* currentAccount = AccountList::getInstance()->getAccountById(m_Account); - - if ((currentAccount->isTlsEnable()) || (currentAccount->getTlsMethod())) { - return true; - } - return false; + return currentAccount && ((currentAccount->isTlsEnable()) || (currentAccount->getTlsMethod())); } //isSecure Contact* Call::getContact() @@ -598,12 +595,12 @@ call_state Call::stateChanged(const QString& newStateName) if (!m_isConference) { daemon_call_state dcs = toDaemonCallState(newStateName); changeCurrentState(stateChangedStateMap[m_CurrentState][dcs]); - + CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); MapStringString details = callManager.getCallDetails(m_CallId).value(); if (details[CALL_PEER_NAME] != m_PeerName) m_PeerName = details[CALL_PEER_NAME]; - + (this->*(stateChangedFunctionMap[previousState][dcs]))(); } else { @@ -640,6 +637,7 @@ void Call::changeCurrentState(call_state newState) emit isOver(this); } +///Send a text message void Call::sendTextMessage(QString message) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); @@ -652,6 +650,7 @@ void Call::sendTextMessage(QString message) m_pImModel->addOutgoingMessage(message); } +///Private version of setStartTime QDateTime* Call::setStartTime_private(QDateTime* time) { //if (m_pStartTime && time) @@ -660,6 +659,7 @@ QDateTime* Call::setStartTime_private(QDateTime* time) return m_pStartTime = time; } +///Private version of setStopTime QDateTime* Call::setStopTime_private(QDateTime* time) { //if (m_pStopTime && time) @@ -707,7 +707,6 @@ void Call::acceptTransf() qDebug() << "Accepting call and transferring it to number : " << m_TransferNumber << ". callId : " << m_CallId << "ConfId:" << m_ConfId; callManager.accept(m_CallId); Q_NOREPLY callManager.transfer(m_CallId, m_TransferNumber); -// m_HistoryState = TRANSFERRED; } ///Put the call on hold @@ -789,6 +788,7 @@ void Call::transfer() setStopTime_private(new QDateTime(QDateTime::currentDateTime())); } +///Unhold the call void Call::unhold() { CallManagerInterface & callManager = CallManagerInterfaceSingleton::getInstance(); @@ -799,14 +799,6 @@ void Call::unhold() Q_NOREPLY callManager.unholdConference(m_ConfId); } -/* -void Call::switchRecord() -{ - qDebug() << "Switching record state for call automate. callId : " << callId; - m_Recording = !m_Recording; -} -*/ - ///Record the call void Call::setRecord() { @@ -867,7 +859,7 @@ void Call::appendText(const QString& str) QString* editNumber; switch (m_CurrentState) { - case CALL_STATE_TRANSFERRED : + case CALL_STATE_TRANSFERRED : case CALL_STATE_TRANSF_HOLD : editNumber = &m_TransferNumber; break; @@ -890,7 +882,7 @@ void Call::backspaceItemText() QString* editNumber; switch (m_CurrentState) { - case CALL_STATE_TRANSFERRED : + case CALL_STATE_TRANSFERRED : case CALL_STATE_TRANSF_HOLD : editNumber = &m_TransferNumber; break; diff --git a/src/Call.h b/src/Call.h index 1a12c8fff24c6ab9e854c2c4ddbc282d5bef8611..ce67bf620cce970f8e6a6f7a6fa593172dc0b851 100644 --- a/src/Call.h +++ b/src/Call.h @@ -30,7 +30,6 @@ class QWidget; //SFLPhone #include "sflphone_const.h" #include "typedefs.h" - class ContactBackend; class Contact; class Account; @@ -43,20 +42,14 @@ class InstantMessagingModel; */ typedef enum { - /** Ringing outgoing or incoming call */ - DAEMON_CALL_STATE_RINGING, - /** Call to which the user can speak and hear */ - DAEMON_CALL_STATE_CURRENT, - /** Call is busy */ - DAEMON_CALL_STATE_BUSY, - /** Call is on hold */ - DAEMON_CALL_STATE_HOLD, - /** Call is over */ - DAEMON_CALL_STATE_HUNG_UP, - /** Call has failed */ - DAEMON_CALL_STATE_FAILURE, - /** Call is recording+current */ - DAEMON_CALL_STATE_RECORD, + + /** Ringing outgoing or incoming call */ DAEMON_CALL_STATE_RINGING, + /** Call to which the user can speak and hear */ DAEMON_CALL_STATE_CURRENT, + /** Call is busy */ DAEMON_CALL_STATE_BUSY , + /** Call is on hold */ DAEMON_CALL_STATE_HOLD , + /** Call is over */ DAEMON_CALL_STATE_HUNG_UP, + /** Call has failed */ DAEMON_CALL_STATE_FAILURE, + /** Call is recording+current */ DAEMON_CALL_STATE_RECORD , } daemon_call_state; /** @enum call_action @@ -64,16 +57,13 @@ typedef enum */ typedef enum { - /** Green button, accept or new call or place call or place transfer */ - CALL_ACTION_ACCEPT, - /** Red button, refuse or hang up */ - CALL_ACTION_REFUSE, - /** Blue button, put into or out of transfer mode where you can type transfer number */ - CALL_ACTION_TRANSFER, - /** Blue-green button, hold or unhold the call */ - CALL_ACTION_HOLD, - /** Record button, enable or disable recording */ - CALL_ACTION_RECORD, + + /** Accept, create or place call or place transfer */ CALL_ACTION_ACCEPT , + /** Red button, refuse or hang up */ CALL_ACTION_REFUSE , + /** Put into or out of transfer mode*/ CALL_ACTION_TRANSFER, + /** Hold or unhold the call */ CALL_ACTION_HOLD , + /** Enable or disable recording */ CALL_ACTION_RECORD , + } call_action; /** @@ -84,7 +74,7 @@ typedef enum { INCOMING, OUTGOING, - MISSED, + MISSED , NONE } history_state; diff --git a/src/CallModel.cpp b/src/CallModel.cpp index 71404b362e7a8296cf2495063ed96c8eb7e3a0f2..c873e2a4ef3f2fa1839b9446883201daa5ddb5b9 100644 --- a/src/CallModel.cpp +++ b/src/CallModel.cpp @@ -30,8 +30,10 @@ CallModelBase::CallModelBase(QObject* parent) : QObject(parent) { if (!dbusInit) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); + #ifdef ENABLE_VIDEO VideoInterface& interface = VideoInterfaceSingleton::getInstance(); - + #endif + //SLOTS /* SENDER SIGNAL RECEIVER SLOT */ /**/connect(&callManager, SIGNAL(callStateChanged(QString,QString)) , this , SLOT(callStateChanged(QString,QString)) ); @@ -41,12 +43,14 @@ CallModelBase::CallModelBase(QObject* parent) : QObject(parent) /**/connect(&callManager, SIGNAL(conferenceRemoved(QString)) , this , SLOT(conferenceRemovedSlot(QString)) ); /**/connect(&callManager, SIGNAL(voiceMailNotify(QString,int)) , this , SLOT(voiceMailNotifySlot(QString,int)) ); /**/connect(&callManager, SIGNAL(volumeChanged(QString,double)) , this , SLOT(volumeChangedSlot(QString,double)) ); + #ifdef ENABLE_VIDEO /**/connect(&interface , SIGNAL(startedDecoding(QString,QString,int,int)), this , SLOT(startedDecoding(QString,QString)) ); /**/connect(&interface , SIGNAL(stoppedDecoding(QString,QString)) , this , SLOT(stoppedDecoding(QString,QString)) ); + #endif /* */ connect(HistoryModel::self(),SIGNAL(newHistoryCall(Call*)),this,SLOT(addPrivateCall(Call*))); - + dbusInit = true; foreach(Call* call,HistoryModel::getHistory()){ @@ -85,9 +89,9 @@ void CallModelBase::callStateChanged(const QString &callID, const QString &state if (call->getCurrentState() == CALL_STATE_OVER) { HistoryModel::add(call); } - + emit callStateChanged(call); - + } @@ -177,15 +181,12 @@ void CallModelBase::removeActiveCall(Call* call) //m_sActiveCalls[call->getCallId()] = nullptr; } +#ifdef ENABLE_VIDEO ///Updating call state when video is added void CallModelBase::startedDecoding(const QString& callId, const QString& shmKey ) { Q_UNUSED(callId) Q_UNUSED(shmKey) -// Call* call = getCall(callId); -// if (call) { -// -// } } ///Updating call state when video is removed @@ -193,11 +194,8 @@ void CallModelBase::stoppedDecoding(const QString& callId, const QString& shmKey { Q_UNUSED(callId) Q_UNUSED(shmKey) -// Call* call = getCall(callId); -// if (call) { -// -// } } +#endif /***************************************************************************** * * diff --git a/src/CallModel.h b/src/CallModel.h index 1de0c945406db86cd1ff3124eeb2eeb81e5686c4..ca61533c4d6d81f3bd5bff935dc241b5c4cde1eb 100644 --- a/src/CallModel.h +++ b/src/CallModel.h @@ -66,8 +66,10 @@ private slots: void volumeChangedSlot ( const QString& device , double value ); void removeActiveCall ( Call* call ); void addPrivateCall ( Call* call ); + #ifdef ENABLE_VIDEO void startedDecoding ( const QString& callId , const QString& shmKey ); void stoppedDecoding ( const QString& callId , const QString& shmKey ); + #endif protected: virtual Call* findCallByCallId ( const QString& callId ) = 0; @@ -206,8 +208,7 @@ class LIB_EXPORT CallModel : public CallModelBase { static InternalIndex m_sPrivateCallList_index ; static CallMap m_lConfList; - - static bool m_sCallInit ; + static bool m_sCallInit; private: static bool m_sInstanceInit; diff --git a/src/CallModel.hpp b/src/CallModel.hpp index 8cd53be609a5b3c7694553cdc1189146f844a85b..115c05e2a2bb0a4f5518a4118767a7dd7e79ea1a 100644 --- a/src/CallModel.hpp +++ b/src/CallModel.hpp @@ -71,10 +71,10 @@ CALLMODEL_TEMPLATE void CALLMODEL_T::destroy() foreach (InternalStruct* s, m_sPrivateCallList_call.values()) { delete s; } - m_sPrivateCallList_call.clear(); + m_sPrivateCallList_call.clear (); m_sPrivateCallList_callId.clear(); m_sPrivateCallList_widget.clear(); - m_sPrivateCallList_index.clear(); + m_sPrivateCallList_index.clear (); } ///Destructor @@ -98,15 +98,15 @@ CALLMODEL_TEMPLATE bool CALLMODEL_T::initCall() { if (!m_sCallInit) { CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); - QStringList callList = callManager.getCallList(); - foreach (QString callId, callList) { + const QStringList callList = callManager.getCallList(); + foreach (const QString& callId, callList) { Call* tmpCall = Call::buildExistingCall(callId); m_sActiveCalls[tmpCall->getCallId()] = tmpCall; addCall(tmpCall); } - - QStringList confList = callManager.getConferenceList(); - foreach (QString confId, confList) { + + const QStringList confList = callManager.getConferenceList(); + foreach (const QString& confId, confList) { CallModelBase::addConferenceS(addConference(confId)); } } @@ -150,12 +150,12 @@ CALLMODEL_TEMPLATE CallList CALLMODEL_T::getConferenceList() CallList confList; //That way it can not be invalid - QStringList confListS = CallManagerInterfaceSingleton::getInstance().getConferenceList(); - foreach (QString confId, confListS) { - if (m_lConfList[confId] != nullptr) - confList << m_lConfList[confId]; - else - confList << addConference(confId); + const QStringList confListS = CallManagerInterfaceSingleton::getInstance().getConferenceList(); + foreach (const QString& confId, confListS) { + if (m_lConfList[confId] != nullptr) + confList << m_lConfList[confId]; + else + confList << addConference(confId); } return confList; } @@ -178,8 +178,8 @@ CALLMODEL_TEMPLATE Call* CALLMODEL_T::addCall(Call* call, Call* parent) aNewStruct->call_real = call; aNewStruct->conference = false; - m_sPrivateCallList_call[call] = aNewStruct; - m_sPrivateCallList_callId[call->getCallId()] = aNewStruct; + m_sPrivateCallList_call [ call ] = aNewStruct; + m_sPrivateCallList_callId[ call->getCallId() ] = aNewStruct; //setCurrentItem(callItem); CallModelBase::addCall(call,parent); @@ -225,8 +225,7 @@ CALLMODEL_TEMPLATE Call* CALLMODEL_T::addRingingCall(const QString& callId) CALLMODEL_TEMPLATE QString CALLMODEL_T::generateCallId() { int id = qrand(); - QString res = QString::number(id); - return res; + return QString::number(id); } ///Remove a call and update the internal structure @@ -271,9 +270,9 @@ CALLMODEL_TEMPLATE void CALLMODEL_T::attendedTransfer(Call* toTransfer, Call* ta CALLMODEL_TEMPLATE void CALLMODEL_T::transfer(Call* toTransfer, QString target) { qDebug() << "Transferring call " << toTransfer->getCallId() << "to" << target; - toTransfer->setTransferNumber(target); - toTransfer->actionPerformed(CALL_ACTION_TRANSFER); - toTransfer->changeCurrentState(CALL_STATE_OVER); + toTransfer->setTransferNumber ( target ); + toTransfer->actionPerformed ( CALL_ACTION_TRANSFER ); + toTransfer->changeCurrentState( CALL_STATE_OVER ); } //transfer /***************************************************************************** @@ -287,14 +286,14 @@ CALLMODEL_TEMPLATE Call* CALLMODEL_T::addConference(const QString & confID) { qDebug() << "Notified of a new conference " << confID; CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); - QStringList callList = callManager.getParticipantList(confID); + const QStringList callList = callManager.getParticipantList(confID); qDebug() << "Paticiapants are:" << callList; - + if (!callList.size()) { qDebug() << "This conference (" + confID + ") contain no call"; return 0; } - + if (!m_sPrivateCallList_callId[callList[0]]) { qDebug() << "Invalid call"; return 0; @@ -303,7 +302,7 @@ CALLMODEL_TEMPLATE Call* CALLMODEL_T::addConference(const QString & confID) Call* newConf = nullptr; if (m_sPrivateCallList_callId[callList[0]]->call_real->getAccount()) newConf = new Call(confID, m_sPrivateCallList_callId[callList[0]]->call_real->getAccount()->getAccountId()); - + if (newConf) { InternalStruct* aNewStruct = new InternalStruct; aNewStruct->call_real = newConf; @@ -312,7 +311,7 @@ CALLMODEL_TEMPLATE Call* CALLMODEL_T::addConference(const QString & confID) m_sPrivateCallList_call[newConf] = aNewStruct; m_sPrivateCallList_callId[confID] = aNewStruct; - m_lConfList[newConf->getConfId()] = newConf; + m_lConfList[newConf->getConfId()] = newConf ; } return newConf; } //addConference @@ -361,12 +360,12 @@ CALLMODEL_TEMPLATE bool CALLMODEL_T::changeConference(const QString& confId, con { qDebug() << "Conf changed"; Q_UNUSED(state) - + if (!m_sPrivateCallList_callId[confId]) { qDebug() << "The conference does not exist"; return false; } - + if (!m_sPrivateCallList_callId[confId]->index) { qDebug() << "The conference item does not exist"; return false; @@ -386,7 +385,7 @@ CALLMODEL_TEMPLATE void CALLMODEL_T::removeConference(const QString &confId) CALLMODEL_TEMPLATE void CALLMODEL_T::removeConference(Call* call) { InternalStruct* internal = m_sPrivateCallList_call[call]; - + if (!internal) { qDebug() << "Cannot remove conference: call not found"; return; diff --git a/src/ContactBackend.cpp b/src/ContactBackend.cpp index ddfbdd9e9a6f942c7de063534df8e71de0b00268..e230b27df46b57f87d5ecfae790c41f01f3e002f 100644 --- a/src/ContactBackend.cpp +++ b/src/ContactBackend.cpp @@ -30,7 +30,7 @@ ///Constructor ContactBackend::ContactBackend(QObject* parent) : QObject(parent) { - + } ///Destructor @@ -58,12 +58,7 @@ QString ContactBackend::getUserFromPhone(QString phoneNumber) { if (phoneNumber.indexOf('@') != -1) { QString user = phoneNumber.split('@')[0]; - if (user.indexOf(':') != -1) { - return user.split(':')[1]; - } - else { - return user; - } + return (user.indexOf(':') != -1)?user.split(':')[1]:user; } return phoneNumber; } //getUserFromPhone diff --git a/src/ContactBackend.h b/src/ContactBackend.h index 0eb05e5a92d7197a16c2bd2302ec6b35622b86db..b833971b3f9653929b3604b8637e13cbfa2e11e7 100644 --- a/src/ContactBackend.h +++ b/src/ContactBackend.h @@ -56,10 +56,10 @@ public: ///Add a new phone number to an existing contact virtual void addPhoneNumber( Contact* contact , QString number, QString type )=0; protected: - virtual ContactList update_slot ( ) = 0; + virtual ContactList update_slot ( ) = 0; //Helper - QString getUserFromPhone(QString phoneNumber); + QString getUserFromPhone (QString phoneNumber); QString getHostNameFromPhone(QString phoneNumber); //Attributes diff --git a/src/CredentialModel.cpp b/src/CredentialModel.cpp index ba967bf6191a2b9dde8769d56aa9ea40d017f564..ba37f0161ba28c63ec01b04db3122baecdaa60b7 100644 --- a/src/CredentialModel.cpp +++ b/src/CredentialModel.cpp @@ -26,18 +26,21 @@ CredentialModel::CredentialModel(QObject* parent) : QAbstractListModel(parent) { ///Model data QVariant CredentialModel::data(const QModelIndex& index, int role) const { - if(index.column() == 0 && role == Qt::DisplayRole) - return QVariant(m_lCredentials[index.row()]->name); -// else if(index.column() == 0 && role == Qt::CheckStateRole) -// return QVariant(account->isEnabled() ? Qt::Checked : Qt::Unchecked); - else if (index.column() == 0 && role == CredentialModel::NAME_ROLE) { - return m_lCredentials[index.row()]->name; - } - else if (index.column() == 0 && role == CredentialModel::PASSWORD_ROLE) { - return m_lCredentials[index.row()]->password; - } - else if (index.column() == 0 && role == CredentialModel::REALM_ROLE) { - return m_lCredentials[index.row()]->realm; + if (index.column() == 0) { + switch (role) { + case Qt::DisplayRole: + return QVariant(m_lCredentials[index.row()]->name); + break; + case CredentialModel::NAME_ROLE: + return m_lCredentials[index.row()]->name; + break; + case CredentialModel::PASSWORD_ROLE: + return m_lCredentials[index.row()]->password; + break; + case CredentialModel::REALM_ROLE: + return m_lCredentials[index.row()]->realm; + break; + } } return QVariant(); } diff --git a/src/CredentialModel.h b/src/CredentialModel.h index c51ca928db40bd2b6e42a4676baf87d4530a1c25..29b8b1c380bd57f6fb5fc117a9d549fc0787bb31 100644 --- a/src/CredentialModel.h +++ b/src/CredentialModel.h @@ -54,10 +54,9 @@ private: QString password; QString realm ; }; - + //Attributes QList<CredentialData2*> m_lCredentials; - }; #endif diff --git a/src/HistoryModel.h b/src/HistoryModel.h index 657c8d2b48565fb6221ccc30f275587c9ae7cdce..fcadd398eff2cee23ca0d8d6ae10e67cdb99870b 100644 --- a/src/HistoryModel.h +++ b/src/HistoryModel.h @@ -44,12 +44,12 @@ public: static const CallMap& getHistory (); static const QStringList getHistoryCallId (); static const QStringList getNumbersByPopularity (); - + //Setters static void add(Call* call); private: - + //Constructor HistoryModel(); bool initHistory (); @@ -63,12 +63,7 @@ private: //Attributes static CallMap m_sHistoryCalls; bool m_HistoryInit; - -public slots: - -private slots: - signals: ///Emitted when the history change (new items, cleared) void historyChanged ( ); diff --git a/src/InstantMessagingModel.cpp b/src/InstantMessagingModel.cpp index e3e983b8331a76600f4bd968a0b009ff3f45b903..f4a031a0cb696934157867cd7c71927391fe25ca 100644 --- a/src/InstantMessagingModel.cpp +++ b/src/InstantMessagingModel.cpp @@ -24,6 +24,15 @@ InstantMessagingModelManager* InstantMessagingModelManager::m_spInstance = nullptr; CallModelBase* InstantMessagingModelManager::m_spCallModel = nullptr; + +///Constructor +InstantMessagingModelManager::InstantMessagingModelManager() : QObject(0) +{ + CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); + connect(&callManager, SIGNAL(incomingMessage(QString,QString,QString)), this, SLOT(newMessage(QString,QString,QString))); +} + +///Called when a new message is incoming void InstantMessagingModelManager::newMessage(QString callId, QString from, QString message) { if (!m_lModels[callId] && m_spCallModel) { @@ -40,12 +49,7 @@ void InstantMessagingModelManager::newMessage(QString callId, QString from, QStr } } -InstantMessagingModelManager::InstantMessagingModelManager() : QObject(0) -{ - CallManagerInterface& callManager = CallManagerInterfaceSingleton::getInstance(); - connect(&callManager, SIGNAL(incomingMessage(QString,QString,QString)), this, SLOT(newMessage(QString,QString,QString))); -} - +///Singleton InstantMessagingModel* InstantMessagingModelManager::getModel(Call* call) { QString key = call->isConference()?call->getConfId():call->getCallId(); if (!m_lModels[key]) { @@ -55,47 +59,64 @@ InstantMessagingModel* InstantMessagingModelManager::getModel(Call* call) { return m_lModels[key]; } +///Constructor InstantMessagingModel::InstantMessagingModel(Call* call, QObject* parent) : QAbstractListModel(parent),m_pCall(call) { //QStringList callList = callManager.getCallList(); } +///Get data from the model QVariant InstantMessagingModel::data( const QModelIndex& index, int role) const { - if(index.column() == 0 && role == Qt::DisplayRole) - return QVariant(m_lMessages[index.row()].message); - else if (index.column() == 0 && role == MESSAGE_TYPE_ROLE ) - return QVariant(m_lMessages[index.row()].message); - else if (index.column() == 0 && role == MESSAGE_FROM_ROLE ) - return QVariant(m_lMessages[index.row()].from); - else if (index.column() == 0 && role == MESSAGE_TEXT_ROLE ) - return INCOMMING_IM; - else if (index.column() == 0 && role == MESSAGE_CONTACT_ROLE && m_pCall->getContact()) - return QVariant(); - else if (index.column() == 0 && role == MESSAGE_IMAGE_ROLE ) { - if (m_lImages.find(index) != m_lImages.end()) - return m_lImages[index]; - Contact* c =m_pCall->getContact(); - if (c && c->getPhoto()) { - return QVariant::fromValue<void*>((void*)c->getPhoto()); + if (index.column() == 0) { + switch (role) { + case Qt::DisplayRole: + return QVariant(m_lMessages[index.row()].message); + break; + case MESSAGE_TYPE_ROLE: + return QVariant(m_lMessages[index.row()].message); + break; + case MESSAGE_FROM_ROLE: + return QVariant(m_lMessages[index.row()].from); + break; + case MESSAGE_TEXT_ROLE: + return INCOMMING_IM; + break; + case MESSAGE_CONTACT_ROLE: + if (m_pCall->getContact()) { + return QVariant(); + } + break; + case MESSAGE_IMAGE_ROLE: { + if (m_lImages.find(index) != m_lImages.end()) + return m_lImages[index]; + Contact* c =m_pCall->getContact(); + if (c && c->getPhoto()) { + return QVariant::fromValue<void*>((void*)c->getPhoto()); + } + return QVariant(); + break; + } } - return QVariant(); } return QVariant(); } +///Number of row int InstantMessagingModel::rowCount(const QModelIndex& parent) const { Q_UNUSED(parent) return m_lMessages.size(); } +///Model flags Qt::ItemFlags InstantMessagingModel::flags(const QModelIndex& index) const { Q_UNUSED(index) return Qt::ItemIsEnabled; } +///Set model data bool InstantMessagingModel::setData(const QModelIndex& index, const QVariant &value, int role) { Q_UNUSED(index) @@ -107,19 +128,21 @@ bool InstantMessagingModel::setData(const QModelIndex& index, const QVariant &va return false; } +///Add new incoming message (to be used internally) void InstantMessagingModel::addIncommingMessage(QString from, QString message) { InternalIM im; - im.from = from; + im.from = from; im.message = message; m_lMessages << im; emit dataChanged(index(m_lMessages.size() -1,0), index(m_lMessages.size()-1,0)); } +///Add new outgoing message (to be used internally and externally) void InstantMessagingModel::addOutgoingMessage(QString message) { InternalIM im; - im.from = "Me"; + im.from = "Me"; im.message = message; m_lMessages << im; emit dataChanged(index(m_lMessages.size() -1,0), index(m_lMessages.size()-1,0)); diff --git a/src/InstantMessagingModel.h b/src/InstantMessagingModel.h index 25c9ad381df8f6307346c05dfa74963bbb627975..94f9b573f849553d34e5deb9d742c9426d4aed46 100644 --- a/src/InstantMessagingModel.h +++ b/src/InstantMessagingModel.h @@ -24,20 +24,25 @@ #include "typedefs.h" #include <QtCore/QDebug> +///Represent the direction a message is taking enum MessageRole { - INCOMMING_IM, - OUTGOING_IM, + INCOMMING_IM , + OUTGOING_IM , MIME_TRANSFER, }; +//SFLPhone class Call; class CallModelBase; class InstantMessagingModel; +///Manager for all IM conversations class LIB_EXPORT InstantMessagingModelManager : public QObject { Q_OBJECT public: + + //Singleton static InstantMessagingModelManager* getInstance() { if (!m_spInstance) { m_spInstance = new InstantMessagingModelManager(); @@ -48,49 +53,67 @@ public: m_spCallModel = model; getInstance(); } + + //Getter InstantMessagingModel* getModel(Call* call); private: + //Constructor explicit InstantMessagingModelManager(); + + //Attributes + QHash<QString,InstantMessagingModel*> m_lModels; + + //Static attributes static InstantMessagingModelManager* m_spInstance; static CallModelBase* m_spCallModel; - QHash<QString,InstantMessagingModel*> m_lModels; + + private slots: void newMessage(QString callId, QString from, QString message); + signals: + ///Emitted when a new message is available void newMessagingModel(Call*,InstantMessagingModel*); }; +///Qt model for the Instant Messaging (IM) features class LIB_EXPORT InstantMessagingModel : public QAbstractListModel { Q_OBJECT friend class InstantMessagingModelManager; friend class Call; public: + //Role const static const int MESSAGE_TYPE_ROLE = 100; static const int MESSAGE_FROM_ROLE = 101; static const int MESSAGE_TEXT_ROLE = 102; static const int MESSAGE_IMAGE_ROLE = 103; static const int MESSAGE_CONTACT_ROLE = 104; + //Constructor explicit InstantMessagingModel(Call* call, QObject* parent = nullptr); + + //Abstract model function QVariant data ( const QModelIndex& index, int role = Qt::DisplayRole ) const; int rowCount ( const QModelIndex& parent = QModelIndex() ) const; Qt::ItemFlags flags ( const QModelIndex& index ) const; virtual bool setData ( const QModelIndex& index, const QVariant &value, int role) ; private: + //Private members void addIncommingMessage(QString from, QString message); void addOutgoingMessage(QString message); - + + //Interal struct struct InternalIM { QString from; QString message; }; - QList<InternalIM> m_lMessages; - QHash<QModelIndex,QVariant> m_lImages; - Call* m_pCall; - + + //Attributes + QList<InternalIM> m_lMessages; + QHash<QModelIndex,QVariant> m_lImages ; + Call* m_pCall ; }; - #endif diff --git a/src/VideoCodecModel.cpp b/src/VideoCodecModel.cpp index 5315080b405046ef5b65d55d557f549e13084695..60487a60a3101112d1b3bcfab3f1cd8eec7e6e20 100644 --- a/src/VideoCodecModel.cpp +++ b/src/VideoCodecModel.cpp @@ -60,6 +60,7 @@ bool VideoCodecModel::setData(const QModelIndex& index, const QVariant &value, i else if (index.column() == 0 && role == VideoCodecModel::BITRATE_ROLE) { m_lCodecs[index.row()]->setBitrate(value.toInt()); emit dataChanged(index, index); + return true; } return false; } diff --git a/src/VideoCodecModel.h b/src/VideoCodecModel.h index da105cd988c8cee3a9debc309eef02287879cace..bddcf380a661777c3c1fbd50285b72b719e6cfcc 100644 --- a/src/VideoCodecModel.h +++ b/src/VideoCodecModel.h @@ -32,6 +32,7 @@ class Account; class VideoCodec; typedef QHash<QString,VideoCodec*> CodecHash; +///Abstract model for managing account video codec list class LIB_EXPORT VideoCodecModel : public QAbstractListModel { Q_OBJECT friend class Account; @@ -47,7 +48,7 @@ public: void reload(); void save(); - bool moveUp(QModelIndex idx); + bool moveUp (QModelIndex idx); bool moveDown(QModelIndex idx); private: diff --git a/src/VideoDevice.h b/src/VideoDevice.h index bae8a690db24d0a2780af7edb475a5807dcb24fc..a391423acd0e2709a1113c7624246c9d5d7bb981 100644 --- a/src/VideoDevice.h +++ b/src/VideoDevice.h @@ -19,6 +19,8 @@ #define VIDEO_DEVICE_H #include "typedefs.h" + +//Qt #include <QStringList> #include <QtCore/QSize> diff --git a/src/VideoModel.cpp b/src/VideoModel.cpp index d9f7df49eb1db87f65c77fc7a06e7ae387c4ec3b..d78b42f6c80207d5376e6b051bb0414decfef600 100644 --- a/src/VideoModel.cpp +++ b/src/VideoModel.cpp @@ -97,32 +97,11 @@ void VideoModel::deviceEvent() } -///Return the current resolution -// Resolution VideoModel::getActiveResolution() -// { -// return m_Res; -// } - ///A video is not being rendered void VideoModel::startedDecoding(QString id, QString shmPath, int width, int height) { Q_UNUSED(id) - qDebug() << "PREVIEW ID" << id; -// m_pRenderer->m_ShmPath = shmPath; -// m_Res.width = width ; -// m_Res.height = height ; -// m_pRenderer->m_Width = width ; -// m_pRenderer->m_Height = height ; -// m_pRenderer->m_isRendering = true; -// m_pRenderer->startShm(); - -// if (!m_pTimer) { -// m_pTimer = new QTimer(this); -// connect(m_pTimer,SIGNAL(timeout()),this,SLOT(timedEvents())); -// m_pTimer->setInterval(42); -// } -// m_pTimer->start(); - + if (m_lRenderers[id] == nullptr ) { m_lRenderers[id] = new VideoRenderer(shmPath,Resolution(width,height)); } @@ -132,9 +111,6 @@ void VideoModel::startedDecoding(QString id, QString shmPath, int width, int hei renderer->setResolution(QSize(width,height)); } -// if (!m_pRenderer) -// m_pRenderer = m_lRenderers[id]; - m_lRenderers[id]->startRendering(); if (id != "local") { qDebug() << "Starting video for call" << id; @@ -148,10 +124,6 @@ void VideoModel::stoppedDecoding(QString id, QString shmPath) Q_UNUSED(shmPath) if ( m_lRenderers[id] ) m_lRenderers[id]->stopRendering(); -// m_pRenderer->m_isRendering = false; -// m_pRenderer->stopShm(); qDebug() << "Video stopped for call" << id; emit videoStopped(); -// if (m_pTimer) -// m_pTimer->stop(); } diff --git a/src/VideoRenderer.h b/src/VideoRenderer.h index 828def3878c66c690195fd2b6adff3282a019a79..024b49f94d817fb76bcefb2550bf36c9979782ce 100644 --- a/src/VideoRenderer.h +++ b/src/VideoRenderer.h @@ -32,7 +32,7 @@ struct SHMHeader; ///Manage shared memory and convert it to QByteArray class LIB_EXPORT VideoRenderer : public QObject { Q_OBJECT - + public: //Constructor VideoRenderer (QString shmPath,Resolution res); diff --git a/src/callmanager_interface_singleton.h b/src/callmanager_interface_singleton.h index 48536c066eaf802be3cfb71b40cbf78ee9f1c540..6583fc4e1f0fe46e2b0cc54bbfb3c91b8858e274 100644 --- a/src/callmanager_interface_singleton.h +++ b/src/callmanager_interface_singleton.h @@ -23,15 +23,14 @@ #include "src/lib/callmanager_dbus_interface.h" #include "typedefs.h" +///Singleton to access dbus "CallManager" interface class LIB_EXPORT CallManagerInterfaceSingleton { - -private: - static CallManagerInterface* interface; - public: static CallManagerInterface& getInstance(); +private: + static CallManagerInterface* interface; }; #endif diff --git a/src/configurationmanager_interface_singleton.cpp b/src/configurationmanager_interface_singleton.cpp index de9ccc47b2aec18923ffdc1dac0987d54532075a..da547ff0b082f56645ca9e1fe04278edd87f0c75 100644 --- a/src/configurationmanager_interface_singleton.cpp +++ b/src/configurationmanager_interface_singleton.cpp @@ -16,13 +16,11 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ - - #include "configurationmanager_interface_singleton.h" - +#include "configurationmanager_interface_singleton.h" ConfigurationManagerInterface* ConfigurationManagerInterfaceSingleton::interface = nullptr; -ConfigurationManagerInterface & ConfigurationManagerInterfaceSingleton::getInstance() +ConfigurationManagerInterface& ConfigurationManagerInterfaceSingleton::getInstance() { if (!dbus_metaTypeInit) registerCommTypes(); if (!interface) diff --git a/src/configurationmanager_interface_singleton.h b/src/configurationmanager_interface_singleton.h index a1ab9a32c75f458412df3b42f82c1cd85940efcb..fbe6a4397ff420572211f4a20d93f5889a7649ce 100644 --- a/src/configurationmanager_interface_singleton.h +++ b/src/configurationmanager_interface_singleton.h @@ -16,22 +16,20 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ - #ifndef CONFIGURATION_MANAGER_INTERFACE_SINGLETON_H #define CONFIGURATION_MANAGER_INTERFACE_SINGLETON_H #include "src/lib/configurationmanager_dbus_interface.h" #include "typedefs.h" +///Singleton to access the ConfigurationManager dbus interface class LIB_EXPORT ConfigurationManagerInterfaceSingleton { - -private: - static ConfigurationManagerInterface* interface; - public: static ConfigurationManagerInterface& getInstance(); +private: + static ConfigurationManagerInterface* interface; }; #endif diff --git a/src/instance_interface_singleton.h b/src/instance_interface_singleton.h index d95c19134d6a1a718a566db38d2a97c9b23e89ce..3c8058063999db33d7ff2f4adc7fb7e1b1660bba 100644 --- a/src/instance_interface_singleton.h +++ b/src/instance_interface_singleton.h @@ -28,13 +28,11 @@ */ class LIB_EXPORT InstanceInterfaceSingleton { - -private: - static InstanceInterface* interface; - public: static InstanceInterface& getInstance(); +private: + static InstanceInterface* interface; }; #endif diff --git a/src/video_interface_singleton.cpp b/src/video_interface_singleton.cpp index 6a606cf02e72de029789fb430a7eaa984cbc2ca1..2a77284cc7bb3e9492c6a5df19e66dedaa2c3b0a 100644 --- a/src/video_interface_singleton.cpp +++ b/src/video_interface_singleton.cpp @@ -15,7 +15,6 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ - #include "video_interface_singleton.h" VideoInterface* VideoInterfaceSingleton::interface = nullptr; diff --git a/src/video_interface_singleton.h b/src/video_interface_singleton.h index 874cf0f3420553789c68005f527d901f7f0f17e1..17bb0bc9c18861187677f01b1f653a1c40d79756 100644 --- a/src/video_interface_singleton.h +++ b/src/video_interface_singleton.h @@ -15,7 +15,6 @@ * You should have received a copy of the GNU General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * ***************************************************************************/ - #ifndef VIDEO_INTERFACE_SINGLETON_H #define VIDEO_INTERFACE_SINGLETON_H