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
)
return current;
}
return nullptr;
return firstRegisteredAccount(); //We need one
}
QItemSelectionModel* AvailableAccountModel::selectionModel() const
......
......@@ -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)
......
......@@ -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) {
......
......@@ -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]);
}
}
......
......@@ -95,7 +95,12 @@ 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()
......@@ -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());
......
......@@ -26,6 +26,7 @@
#include "callmodel.h"
#include "account.h"
#include "accountmodel.h"
#include "availableaccountmodel.h"
#include "delegates/pixmapmanipulationdelegate.h"
#include "private/useractions.h"
......@@ -113,6 +114,8 @@ const TypedStateMachine< TypedStateMachine< bool , Call::State > , UserActionMod
/*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}},
/*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,11 +405,18 @@ 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
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
m_CurrentActionsState[action] = (state % 100 && state / 100) ? Qt::PartiallyChecked : (state / 100 ? Qt::Checked : Qt::Unchecked);
......@@ -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;
};
......
......@@ -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)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment