r2767 - in trunk/libmsip: . include include/libmsip source source/dialogs source/transactions

erik at minisip.org erik at minisip.org
Thu Sep 14 13:15:34 CEST 2006


Author: erik
Date: 2006-09-14 13:15:33 +0200 (Thu, 14 Sep 2006)
New Revision: 2767

Added:
   trunk/libmsip/include/libmsip/SipDialogUtils.h
Modified:
   trunk/libmsip/Makefile.am
   trunk/libmsip/include/Makefile.am
   trunk/libmsip/include/libmsip/SipCommandDispatcher.h
   trunk/libmsip/include/libmsip/SipDialog.h
   trunk/libmsip/include/libmsip/SipStack.h
   trunk/libmsip/include/libmsip/SipTransaction.h
   trunk/libmsip/include/libmsip/SipTransactionInviteClient.h
   trunk/libmsip/include/libmsip/SipTransactionInviteServer.h
   trunk/libmsip/include/libmsip/SipTransactionInviteServerUA.h
   trunk/libmsip/include/libmsip/SipTransactionNonInviteClient.h
   trunk/libmsip/include/libmsip/SipTransactionNonInviteServer.h
   trunk/libmsip/source/SipCommandDispatcher.cxx
   trunk/libmsip/source/SipLayerDialog.cxx
   trunk/libmsip/source/SipLayerTransaction.cxx
   trunk/libmsip/source/SipLayerTransport.cxx
   trunk/libmsip/source/SipStack.cxx
   trunk/libmsip/source/dialogs/SipDialog.cxx
   trunk/libmsip/source/dialogs/SipDialogManagement.cxx
   trunk/libmsip/source/dialogs/SipDialogRegister.cxx
   trunk/libmsip/source/transactions/SipTransaction.cxx
   trunk/libmsip/source/transactions/SipTransactionInviteClient.cxx
   trunk/libmsip/source/transactions/SipTransactionInviteServer.cxx
   trunk/libmsip/source/transactions/SipTransactionInviteServerUA.cxx
   trunk/libmsip/source/transactions/SipTransactionNonInviteClient.cxx
   trunk/libmsip/source/transactions/SipTransactionNonInviteServer.cxx
Log:

 * Added SipStackInternal.{h,cxx}. This is close to the old SipStack class.

 * Renamed SipTransactionUtils to SipDialogUtils. The transactions classes
   are libmsip internal, and SipDialogUtils is meant to be used when
   implementing new SIP logic.
 
 * SipCommandDispatcher.h is no longer installed/distributed
 
 * Moved the functions to enable/disable debug output of packets to
   to the SipStack class (before they were functions).
 
 * Updated the SipStack class with methods that replaces methods that
   libminisip previously accessed in SipLayerTransport and
   SipCommandDispatcher (they are no longer available from "the outside").




Modified: trunk/libmsip/Makefile.am
===================================================================
--- trunk/libmsip/Makefile.am	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/Makefile.am	2006-09-14 11:15:33 UTC (rev 2767)
@@ -22,6 +22,7 @@
 msip_src =           source/SipDialogConfig.cxx \
 		     source/SipAuthenticationDigest.cxx \
 		     source/SipStack.cxx \
+		     source/SipStackInternal.cxx \
 		     source/SipLayerDialog.cxx \
 		     source/SipLayerTransaction.cxx \
                      source/messages/SipMessage.cxx \

Modified: trunk/libmsip/include/Makefile.am
===================================================================
--- trunk/libmsip/include/Makefile.am	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/include/Makefile.am	2006-09-14 11:15:33 UTC (rev 2767)
@@ -50,7 +50,6 @@
 		     libmsip/SipDialog.h \
 		     libmsip/SipDialogRegister.h \
 		     libmsip/SipAuthenticationDigest.h \
-		     libmsip/SipCommandDispatcher.h \
 		     libmsip/SipDialogManagement.h \
                      libmsip/SipLayerTransaction.h \
 		     libmsip/SipTransaction.h \
@@ -61,6 +60,8 @@
 		     libmsip/SipTransactionInviteClient.h \
 		     libmsip/SipTransactionInviteServer.h \
 		     libmsip/SipTransactionInviteServerUA.h \
+                     libmsip/SipStackInternal.h \
+		     libmsip/SipCommandDispatcher.h \
 			config.h
 
 MAINTAINERCLEANFILES =	$(srcdir)/Makefile.in \

Modified: trunk/libmsip/include/libmsip/SipCommandDispatcher.h
===================================================================
--- trunk/libmsip/include/libmsip/SipCommandDispatcher.h	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/include/libmsip/SipCommandDispatcher.h	2006-09-14 11:15:33 UTC (rev 2767)
@@ -38,7 +38,9 @@
 #include<libmsip/SipLayerDialog.h>
 #include<libmsip/SipLayerTransaction.h>
 #include<libmsip/SipLayerTransport.h>
+#include<libmsip/SipStack.h>
 
+class SipStackInternal;
 class SipDialog;
 
 /**
@@ -54,22 +56,17 @@
 
 class SipLayerDialog;
 class SipLayerTransport;
-class SipStack;
 
 #define TYPE_COMMAND 2
 #define TYPE_TIMEOUT 3
 
-#define HIGH_PRIO_QUEUE 2
-#define LOW_PRIO_QUEUE 4
 
-
-
-class LIBMSIP_API SipCommandDispatcher : public MObject{
+class SipCommandDispatcher : public MObject{
 	public:
-		SipCommandDispatcher(MRef<SipStack*> stack, MRef<SipLayerTransport*> transport);
+		SipCommandDispatcher(MRef<SipStackInternal*> stack, MRef<SipLayerTransport*> transport);
 
 		void setCallback(MRef<CommandReceiver*> cb);
-		MRef<CommandReceiver*> getCallback(){return callback;}
+		MRef<CommandReceiver*> getCallback();
 		
 		void addDialog(MRef<SipDialog*> d);
 		std::list<MRef<SipDialog *> > getDialogs();
@@ -77,9 +74,9 @@
 		void setDialogManagement(MRef<SipDialog*> mgmt);
 
 		virtual void run();
-		void stopRunning(){keepRunning=false;}
+		void stopRunning();
 
-		MRef<SipStack*> getSipStack();
+		MRef<SipStackInternal*> getSipStackInternal();
 		
 //#ifdef DEBUG_OUTPUT
 		virtual std::string getMemObjectType() {return "SipCommandDispatcher";}
@@ -109,7 +106,7 @@
 		                
 	private:
 		MRef<CommandReceiver*> callback;
-		MRef<SipStack *> sipStack;
+		MRef<SipStackInternal *> sipStackInternal;
 
 		Semaphore semaphore;
 		Mutex mlock;
@@ -137,5 +134,6 @@
 };
 
 #include<libmsip/SipDialog.h>
+#include<libmsip/SipStackInternal.h>
 
 #endif

Modified: trunk/libmsip/include/libmsip/SipDialog.h
===================================================================
--- trunk/libmsip/include/libmsip/SipDialog.h	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/include/libmsip/SipDialog.h	2006-09-14 11:15:33 UTC (rev 2767)
@@ -20,12 +20,6 @@
 /*
  * Authors: Erik Eliasson <eliasson at it.kth.se>
  *          Johan Bilien <jobi at via.ecp.fr>
-*/
-
-
-/*
- * Authors: Erik Eliasson <eliasson at it.kth.se>
- *          Johan Bilien <jobi at via.ecp.fr>
  *	    Cesc Santasusana, c e s c dot s a n t a A{T g m a i l dot co m; 2005
  *          Mikael Magnusson <mikma at users.sourceforge.net>
 */
@@ -40,15 +34,13 @@
 #include<libmsip/SipSMCommand.h>
 #include<libmsip/SipResponse.h>
 
-#include<libmsip/SipCommandDispatcher.h>
 #include<libmsip/SipRequest.h>
+#include<libmsip/SipStack.h>
 
-class SipStack;
 class SipTransaction;
 class SipDialogConfig;
 class SipCommandDispatcher;
 class SipAuthenticationDigest;
-//class SipDialogContainer;
 
 
 /**
@@ -167,8 +159,6 @@
 		 */
 		std::string getCallId(){return dialogState.callId;}
 		
-		//MRef<SipCommandDispatcher*> getDispatcher();
-
 		MRef<SipStack*> getSipStack();
 
 		void signalIfNoTransactions();
@@ -231,6 +221,8 @@
 		 */
 		void addAuthorizations( MRef<SipRequest*> req );
 
+		std::string getDialogStatusString();
+
 	protected:
 //		///a list containing all transactions
 //		std::list<MRef<SipTransaction*> > transactions;
@@ -238,8 +230,6 @@
 		///
 		MRef<SipStack*> sipStack;
 		
-		MRef<SipCommandDispatcher*> dispatcher;
-
 		bool updateAuthentication( MRef<SipResponse*> resp,
 					   MRef<SipHeaderValueProxyAuthenticate*> auth);
 	private:
@@ -252,7 +242,6 @@
 
 #include<libmsip/SipStack.h>
 #include<libmsip/SipDialogConfig.h>
-#include<libmsip/SipCommandDispatcher.h>
 
 #endif
 

Copied: trunk/libmsip/include/libmsip/SipDialogUtils.h (from rev 2755, trunk/libmsip/include/libmsip/SipTransactionUtils.h)

Modified: trunk/libmsip/include/libmsip/SipStack.h
===================================================================
--- trunk/libmsip/include/libmsip/SipStack.h	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/include/libmsip/SipStack.h	2006-09-14 11:15:33 UTC (rev 2767)
@@ -75,20 +75,26 @@
 
 #include<libmsip/libmsip_config.h>
 
+class SipStackInternal;
 
-#include<libmutil/minilist.h>
+
 #include<libmutil/CommandString.h>
-#include<libmsip/SipTransaction.h>
 #include<libmsip/SipDialogConfig.h>
+#include<libmutil/Thread.h>
 #include<libmsip/SipTimers.h>
-
-#include<libmsip/SipLayerTransport.h>
 #include<libmcrypto/cert.h>
 #include<libmutil/MessageRouter.h>
+#include<libmsip/SipSMCommand.h>
+#include<libmutil/TimeoutProvider.h>
+#include<libmutil/StateMachine.h>
 
 class SipDialog;
-class SipTransaction;
 
+#define HIGH_PRIO_QUEUE 2
+#define LOW_PRIO_QUEUE 4
+
+
+
 //TODO: Enable conference calling
 
 
@@ -125,8 +131,7 @@
  * See the main documentation document for how to implement application
  * layer support for new header and content types (@see Factories).
 */
-class LIBMSIP_API SipStack: public SipSMCommandReceiver, public Runnable{
-
+class LIBMSIP_API SipStack : public Runnable{
 	public:
 		SipStack( MRef<SipCommonConfig*> stackConfig,
 				MRef<certificate_chain *> cert=NULL,	//The certificate chain is used by TLS 
@@ -134,57 +139,43 @@
 				MRef<ca_db *> cert_db = NULL
 			  );
 
+		~SipStack();
+		
 		void setTransactionHandlesAck(bool transHandleAck);
-
 		void setDefaultDialogCommandHandler(MRef<SipSMCommandReceiver*> cb);
-
-		virtual std::string getMemObjectType(){return "SipStack";}
-		
                 virtual void run();
-
-		MRef<SipCommandDispatcher*> getDispatcher();
-
+		virtual void stopRunning();
 		bool handleCommand(const CommandString &cmd);
+		bool handleCommand(const SipSMCommand &cmd);
+		void enqueueTimeout(MRef<SipDialog*> receiver, const SipSMCommand &cmd);
+		void enqueueCommand(const SipSMCommand &cmd, int queue=LOW_PRIO_QUEUE);
 
-		bool handleCommand(const SipSMCommand &command);
-		
 		void setCallback(MRef<CommandReceiver*> callback);	//Rename to setMessageRouterCallback?
-		MRef<CommandReceiver *> getCallback();
-
+		MRef<CommandReceiver*> getCallback();	
 		void setConfCallback(MRef<CommandReceiver*> callback); // Hack to make the conference calling work - should not be here FIXME
 		MRef<CommandReceiver *> getConfCallback();
-		
 		void addDialog(MRef<SipDialog*> d);
-
-		/**
-		 * Each SipStack object creates a TimeoutProvider that with
-		 * a thread of it's own keeps track of timers waiting to
-		 * fire. This method is used by the transactions and
-		 * dialogs that wish to use timeouts to retrieve which
-		 * timeout provider to use.
-		 */
-		MRef<TimeoutProvider<std::string, MRef<StateMachine<SipSMCommand,std::string>*> > *> getTimeoutProvider();
-
 		MRef<SipTimers*> getTimers();
-		MRef<SipCommonConfig*> getStackConfig(){return config;}
-
+		MRef<SipCommonConfig*> getStackConfig();
 		void addSupportedExtension(std::string extension);
 		std::string getAllSupportedExtensionsStr();
 		bool supports(std::string extension);
-                
-	private:
-		MRef<SipTimers*> timers;
-		MRef<SipCommonConfig *> config;
-		MRef<CommandReceiver*> callback;
-		
-		MRef<CommandReceiver*> confCallback;	//hack to make conference calling work until the ConfMessageRouter is removed
-		
-		//
-		MRef<SipCommandDispatcher*> dispatcher;
+		MRef<TimeoutProvider<std::string, MRef<StateMachine<SipSMCommand,std::string>*> > *> getTimeoutProvider();
+		void setDialogManagement(MRef<SipDialog*> mgmt);
 
-		MRef<TimeoutProvider<std::string, MRef<StateMachine<SipSMCommand,std::string>*> > *> timeoutProvider;
+		std::list<MRef<SipDialog *> > getDialogs();
 
-		std::list<std::string> sipExtensions;
+		void startTcpServer();
+		void startTlsServer();
+
+		void setDebugPrintPackets(bool enable);
+		bool getDebugPrintPackets();
+
+	private:
+		friend class SipDialog;
+		//SipStackInternal* sipStackInternal;
+		void *sipStackInternal; // MRef<SipStackInternal*> sipStackInternal
+
 };
 
 

Modified: trunk/libmsip/include/libmsip/SipTransaction.h
===================================================================
--- trunk/libmsip/include/libmsip/SipTransaction.h	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/include/libmsip/SipTransaction.h	2006-09-14 11:15:33 UTC (rev 2767)
@@ -46,16 +46,16 @@
 class SipMessage;
 class SipCommandDispatcher;
 class SipLayerTransport;
-class SipStack;
+class SipStackInternal;
 class Socket;
 
 /**
  * SipTransaction
  */
-class LIBMSIP_API SipTransaction : public StateMachine<SipSMCommand,std::string>{
+class SipTransaction : public StateMachine<SipSMCommand,std::string>{
 	public:
 		
-		SipTransaction(MRef<SipStack*> stack, 
+		SipTransaction(MRef<SipStackInternal*> stackInternal, 
 				//MRef<SipDialog*> d, 
 				int cseq, 
 				const std::string &cseqMethod, 
@@ -78,7 +78,7 @@
 		 * @param handleAck  TRUE if the "UA" versions of the
 		 *                   INVITE server transactions should be used.
 		 */
-		static MRef<SipTransaction*> create(MRef<SipStack*> stack, 
+		static MRef<SipTransaction*> create(MRef<SipStackInternal*> stackInternal, 
 				MRef<SipRequest*> msg, 
 				bool fromTU, 
 				bool handleAck=false);
@@ -117,7 +117,7 @@
 		
 		void setCSeqNo(int n){cSeqNo=n;}
 		MRef<SipCommandDispatcher*> dispatcher;
-		MRef<SipStack*> sipStack;
+		MRef<SipStackInternal*> sipStackInternal;
 		MRef<SipLayerTransport*> transportLayer;
 		MRef<Socket *> socket;
 		
@@ -137,7 +137,7 @@
 //All sub-classes of SipTransaction are local to libmsip
 class SipTransactionClient: public SipTransaction{
         public:
-                SipTransactionClient(MRef<SipStack*> stack, 
+                SipTransactionClient(MRef<SipStackInternal*> stackInternal, 
 				int seq_no, 
 				const std::string &cSeqMethod, 
 				const std::string &branch, 
@@ -147,7 +147,7 @@
 
 class SipTransactionServer: public SipTransaction{
         public:
-                SipTransactionServer(MRef<SipStack*> stack, 
+                SipTransactionServer(MRef<SipStackInternal*> stackInternal, 
 				int seq_no, 
 				const std::string &cSeqMethod, 
 				const std::string &branch, 

Modified: trunk/libmsip/include/libmsip/SipTransactionInviteClient.h
===================================================================
--- trunk/libmsip/include/libmsip/SipTransactionInviteClient.h	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/include/libmsip/SipTransactionInviteClient.h	2006-09-14 11:15:33 UTC (rev 2767)
@@ -59,7 +59,7 @@
 */
 class SipTransactionInviteClient: public SipTransactionClient{
 	public:
-		SipTransactionInviteClient(MRef<SipStack*> stack, 
+		SipTransactionInviteClient(MRef<SipStackInternal*> stackInternal, 
 				int seq_no, 
 				const std::string &cSeqMethod, 
 				const std::string &callid);

Modified: trunk/libmsip/include/libmsip/SipTransactionInviteServer.h
===================================================================
--- trunk/libmsip/include/libmsip/SipTransactionInviteServer.h	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/include/libmsip/SipTransactionInviteServer.h	2006-09-14 11:15:33 UTC (rev 2767)
@@ -59,7 +59,7 @@
 */
 class SipTransactionInviteServer : public SipTransactionServer{
 	public:
-		SipTransactionInviteServer(MRef<SipStack *> stack, 
+		SipTransactionInviteServer(MRef<SipStackInternal *> stackInternal, 
 				int seq_no, 
 				const std::string &cSeqMethod, 
 				const std::string &branch, 

Modified: trunk/libmsip/include/libmsip/SipTransactionInviteServerUA.h
===================================================================
--- trunk/libmsip/include/libmsip/SipTransactionInviteServerUA.h	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/include/libmsip/SipTransactionInviteServerUA.h	2006-09-14 11:15:33 UTC (rev 2767)
@@ -59,7 +59,7 @@
 */
 class SipTransactionInviteServerUA: public SipTransactionInviteServer{
 	public:
-		SipTransactionInviteServerUA(MRef<SipStack*> stack, 
+		SipTransactionInviteServerUA(MRef<SipStackInternal*> stackInternal, 
 				int seq_no, 
 				const std::string &cSeqMethod, 
 				const std::string &branch, 

Modified: trunk/libmsip/include/libmsip/SipTransactionNonInviteClient.h
===================================================================
--- trunk/libmsip/include/libmsip/SipTransactionNonInviteClient.h	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/include/libmsip/SipTransactionNonInviteClient.h	2006-09-14 11:15:33 UTC (rev 2767)
@@ -57,7 +57,7 @@
 */
 class SipTransactionNonInviteClient: public SipTransactionClient{
 	public:
-		SipTransactionNonInviteClient(MRef<SipStack *> stack, 
+		SipTransactionNonInviteClient(MRef<SipStackInternal *> stackInternal, 
 				int seq_no, 
 				const std::string &cSeqMethod, 
 				const std::string &callid);

Modified: trunk/libmsip/include/libmsip/SipTransactionNonInviteServer.h
===================================================================
--- trunk/libmsip/include/libmsip/SipTransactionNonInviteServer.h	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/include/libmsip/SipTransactionNonInviteServer.h	2006-09-14 11:15:33 UTC (rev 2767)
@@ -56,7 +56,7 @@
 */
 class SipTransactionNonInviteServer: public SipTransactionServer{
 	public:
-		SipTransactionNonInviteServer(MRef<SipStack*> stack, 
+		SipTransactionNonInviteServer(MRef<SipStackInternal*> stackInternal, 
 				int seq_no, 
 				const std::string &cSeqMethod, 
 				const std::string &branch, 

Modified: trunk/libmsip/source/SipCommandDispatcher.cxx
===================================================================
--- trunk/libmsip/source/SipCommandDispatcher.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/SipCommandDispatcher.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -34,7 +34,12 @@
 
 using namespace std;
 
-SipCommandDispatcher::SipCommandDispatcher(MRef<SipStack*> stack, MRef<SipLayerTransport*> transp):sipStack(stack),keepRunning(true){
+SipCommandDispatcher::SipCommandDispatcher(
+		MRef<SipStackInternal*> stackInternal, 
+		MRef<SipLayerTransport*> transp)
+			:sipStackInternal(stackInternal),
+			keepRunning(true){
+
 	transportLayer = transp;
 	transactionLayer = new SipLayerTransaction(this,transportLayer);
 	dialogLayer = new SipLayerDialog(this);
@@ -48,10 +53,18 @@
 void SipCommandDispatcher::setDialogManagement(MRef<SipDialog*> mgmt){
 	managementHandler = mgmt;
 }
-MRef<SipStack*> SipCommandDispatcher::getSipStack(){
-	return sipStack;
+MRef<SipStackInternal*> SipCommandDispatcher::getSipStackInternal(){
+	return sipStackInternal;
 }
 
+MRef<CommandReceiver*> SipCommandDispatcher::getCallback(){
+	return callback;
+}
+
+void SipCommandDispatcher::stopRunning(){
+	keepRunning=false;
+}
+
 list<MRef<SipDialog *> > SipCommandDispatcher::getDialogs(){
 	return dialogLayer->getDialogs();
 }
@@ -310,7 +323,7 @@
 //					SipSMCommand::dispatcher,
 //					SipSMCommand::dispatcher);
 // 			managementHandler->handleCommand(cmd); //process the command, so it moves to terminated state
-			managementHandler->getSipStack()->getDispatcher()->stopRunning();
+			managementHandler->getSipStack()->stopRunning();
 			return true;
 		}else{
 #ifdef DEBUG_OUTPUT

Modified: trunk/libmsip/source/SipLayerDialog.cxx
===================================================================
--- trunk/libmsip/source/SipLayerDialog.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/SipLayerDialog.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -30,6 +30,7 @@
 #include<libmsip/SipSMCommand.h>
 #include<libmsip/SipCommandString.h>
 #include<libmsip/SipCommandDispatcher.h>
+#include<libmsip/SipStackInternal.h>
 
 using namespace std;
 

Modified: trunk/libmsip/source/SipLayerTransaction.cxx
===================================================================
--- trunk/libmsip/source/SipLayerTransaction.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/SipLayerTransaction.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -54,7 +54,7 @@
 		MRef<SipRequest*> req = dynamic_cast<SipRequest*>(*cmd.getCommandPacket());
 		massert(req);
 
-		newTransaction = SipTransaction::create(dispatcher->getSipStack(), 
+		newTransaction = SipTransaction::create(dispatcher->getSipStackInternal(), 
 				req, 
 				cmd.getSource()==SipSMCommand::dialog_layer, 
 				handleAck);

Modified: trunk/libmsip/source/SipLayerTransport.cxx
===================================================================
--- trunk/libmsip/source/SipLayerTransport.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/SipLayerTransport.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -51,6 +51,7 @@
 #include<libmutil/dbg.h>
 //#include<libmsip/SipDialogContainer.h>
 #include<libmsip/SipCommandString.h>
+#include<libmsip/SipCommandDispatcher.h>
 
 #include<cctype>
 #include<string>

Modified: trunk/libmsip/source/SipStack.cxx
===================================================================
--- trunk/libmsip/source/SipStack.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/SipStack.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -22,6 +22,7 @@
 */
 #include<config.h>
 #include<libmsip/SipStack.h>
+#include<libmsip/SipStackInternal.h>
 
 #include<libmsip/SipLayerTransport.h>
 #include<libmsip/SipCommandDispatcher.h>
@@ -68,9 +69,134 @@
 
 using namespace std;
 
+#define STACK (*(MRef<SipStackInternal*> *) sipStackInternal)
+
 SipStack::SipStack( MRef<SipCommonConfig *> stackConfig,
 		MRef<certificate_chain *> cert_chain,
 		MRef<ca_db *> cert_db
+		){
+	
+	SipStackInternal *istack = new SipStackInternal(stackConfig, cert_chain, cert_db);
+
+	sipStackInternal = new MRef<SipStackInternal*>(istack);
+}
+
+SipStack::~SipStack(){
+	MRef<SipStackInternal*> * mrefPtr = (MRef<SipStackInternal*> *) sipStackInternal;
+	delete mrefPtr;
+}
+
+void SipStack::setTransactionHandlesAck(bool transHandlesAck){
+	//sipStackInternal->setTransactionHandlesAck(transHandlesAck);
+	STACK->setTransactionHandlesAck(transHandlesAck);
+
+}
+
+void SipStack::setDefaultDialogCommandHandler(MRef<SipSMCommandReceiver*> cb){
+	STACK->setDefaultDialogCommandHandler(cb);
+}
+
+void SipStack::run(){
+	STACK->run();
+}
+
+void SipStack::stopRunning(){
+	STACK->stopRunning();
+}
+
+bool SipStack::handleCommand(const CommandString &cmd){
+	return STACK->handleCommand(cmd);
+}
+
+void SipStack::setCallback(MRef<CommandReceiver*> callback){
+	STACK->setCallback(callback);
+}
+
+MRef<CommandReceiver*> SipStack::getCallback(){
+	return STACK->getCallback();
+}
+
+void SipStack::setConfCallback(MRef<CommandReceiver*> callback){
+	STACK->setConfCallback(callback);
+}
+
+MRef<CommandReceiver *> SipStack::getConfCallback(){
+	return STACK->getConfCallback();
+}
+
+void SipStack::addDialog(MRef<SipDialog*> d){
+	STACK->addDialog(d);
+}
+
+MRef<SipTimers*> SipStack::getTimers(){
+	return STACK->getTimers();
+}	
+
+MRef<SipCommonConfig*> SipStack::getStackConfig(){
+	return STACK->getStackConfig();
+}
+
+void SipStack::addSupportedExtension(std::string extension){
+	STACK->addSupportedExtension(extension);
+}
+
+std::string SipStack::getAllSupportedExtensionsStr(){
+	return STACK->getAllSupportedExtensionsStr();
+}
+
+bool SipStack::supports(std::string extension){
+	return STACK->supports(extension);
+}
+
+
+MRef<TimeoutProvider<std::string,MRef<StateMachine<SipSMCommand,std::string>*> > *> 
+SipStack::getTimeoutProvider(){
+	return STACK->getTimeoutProvider();
+}
+
+void SipStack::enqueueTimeout(MRef<SipDialog*> receiver, const SipSMCommand &cmd){
+	STACK->getDispatcher()->enqueueTimeout(receiver, cmd);
+}
+
+std::list<MRef<SipDialog *> > SipStack::getDialogs(){
+	return STACK->getDispatcher()->getDialogs();
+}
+
+void SipStack::enqueueCommand(const SipSMCommand &cmd, int queue){
+	STACK->getDispatcher()->enqueueCommand(cmd, queue);
+}
+
+bool SipStack::handleCommand(const SipSMCommand &cmd){
+	return STACK->handleCommand(cmd);
+}
+
+void SipStack::setDialogManagement(MRef<SipDialog*> mgmt){
+	STACK->getDispatcher()->setDialogManagement(mgmt);
+}
+
+void SipStack::startTcpServer(){
+	STACK->getDispatcher()->getLayerTransport()->startTcpServer();
+}
+
+void SipStack::startTlsServer(){
+	STACK->getDispatcher()->getLayerTransport()->startTlsServer();
+}
+
+void SipStack::setDebugPrintPackets(bool enable){
+	set_debug_print_packets(enable);	
+}
+
+bool SipStack::getDebugPrintPackets(){
+	return get_debug_print_packets();
+}
+
+
+
+#if 0
+
+SipStack::SipStack( MRef<SipCommonConfig *> stackConfig,
+		MRef<certificate_chain *> cert_chain,
+		MRef<ca_db *> cert_db
 		)
 {
 	timers = new SipTimers;
@@ -234,3 +360,5 @@
 	return ret;
 }
 
+#endif
+

Modified: trunk/libmsip/source/dialogs/SipDialog.cxx
===================================================================
--- trunk/libmsip/source/dialogs/SipDialog.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/dialogs/SipDialog.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -32,10 +32,10 @@
 #include<libmsip/SipHeaderTo.h>
 #include<libmsip/SipTransaction.h>
 #include<libmsip/SipStack.h>
+#include<libmsip/SipStackInternal.h>
 #include<libmsip/SipDialogConfig.h>
 #include<libmsip/SipDialog.h>
 #include<libmsip/SipAuthenticationDigest.h>
-//#include<libmsip/SipDialogContainer.h>
 #include<libmutil/dbg.h>
 #include<libmsip/SipSMCommand.h>
 #include<libmsip/SipCommandString.h>
@@ -49,7 +49,9 @@
 #include<libmsip/SipHeaderProxyAuthenticate.h>
 #include<libmsip/SipHeaderProxyAuthorization.h>
 #include<libmsip/SipHeaderWWWAuthenticate.h>
+#include<libmsip/SipCommandDispatcher.h>
 #include<libmutil/CommandString.h>
+#include<libmutil/termmanip.h>
 
 using namespace std;
 
@@ -58,7 +60,7 @@
                 sipStack(stack), 
                 callConfig(callconf)
 {
-	dispatcher = stack->getDispatcher();
+	//dispatcher = stack->getDispatcher();
 	dialogState.seqNo=100 * (rand()%9+1);
 	dialogState.remoteSeqNo=-1;
 	dialogState.secure=false;	//TODO: this variable is not maintained 
@@ -83,7 +85,8 @@
 			SipSMCommand::dialog_layer, 
 			SipSMCommand::dialog_layer );
 
-	dispatcher->enqueueTimeout( this, cmd);
+	//sipStack->sipStackInternal->getDispatcher()->enqueueTimeout( this, cmd);
+	(*(MRef<SipStackInternal*> *) sipStack->sipStackInternal)->getDispatcher()->enqueueTimeout( this, cmd);
 }
 
 void SipDialog::signalIfNoTransactions(){
@@ -103,7 +106,8 @@
 			// transactions), and can be placed in the end of the queue. 
 			// It is placed in the high prio queue so that it is guaranteed 
 			// to be deleted even under high load.
-			dispatcher->enqueueCommand(cmd, HIGH_PRIO_QUEUE); 
+			//dispatcher->enqueueCommand(cmd, HIGH_PRIO_QUEUE); 
+			(*(MRef<SipStackInternal*> *) sipStack->sipStackInternal)->getDispatcher()->enqueueCommand(cmd);
 		}
 	}
 }
@@ -129,7 +133,7 @@
 }
 
 list<MRef<SipTransaction*> > SipDialog::getTransactions(){
-	return sipStack->getDispatcher()->getLayerTransaction()->getTransactionsWithCallId(getCallId());
+	return (*(MRef<SipStackInternal*> *) sipStack->sipStackInternal)->getDispatcher()->getLayerTransaction()->getTransactionsWithCallId(getCallId());
 }
 
 bool SipDialog::handleCommand(const SipSMCommand &command){
@@ -261,7 +265,7 @@
 
 void SipDialog::sendSipMessage( MRef<SipMessage*> msg, int queue ){
 	SipSMCommand cmd( *msg, SipSMCommand::dialog_layer, SipSMCommand::transaction_layer );
-	dispatcher->enqueueCommand( cmd, queue );
+	(*(MRef<SipStackInternal*> *) sipStack->sipStackInternal)->getDispatcher()->enqueueCommand( cmd, queue );
 }
 
 bool SipDialog::updateAuthentication( MRef<SipResponse*> resp,
@@ -480,3 +484,87 @@
 	}
 }
 
+std::string SipDialog::getDialogStatusString(){
+
+	list <TPRequest<string,MRef<StateMachine<SipSMCommand,string>*> > > torequests = 
+		sipStack->getTimeoutProvider()->getTimeoutRequests();
+
+	cerr << (getName() + "   State: " + getCurrentStateName())<< endl;
+
+
+	cerr << BOLD << "        SipDialogState: "<< PLAIN << endl;
+	cerr <<         "            secure="<<dialogState.secure 
+			<<"; localTag="<<dialogState.localTag
+			<<"; remoteTag="<<dialogState.remoteTag 
+			<<"; seqNo="<< dialogState.seqNo
+			<<"; remoteSeqNo="<< dialogState.remoteSeqNo
+			<<"; remoteUri="<< dialogState.remoteUri
+			<<"; remoteTarget="<<dialogState.remoteTarget
+			<<"; isEarly="<<dialogState.isEarly
+			<< endl;
+	cerr <<         "            route_set: ";
+	
+	list<string>::iterator i;
+	for (i=dialogState.routeSet.begin(); i!= dialogState.routeSet.end(); i++){
+		if (i!=dialogState.routeSet.begin())
+			cerr << ",";
+		cerr << *i;
+	}
+	cerr <<endl;
+	
+	cerr << BOLD << "        Identity: "<< PLAIN << endl;
+	cerr <<         "            "<< getDialogConfig()->inherited->sipIdentity->getDebugString();
+	cerr <<endl;
+	
+	cerr << BOLD << "        Timeouts:"<< PLAIN << endl;
+	int ntimeouts=0;
+	std::list<TPRequest<string,MRef<StateMachine<SipSMCommand,string>*> > >::iterator jj=torequests.begin();
+	for (uint32_t j=0; j< torequests.size(); j++,jj++){
+		if ( this == *((*jj).get_subscriber()) ){
+			int ms= (*jj).get_ms_to_timeout();
+			cerr << string("            timeout: ")+ (*jj).get_command()
+				+ "  Time: " + itoa(ms/1000) + "." + itoa(ms%1000) << endl;
+			ntimeouts++;
+		}
+	}
+	if (ntimeouts==0){
+		cerr << "            (no timeouts)"<< endl;
+	}
+
+
+	cerr << BOLD << "        Transactions:"<< PLAIN << endl;
+	list<MRef<SipTransaction*> > transactions = getTransactions();
+	if (transactions.size()==0)
+		cerr << "            (no transactions)"<< endl;
+	else{
+		int n=0;
+		for (list<MRef<SipTransaction*> >::iterator i = transactions.begin();
+				i!=transactions.end(); i++){
+			cerr << string("            (")+itoa(n)+") "+
+				(*i)->getName() 
+				+ "   State: "
+				+ (*i)->getCurrentStateName() << endl;
+			n++;
+
+			cerr << BOLD << "                Timeouts:" << PLAIN << endl;
+
+			int ntimeouts=0;
+			std::list<TPRequest<string,   MRef<StateMachine<SipSMCommand,string>*>  > >::iterator jj=torequests.begin();
+			for (uint32_t j=0; j< torequests.size(); j++, jj++){
+				if ( *((*i)) == *((*jj).get_subscriber()) ){
+					int ms= (*jj).get_ms_to_timeout();
+					cerr << string("                        timeout: ")
+						+ (*jj).get_command()
+						+ "  Time: " + itoa(ms/1000) + "." + itoa(ms%1000)<< endl;
+					ntimeouts++;
+				}
+			}
+			if (ntimeouts==0)
+				cerr << "                        (no timeouts)"<< endl;
+		}
+	}
+
+
+	return "";
+}
+

Modified: trunk/libmsip/source/dialogs/SipDialogManagement.cxx
===================================================================
--- trunk/libmsip/source/dialogs/SipDialogManagement.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/dialogs/SipDialogManagement.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -30,6 +30,9 @@
 #include<config.h>
 
 #include<libmsip/SipDialogManagement.h>
+#include<libmsip/SipStack.h>
+#include<libmsip/SipStackInternal.h>
+#include<libmsip/SipCommandDispatcher.h>
 
 #ifdef DEBUG_OUTPUT
 #include<libmutil/dbg.h>
@@ -67,7 +70,7 @@
 		SipSMCommand cmd( CommandString( "", SipCommandString::terminate_all_calls),
 			SipSMCommand::dispatcher,
 			SipSMCommand::dispatcher);
-		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+		sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 		ret = true;
 	} else {
 		ret = false;
@@ -117,7 +120,7 @@
 		SipSMCommand cmd( CommandString( "", SipCommandString::unregister_all_identities),
 			SipSMCommand::dispatcher,
 			SipSMCommand::dispatcher);
-		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+		sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 		ret = true;
 	} else {
 		ret = false;
@@ -136,7 +139,7 @@
 		SipSMCommand cmd( CommandString( "", SipCommandString::unregister_all_identities),
 			SipSMCommand::dispatcher,
 			SipSMCommand::dispatcher);
-		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+		sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 		ret = true;
 	} else {
 		ret = false;
@@ -299,7 +302,7 @@
 		SipSMCommand cmd( CommandString( "", SipCommandString::unregister_all_identities),
 			SipSMCommand::dispatcher,
 			SipSMCommand::dispatcher);
-		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+		sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 		ret = true;
 	} else {
 		ret = false;
@@ -696,7 +699,8 @@
 
 bool SipDialogManagement::terminateAllCalls() {
 	list<MRef<SipDialog *> > dlgs;
-	dlgs = sipStack->getDispatcher()->getDialogs();
+	dlgs = sipStack->getDialogs();
+
 	merr << end; 
 	merr << "Terminating all ongoing calls:" << end;
 	for( list<MRef<SipDialog *> >::iterator it = dlgs.begin();
@@ -710,7 +714,7 @@
 		SipSMCommand cmd( CommandString( (*it)->dialogState.callId, SipCommandString::hang_up),
 				SipSMCommand::dialog_layer,
 				SipSMCommand::dialog_layer);
-		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+		sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 		pendingHangUps++;
 		merr << "    - Hanging up " << (*it)->dialogState.remoteUri << end;
 	}
@@ -720,7 +724,7 @@
 		SipSMCommand cmd( CommandString( "", SipCommandString::terminate_all_calls_done),
 				SipSMCommand::dispatcher,
 				SipSMCommand::dispatcher);
-		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+		sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 	}
 	return true;
 }
@@ -732,14 +736,14 @@
 		SipSMCommand cmd( CommandString( "", SipCommandString::terminate_all_calls_done),
 				SipSMCommand::dispatcher,
 				SipSMCommand::dispatcher);
-		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+		sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 	}
 	return true;
 }
 
 bool SipDialogManagement::deRegisterAll() {
 	list<MRef<SipDialog *> > dlgs;
-	dlgs = sipStack->getDispatcher()->getDialogs();
+	dlgs = sipStack->getDialogs();
 	merr << end; 
 	merr << "De-Registering all identities from their registrar:" << end;
 	for( list<MRef<SipDialog *> >::iterator it = dlgs.begin();
@@ -762,7 +766,7 @@
 		SipSMCommand cmd( cmdstr,
 				SipSMCommand::dialog_layer,
 				SipSMCommand::dialog_layer);
-		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+		sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 		pendingDeRegs++;
 		merr << "    De-registration request sent (username = " << 
 			(*it)->getDialogConfig()->inherited->sipIdentity->getSipUri() << ")" << end;
@@ -773,14 +777,14 @@
 		SipSMCommand cmd( CommandString( "", SipCommandString::unregister_all_identities_done),
 				SipSMCommand::dispatcher,
 				SipSMCommand::dispatcher);
-		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+		sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 	}
 	return true;
 }
 
 bool SipDialogManagement::registerAll() {
 	list<MRef<SipDialog *> > dlgs;
-	dlgs = sipStack->getDispatcher()->getDialogs();
+	dlgs = sipStack->getDialogs();
 	merr << end; 
 	merr << "Registering all identities to their registrar:" << end;
 	for( list<MRef<SipDialog *> >::iterator it = dlgs.begin();
@@ -804,7 +808,7 @@
 		SipSMCommand cmd( cmdstr,
 				SipSMCommand::dialog_layer,
 				SipSMCommand::dialog_layer);
-		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+		sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 		pendingDeRegs++;
 		merr << "    Registration request sent (username = " << 
 			(*it)->getDialogConfig()->inherited->sipIdentity->getSipUri() << ")" << end;
@@ -815,7 +819,7 @@
 		SipSMCommand cmd( CommandString( "", SipCommandString::unregister_all_identities_done),
 				SipSMCommand::dispatcher,
 				SipSMCommand::dispatcher);
-		sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+		sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 	}
 	return true;
 }
@@ -830,13 +834,13 @@
 			SipSMCommand cmd( CommandString( "", SipCommandString::unregister_all_identities_done),
 				SipSMCommand::dispatcher,
 				SipSMCommand::dispatcher);
-			sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+			sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 		} else {
 			merr << "    REGISTER: all identities have been registered correctly!" << end;
 			SipSMCommand cmd( CommandString( "", SipCommandString::register_all_identities_done),
 				SipSMCommand::dispatcher,
 				SipSMCommand::dispatcher);
-			sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+			sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 		}
 	}
 	return true;
@@ -865,6 +869,6 @@
 		CommandString( "", SipCommandString::sip_stack_shutdown_done),
 		SipSMCommand::dispatcher, 
 		SipSMCommand::dispatcher);
-	sipStack->getDispatcher()->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+	sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 	return true;
 }

Modified: trunk/libmsip/source/dialogs/SipDialogRegister.cxx
===================================================================
--- trunk/libmsip/source/dialogs/SipDialogRegister.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/dialogs/SipDialogRegister.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -118,7 +118,7 @@
 		
 		CommandString cmdstr( dialogState.callId, SipCommandString::register_sent);
 		cmdstr["identityId"] = getDialogConfig()->inherited->sipIdentity->getId();
-		dispatcher->getCallback()->handleCommand("gui", cmdstr );
+		sipStack->getCallback()->handleCommand("gui", cmdstr );
 
 		return true;
 	}else{
@@ -148,13 +148,13 @@
 			getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyAddressString);
 		cmdstr["identityId"] = getDialogConfig()->inherited->sipIdentity->getId();
 		if (getGuiFeedback()){
-			dispatcher->getCallback()->handleCommand("gui", cmdstr );
+			sipStack->getCallback()->handleCommand("gui", cmdstr );
 			setGuiFeedback(false);
 		}
 		
 		//this is for the shutdown dialog 
 		SipSMCommand cmd( cmdstr, SipSMCommand::dialog_layer, SipSMCommand::dispatcher );
-		dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE ); 
+		sipStack->enqueueCommand( cmd, HIGH_PRIO_QUEUE ); 
 
 		//request a timeout to retx a proxy_register only if we are registered ... 
 		//otherwise we would just be unregistering every now and then ...
@@ -206,7 +206,7 @@
 			SipCommandString::ask_password, 
 			getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyAddressString);
 		cmdstr["identityId"] = getDialogConfig()->inherited->sipIdentity->getId();
-		dispatcher->getCallback()->handleCommand("gui", cmdstr );
+		sipStack->getCallback()->handleCommand("gui", cmdstr );
 		//extract authentication info from received response
 		MRef<SipResponse*> resp( (SipResponse *)*command.getCommandPacket());
 		updateAuthentications( resp );
@@ -230,7 +230,7 @@
 			SipCommandString::ask_password, 
 			getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyAddressString);
 		cmdstr["identityId"] = getDialogConfig()->inherited->sipIdentity->getId();
-		dispatcher->getCallback()->handleCommand("gui", cmdstr );
+		sipStack->getCallback()->handleCommand("gui", cmdstr );
 		//extract authentication info from received response
 		MRef<SipResponse*> resp( (SipResponse *)*command.getCommandPacket());
 		updateAuthentications( resp );
@@ -300,12 +300,12 @@
 		cmdstr["identityId"] = getDialogConfig()->inherited->sipIdentity->getId();
 		//TODO: inform GUI
 		if (getGuiFeedback()){
-			dispatcher->getCallback()->handleCommand("gui", cmdstr );
+			sipStack->getCallback()->handleCommand("gui", cmdstr );
 			setGuiFeedback(false);
 		}		
 		//this is for the shutdown dialog 
 		SipSMCommand cmd( cmdstr, SipSMCommand::dialog_layer, SipSMCommand::dispatcher );
-		dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE ); 
+		sipStack->enqueueCommand( cmd, HIGH_PRIO_QUEUE ); 
 		
 		//requestTimeout(1000*60*14,SipCommandString::proxy_register);
 		//request a timeout to retx a proxy_register only if we are registered ... 
@@ -337,7 +337,7 @@
 			SipCommandString::ask_password, 
 			getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyAddressString);
 		cmdstr["identityId"] = getDialogConfig()->inherited->sipIdentity->getId();
-		dispatcher->getCallback()->handleCommand("gui", cmdstr );
+		sipStack->getCallback()->handleCommand("gui", cmdstr );
 		//extract authentication info from received response
 		MRef<SipResponse*> resp = (SipResponse *)*command.getCommandPacket();
 		updateAuthentications( resp );
@@ -364,12 +364,12 @@
 			getDialogConfig()->inherited->sipIdentity->getSipProxy()->sipProxyAddressString);   
 		cmdstr["identityId"] = getDialogConfig()->inherited->sipIdentity->getId();
 		if (getGuiFeedback()){
-			dispatcher->getCallback()->handleCommand("gui", cmdstr );
+			sipStack->getCallback()->handleCommand("gui", cmdstr );
 			setGuiFeedback(false);
 		}
 		//this is for the shutdown dialog 
 		SipSMCommand cmd( cmdstr, SipSMCommand::dialog_layer, SipSMCommand::dispatcher );
-		dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE ); 
+		sipStack->enqueueCommand( cmd, HIGH_PRIO_QUEUE ); 
 		
 		//requestTimeout(1000*60*14,SipCommandString::proxy_register);
 		//request a timeout to retx a proxy_register only if we are registered ... 
@@ -419,7 +419,7 @@
 		
 		CommandString cmdstr( dialogState.callId, SipCommandString::transport_error);
 		cmdstr["identityId"] = getDialogConfig()->inherited->sipIdentity->getId();
-		dispatcher->getCallback()->handleCommand("gui", cmdstr );
+		sipStack->getCallback()->handleCommand("gui", cmdstr );
 		return true;
 	}else{
 		return false;
@@ -461,7 +461,7 @@
 		
 		CommandString cmdstr(dialogState.callId, SipCommandString::register_sent);
 		cmdstr["identityId"] = getDialogConfig()->inherited->sipIdentity->getId();
-		dispatcher->getCallback()->handleCommand("gui", cmdstr );
+		sipStack->getCallback()->handleCommand("gui", cmdstr );
 		return true;
 	}else{
 		return false;
@@ -483,7 +483,7 @@
 				SipSMCommand::dialog_layer,
 				SipSMCommand::dispatcher);
 		
-		dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE );
+		sipStack->enqueueCommand( cmd, HIGH_PRIO_QUEUE );
 
 		return true;
 	}else{
@@ -707,6 +707,6 @@
 	addRoute( reg );
 
 	SipSMCommand cmd(*reg, SipSMCommand::dialog_layer, SipSMCommand::transaction_layer);
-	dispatcher->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
+	sipStack->enqueueCommand(cmd, HIGH_PRIO_QUEUE);
 }
 

Modified: trunk/libmsip/source/transactions/SipTransaction.cxx
===================================================================
--- trunk/libmsip/source/transactions/SipTransaction.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/transactions/SipTransaction.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -34,7 +34,7 @@
 
 
 #include<libmsip/SipTransaction.h>
-#include<libmsip/SipStack.h>
+#include<libmsip/SipStackInternal.h>
 #include<libmsip/SipCommandDispatcher.h>
 #include<libmsip/SipHeaderVia.h>
 #include<libmsip/SipLayerTransport.h>
@@ -50,18 +50,18 @@
 
 using namespace std;
 
-SipTransaction::SipTransaction(MRef<SipStack*> stack, 
+SipTransaction::SipTransaction(MRef<SipStackInternal*> stackInternal, 
 		int cseq, 
 		const string &cSeqMethod, 
 		const string &b, 
 		const string &callid): 
-			StateMachine<SipSMCommand, string>(stack->getTimeoutProvider() ), 
-			sipStack(stack),
+			StateMachine<SipSMCommand, string>(stackInternal->getTimeoutProvider() ), 
+			sipStackInternal(stackInternal),
 			cSeqNo(cseq),
 			cSeqMethod(cSeqMethod),
 			branch(b)
 {
-	dispatcher = stack->getDispatcher();
+	dispatcher = stackInternal->getDispatcher();
 	assert(dispatcher);
 	transportLayer = dispatcher->getLayerTransport();
 	assert(transportLayer);
@@ -75,7 +75,7 @@
 SipTransaction::~SipTransaction(){
 }
 
-MRef<SipTransaction*> SipTransaction::create(MRef<SipStack*> stack, 
+MRef<SipTransaction*> SipTransaction::create(MRef<SipStackInternal*> stackInternal, 
 		MRef<SipRequest*> req, 
 		bool fromTU, 
 		bool handleAck)
@@ -94,10 +94,10 @@
 // 			if (handleAck){	//UA-version
 // 				return new SipTransactionInviteClientUA(stack,seqNo,seqMethod,callId);
 // 			}else{
-				return new SipTransactionInviteClient(stack,seqNo,seqMethod,callId);
+				return new SipTransactionInviteClient(stackInternal,seqNo,seqMethod,callId);
 // 			}
 		}else{
-			MRef<SipTransaction *> res = new SipTransactionNonInviteClient(stack,seqNo,seqMethod,callId);
+			MRef<SipTransaction *> res = new SipTransactionNonInviteClient(stackInternal,seqNo,seqMethod,callId);
 			if( req->getType()=="CANCEL"){
 				// A CANCEL constructed by a client
 				// MUST have only a single Via header
@@ -112,12 +112,12 @@
 	}else{	//server transaction
 		if (req->getType()=="INVITE"){
 			if (handleAck){	//UA-version
-				return new SipTransactionInviteServerUA(stack,seqNo,seqMethod,branch,callId);
+				return new SipTransactionInviteServerUA(stackInternal,seqNo,seqMethod,branch,callId);
 			}else{
-				return new SipTransactionInviteServer(stack,seqNo,seqMethod,branch,callId);
+				return new SipTransactionInviteServer(stackInternal,seqNo,seqMethod,branch,callId);
 			}
 		}else{
-			return new SipTransactionNonInviteServer(stack,seqNo,seqMethod,branch,callId);
+			return new SipTransactionNonInviteServer(stackInternal,seqNo,seqMethod,branch,callId);
 		}
 	}
 	
@@ -217,12 +217,12 @@
 }
 
 
-SipTransactionClient::SipTransactionClient(MRef<SipStack*> stack, 
+SipTransactionClient::SipTransactionClient(MRef<SipStackInternal*> stackInternal, 
 		int seq_no, 
 		const string &cSeqMethod, 
 		const string &branch, 
 		const string &callid):
-			SipTransaction(stack, seq_no,cSeqMethod,branch,callid)
+			SipTransaction(stackInternal, seq_no,cSeqMethod,branch,callid)
 {
 	
 }
@@ -231,12 +231,12 @@
 
 }
 
-SipTransactionServer::SipTransactionServer(MRef<SipStack*> stack, 
+SipTransactionServer::SipTransactionServer(MRef<SipStackInternal*> stackInternal, 
 		int seq_no, 
 		const string &cSeqMethod, 
 		const string &branch, 
 		const string &callid):
-			SipTransaction(stack,seq_no,cSeqMethod,branch,callid)
+			SipTransaction(stackInternal,seq_no,cSeqMethod,branch,callid)
 {
 	
 }

Modified: trunk/libmsip/source/transactions/SipTransactionInviteClient.cxx
===================================================================
--- trunk/libmsip/source/transactions/SipTransactionInviteClient.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/transactions/SipTransactionInviteClient.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -107,7 +107,7 @@
 		if (statusCode>100 && statusCode<200 && resp->requires("100rel")){
 			dialog->dialogState.seqNo++;
 			MRef<SipTransaction*> trans =
-				new SipTransactionNonInviteClient(sipStack, dialog, dialog->dialogState.seqNo, "PRACK", dialog->dialogState.callId);
+				new SipTransactionNonInviteClient(sipStackInternal, dialog, dialog->dialogState.seqNo, "PRACK", dialog->dialogState.callId);
 			dialog->registerTransaction(trans);
 			sendAck(resp,trans->getBranch(), true); //last argument means that yes, we are ack:ing a 1xx -> PRACK
 		}
@@ -119,11 +119,11 @@
 	if (transitionMatch("INVITE", command, SipSMCommand::dialog_layer, SipSMCommand::transaction_layer)){
 		lastInvite = (SipRequest*) *command.getCommandPacket();
 		if( isUnreliable() ) { // retx timer
-			timerA = sipStack->getTimers()->getA();
+			timerA = sipStackInternal->getTimers()->getA();
 			requestTimeout( timerA , "timerA" );
 		}
 		
-		requestTimeout( sipStack->getTimers()->getB(), "timerB" ); //transaction timeout
+		requestTimeout( sipStackInternal->getTimers()->getB(), "timerB" ); //transaction timeout
 
 /* TODO/FIXME: re-implement this functionality
 
@@ -201,7 +201,7 @@
 		cancelTimeout("timerA");
 		cancelTimeout("timerB");
 		if( isUnreliable() )
-			requestTimeout(sipStack->getTimers()->getD(),"timerD");
+			requestTimeout(sipStackInternal->getTimers()->getD(),"timerD");
 		else 
 			requestTimeout( 0,"timerD");
 		SipSMCommand cmd( command.getCommandPacket(), 
@@ -369,7 +369,7 @@
 		cancelTimeout("timerA");
 		cancelTimeout("timerB");
 		if( isUnreliable() )
-			requestTimeout(sipStack->getTimers()->getD(),"timerD");
+			requestTimeout(sipStackInternal->getTimers()->getD(),"timerD");
 		else 
 			requestTimeout( 0,"timerD");
                 
@@ -526,7 +526,7 @@
 }
 
 
-SipTransactionInviteClient::SipTransactionInviteClient(MRef<SipStack*> stack, 
+SipTransactionInviteClient::SipTransactionInviteClient(MRef<SipStackInternal*> stack, 
 		//MRef<SipDialog*> call, 
 		int seq_no, 
 		const string &cSeqMethod, 
@@ -541,7 +541,7 @@
 //		conf = sipStack->getStackConfig();
 //	}
 	
-	timerA=sipStack->getTimers()->getA();
+	timerA=sipStackInternal->getTimers()->getA();
 	//toaddr = conf->sipIdentity->getSipProxy()->sipProxyIpAddr->clone();
 	//port = getConfig()->sipIdentity->getSipProxy()->sipProxyPort;
 	setUpStateMachine();

Modified: trunk/libmsip/source/transactions/SipTransactionInviteServer.cxx
===================================================================
--- trunk/libmsip/source/transactions/SipTransactionInviteServer.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/transactions/SipTransactionInviteServer.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -204,10 +204,10 @@
 		cancelTimeout("timerRel1xxResend");
 		lastResponse = MRef<SipResponse*>((SipResponse*)*command.getCommandPacket());		
 		if( isUnreliable() ) {
-			timerG = sipStack->getTimers()->getG();
+			timerG = sipStackInternal->getTimers()->getG();
 			requestTimeout(timerG, "timerG");
 		}
-		requestTimeout(sipStack->getTimers()->getH(),"timerH");
+		requestTimeout(sipStackInternal->getTimers()->getH(),"timerH");
 		
 		//no need for via header, it is copied from the request msg
 		send(command.getCommandPacket(), false);
@@ -309,7 +309,7 @@
 		cancelTimeout("timerG");//response re-tx 
 		cancelTimeout("timerH"); //wait for ACK reception
 		if( isUnreliable() )
-			requestTimeout(sipStack->getTimers()->getI(), "timerI");
+			requestTimeout(sipStackInternal->getTimers()->getI(), "timerI");
 		else
 			requestTimeout( 0, "timerI");
 		return true;
@@ -332,8 +332,8 @@
 				SipSMCommand::transaction_layer)){
 		MRef<SipResponse*> resp = lastResponse;
 		timerG *= 2;
-		if( timerG > sipStack->getTimers()->getT2() )
-			timerG = sipStack->getTimers()->getT2();
+		if( timerG > sipStackInternal->getTimers()->getT2() )
+			timerG = sipStackInternal->getTimers()->getT2();
 		requestTimeout( timerG, "timerG");
 		send(MRef<SipMessage*>(*resp), false);
 		return true;
@@ -497,7 +497,7 @@
 }
 
 
-SipTransactionInviteServer::SipTransactionInviteServer(MRef<SipStack*> stack, 
+SipTransactionInviteServer::SipTransactionInviteServer(MRef<SipStackInternal*> stack, 
 		//MRef<SipDialog*> d, 
 		int seq_no, 
 		const string &cSeqMethod, 

Modified: trunk/libmsip/source/transactions/SipTransactionInviteServerUA.cxx
===================================================================
--- trunk/libmsip/source/transactions/SipTransactionInviteServerUA.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/transactions/SipTransactionInviteServerUA.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -101,10 +101,10 @@
 		lastResponse = MRef<SipResponse*>((SipResponse*)*command.getCommandPacket());
 		
 		if( isUnreliable() ) {
-			timerG = sipStack->getTimers()->getG();
+			timerG = sipStackInternal->getTimers()->getG();
 			requestTimeout(timerG, "timerG");
 		}
-		requestTimeout(sipStack->getTimers()->getH(),"timerH");
+		requestTimeout(sipStackInternal->getTimers()->getH(),"timerH");
 		
 		send(command.getCommandPacket(), false);
 
@@ -137,7 +137,7 @@
 }
 
 
-SipTransactionInviteServerUA::SipTransactionInviteServerUA(MRef<SipStack*> stack,
+SipTransactionInviteServerUA::SipTransactionInviteServerUA(MRef<SipStackInternal*> stack,
 		//MRef<SipDialog*> d, 
 		int seq_no, 
 		const string &cSeqMethod, 

Modified: trunk/libmsip/source/transactions/SipTransactionNonInviteClient.cxx
===================================================================
--- trunk/libmsip/source/transactions/SipTransactionNonInviteClient.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/transactions/SipTransactionNonInviteClient.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -55,10 +55,10 @@
 #endif
 		lastRequest = dynamic_cast<SipRequest*>(*command.getCommandPacket());
 		if( isUnreliable() ) {
-			timerE = sipStack->getTimers()->getE();
+			timerE = sipStackInternal->getTimers()->getE();
 			requestTimeout(timerE, "timerE");
 		}
-		requestTimeout(sipStack->getTimers()->getF(), "timerF");
+		requestTimeout(sipStackInternal->getTimers()->getF(), "timerF");
 
 /* TODO/FIXME: This is a bit tricky - we don't know which identity is
  * currently being used (the getConfig() one will have a null one if
@@ -143,7 +143,7 @@
 		MRef<SipResponse*> pack((SipResponse *)*command.getCommandPacket());
 		cancelTimeout("timerE"); //no more retx of the request
 		if( isUnreliable() ) //response re-tx timer
-			requestTimeout(sipStack->getTimers()->getT4(),"timerK");
+			requestTimeout(sipStackInternal->getTimers()->getT4(),"timerK");
 		else
 			requestTimeout(0,"timerK");
 		
@@ -166,11 +166,11 @@
 	
 	if (transitionMatch(command, "timerE",SipSMCommand::transaction_layer,SipSMCommand::transaction_layer)){
 		timerE *= 2;
-		if( timerE > sipStack->getTimers()->getT2() ) 
-			timerE = sipStack->getTimers()->getT2();
+		if( timerE > sipStackInternal->getTimers()->getT2() ) 
+			timerE = sipStackInternal->getTimers()->getT2();
 		requestTimeout(timerE,"timerE");
 		massert(!lastRequest.isNull());
-		timerE = sipStack->getTimers()->getT2();
+		timerE = sipStackInternal->getTimers()->getT2();
 		requestTimeout(timerE,"timerE");
 		lastRequest->removeAllViaHeaders();
 		send( *lastRequest, true);	//add via, we have removed all from previous request
@@ -248,7 +248,7 @@
 		dispatcher->enqueueCommand( cmd, HIGH_PRIO_QUEUE );
 		
 		if( isUnreliable() ) 
-			requestTimeout(sipStack->getTimers()->getK(), "timerK");
+			requestTimeout(sipStackInternal->getTimers()->getK(), "timerK");
 		else 
 			requestTimeout( 0, "timerK");
 			
@@ -268,8 +268,8 @@
 				SipSMCommand::transaction_layer)){
 		//no need to check if isUnreliable() ... timerE will never be started anyway
 		timerE *= 2;
-		if( timerE > sipStack->getTimers()->getT2() ) 
-			timerE = sipStack->getTimers()->getT2();
+		if( timerE > sipStackInternal->getTimers()->getT2() ) 
+			timerE = sipStackInternal->getTimers()->getT2();
 		requestTimeout(timerE,"timerE");
 		
 		massert( !lastRequest.isNull());
@@ -373,7 +373,7 @@
 
 
 SipTransactionNonInviteClient::SipTransactionNonInviteClient(
-		MRef<SipStack *> stack,
+		MRef<SipStackInternal *> stack,
 		//MRef<SipDialog*> d, 
 		int seq_no, 
 		const string &cSeqMethod, 

Modified: trunk/libmsip/source/transactions/SipTransactionNonInviteServer.cxx
===================================================================
--- trunk/libmsip/source/transactions/SipTransactionNonInviteServer.cxx	2006-09-14 09:52:20 UTC (rev 2766)
+++ trunk/libmsip/source/transactions/SipTransactionNonInviteServer.cxx	2006-09-14 11:15:33 UTC (rev 2767)
@@ -92,7 +92,7 @@
 		
 		lastResponse = MRef<SipResponse*>((SipResponse*)*command.getCommandPacket());
 		send(command.getCommandPacket(), false); 		//Do not add via header to responses
-		requestTimeout(/*64 * timerT1*/ sipStack->getTimers()->getJ(), "timerJ");
+		requestTimeout(/*64 * timerT1*/ sipStackInternal->getTimers()->getJ(), "timerJ");
 		
 		return true;
 	}else{
@@ -108,7 +108,7 @@
 		lastResponse = MRef<SipResponse*>((SipResponse*)*command.getCommandPacket());
 		send(command.getCommandPacket(), false); 		//Do not add via header to responses
 		if( isUnreliable() )
-			requestTimeout(sipStack->getTimers()->getJ(), "timerJ");
+			requestTimeout(sipStackInternal->getTimers()->getJ(), "timerJ");
 		else 
 			requestTimeout( 0, "timerJ");
 		
@@ -329,7 +329,7 @@
 	setCurrentState(s_start);
 }
 
-SipTransactionNonInviteServer::SipTransactionNonInviteServer(MRef<SipStack*> stack, 
+SipTransactionNonInviteServer::SipTransactionNonInviteServer(MRef<SipStackInternal*> stack, 
 	//	MRef<SipDialog*> call, 
 		int seq_no, 
 		const string &cSeqMethod, 



More information about the Minisip-devel mailing list