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

various: Fix various minor issues

* SecurityValidator not initialized
* UserActionModel not initialized
* Video rendering inefisciency

Refs #68325
parent d236417e
Branches
Tags
No related merge requests found
...@@ -144,7 +144,7 @@ Account* AvailableAccountModelPrivate::firstRegisteredAccount(URI::SchemeType ty ...@@ -144,7 +144,7 @@ Account* AvailableAccountModelPrivate::firstRegisteredAccount(URI::SchemeType ty
) )
return current; return current;
} }
return nullptr; return firstRegisteredAccount(); //We need one
} }
QItemSelectionModel* AvailableAccountModel::selectionModel() const QItemSelectionModel* AvailableAccountModel::selectionModel() const
......
...@@ -569,7 +569,6 @@ QMimeData* HistoryModel::mimeData(const QModelIndexList &indexes) const ...@@ -569,7 +569,6 @@ QMimeData* HistoryModel::mimeData(const QModelIndexList &indexes) const
return mimeData2; return mimeData2;
} }
bool HistoryModel::dropMimeData(const QMimeData *mime, Qt::DropAction action, int row, int column, const QModelIndex &parentIdx) bool HistoryModel::dropMimeData(const QMimeData *mime, Qt::DropAction action, int row, int column, const QModelIndex &parentIdx)
{ {
Q_UNUSED(row) Q_UNUSED(row)
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
*/ */
namespace UserActions { namespace UserActions {
bool addNew();
bool accept(const QList<Call*> calls); bool accept(const QList<Call*> calls);
bool hangup(const QList<Call*> calls); bool hangup(const QList<Call*> calls);
bool refuse(const QList<Call*> calls); bool refuse(const QList<Call*> calls);
...@@ -34,15 +35,20 @@ bool unhold(const QList<Call*> calls); ...@@ -34,15 +35,20 @@ bool unhold(const QList<Call*> calls);
bool transfer(const QList<Call*> calls); bool transfer(const QList<Call*> calls);
bool record(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 accept(const QList<Call*> calls)
{ {
bool ret = true; bool ret = true;
//Add a new call if none is there //Add a new call if none is there
if (!calls.size()) { if (!calls.size()) {
Call* call = CallModel::instance()->dialingCall(); return addNew();
CallModel::instance()->selectionModel()->setCurrentIndex(CallModel::instance()->getIndex(call), QItemSelectionModel::ClearAndSelect);
return true;
} }
for (Call* call : calls) { for (Call* call : calls) {
......
...@@ -162,41 +162,42 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri ...@@ -162,41 +162,42 @@ void VideoRendererManagerPrivate::startedDecoding(const QString& id, const QStri
{ {
const QSize res = QSize(width,height); 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) #if defined(Q_OS_DARWIN)
m_lRenderers[id.toLatin1()] = new Video::DirectRenderer(id.toLatin1(), res); m_lRenderers[rid] = new Video::DirectRenderer(rid, res);
#else #else
m_lRenderers[id.toLatin1()] = new Video::ShmRenderer(id.toLatin1(),shmPath,res); m_lRenderers[rid] = new Video::ShmRenderer(rid,shmPath,res);
#endif #endif
m_lRenderers[id.toLatin1()]->moveToThread(q_ptr); m_lRenderers[rid]->moveToThread(q_ptr);
if (!q_ptr->isRunning()) if (!q_ptr->isRunning())
q_ptr->start(); q_ptr->start();
} }
else { else {
// Video::Renderer* Renderer = m_lRenderers[id.toLatin1()]; // Video::Renderer* Renderer = m_lRenderers[rid];
//TODO: do direct renderer stuff here //TODO: do direct renderer stuff here
m_lRenderers[id.toLatin1()]->setSize(res); m_lRenderers[rid]->setSize(res);
#if !defined(Q_OS_DARWIN) #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 #endif
} }
m_lRenderers[id.toLatin1()]->startRendering(); m_lRenderers[rid]->startRendering();
Video::Device* dev = Video::DeviceModel::instance()->getDevice(id); Video::Device* dev = Video::DeviceModel::instance()->getDevice(id);
if (dev) { if (dev) {
emit dev->renderingStarted(m_lRenderers[id.toLatin1()]); emit dev->renderingStarted(m_lRenderers[rid]);
} }
if (id != "local") { if (id != "local") {
qDebug() << "Starting video for call" << id; qDebug() << "Starting video for call" << id;
Call* c = CallModel::instance()->getCall(id); Call* c = CallModel::instance()->getCall(id);
if (c) if (c)
c->d_ptr->registerRenderer(m_lRenderers[id.toLatin1()]); c->d_ptr->registerRenderer(m_lRenderers[rid]);
} }
else { else {
m_PreviewState = true; m_PreviewState = true;
emit q_ptr->previewStateChanged(true); emit q_ptr->previewStateChanged(true);
emit q_ptr->previewStarted(m_lRenderers[id.toLatin1()]); emit q_ptr->previewStarted(m_lRenderers[rid]);
} }
} }
......
...@@ -95,12 +95,17 @@ m_pAccount(account), m_CurrentSecurityLevel(SecurityValidationModel::SecurityLev ...@@ -95,12 +95,17 @@ m_pAccount(account), m_CurrentSecurityLevel(SecurityValidationModel::SecurityLev
SecurityValidationModel::SecurityValidationModel(Account* account) : QAbstractListModel(account), SecurityValidationModel::SecurityValidationModel(Account* account) : QAbstractListModel(account),
d_ptr(new SecurityValidationModelPrivate(account,this)) 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() SecurityValidationModel::~SecurityValidationModel()
{ {
} }
QHash<int,QByteArray> SecurityValidationModel::roleNames() const QHash<int,QByteArray> SecurityValidationModel::roleNames() const
...@@ -162,6 +167,10 @@ SecurityFlaw* SecurityValidationModelPrivate::getFlaw(SecurityValidationModel::A ...@@ -162,6 +167,10 @@ SecurityFlaw* SecurityValidationModelPrivate::getFlaw(SecurityValidationModel::A
#define _F(_se,_ty) getFlaw(SecurityValidationModel::AccountSecurityFlaw::_se,_ty); #define _F(_se,_ty) getFlaw(SecurityValidationModel::AccountSecurityFlaw::_se,_ty);
void SecurityValidationModelPrivate::update() void SecurityValidationModelPrivate::update()
{ {
if (!m_pAccount)
return; //TODO use the local certificates
qDebug() << "\n\n\nUPDATING";
m_lCurrentFlaws.clear(); m_lCurrentFlaws.clear();
/********************************** /**********************************
...@@ -189,7 +198,15 @@ void SecurityValidationModelPrivate::update() ...@@ -189,7 +198,15 @@ void SecurityValidationModelPrivate::update()
* Certificates issues * * Certificates issues *
*********************************/ *********************************/
QList<Certificate*> certs; 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) { foreach (Certificate* cert, certs) {
if (cert->exist() == Certificate::CheckValues::FAILED) { if (cert->exist() == Certificate::CheckValues::FAILED) {
m_lCurrentFlaws << _F(END_CERTIFICATE_MISSING,cert->type()); m_lCurrentFlaws << _F(END_CERTIFICATE_MISSING,cert->type());
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "callmodel.h" #include "callmodel.h"
#include "account.h" #include "account.h"
#include "accountmodel.h" #include "accountmodel.h"
#include "availableaccountmodel.h"
#include "delegates/pixmapmanipulationdelegate.h" #include "delegates/pixmapmanipulationdelegate.h"
#include "private/useractions.h" #include "private/useractions.h"
...@@ -112,7 +113,9 @@ const TypedStateMachine< TypedStateMachine< bool , Call::State > , UserActionMod ...@@ -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}}, /*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 }}, /*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 > ...@@ -130,6 +133,8 @@ const TypedStateMachine< TypedStateMachine< bool , Account::RegistrationState >
/* HANGUP */ {{ true , true , true , true }}, /* HANGUP */ {{ true , true , true , true }},
/* JOIN */ {{ 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 ...@@ -146,6 +151,8 @@ const TypedStateMachine< TypedStateMachine< bool , UserActionModelPrivate::Selec
/* HANGUP */ {{ false, true , true }}, /* HANGUP */ {{ false, true , true }},
/* JOIN */ {{ false, false, true }}, /* JOIN */ {{ false, false, true }},
/* ADD_NEW */ {{ true , false, false }},
}}; }};
/** /**
...@@ -161,6 +168,8 @@ const TypedStateMachine< bool, UserActionModel::Action > UserActionModelPrivate: ...@@ -161,6 +168,8 @@ const TypedStateMachine< bool, UserActionModel::Action > UserActionModelPrivate:
/* HANGUP */ true , /* N/A */ /* HANGUP */ true , /* N/A */
/* JOIN */ true , /* N/A */ /* JOIN */ true , /* N/A */
/* ADD_NEW */ false , /* N/A */
}}; }};
/** /**
...@@ -177,6 +186,8 @@ const TypedStateMachine< TypedStateMachine< bool , Account::Protocol > , UserAct ...@@ -177,6 +186,8 @@ const TypedStateMachine< TypedStateMachine< bool , Account::Protocol > , UserAct
/* HANGUP */ {{ true , true , true }}, /* HANGUP */ {{ true , true , true }},
/* JOIN */ {{ true , true , true }}, /* JOIN */ {{ true , true , true }},
/* ADD_NEW */ {{ true , true , true }},
}}; }};
/** /**
...@@ -197,6 +208,8 @@ const TypedStateMachine< TypedStateMachine< UserActionModel::ActionStatfulnessLe ...@@ -197,6 +208,8 @@ const TypedStateMachine< TypedStateMachine< UserActionModel::ActionStatfulnessLe
/* HANGUP */ {{ ST UNISTATE, ST UNISTATE , ST TRISTATE }}, /* HANGUP */ {{ ST UNISTATE, ST UNISTATE , ST TRISTATE }},
/* JOIN */ {{ ST UNISTATE, ST UNISTATE , ST UNISTATE }}, /* JOIN */ {{ ST UNISTATE, ST UNISTATE , ST UNISTATE }},
/* ADD_NEW */ {{ ST UNISTATE, ST UNISTATE , ST UNISTATE }},
}}; }};
#undef ST #undef ST
...@@ -210,6 +223,8 @@ const TypedStateMachine< QString, UserActionModel::Action> UserActionModelPrivat ...@@ -210,6 +223,8 @@ const TypedStateMachine< QString, UserActionModel::Action> UserActionModelPrivat
/* HANGUP */ QObject::tr("HANGUP" ), /* HANGUP */ QObject::tr("HANGUP" ),
/* JOIN */ QObject::tr("JOIN" ), /* JOIN */ QObject::tr("JOIN" ),
/* JOIN */ QObject::tr("ADD_NEW" ),
}}; }};
UserActionModelPrivate::UserActionModelPrivate(UserActionModel* parent) : QObject(parent),q_ptr(parent), UserActionModelPrivate::UserActionModelPrivate(UserActionModel* parent) : QObject(parent),q_ptr(parent),
...@@ -230,6 +245,7 @@ UserActionModel::UserActionModel(Call* parent) : QAbstractListModel(parent),d_pt ...@@ -230,6 +245,7 @@ UserActionModel::UserActionModel(Call* parent) : QAbstractListModel(parent),d_pt
d_ptr->m_pCall = parent; d_ptr->m_pCall = parent;
connect(AccountModel::instance(), SIGNAL(accountStateChanged(Account*,Account::RegistrationState)), d_ptr.data(), SLOT(slotStateChanged())); 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) ...@@ -245,6 +261,7 @@ UserActionModel::UserActionModel(CallModel* parent) : QAbstractListModel(parent)
connect(parent->selectionModel(), SIGNAL(selectionChanged(QItemSelection,QItemSelection)) , d_ptr.data(), SLOT(updateActions())); 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(parent, SIGNAL(callStateChanged(Call*,Call::State)) , d_ptr.data(), SLOT(updateActions()));
connect(AccountModel::instance(), SIGNAL(accountStateChanged(Account*,Account::RegistrationState)), d_ptr.data(), SLOT(updateActions())); connect(AccountModel::instance(), SIGNAL(accountStateChanged(Account*,Account::RegistrationState)), d_ptr.data(), SLOT(updateActions()));
d_ptr->updateActions();
} }
UserActionModel::~UserActionModel() UserActionModel::~UserActionModel()
...@@ -299,7 +316,7 @@ int UserActionModel::rowCount(const QModelIndex& parent ) const ...@@ -299,7 +316,7 @@ int UserActionModel::rowCount(const QModelIndex& parent ) const
///For now, this model probably wont be used that way ///For now, this model probably wont be used that way
Qt::ItemFlags UserActionModel::flags(const QModelIndex& idx ) const 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; return Qt::NoItemFlags;
UserActionModel::Action action = static_cast<UserActionModel::Action>(idx.row()); UserActionModel::Action action = static_cast<UserActionModel::Action>(idx.row());
...@@ -355,6 +372,9 @@ void UserActionModelPrivate::updateCheckMask(int& ret, UserActionModel::Action a ...@@ -355,6 +372,9 @@ void UserActionModelPrivate::updateCheckMask(int& ret, UserActionModel::Action a
case UserActionModel::Action::JOIN : case UserActionModel::Action::JOIN :
ret += 0; ret += 0;
break; break;
case UserActionModel::Action::ADD_NEW :
ret += 0;
break;
case UserActionModel::Action::COUNT__: case UserActionModel::Action::COUNT__:
break; break;
}; };
...@@ -385,10 +405,17 @@ bool UserActionModelPrivate::updateAction(UserActionModel::Action action) ...@@ -385,10 +405,17 @@ bool UserActionModelPrivate::updateAction(UserActionModel::Action action)
m_SelectionState = CallModel::instance()->selectionModel()->selectedRows().size() > 1 ? SelectionState::MULTI : SelectionState::UNIQUE; m_SelectionState = CallModel::instance()->selectionModel()->selectedRows().size() > 1 ? SelectionState::MULTI : SelectionState::UNIQUE;
//Aggregate and reduce the action state for each selected calls //Aggregate and reduce the action state for each selected calls
for (const QModelIndex& idx : CallModel::instance()->selectionModel()->selectedRows()) { if (CallModel::instance()->selectionModel()->selectedRows().size()) {
const Call* c = qvariant_cast<Call*>(idx.data(static_cast<int>(Call::Role::Object))); for (const QModelIndex& idx : CallModel::instance()->selectionModel()->selectedRows()) {
updateCheckMask ( state ,action, c ); const Call* c = qvariant_cast<Call*>(idx.data(static_cast<int>(Call::Role::Object)));
ret &= updateByCall( action , c ); 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 //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 ...@@ -485,6 +512,10 @@ bool UserActionModel::execute(const UserActionModel::Action action) const
case UserActionModel::Action::JOIN : case UserActionModel::Action::JOIN :
//TODO unimplemented //TODO unimplemented
break; break;
case UserActionModel::Action::ADD_NEW :
if (UserActions::addNew())
d_ptr->updateActions();
break;
case UserActionModel::Action::COUNT__: case UserActionModel::Action::COUNT__:
break; break;
}; };
......
...@@ -70,6 +70,9 @@ public: ...@@ -70,6 +70,9 @@ public:
//Multi selection //Multi selection
JOIN , /*!< [Stateful] Join all seclect calls into a conference */ JOIN , /*!< [Stateful] Join all seclect calls into a conference */
//No selection
ADD_NEW , /*!< Add a new call */
COUNT__, COUNT__,
}; };
Q_ENUMS(Action) Q_ENUMS(Action)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment