Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
BC
public
liblinphone
Commits
a2a896e3
Commit
a2a896e3
authored
10 years ago
by
Simon Morlat
Browse files
Options
Download
Patches
Plain Diff
add new command to set/get config items
parent
fd685faa
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
daemon/Makefile.am
+1
-0
daemon/Makefile.am
daemon/commands/config.cc
+60
-0
daemon/commands/config.cc
daemon/commands/configcommand.h
+18
-0
daemon/commands/configcommand.h
daemon/daemon.cc
+3
-0
daemon/daemon.cc
with
82 additions
and
0 deletions
daemon/Makefile.am
+
1
−
0
View file @
a2a896e3
...
...
@@ -39,6 +39,7 @@ linphone_daemon_SOURCES=daemon.cc \
commands/quit.cc
\
commands/version.cc
\
commands/contact.cc
\
commands/config.cc commands/configcommand.h
\
daemon.h
\
commands/adaptive-jitter-compensation.h
\
commands/answer.h
\
...
...
This diff is collapsed.
Click to expand it.
daemon/commands/config.cc
0 → 100644
+
60
−
0
View file @
a2a896e3
#include
"configcommand.h"
using
namespace
std
;
class
ConfigResponse
:
public
Response
{
public:
ConfigResponse
(
const
char
*
value
);
};
ConfigResponse
::
ConfigResponse
(
const
char
*
value
)
:
Response
()
{
ostringstream
ost
;
ost
<<
"Value: "
<<
(
value
?
value
:
"<unset>"
);
setBody
(
ost
.
str
().
c_str
());
}
ConfigGetCommand
::
ConfigGetCommand
()
:
DaemonCommand
(
"config-get"
,
"config section key"
,
"Reads a configuration value from linphone's configuration database."
)
{
addExample
(
new
DaemonCommandExample
(
"config rtp symmetric"
,
"Status: Ok
\n\n
"
"Value: <unset>"
));
}
void
ConfigGetCommand
::
exec
(
Daemon
*
app
,
const
char
*
args
)
{
string
section
,
key
;
istringstream
ist
(
args
);
ist
>>
section
>>
key
;
if
(
ist
.
fail
())
{
app
->
sendResponse
(
Response
(
"Missing section and/or key names."
));
}
else
{
const
char
*
read_value
=
lp_config_get_string
(
linphone_core_get_config
(
app
->
getCore
()),
section
.
c_str
(),
key
.
c_str
(),
NULL
);
app
->
sendResponse
(
ConfigResponse
(
read_value
));
}
}
ConfigSetCommand
::
ConfigSetCommand
()
:
DaemonCommand
(
"config-set"
,
"config section key value"
,
"Sets a configuration value into linphone's configuration database."
)
{
addExample
(
new
DaemonCommandExample
(
"config-set rtp symmetric 1"
,
"Status: Ok
\n\n
"
"Value: 2"
));
addExample
(
new
DaemonCommandExample
(
"config-set rtp symmetric"
,
"Status: Ok
\n\n
"
"Value: <unset>"
));
}
void
ConfigSetCommand
::
exec
(
Daemon
*
app
,
const
char
*
args
)
{
string
section
,
key
,
value
;
istringstream
ist
(
args
);
ist
>>
section
>>
key
;
if
(
ist
.
fail
())
{
app
->
sendResponse
(
Response
(
"Missing section and/or key names."
));
}
else
{
ist
>>
value
;
lp_config_set_string
(
linphone_core_get_config
(
app
->
getCore
()),
section
.
c_str
(),
key
.
c_str
(),
value
.
size
()
>
0
?
value
.
c_str
()
:
NULL
);
app
->
sendResponse
(
ConfigResponse
(
value
.
c_str
()));
}
}
This diff is collapsed.
Click to expand it.
daemon/commands/configcommand.h
0 → 100644
+
18
−
0
View file @
a2a896e3
#ifndef COMMAND_CONFIG_H_
#define COMMAND_CONFIG_H_
#include
"../daemon.h"
class
ConfigGetCommand
:
public
DaemonCommand
{
public:
ConfigGetCommand
();
virtual
void
exec
(
Daemon
*
app
,
const
char
*
args
);
};
class
ConfigSetCommand
:
public
DaemonCommand
{
public:
ConfigSetCommand
();
virtual
void
exec
(
Daemon
*
app
,
const
char
*
args
);
};
#endif //COMMAND_IPV6_H_
This diff is collapsed.
Click to expand it.
daemon/daemon.cc
+
3
−
0
View file @
a2a896e3
...
...
@@ -48,6 +48,7 @@
#include
"commands/terminate.h"
#include
"commands/unregister.h"
#include
"commands/quit.h"
#include
"commands/configcommand.h"
#include
"commands/version.h"
#include
"private.h"
...
...
@@ -447,6 +448,8 @@ void Daemon::initCommands() {
mCommands
.
push_back
(
new
VersionCommand
());
mCommands
.
push_back
(
new
QuitCommand
());
mCommands
.
push_back
(
new
HelpCommand
());
mCommands
.
push_back
(
new
ConfigGetCommand
());
mCommands
.
push_back
(
new
ConfigSetCommand
());
}
void
Daemon
::
uninitCommands
()
{
...
...
This diff is collapsed.
Click to expand it.
Preview
Supports
Markdown
0%
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
Menu
Explore
Projects
Groups
Topics
Snippets