Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jami-libclient
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
savoirfairelinux
jami-libclient
Commits
fecd9efe
Commit
fecd9efe
authored
Dec 19, 2013
by
Emmanuel Lepage Vallee
Browse files
Options
Downloads
Patches
Plain Diff
[ #37237 ] Improve security configuration dialog usability
parent
5f38b539
No related branches found
No related tags found
No related merge requests found
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/account.cpp
+11
-2
11 additions, 2 deletions
src/account.cpp
src/account.h
+10
-8
10 additions, 8 deletions
src/account.h
src/keyexchangemodel.cpp
+52
-10
52 additions, 10 deletions
src/keyexchangemodel.cpp
src/keyexchangemodel.h
+33
-7
33 additions, 7 deletions
src/keyexchangemodel.h
with
106 additions
and
27 deletions
src/account.cpp
+
11
−
2
View file @
fecd9efe
...
...
@@ -57,7 +57,8 @@ const account_function Account::stateMachineActionsOnState[6][7] = {
///Constructors
Account
::
Account
()
:
QObject
(
AccountListModel
::
instance
()),
m_pCredentials
(
nullptr
),
m_pAudioCodecs
(
nullptr
),
m_CurrentState
(
AccountEditState
::
READY
),
m_pVideoCodecs
(
nullptr
),
m_LastErrorCode
(
-
1
),
m_VoiceMailCount
(
0
),
m_pRingToneModel
(
nullptr
),
m_pAccountNumber
(
nullptr
)
m_pVideoCodecs
(
nullptr
),
m_LastErrorCode
(
-
1
),
m_VoiceMailCount
(
0
),
m_pRingToneModel
(
nullptr
),
m_pAccountNumber
(
nullptr
),
m_pKeyExchangeModel
(
nullptr
)
{
}
...
...
@@ -303,6 +304,14 @@ RingToneModel* Account::ringToneModel() const
return
m_pRingToneModel
;
}
KeyExchangeModel
*
Account
::
keyExchangeModel
()
const
{
if
(
!
m_pKeyExchangeModel
)
{
const_cast
<
Account
*>
(
this
)
->
m_pKeyExchangeModel
=
new
KeyExchangeModel
(
const_cast
<
Account
*>
(
this
));
}
return
m_pKeyExchangeModel
;
}
void
Account
::
setAlias
(
const
QString
&
detail
)
{
bool
accChanged
=
detail
!=
alias
();
...
...
@@ -1073,7 +1082,7 @@ void Account::setRoleData(int role, const QVariant& value)
}
case
Account
::
Role
::
KeyExchange
:
{
const
int
method
=
value
.
toInt
();
setKeyExchange
(
method
<=
K
eyExchangeModel
::
instance
()
->
rowCount
()
?
static_cast
<
KeyExchangeModel
::
Type
>
(
method
)
:
KeyExchangeModel
::
Type
::
NONE
);
setKeyExchange
(
method
<=
k
eyExchangeModel
()
->
rowCount
()
?
static_cast
<
KeyExchangeModel
::
Type
>
(
method
)
:
KeyExchangeModel
::
Type
::
NONE
);
}
case
Account
::
Role
::
RegistrationExpire
:
setRegistrationExpire
(
value
.
toInt
());
...
...
This diff is collapsed.
Click to expand it.
src/account.h
+
10
−
8
View file @
fecd9efe
...
...
@@ -305,6 +305,7 @@ class LIB_EXPORT Account : public QObject {
Q_INVOKABLE
AudioCodecModel
*
audioCodecModel
()
const
;
Q_INVOKABLE
VideoCodecModel
*
videoCodecModel
()
const
;
Q_INVOKABLE
RingToneModel
*
ringToneModel
()
const
;
Q_INVOKABLE
KeyExchangeModel
*
keyExchangeModel
()
const
;
//Getters
QString
hostname
()
const
;
...
...
@@ -453,6 +454,7 @@ class LIB_EXPORT Account : public QObject {
AudioCodecModel
*
m_pAudioCodecs
;
VideoCodecModel
*
m_pVideoCodecs
;
RingToneModel
*
m_pRingToneModel
;
KeyExchangeModel
*
m_pKeyExchangeModel
;
AccountEditState
m_CurrentState
;
static
const
account_function
stateMachineActionsOnState
[
6
][
7
];
...
...
This diff is collapsed.
Click to expand it.
src/keyexchangemodel.cpp
+
52
−
10
View file @
fecd9efe
...
...
@@ -19,9 +19,19 @@
#include
<QtCore/QCoreApplication>
KeyExchangeModel
*
KeyExchangeModel
::
m_spInstance
=
nullptr
;
#include
"account.h"
KeyExchangeModel
::
KeyExchangeModel
()
:
QAbstractListModel
(
QCoreApplication
::
instance
())
{}
const
TypedStateMachine
<
TypedStateMachine
<
bool
,
KeyExchangeModel
::
Type
>
,
KeyExchangeModel
::
Options
>
KeyExchangeModel
::
availableOptions
=
{{
/* */
/* ZRTP */
/* SDES */
/* NONE */
/* RTP_FALLBACK */
{{
false
,
true
,
false
}},
/* DISPLAY_SAS */
{{
true
,
false
,
false
}},
/* NOT_SUPP_WARNING */
{{
true
,
false
,
false
}},
/* HELLO_HASH */
{{
true
,
false
,
false
}},
/* DISPLAY_SAS_ONCE */
{{
true
,
false
,
false
}},
}};
KeyExchangeModel
::
KeyExchangeModel
(
Account
*
account
)
:
QAbstractListModel
(
account
),
m_pAccount
(
account
)
{}
//Model functions
QVariant
KeyExchangeModel
::
data
(
const
QModelIndex
&
index
,
int
role
)
const
...
...
@@ -39,6 +49,8 @@ QVariant KeyExchangeModel::data( const QModelIndex& index, int role) const
case
KeyExchangeModel
::
Type
::
SDES
:
return
KeyExchangeModel
::
Name
::
SDES
;
break
;
case
KeyExchangeModel
::
Type
::
COUNT
:
break
;
};
}
return
QVariant
();
...
...
@@ -46,7 +58,7 @@ QVariant KeyExchangeModel::data( const QModelIndex& index, int role) const
int
KeyExchangeModel
::
rowCount
(
const
QModelIndex
&
parent
)
const
{
return
parent
.
isValid
()
?
0
:
3
;
return
parent
.
isValid
()
?
0
:
2
;
}
Qt
::
ItemFlags
KeyExchangeModel
::
flags
(
const
QModelIndex
&
index
)
const
...
...
@@ -63,13 +75,6 @@ bool KeyExchangeModel::setData( const QModelIndex& index, const QVariant &value,
return
false
;
}
KeyExchangeModel
*
KeyExchangeModel
::
instance
()
{
if
(
!
m_spInstance
)
m_spInstance
=
new
KeyExchangeModel
();
return
m_spInstance
;
}
///Translate enum type to QModelIndex
QModelIndex
KeyExchangeModel
::
toIndex
(
KeyExchangeModel
::
Type
type
)
const
{
...
...
@@ -89,6 +94,8 @@ const char* KeyExchangeModel::toDaemonName(KeyExchangeModel::Type type)
case
KeyExchangeModel
::
Type
::
SDES
:
return
KeyExchangeModel
::
DaemonName
::
SDES
;
break
;
case
KeyExchangeModel
::
Type
::
COUNT
:
break
;
};
return
nullptr
;
//Cannot heppen
}
...
...
@@ -104,3 +111,38 @@ KeyExchangeModel::Type KeyExchangeModel::fromDaemonName(const QString& name)
qDebug
()
<<
"Undefined Key exchange mechanism"
<<
name
;
return
KeyExchangeModel
::
Type
::
NONE
;
}
void
KeyExchangeModel
::
enableSRTP
(
bool
enable
)
{
if
(
enable
&&
m_pAccount
->
keyExchange
()
==
KeyExchangeModel
::
Type
::
NONE
)
{
m_pAccount
->
setKeyExchange
(
KeyExchangeModel
::
Type
::
ZRTP
);
}
else
if
(
!
enable
)
{
m_pAccount
->
setKeyExchange
(
KeyExchangeModel
::
Type
::
NONE
);
}
}
bool
KeyExchangeModel
::
isRtpFallbackEnabled
()
const
{
return
availableOptions
[
Options
::
RTP_FALLBACK
][
m_pAccount
->
keyExchange
()];
}
bool
KeyExchangeModel
::
isDisplaySASEnabled
()
const
{
return
availableOptions
[
Options
::
DISPLAY_SAS
][
m_pAccount
->
keyExchange
()];
}
bool
KeyExchangeModel
::
isDisplaySasOnce
()
const
{
return
availableOptions
[
Options
::
DISPLAY_SAS_ONCE
][
m_pAccount
->
keyExchange
()];
}
bool
KeyExchangeModel
::
areWarningSupressed
()
const
{
return
availableOptions
[
Options
::
NOT_SUPP_WARNING
][
m_pAccount
->
keyExchange
()];
}
bool
KeyExchangeModel
::
isHelloHashEnabled
()
const
{
return
availableOptions
[
Options
::
HELLO_HASH
][
m_pAccount
->
keyExchange
()];
}
This diff is collapsed.
Click to expand it.
src/keyexchangemodel.h
+
33
−
7
View file @
fecd9efe
...
...
@@ -21,19 +21,33 @@
#include
"typedefs.h"
#include
<QtCore/QAbstractListModel>
class
Account
;
///Static model for handling encryption types
class
LIB_EXPORT
KeyExchangeModel
:
public
QAbstractListModel
{
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
Q_OBJECT
#pragma GCC diagnostic pop
friend
class
Account
;
public:
///@enum Type Every supported encryption types
enum
class
Type
{
NONE
=
0
,
ZRTP
=
1
,
SDES
=
2
,
ZRTP
=
0
,
SDES
=
1
,
NONE
=
2
,
COUNT
,
};
///@enum Options Every Key exchange options
enum
class
Options
{
RTP_FALLBACK
=
0
,
DISPLAY_SAS
=
1
,
NOT_SUPP_WARNING
=
2
,
HELLO_HASH
=
3
,
DISPLAY_SAS_ONCE
=
4
,
COUNT
,
};
class
Name
{
...
...
@@ -51,7 +65,7 @@ public:
};
//Private constructor, can only be called by 'Account'
explicit
KeyExchangeModel
();
explicit
KeyExchangeModel
(
Account
*
account
);
//Model functions
QVariant
data
(
const
QModelIndex
&
index
,
int
role
=
Qt
::
DisplayRole
)
const
;
...
...
@@ -64,11 +78,23 @@ public:
static
const
char
*
toDaemonName
(
KeyExchangeModel
::
Type
type
)
;
static
KeyExchangeModel
::
Type
fromDaemonName
(
const
QString
&
name
)
;
//Singleton
static
KeyExchangeModel
*
instance
();
bool
isRtpFallbackEnabled
()
const
;
bool
isDisplaySASEnabled
()
const
;
bool
isDisplaySasOnce
()
const
;
bool
areWarningSupressed
()
const
;
bool
isHelloHashEnabled
()
const
;
private
:
static
KeyExchangeModel
*
m_spInstance
;
KeyExchangeModel
::
Type
m_CurrentMethod
;
Account
*
m_pAccount
;
static
const
TypedStateMachine
<
TypedStateMachine
<
bool
,
KeyExchangeModel
::
Type
>
,
KeyExchangeModel
::
Options
>
availableOptions
;
public
Q_SLOTS
:
void
enableSRTP
(
bool
enable
);
Q_SIGNALS
:
void
srtpEnabled
(
bool
);
};
Q_DECLARE_METATYPE
(
KeyExchangeModel
*
)
#endif
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment