Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
1439b8e8
Commit
1439b8e8
authored
13 years ago
by
Emmanuel Lepage
Browse files
Options
Downloads
Patches
Plain Diff
[ #12352 ] Improve model code quality
parent
443dbb4c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
kde/src/lib/CallModel.cpp
+56
-22
56 additions, 22 deletions
kde/src/lib/CallModel.cpp
kde/src/lib/CallModel.h
+10
-9
10 additions, 9 deletions
kde/src/lib/CallModel.h
with
66 additions
and
31 deletions
kde/src/lib/CallModel.cpp
+
56
−
22
View file @
1439b8e8
...
@@ -26,6 +26,7 @@ bool CallModelBase::dbusInit = false;
...
@@ -26,6 +26,7 @@ bool CallModelBase::dbusInit = false;
CallMap
CallModelBase
::
m_sActiveCalls
;
CallMap
CallModelBase
::
m_sActiveCalls
;
AccountList
*
CallModelBase
::
m_spAccountList
=
NULL
;
AccountList
*
CallModelBase
::
m_spAccountList
=
NULL
;
///Constructor
CallModelBase
::
CallModelBase
(
QObject
*
parent
)
:
QObject
(
parent
)
CallModelBase
::
CallModelBase
(
QObject
*
parent
)
:
QObject
(
parent
)
{
{
if
(
!
dbusInit
)
{
if
(
!
dbusInit
)
{
...
@@ -33,13 +34,13 @@ CallModelBase::CallModelBase(QObject* parent) : QObject(parent)
...
@@ -33,13 +34,13 @@ CallModelBase::CallModelBase(QObject* parent) : QObject(parent)
//SLOTS
//SLOTS
// SENDER SIGNAL RECEIVER SLOT /
// SENDER SIGNAL RECEIVER SLOT /
/**/
connect
(
&
callManager
,
SIGNAL
(
callStateChanged
(
const
QString
&
,
const
QString
&
)
),
this
,
SLOT
(
on1_
callStateChanged
(
const
QString
&
,
const
QString
&
)
)
);
/**/
connect
(
&
callManager
,
SIGNAL
(
callStateChanged
(
const
QString
&
,
const
QString
&
)
),
this
,
SLOT
(
callStateChanged
(
const
QString
&
,
const
QString
&
)
)
);
/**/
connect
(
&
callManager
,
SIGNAL
(
incomingCall
(
const
QString
&
,
const
QString
&
,
const
QString
&
)
),
this
,
SLOT
(
on1_
incomingCall
(
const
QString
&
,
const
QString
&
)
)
);
/**/
connect
(
&
callManager
,
SIGNAL
(
incomingCall
(
const
QString
&
,
const
QString
&
,
const
QString
&
)
),
this
,
SLOT
(
incomingCall
(
const
QString
&
,
const
QString
&
)
)
);
/**/
connect
(
&
callManager
,
SIGNAL
(
conferenceCreated
(
const
QString
&
)
),
this
,
SLOT
(
on1_
incomingConference
(
const
QString
&
)
)
);
/**/
connect
(
&
callManager
,
SIGNAL
(
conferenceCreated
(
const
QString
&
)
),
this
,
SLOT
(
incomingConference
(
const
QString
&
)
)
);
/**/
connect
(
&
callManager
,
SIGNAL
(
conferenceChanged
(
const
QString
&
,
const
QString
&
)
),
this
,
SLOT
(
on1_
changingConference
(
const
QString
&
,
const
QString
&
)
)
);
/**/
connect
(
&
callManager
,
SIGNAL
(
conferenceChanged
(
const
QString
&
,
const
QString
&
)
),
this
,
SLOT
(
changingConference
(
const
QString
&
,
const
QString
&
)
)
);
/**/
connect
(
&
callManager
,
SIGNAL
(
conferenceRemoved
(
const
QString
&
)
),
this
,
SLOT
(
on1_
conferenceRemoved
(
const
QString
&
)
)
);
/**/
connect
(
&
callManager
,
SIGNAL
(
conferenceRemoved
(
const
QString
&
)
),
this
,
SLOT
(
conferenceRemoved
(
const
QString
&
)
)
);
/**/
connect
(
&
callManager
,
SIGNAL
(
voiceMailNotify
(
const
QString
&
,
int
)
),
this
,
SLOT
(
on1_
voiceMailNotify
(
const
QString
&
,
int
)
)
);
/**/
connect
(
&
callManager
,
SIGNAL
(
voiceMailNotify
(
const
QString
&
,
int
)
),
this
,
SLOT
(
voiceMailNotify
(
const
QString
&
,
int
)
)
);
/**/
connect
(
&
callManager
,
SIGNAL
(
volumeChanged
(
const
QString
&
,
double
)
),
this
,
SLOT
(
on1_
volumeChanged
(
const
QString
&
,
double
)
)
);
/**/
connect
(
&
callManager
,
SIGNAL
(
volumeChanged
(
const
QString
&
,
double
)
),
this
,
SLOT
(
volumeChanged
(
const
QString
&
,
double
)
)
);
/* */
/* */
connect
(
HistoryModel
::
self
(),
SIGNAL
(
newHistoryCall
(
Call
*
)),
this
,
SLOT
(
addPrivateCall
(
Call
*
)));
connect
(
HistoryModel
::
self
(),
SIGNAL
(
newHistoryCall
(
Call
*
)),
this
,
SLOT
(
addPrivateCall
(
Call
*
)));
...
@@ -53,13 +54,15 @@ CallModelBase::CallModelBase(QObject* parent) : QObject(parent)
...
@@ -53,13 +54,15 @@ CallModelBase::CallModelBase(QObject* parent) : QObject(parent)
}
}
}
}
///Destructor
CallModelBase
::~
CallModelBase
()
CallModelBase
::~
CallModelBase
()
{
{
if
(
m_spAccountList
)
delete
m_spAccountList
;
if
(
m_spAccountList
)
delete
m_spAccountList
;
m_spAccountList
=
NULL
;
m_spAccountList
=
NULL
;
}
}
void
CallModelBase
::
on1_callStateChanged
(
const
QString
&
callID
,
const
QString
&
state
)
///When a call state change
void
CallModelBase
::
callStateChanged
(
const
QString
&
callID
,
const
QString
&
state
)
{
{
//This code is part of the CallModel iterface too
//This code is part of the CallModel iterface too
qDebug
()
<<
"Call State Changed for call "
<<
callID
<<
" . New state : "
<<
state
;
qDebug
()
<<
"Call State Changed for call "
<<
callID
<<
" . New state : "
<<
state
;
...
@@ -87,7 +90,15 @@ void CallModelBase::on1_callStateChanged(const QString &callID, const QString &s
...
@@ -87,7 +90,15 @@ void CallModelBase::on1_callStateChanged(const QString &callID, const QString &s
}
}
void
CallModelBase
::
on1_incomingCall
(
const
QString
&
accountID
,
const
QString
&
callID
)
/*****************************************************************************
* *
* Slots *
* *
****************************************************************************/
///When a new call is incoming
void
CallModelBase
::
incomingCall
(
const
QString
&
accountID
,
const
QString
&
callID
)
{
{
Q_UNUSED
(
accountID
)
Q_UNUSED
(
accountID
)
qDebug
()
<<
"Signal : Incoming Call ! ID = "
<<
callID
;
qDebug
()
<<
"Signal : Incoming Call ! ID = "
<<
callID
;
...
@@ -96,14 +107,16 @@ void CallModelBase::on1_incomingCall(const QString & accountID, const QString &
...
@@ -96,14 +107,16 @@ void CallModelBase::on1_incomingCall(const QString & accountID, const QString &
emit
incomingCall
(
call
);
emit
incomingCall
(
call
);
}
}
void
CallModelBase
::
on1_incomingConference
(
const
QString
&
confID
)
///When a new conference is incoming
void
CallModelBase
::
incomingConference
(
const
QString
&
confID
)
{
{
Call
*
conf
=
addConference
(
confID
);
Call
*
conf
=
addConference
(
confID
);
qDebug
()
<<
"---------------Adding conference"
<<
conf
<<
confID
<<
"---------------"
;
qDebug
()
<<
"---------------Adding conference"
<<
conf
<<
confID
<<
"---------------"
;
emit
conferenceCreated
(
conf
);
emit
conferenceCreated
(
conf
);
}
}
void
CallModelBase
::
on1_changingConference
(
const
QString
&
confID
,
const
QString
&
state
)
///When a conference change
void
CallModelBase
::
changingConference
(
const
QString
&
confID
,
const
QString
&
state
)
{
{
Call
*
conf
=
getCall
(
confID
);
Call
*
conf
=
getCall
(
confID
);
qDebug
()
<<
"Changing conference state"
<<
conf
<<
confID
;
qDebug
()
<<
"Changing conference state"
<<
conf
<<
confID
;
...
@@ -117,7 +130,8 @@ void CallModelBase::on1_changingConference(const QString &confID, const QString
...
@@ -117,7 +130,8 @@ void CallModelBase::on1_changingConference(const QString &confID, const QString
}
}
}
}
void
CallModelBase
::
on1_conferenceRemoved
(
const
QString
&
confId
)
///When a conference is removed
void
CallModelBase
::
conferenceRemoved
(
const
QString
&
confId
)
{
{
Call
*
conf
=
getCall
(
confId
);
Call
*
conf
=
getCall
(
confId
);
emit
aboutToRemoveConference
(
conf
);
emit
aboutToRemoveConference
(
conf
);
...
@@ -125,17 +139,20 @@ void CallModelBase::on1_conferenceRemoved(const QString &confId)
...
@@ -125,17 +139,20 @@ void CallModelBase::on1_conferenceRemoved(const QString &confId)
emit
conferenceRemoved
(
confId
);
emit
conferenceRemoved
(
confId
);
}
}
void
CallModelBase
::
on1_voiceMailNotify
(
const
QString
&
accountID
,
int
count
)
///When a new voice mail is available
void
CallModelBase
::
voiceMailNotify
(
const
QString
&
accountID
,
int
count
)
{
{
qDebug
()
<<
"Signal : VoiceMail Notify ! "
<<
count
<<
" new voice mails for account "
<<
accountID
;
qDebug
()
<<
"Signal : VoiceMail Notify ! "
<<
count
<<
" new voice mails for account "
<<
accountID
;
emit
voiceMailNotify
(
accountID
,
count
);
emit
voiceMailNotify
(
accountID
,
count
);
}
}
void
CallModelBase
::
on1_volumeChanged
(
const
QString
&
device
,
double
value
)
///When the daemon change the volume
void
CallModelBase
::
volumeChanged
(
const
QString
&
device
,
double
value
)
{
{
emit
volumeChanged
(
device
,
value
);
emit
volumeChanged
(
device
,
value
);
}
}
///Add a call to the model (reimplemented in .hpp)
Call
*
CallModelBase
::
addCall
(
Call
*
call
,
Call
*
parent
)
Call
*
CallModelBase
::
addCall
(
Call
*
call
,
Call
*
parent
)
{
{
if
(
call
->
getCurrentState
()
!=
CALL_STATE_OVER
)
if
(
call
->
getCurrentState
()
!=
CALL_STATE_OVER
)
...
@@ -145,12 +162,14 @@ Call* CallModelBase::addCall(Call* call, Call* parent)
...
@@ -145,12 +162,14 @@ Call* CallModelBase::addCall(Call* call, Call* parent)
return
call
;
return
call
;
}
}
///Emit conference created signal
Call
*
CallModelBase
::
addConferenceS
(
Call
*
conf
)
Call
*
CallModelBase
::
addConferenceS
(
Call
*
conf
)
{
{
emit
conferenceCreated
(
conf
);
emit
conferenceCreated
(
conf
);
return
conf
;
return
conf
;
}
}
///Account status changed
void
CallModelBase
::
accountChanged
(
const
QString
&
account
,
const
QString
&
state
,
int
code
)
void
CallModelBase
::
accountChanged
(
const
QString
&
account
,
const
QString
&
state
,
int
code
)
{
{
Q_UNUSED
(
code
)
Q_UNUSED
(
code
)
...
@@ -160,6 +179,21 @@ void CallModelBase::accountChanged(const QString& account,const QString& state,
...
@@ -160,6 +179,21 @@ void CallModelBase::accountChanged(const QString& account,const QString& state,
}
}
}
}
///Remove it from active calls
void
CallModelBase
::
removeActiveCall
(
Call
*
call
)
{
Q_UNUSED
(
call
);
//There is a race condition
//m_sActiveCalls[call->getCallId()] = nullptr;
}
/*****************************************************************************
* *
* Getter *
* *
****************************************************************************/
///Return a list of registered accounts
///Return a list of registered accounts
AccountList
*
CallModelBase
::
getAccountList
()
AccountList
*
CallModelBase
::
getAccountList
()
{
{
...
@@ -169,14 +203,14 @@ AccountList* CallModelBase::getAccountList()
...
@@ -169,14 +203,14 @@ AccountList* CallModelBase::getAccountList()
return
m_spAccountList
;
return
m_spAccountList
;
}
}
///Remove it from active calls
void
CallModelBase
::
removeActiveCall
(
Call
*
call
)
{
Q_UNUSED
(
call
);
//There is a race condition
//m_sActiveCalls[call->getCallId()] = nullptr;
}
/*****************************************************************************
* *
* Setters *
* *
****************************************************************************/
///Add call slot
void
CallModelBase
::
addPrivateCall
(
Call
*
call
)
{
void
CallModelBase
::
addPrivateCall
(
Call
*
call
)
{
addCall
(
call
,
0
);
addCall
(
call
,
0
);
}
}
...
...
This diff is collapsed.
Click to expand it.
kde/src/lib/CallModel.h
+
10
−
9
View file @
1439b8e8
...
@@ -40,6 +40,7 @@ class Account;
...
@@ -40,6 +40,7 @@ class Account;
class
ContactBackend
;
class
ContactBackend
;
class
HistoryModel
;
class
HistoryModel
;
//Typedef
typedef
QMap
<
QString
,
Call
*>
CallMap
;
typedef
QMap
<
QString
,
Call
*>
CallMap
;
typedef
QList
<
Call
*>
CallList
;
typedef
QList
<
Call
*>
CallList
;
...
@@ -64,13 +65,13 @@ public:
...
@@ -64,13 +65,13 @@ public:
static
AccountList
*
getAccountList
(
);
static
AccountList
*
getAccountList
(
);
public
slots
:
public
slots
:
void
on1_
callStateChanged
(
const
QString
&
callID
,
const
QString
&
state
);
void
callStateChanged
(
const
QString
&
callID
,
const
QString
&
state
);
void
on1_
incomingCall
(
const
QString
&
accountID
,
const
QString
&
callID
);
void
incomingCall
(
const
QString
&
accountID
,
const
QString
&
callID
);
void
on1_
incomingConference
(
const
QString
&
confID
);
void
incomingConference
(
const
QString
&
confID
);
void
on1_
changingConference
(
const
QString
&
confID
,
const
QString
&
state
);
void
changingConference
(
const
QString
&
confID
,
const
QString
&
state
);
void
on1_
conferenceRemoved
(
const
QString
&
confId
);
void
conferenceRemoved
(
const
QString
&
confId
);
void
on1_
voiceMailNotify
(
const
QString
&
accountID
,
int
count
);
void
voiceMailNotify
(
const
QString
&
accountID
,
int
count
);
void
on1_
volumeChanged
(
const
QString
&
device
,
double
value
);
void
volumeChanged
(
const
QString
&
device
,
double
value
);
protected:
protected:
static
CallMap
m_sActiveCalls
;
static
CallMap
m_sActiveCalls
;
...
...
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