diff --git a/src/availableaccountmodel.cpp b/src/availableaccountmodel.cpp index e37a1fdb54b29afff45e5a9e545f6cec9fc27592..4094e39785518b3a9135e5fa01e2083de6406119 100644 --- a/src/availableaccountmodel.cpp +++ b/src/availableaccountmodel.cpp @@ -144,7 +144,7 @@ Account* AvailableAccountModelPrivate::firstRegisteredAccount(URI::SchemeType ty ) return current; } - return nullptr; + return firstRegisteredAccount(); //We need one } QItemSelectionModel* AvailableAccountModel::selectionModel() const diff --git a/src/historymodel.cpp b/src/historymodel.cpp index 4d81506ba9a2db054a1d175100c9323d015d584d..090414ec1afa69debe2e2c9b5f2172764469681e 100644 --- a/src/historymodel.cpp +++ b/src/historymodel.cpp @@ -569,7 +569,6 @@ QMimeData* HistoryModel::mimeData(const QModelIndexList &indexes) const return mimeData2; } - bool HistoryModel::dropMimeData(const QMimeData *mime, Qt::DropAction action, int row, int column, const QModelIndex &parentIdx) { Q_UNUSED(row) diff --git a/src/private/useractions.h b/src/private/useractions.h index 46f81d683fb0892089b0d21f8518be2d57d7290c..e9bc776d105f177904db6c1cbf214d50f8c1a95c 100644 --- a/src/private/useractions.h +++ b/src/private/useractions.h @@ -26,6 +26,7 @@ */ namespace UserActions { +bool addNew(); bool accept(const QList<Call*> calls); bool hangup(const QList<Call*> calls); bool refuse(const QList<Call*> calls); @@ -34,15 +35,20 @@ bool unhold(const QList<Call*> calls); bool transfer(const QList<Call*> calls); bool record(const QList<Call*> calls); +bool addNew() +{ + Call* call = CallModel::instance()->dialingCall(); + CallModel::instance()->selectionModel()->setCurrentIndex(CallModel::instance()->getIndex(call), QItemSelectionModel::ClearAndSelect); + return true; +} + bool accept(const QList<Call*> calls) { bool ret = true; //Add a new call if none is there if (!calls.size()) { - Call* call = CallModel::instance()->dialingCall(); - CallModel::instance()->selectionModel()->setCurrentIndex(CallModel::instance()->getIndex(call), QItemSelectionModel::ClearAndSelect); - return true; + return addNew(); } for (Call* call : calls) { diff --git a/src/private/videorenderermanager.cpp b/src/private/videorenderermanager.cpp index 4086b791f3d60c68bbd010fd415330f12aa1d03d..f6aa8117694b3e2ca3d6d34fb0521696be2db711 100644 --- a/src/private/videorenderermanager.cpp +++ b/src/private/videorenderermanager.cpp @@ -162,41 +162,42 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri { const QSize res = QSize(width,height); + const QByteArray rid = id.toLatin1(); - if (m_lRenderers[id.toLatin1()] == nullptr ) { + if (m_lRenderers[rid] == nullptr ) { #if defined(Q_OS_DARWIN) - m_lRenderers[id.toLatin1()] = new Video::DirectRenderer(id.toLatin1(), res); + m_lRenderers[rid] = new Video::DirectRenderer(rid, res); #else - m_lRenderers[id.toLatin1()] = new Video::ShmRenderer(id.toLatin1(),shmPath,res); + m_lRenderers[rid] = new Video::ShmRenderer(rid,shmPath,res); #endif - m_lRenderers[id.toLatin1()]->moveToThread(q_ptr); + m_lRenderers[rid]->moveToThread(q_ptr); if (!q_ptr->isRunning()) q_ptr->start(); } else { - // Video::Renderer* Renderer = m_lRenderers[id.toLatin1()]; + // Video::Renderer* Renderer = m_lRenderers[rid]; //TODO: do direct renderer stuff here - m_lRenderers[id.toLatin1()]->setSize(res); + m_lRenderers[rid]->setSize(res); #if !defined(Q_OS_DARWIN) - static_cast<Video::ShmRenderer*>(m_lRenderers[id.toLatin1()])->setShmPath(shmPath); + static_cast<Video::ShmRenderer*>(m_lRenderers[rid])->setShmPath(shmPath); #endif } - m_lRenderers[id.toLatin1()]->startRendering(); + m_lRenderers[rid]->startRendering(); Video::Device* dev = Video::DeviceModel::instance()->getDevice(id); if (dev) { - emit dev->renderingStarted(m_lRenderers[id.toLatin1()]); + emit dev->renderingStarted(m_lRenderers[rid]); } if (id != "local") { qDebug() << "Starting video for call" << id; Call* c = CallModel::instance()->getCall(id); if (c) - c->d_ptr->registerRenderer(m_lRenderers[id.toLatin1()]); + c->d_ptr->registerRenderer(m_lRenderers[rid]); } else { m_PreviewState = true; emit q_ptr->previewStateChanged(true); - emit q_ptr->previewStarted(m_lRenderers[id.toLatin1()]); + emit q_ptr->previewStarted(m_lRenderers[rid]); } } diff --git a/src/securityvalidationmodel.cpp b/src/securityvalidationmodel.cpp index 0d3439a38c07ccd25d71e8965d72c1fb3c3d190a..3706af18f1f3be9ca9083bef62c2bd689131c46f 100644 --- a/src/securityvalidationmodel.cpp +++ b/src/securityvalidationmodel.cpp @@ -95,12 +95,17 @@ m_pAccount(account), m_CurrentSecurityLevel(SecurityValidationModel::SecurityLev SecurityValidationModel::SecurityValidationModel(Account* account) : QAbstractListModel(account), d_ptr(new SecurityValidationModelPrivate(account,this)) { - + if (account) { + d_ptr->m_pCa = d_ptr->m_pAccount->tlsCaListCertificate (); + d_ptr->m_pCert = d_ptr->m_pAccount->tlsCertificate (); + d_ptr->m_pPrivateKey = d_ptr->m_pAccount->tlsPrivateKeyCertificate(); + d_ptr->update(); + } } SecurityValidationModel::~SecurityValidationModel() { - + } QHash<int,QByteArray> SecurityValidationModel::roleNames() const @@ -162,6 +167,10 @@ SecurityFlaw* SecurityValidationModelPrivate::getFlaw(SecurityValidationModel::A #define _F(_se,_ty) getFlaw(SecurityValidationModel::AccountSecurityFlaw::_se,_ty); void SecurityValidationModelPrivate::update() { + if (!m_pAccount) + return; //TODO use the local certificates + qDebug() << "\n\n\nUPDATING"; + m_lCurrentFlaws.clear(); /********************************** @@ -189,7 +198,15 @@ void SecurityValidationModelPrivate::update() * Certificates issues * *********************************/ QList<Certificate*> certs; - certs << m_pAccount->tlsCaListCertificate() << m_pAccount->tlsCertificate() << m_pAccount->tlsPrivateKeyCertificate(); + if (m_pCa) + certs << m_pCa; + + if (m_pCert) + certs << m_pCert; + +// if (m_pPrivateKey) +// certs << m_pPrivateKey; + foreach (Certificate* cert, certs) { if (cert->exist() == Certificate::CheckValues::FAILED) { m_lCurrentFlaws << _F(END_CERTIFICATE_MISSING,cert->type()); diff --git a/src/useractionmodel.cpp b/src/useractionmodel.cpp index 537ea8ab461a536cd97b3f608a256cbd2a9fa4e9..e1fa7d46bd2470830e10aa2bd165f493f8198e5d 100644 --- a/src/useractionmodel.cpp +++ b/src/useractionmodel.cpp @@ -26,6 +26,7 @@ #include "callmodel.h" #include "account.h" #include "accountmodel.h" +#include "availableaccountmodel.h" #include "delegates/pixmapmanipulationdelegate.h" #include "private/useractions.h" @@ -112,7 +113,9 @@ const TypedStateMachine< TypedStateMachine< bool , Call::State > , UserActionMod /*RECORD */ {{ false , true , true , false, true , false, false, true , true , false, false, true , true , false}}, /*HANGUP */ {{ true , true , true , true , true , true , true , true , true , false, true , true , true , true }}, - /*JOIN */ {{ false , true , true , false, true , false, false, true , true , false, false, true , true , false }}, + /*JOIN */ {{ false , true , true , false, true , false, false, true , true , false, false, true , true , false}}, + + /*ADD_NEW */ {{ false , false, false, false, false, false, false, false, false, false, false, false, false, false}}, }}; /** @@ -130,6 +133,8 @@ const TypedStateMachine< TypedStateMachine< bool , Account::RegistrationState > /* HANGUP */ {{ true , true , true , true }}, /* JOIN */ {{ true , true , true , true }}, + + /* ADD_NEW */ {{ true , false, true , true }}, }}; /** @@ -146,6 +151,8 @@ const TypedStateMachine< TypedStateMachine< bool , UserActionModelPrivate::Selec /* HANGUP */ {{ false, true , true }}, /* JOIN */ {{ false, false, true }}, + + /* ADD_NEW */ {{ true , false, false }}, }}; /** @@ -161,6 +168,8 @@ const TypedStateMachine< bool, UserActionModel::Action > UserActionModelPrivate: /* HANGUP */ true , /* N/A */ /* JOIN */ true , /* N/A */ + + /* ADD_NEW */ false , /* N/A */ }}; /** @@ -177,6 +186,8 @@ const TypedStateMachine< TypedStateMachine< bool , Account::Protocol > , UserAct /* HANGUP */ {{ true , true , true }}, /* JOIN */ {{ true , true , true }}, + + /* ADD_NEW */ {{ true , true , true }}, }}; /** @@ -197,6 +208,8 @@ const TypedStateMachine< TypedStateMachine< UserActionModel::ActionStatfulnessLe /* HANGUP */ {{ ST UNISTATE, ST UNISTATE , ST TRISTATE }}, /* JOIN */ {{ ST UNISTATE, ST UNISTATE , ST UNISTATE }}, + + /* ADD_NEW */ {{ ST UNISTATE, ST UNISTATE , ST UNISTATE }}, }}; #undef ST @@ -210,6 +223,8 @@ const TypedStateMachine< QString, UserActionModel::Action> UserActionModelPrivat /* HANGUP */ QObject::tr("HANGUP" ), /* JOIN */ QObject::tr("JOIN" ), + + /* JOIN */ QObject::tr("ADD_NEW" ), }}; UserActionModelPrivate::UserActionModelPrivate(UserActionModel* parent) : QObject(parent),q_ptr(parent), @@ -230,6 +245,7 @@ UserActionModel::UserActionModel(Call* parent) : QAbstractListModel(parent),d_pt d_ptr->m_pCall = parent; connect(AccountModel::instance(), SIGNAL(accountStateChanged(Account*,Account::RegistrationState)), d_ptr.data(), SLOT(slotStateChanged())); + d_ptr->updateActions(); } /** @@ -245,6 +261,7 @@ UserActionModel::UserActionModel(CallModel* parent) : QAbstractListModel(parent) connect(parent->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)) , d_ptr.data(), SLOT(updateActions())); connect(parent, SIGNAL(callStateChanged(Call*,Call::State)) , d_ptr.data(), SLOT(updateActions())); connect(AccountModel::instance(), SIGNAL(accountStateChanged(Account*,Account::RegistrationState)), d_ptr.data(), SLOT(updateActions())); + d_ptr->updateActions(); } UserActionModel::~UserActionModel() @@ -299,7 +316,7 @@ int UserActionModel::rowCount(const QModelIndex& parent ) const ///For now, this model probably wont be used that way Qt::ItemFlags UserActionModel::flags(const QModelIndex& idx ) const { - if (!idx.isValid() && (idx.row()>=0 && idx.row() < enum_class_size<UserActionModel::Action>())) + if ((!idx.isValid()) || !(idx.row()>=0 && idx.row() < enum_class_size<UserActionModel::Action>())) return Qt::NoItemFlags; UserActionModel::Action action = static_cast<UserActionModel::Action>(idx.row()); @@ -355,6 +372,9 @@ void UserActionModelPrivate::updateCheckMask(int& ret, UserActionModel::Action a case UserActionModel::Action::JOIN : ret += 0; break; + case UserActionModel::Action::ADD_NEW : + ret += 0; + break; case UserActionModel::Action::COUNT__: break; }; @@ -385,10 +405,17 @@ bool UserActionModelPrivate::updateAction(UserActionModel::Action action) m_SelectionState = CallModel::instance()->selectionModel()->selectedRows().size() > 1 ? SelectionState::MULTI : SelectionState::UNIQUE; //Aggregate and reduce the action state for each selected calls - for (const QModelIndex& idx : CallModel::instance()->selectionModel()->selectedRows()) { - const Call* c = qvariant_cast<Call*>(idx.data(static_cast<int>(Call::Role::Object))); - updateCheckMask ( state ,action, c ); - ret &= updateByCall( action , c ); + if (CallModel::instance()->selectionModel()->selectedRows().size()) { + for (const QModelIndex& idx : CallModel::instance()->selectionModel()->selectedRows()) { + const Call* c = qvariant_cast<Call*>(idx.data(static_cast<int>(Call::Role::Object))); + updateCheckMask ( state ,action, c ); + ret &= updateByCall( action , c ); + } + } + else { + Account* a = AvailableAccountModel::instance()->currentDefaultAccount(); + ret = multi_call_options[action][UserActionModelPrivate::SelectionState::NONE] + && (a?availableAccountActionMap[action][a->registrationState()]:false); } //Detect if the multiple selection has mismatching item states, disable it if necessary @@ -485,6 +512,10 @@ bool UserActionModel::execute(const UserActionModel::Action action) const case UserActionModel::Action::JOIN : //TODO unimplemented break; + case UserActionModel::Action::ADD_NEW : + if (UserActions::addNew()) + d_ptr->updateActions(); + break; case UserActionModel::Action::COUNT__: break; }; diff --git a/src/useractionmodel.h b/src/useractionmodel.h index 1e953fa4985721cbe9a9de0e9e1eac94885206e1..fa8ef082bfa2c4f4355726014b7618212dc233f5 100644 --- a/src/useractionmodel.h +++ b/src/useractionmodel.h @@ -70,6 +70,9 @@ public: //Multi selection JOIN , /*!< [Stateful] Join all seclect calls into a conference */ + + //No selection + ADD_NEW , /*!< Add a new call */ COUNT__, }; Q_ENUMS(Action)