r3173 - in trunk/libminisip: include/libminisip source
erik at minisip.org
erik at minisip.org
Thu Feb 1 10:57:30 CET 2007
Author: erik
Date: 2007-02-01 10:57:29 +0100 (Thu, 01 Feb 2007)
New Revision: 3173
Modified:
trunk/libminisip/include/libminisip/Minisip.h
trunk/libminisip/source/Minisip.cxx
Log:
* Make the Minisip constructor react on a few parameters passed to it:
"-c <configuration path>"
example "minisip_gtkgui -C mxml:/path/to/myconfig.conf"
"-p <plugin path>"
Perhaps we should use more exotic switches to avoid cases where
"Minisip" is used in an application that uses either the "-c" or
"-p" switches. There is a risk that the application passes its
argv to us, and we react to a switch not meant for us.
Modified: trunk/libminisip/include/libminisip/Minisip.h
===================================================================
--- trunk/libminisip/include/libminisip/Minisip.h 2007-02-01 09:49:23 UTC (rev 3172)
+++ trunk/libminisip/include/libminisip/Minisip.h 2007-02-01 09:57:29 UTC (rev 3173)
@@ -23,6 +23,10 @@
std::string getMemObjectType() const {return "Minisip";}
+ void setConfigurationLocation(std::string c){
+ confPath = c;
+ }
+
int exit();
int startSip();
int runGui();
@@ -34,6 +38,7 @@
int initParseConfig();
+ std::string confPath;
MRef<MediaHandler *> mediaHandler;
MRef<Gui *> gui;
MRef<SipSoftPhoneConfiguration *> phoneConf;
Modified: trunk/libminisip/source/Minisip.cxx
===================================================================
--- trunk/libminisip/source/Minisip.cxx 2007-02-01 09:49:23 UTC (rev 3172)
+++ trunk/libminisip/source/Minisip.cxx 2007-02-01 09:57:29 UTC (rev 3173)
@@ -35,6 +35,7 @@
#include<libmutil/Timestamp.h>
#include<libmutil/TextUI.h>
#include<libmutil/Thread.h>
+#include<libminisip/MinisipExceptions.h>
#ifndef WIN32
# ifdef DEBUG_OUTPUT
@@ -83,10 +84,12 @@
#include<libosso.h>
#endif
+#ifdef SCSIM_SUPPORT
+#include<libmcrypto/SmartCard.h>
+#endif
+
using namespace std;
-extern Mutex global;
-
#ifndef WIN32
#ifdef DEBUG_OUTPUT
static void signal_handler( int signal ){
@@ -159,8 +162,43 @@
pluginManager->loadFromDirectory( pluginPath );
}
+/**
+ *
+ * -p <plugin path>
+ * -c <configuration file>
+*/
Minisip::Minisip( MRef<Gui *> gui, int /*argc*/, char **argv ) : gui(gui){
+ string pluginPath;
+ int i=0;
+ char *a;
+ do{
+ char *path;
+ a = argv[i++];
+ if (a && a[0]=='-'){
+ switch (a[1]){
+ case 'p':
+ path = argv[i++];
+ if (path)
+ pluginPath = path;
+ else
+ throw MinisipBadArgument("bad argument for -p");
+ break;
+
+ case 'c':
+ path = argv[i++];
+ if (path)
+ confPath = path;
+ else
+ throw
+ MinisipBadArgument("bad argument for -c");
+ break;
+ }
+
+ }
+
+ }while(a);
+
libmcryptoInit();
srand((unsigned int)time(0));
@@ -176,7 +214,7 @@
mdbg << "Loading plugins"<<end;
#endif
- loadPlugins( argv ? argv[0] : "" );
+ loadPlugins( pluginPath );
#ifdef DEBUG_OUTPUT
mout << "Initializing NetUtil"<<end;
@@ -194,12 +232,6 @@
phoneConf = new SipSoftPhoneConfiguration();
//phoneConf->sip=NULL;
- #ifdef MINISIP_AUTOCALL
- if (argc==3){
- phoneConf->autoCall = string(argv[2]);
- }
- #endif
-
#ifdef DEBUG_OUTPUT
mout << BOLD << "init 1/9: Creating contact database" << PLAIN << end;
#endif
@@ -372,6 +404,13 @@
confMessageRouter->setGui(gui);
+
+#ifdef SCSIM_SUPPORT
+ MRef<SmartCardDetector*> scdetect = new SmartCardDetector(*messageRouter);
+ messageRouter->addSubsystem("smartcard",*scdetect);
+ scdetect->start();
+#endif
+
/*
mdbg << "Starting presence server"<< end;
CommandString subscribeserver("", SipCommandString::start_presence_server);
@@ -424,12 +463,14 @@
#ifdef DEBUG_OUTPUT
mout << BOLD << "init 3/9: Parsing configuration" << PLAIN << end;
#endif
- MRef<ConfBackend *> confBackend = ConfigRegistry::getInstance()->createBackend( gui );
+ MRef<ConfBackend *> confBackend =
+ ConfigRegistry::getInstance()->createBackend( gui, confPath);
if( !confBackend ){
merr << "Minisip could not load a configuration" << end <<
"back end. The application will now" << end <<
"exit." << end;
- ::exit( 1 );
+ throw new MinisipBadArgument("The configured backend could not be loaded");
+ //::exit( 1 );
}
string ret = phoneConf->load( confBackend );
@@ -471,7 +512,7 @@
void Minisip::startDebugger(){
cerr << "startDebugger" << endl;
- consoleDbg = MRef<ConsoleDebugger*>(new ConsoleDebugger(phoneConf->sipStack));
+ consoleDbg = MRef<ConsoleDebugger*>(new ConsoleDebugger(phoneConf));
MRef<Thread *> consoleDbgThread = consoleDbg->start();
}
More information about the Minisip-devel
mailing list