merge patch to add a contact command and improve register command to set userid.

This commit is contained in:
Simon Morlat 2013-01-15 13:05:29 +01:00
parent 3f8969c949
commit 6271211296
3 changed files with 13 additions and 5 deletions

View file

@ -31,6 +31,7 @@ linphone_daemon_SOURCES=daemon.cc \
commands/unregister.cc \
commands/quit.cc \
commands/version.cc \
commands/contact.cc \
daemon.h \
commands/adaptive-jitter-compensation.h \
commands/answer.h \
@ -59,6 +60,7 @@ linphone_daemon_SOURCES=daemon.cc \
commands/terminate.h \
commands/unregister.h \
commands/quit.h \
commands/contact.h \
commands/version.h
linphone_daemon_pipetest_SOURCES=daemon-pipetest.c

View file

@ -1,22 +1,26 @@
#include "register.h"
#include "linphonecore.h"
#include "private.h"
#include "lpconfig.h"
using namespace std;
RegisterCommand::RegisterCommand() :
DaemonCommand("register", "register <identity> <proxy-address> <password>", "Register the daemon to a SIP proxy.") {
addExample(new DaemonCommandExample("register sip:daemon-test@sip.linphone.org sip.linphone.org password",
DaemonCommand("register", "register <identity> <proxy-address> <password> <userid> <realm>", "Register the daemon to a SIP proxy. If one of the parameters <password>, <userid> and <realm> is not needed, send the string \"NULL\"") {
addExample(new DaemonCommandExample("register sip:daemon-test@sip.linphone.org sip.linphone.org password bob linphone.org",
"Status: Ok\n\n"
"Id: 1"));
}
void RegisterCommand::exec(Daemon *app, const char *args) {
LinphoneCore *lc = app->getCore();
char proxy[256] = { 0 }, identity[128] = { 0 }, password[64] = { 0 };
if (sscanf(args, "%255s %127s %63s", identity, proxy, password) >= 2) {
char proxy[256] = { 0 }, identity[128] = { 0 }, password[64] = { 0 }, userid[128] = { 0 }, realm[128] = { 0 };
if (sscanf(args, "%255s %127s %63s %127s %127s", identity, proxy, password, userid, realm) >= 2) {
LinphoneProxyConfig *cfg = linphone_proxy_config_new();
if (password[0] != '\0') {
LinphoneAddress *from = linphone_address_new(identity);
if (from != NULL) {
LinphoneAuthInfo *info = linphone_auth_info_new(linphone_address_get_username(from), NULL, password, NULL, NULL); /*create authentication structure from identity*/
LinphoneAuthInfo *info = linphone_auth_info_new(linphone_address_get_username(from), userid, password, NULL, realm); /*create authentication structure from identity*/
linphone_core_add_auth_info(lc, info); /*add authentication info to LinphoneCore*/
linphone_address_destroy(from);
linphone_auth_info_destroy(info);

View file

@ -25,6 +25,7 @@
#include "commands/call.h"
#include "commands/call-stats.h"
#include "commands/call-status.h"
#include "commands/contact.h"
#include "commands/dtmf.h"
#include "commands/firewall-policy.h"
#include "commands/help.h"
@ -360,6 +361,7 @@ void Daemon::removeAudioStream(int id) {
void Daemon::initCommands() {
mCommands.push_back(new RegisterCommand());
mCommands.push_back(new ContactCommand());
mCommands.push_back(new RegisterStatusCommand());
mCommands.push_back(new UnregisterCommand());
mCommands.push_back(new CallCommand());