From 6271211296f18fa71765829dc406da67e807e55b Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Tue, 15 Jan 2013 13:05:29 +0100 Subject: [PATCH] merge patch to add a contact command and improve register command to set userid. --- daemon/Makefile.am | 2 ++ daemon/commands/register.cc | 14 +++++++++----- daemon/daemon.cc | 2 ++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/daemon/Makefile.am b/daemon/Makefile.am index 4ae6295ef..15979a318 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -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 diff --git a/daemon/commands/register.cc b/daemon/commands/register.cc index 46fa52dc8..d708ccd39 100644 --- a/daemon/commands/register.cc +++ b/daemon/commands/register.cc @@ -1,22 +1,26 @@ #include "register.h" +#include "linphonecore.h" +#include "private.h" +#include "lpconfig.h" + using namespace std; RegisterCommand::RegisterCommand() : - DaemonCommand("register", "register ", "Register the daemon to a SIP proxy.") { - addExample(new DaemonCommandExample("register sip:daemon-test@sip.linphone.org sip.linphone.org password", + DaemonCommand("register", "register ", "Register the daemon to a SIP proxy. If one of the parameters , and 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); diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 88e39cbaa..8fee5540e 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -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());