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
89c6de0b
Commit
89c6de0b
authored
13 years ago
by
Rafaël Carré
Browse files
Options
Downloads
Patches
Plain Diff
simplify history serialization and remove some debug
parent
257a662d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
daemon/src/history/historyitem.cpp
+47
-80
47 additions, 80 deletions
daemon/src/history/historyitem.cpp
daemon/src/history/historymanager.cpp
+4
-13
4 additions, 13 deletions
daemon/src/history/historymanager.cpp
with
51 additions
and
93 deletions
daemon/src/history/historyitem.cpp
+
47
−
80
View file @
89c6de0b
...
...
@@ -36,7 +36,6 @@
#include
<manager.h>
#define ITEM_SEPARATOR "|"
#define EMPTY_STRING "empty"
HistoryItem
::
HistoryItem
(
std
::
string
timestamp_start
,
CallType
call_type
,
std
::
string
timestamp_stop
,
std
::
string
name
,
std
::
string
number
,
std
::
string
id
,
std
::
string
account_id
,
std
::
string
recording
,
std
::
string
confID
,
std
::
string
timeAdded
)
:
_timestamp_start
(
timestamp_start
),
...
...
@@ -55,57 +54,40 @@ HistoryItem::HistoryItem (std::string timestamp_start, CallType call_type, std::
HistoryItem
::
HistoryItem
(
std
::
string
serialized_form
)
{
size_t
pos
;
std
::
string
tmp
,
type
,
name
,
number
,
start
,
stop
,
id
,
account
,
recordFile
;
std
::
string
confID
,
timeAdded
;
int
indice
=
0
;
while
(
serialized_form
.
find
(
ITEM_SEPARATOR
,
0
)
!=
std
::
string
::
npos
)
{
pos
=
serialized_form
.
find
(
ITEM_SEPARATOR
,
0
);
tmp
=
serialized_form
.
substr
(
0
,
pos
);
size_t
pos
=
serialized_form
.
find
(
ITEM_SEPARATOR
,
0
);
std
::
string
tmp
=
serialized_form
.
substr
(
0
,
pos
);
serialized_form
.
erase
(
0
,
pos
+
1
);
switch
(
indice
)
{
case
0
:
// The call type
type
=
tmp
;
_error
(
"Unserialized type: %s"
,
tmp
.
c_str
());
break
;
case
1
:
// The number field
number
=
tmp
;
_error
(
"Serialized number: %s"
,
tmp
.
c_str
());
break
;
case
2
:
// The name field
name
=
tmp
;
_error
(
"Serialized name: %s"
,
tmp
.
c_str
());
break
;
case
3
:
// The start timestamp
_error
(
"Serialized time start: %s"
,
tmp
.
c_str
());
start
=
tmp
;
break
;
case
4
:
// The end timestamp
_error
(
"Serialized time stop: %s"
,
tmp
.
c_str
());
stop
=
tmp
;
break
;
case
5
:
// The ID
_error
(
"Serialized id: %s"
,
tmp
.
c_str
());
id
=
tmp
;
break
;
case
6
:
// The account ID
_error
(
"Serialized account: %s"
,
tmp
.
c_str
());
account
=
tmp
;
break
;
case
7
:
// The recorded file name
_error
(
"Serialized recordfile: %s"
,
tmp
.
c_str
());
recordFile
=
tmp
;
break
;
case
8
:
// The conference ID
_error
(
"Serialized conferenceID: %s"
,
tmp
.
c_str
());
confID
=
tmp
;
break
;
case
9
:
// The time
_error
(
"Serialized timeadded: %s"
,
tmp
.
c_str
());
timeAdded
=
tmp
;
break
;
case
0
:
// The call type
_call_type
=
(
CallType
)
atoi
(
tmp
.
c_str
());
break
;
case
1
:
// The number field
_number
=
tmp
;
break
;
case
2
:
// The name field
_name
=
tmp
;
if
(
_name
==
"empty"
)
_name
=
""
;
break
;
case
3
:
// The start timestamp
_timestamp_start
=
tmp
;
break
;
case
6
:
// The account ID
_account_id
=
tmp
;
break
;
case
7
:
// The recorded file name
_recording_file
=
tmp
;
break
;
case
8
:
// The conference ID
_confID
=
tmp
;
break
;
case
9
:
// The time
_timeAdded
=
tmp
;
break
;
default:
// error
_error
(
"Unserialized form %d not recognized
\n
"
,
indice
);
break
;
...
...
@@ -114,21 +96,8 @@ HistoryItem::HistoryItem (std::string serialized_form)
indice
++
;
}
_id
=
id
;
_call_type
=
(
CallType
)
atoi
(
type
.
c_str
());
_number
=
number
;
(
name
==
EMPTY_STRING
)
?
_name
=
""
:
_name
=
name
;
_timestamp_start
=
start
;
_timestamp_stop
=
stop
;
// (serialized_form == EMPTY_STRING) ? _account_id = "" : _account_id = tmp;
_account_id
=
account
;
_confID
=
confID
;
_timeAdded
=
timeAdded
;
_recording_file
=
recordFile
;
_id
=
""
;
_timestamp_stop
=
""
;
}
HistoryItem
::~
HistoryItem
()
...
...
@@ -140,17 +109,14 @@ bool HistoryItem::save (Conf::ConfigTree **history)
{
std
::
stringstream
section
;
std
::
stringstream
call_type
;
std
::
string
sectionstr
;
bool
res
;
// The section is : "[" + timestamp = "]"
section
<<
rand
();
std
::
string
sectionstr
=
section
.
str
();
call_type
<<
_call_type
;
sectionstr
=
section
.
str
();
_error
(
"-- Unserialized type: %s"
,
call_type
.
str
().
c_str
());
/*
_error("-- Unserialized type: %s", call_type.str().c_str());
_error("-- Unserialized time start: %s", _timestamp_start.c_str());
_error("-- Unserialized time stop: %s", _timestamp_stop.c_str());
_error("-- Unserialized number: %s", _number.c_str());
...
...
@@ -162,35 +128,36 @@ bool HistoryItem::save (Conf::ConfigTree **history)
_error("-- Unserialized time added: %s", _timeAdded.c_str());
*/
re
s
=
(
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"type"
,
call_type
.
str
())
re
turn
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"type"
,
call_type
.
str
())
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"timestamp_start"
,
_timestamp_start
)
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"timestamp_stop"
,
_timestamp_stop
)
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"number"
,
_number
)
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"timestamp_stop"
,
_timestamp_stop
)
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"number"
,
_number
)
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"id"
,
_id
)
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"accountid"
,
_account_id
)
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"name"
,
_name
)
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"accountid"
,
_account_id
)
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"name"
,
_name
)
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"recordfile"
,
_recording_file
)
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"confid"
,
_confID
)
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"timeadded"
,
_timeAdded
));
return
res
;
&&
(
*
history
)
->
setConfigTreeItem
(
sectionstr
,
"timeadded"
,
_timeAdded
);
}
std
::
string
HistoryItem
::
serialize
(
void
)
{
std
::
stringstream
res
;
std
::
string
separator
=
ITEM_SEPARATOR
;
std
::
string
name
,
accountID
;
// Replace empty string with a valid standard string value
(
_name
==
""
)
?
name
=
EMPTY_STRING
:
name
=
_name
;
std
::
string
name
(
_name
);
if
(
name
==
""
)
name
=
"empty"
;
// For the account ID, check also if the accountID corresponds to an existing account
// ie the account may have been removed
(
_account_id
==
""
||
non_valid_account
(
_account_id
))
?
accountID
=
"empty"
:
accountID
=
_account_id
;
std
::
string
accountID
(
_account_id
);
if
(
_account_id
==
""
||
non_valid_account
(
_account_id
))
accountID
=
"empty"
;
// Serialize it
res
<<
_call_type
<<
separator
<<
_number
<<
separator
<<
name
<<
separator
<<
_timestamp_start
<<
separator
<<
_timestamp_stop
<<
separator
<<
_id
<<
separator
<<
accountID
<<
separator
<<
_recording_file
<<
separator
<<
_confID
<<
separator
<<
_timeAdded
;
res
<<
_call_type
<<
ITEM_SEPARATOR
<<
_number
<<
ITEM_SEPARATOR
<<
name
<<
ITEM_SEPARATOR
<<
_timestamp_start
<<
ITEM_SEPARATOR
<<
_timestamp_stop
<<
ITEM_SEPARATOR
<<
_id
<<
ITEM_SEPARATOR
<<
accountID
<<
ITEM_SEPARATOR
<<
_recording_file
<<
ITEM_SEPARATOR
<<
_confID
<<
ITEM_SEPARATOR
<<
_timeAdded
;
return
res
.
str
();
}
...
...
This diff is collapsed.
Click to expand it.
daemon/src/history/historymanager.cpp
+
4
−
13
View file @
89c6de0b
...
...
@@ -243,22 +243,13 @@ std::vector<std::string> HistoryManager::get_history_serialized (void)
{
std
::
vector
<
std
::
string
>
serialized
;
HistoryItemMap
::
iterator
iter
;
HistoryItem
*
current
;
std
::
string
res
;
_debug
(
"HistoryManager: Get history serialized"
);
iter
=
_history_items
.
begin
();
while
(
iter
!=
_history_items
.
end
())
{
current
=
*
iter
;
if
(
current
)
{
res
=
current
->
serialize
();
serialized
.
push_back
(
res
);
}
iter
++
;
for
(
iter
=
_history_items
.
begin
();
iter
!=
_history_items
.
end
();
++
iter
)
{
HistoryItem
*
current
=
*
iter
;
if
(
current
)
serialized
.
push_back
(
current
->
serialize
());
}
return
serialized
;
...
...
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