From 0c2cb8264e41b547fc717a80b8878c1965037746 Mon Sep 17 00:00:00 2001
From: yanmorin <yanmorin>
Date: Mon, 26 Sep 2005 21:50:12 +0000
Subject: [PATCH] New tests and features Add mute/unmute Change the refuse
 message send

---
 src/gui/guiframework.cpp          | 11 +++++++++++
 src/gui/guiframework.h            |  2 ++
 src/gui/server/guiserverimpl.cpp  | 12 +++++++++++-
 src/gui/server/request.cpp        |  6 ++++--
 src/gui/server/request.h          |  1 +
 src/gui/server/requestfactory.cpp |  4 ++--
 src/managerimpl.cpp               | 15 +++++++++++++--
 src/managerimpl.h                 |  5 ++++-
 src/sipvoiplink.cpp               |  8 +++++---
 9 files changed, 53 insertions(+), 11 deletions(-)

diff --git a/src/gui/guiframework.cpp b/src/gui/guiframework.cpp
index adafcec026..809d820779 100644
--- a/src/gui/guiframework.cpp
+++ b/src/gui/guiframework.cpp
@@ -94,6 +94,17 @@ GuiFramework::transferCall (short id, const string& to)
 	}
 }
 
+void
+GuiFramework::mute() 
+{
+  Manager::instance().mute();
+}
+void
+GuiFramework::unmute() 
+{
+  Manager::instance().unmute();
+}
+
 void
 GuiFramework::muteOn (short id)
 {
diff --git a/src/gui/guiframework.h b/src/gui/guiframework.h
index 851d4e397f..cbbb5d99a9 100644
--- a/src/gui/guiframework.h
+++ b/src/gui/guiframework.h
@@ -55,6 +55,8 @@ public:
 	int onHoldCall (short id);
 	int offHoldCall (short id);
 	int transferCall (short id, const std::string& to);
+	void mute ();
+	void unmute ();
 	void muteOn (short id);
 	void muteOff (short id);
 	int refuseCall (short id);
diff --git a/src/gui/server/guiserverimpl.cpp b/src/gui/server/guiserverimpl.cpp
index 112b7c86b2..c3d6ccfa9b 100644
--- a/src/gui/server/guiserverimpl.cpp
+++ b/src/gui/server/guiserverimpl.cpp
@@ -181,6 +181,16 @@ GUIServerImpl::dtmfCall(const std::string& callId, const std::string& dtmfKey)
 int 
 GUIServerImpl::incomingCall (short id) 
 {
+  std::ostringstream responseMessage, callId;
+  callId << "s" << id;
+  responseMessage << "acc1 " << callId.str() << " call";
+
+  SubCall subcall("seq0", callId.str());
+
+  insertSubCall(id, subcall);
+
+  _requestManager.sendResponse(ResponseMessage("001", "seq0", responseMessage.str()));
+
   return 0;
 }
 
@@ -228,7 +238,7 @@ GUIServerImpl::displayTextMessage (short id, const std::string& message)
 {
   std::ostringstream responseMessage;
   std::string seq = getSequenceIdFromId(id);
-  responseMessage <<"s" << id << "text message: " + message;
+  responseMessage << "s" << id << " text message: " + message;
   _requestManager.sendResponse(ResponseMessage("700", seq, responseMessage.str()));
 }
 
diff --git a/src/gui/server/request.cpp b/src/gui/server/request.cpp
index ddd84bf882..ec8704996e 100644
--- a/src/gui/server/request.cpp
+++ b/src/gui/server/request.cpp
@@ -112,13 +112,15 @@ RequestDTMF::execute()
 ResponseMessage
 RequestMute::execute()
 {
-  return message("200","TODO");
+  GUI::instance().muteOn();
+  return message("200","OK");
 }
 
 ResponseMessage
 RequestUnmute::execute()
 {
-  return message("200","TODO");
+  GUI::instance().unmute();
+  return message("200","OK");
 }
 
 ResponseMessage
diff --git a/src/gui/server/request.h b/src/gui/server/request.h
index 12cc6dd879..4851952e73 100644
--- a/src/gui/server/request.h
+++ b/src/gui/server/request.h
@@ -95,6 +95,7 @@ class RequestGlobalCall : public Request
 public:
   RequestGlobalCall(const std::string &sequenceId, const TokenList& argList) : Request(sequenceId, argList) {
     TokenList::iterator iter = _argList.begin();
+
     if (iter != _argList.end() && ((*iter)[0]=='c' || (*iter)[0]=='s') ) {
       _callId = *iter;
       _argList.pop_front();
diff --git a/src/gui/server/requestfactory.cpp b/src/gui/server/requestfactory.cpp
index 895c30bf05..20995e9c40 100644
--- a/src/gui/server/requestfactory.cpp
+++ b/src/gui/server/requestfactory.cpp
@@ -87,12 +87,12 @@ RequestFactory::registerAll() {
   registerRequest<RequestSyntaxError> ("syntaxerror");
   registerRequest<RequestCall>     ("call");
   registerRequest<RequestQuit>     ("quit");
-  registerRequest<RequestAnswer>   ("anwser");
+  registerRequest<RequestAnswer>   ("answer");
   registerRequest<RequestRefuse>   ("refuse");
   registerRequest<RequestHold>     ("hold");
   registerRequest<RequestUnhold>   ("unhold");
   registerRequest<RequestHangup>   ("hangup");
-  registerRequest<RequestDTMF> ("dtmf");
+  registerRequest<RequestDTMF>     ("dtmf");
   registerRequest<RequestTransfer> ("transfer");
   registerRequest<RequestMute>     ("mute");
   registerRequest<RequestUnmute>   ("unmute");
diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp
index 7998a1ef69..342cb6e2b5 100644
--- a/src/managerimpl.cpp
+++ b/src/managerimpl.cpp
@@ -87,7 +87,8 @@ ManagerImpl::ManagerImpl (void)
 
   // Initialize after by init() -> initVolume()
   _spkr_volume = 0;
-  _mic_volume  = 0;
+  _mic_volume  = 0; 
+  _mic_volume_before_mute = 0;
 }
 
 ManagerImpl::~ManagerImpl (void) 
@@ -430,6 +431,16 @@ ManagerImpl::transferCall (short id, const string& to)
 	call->setState(Transfered);
 	return call->transfer(to);
 }
+void
+ManagerImpl::mute() {
+  _mic_volume_before_mute = _mic_volume;
+  _mic_volume = 0;
+}
+
+void
+ManagerImpl::unmute() {
+  _mic_volume = _mic_volume_before_mute;
+}
 
 void 
 ManagerImpl::muteOn (short id)
@@ -559,7 +570,7 @@ ManagerImpl::incomingCall (short id)
 	call->setStatus(string(RINGING_STATUS));
 	call->setState(Progressing);
 	ringtone(true);
-	displayStatus(RINGING_STATUS);
+	//displayStatus(RINGING_STATUS);
 	return _gui->incomingCall(id);
 }
 
diff --git a/src/managerimpl.h b/src/managerimpl.h
index 05c7ae480b..d369c10404 100644
--- a/src/managerimpl.h
+++ b/src/managerimpl.h
@@ -149,6 +149,8 @@ public:
 	int onHoldCall (short id);
 	int offHoldCall (short id);
 	int transferCall (short id, const std::string& to);
+  void mute();
+  void unmute();
 	void muteOn (short id);
 	void muteOff (short id);
 	int refuseCall (short id);
@@ -220,7 +222,7 @@ public:
 	inline int getSpkrVolume 	(void) 			{ return _spkr_volume; }
 	inline void setSpkrVolume 	(int spkr_vol) 	{ _spkr_volume = spkr_vol; }
 	inline int getMicroVolume 	(void) 			{ return _mic_volume; }
-	inline void setMicroVolume 	(int mic_vol) 	{ _mic_volume = mic_vol; }
+	inline void setMicroVolume 	(int mic_vol) 	{ _mic_volume = _mic_volume_before_mute = mic_vol; }
 	
 	/*
 	 * Manage information about firewall
@@ -341,6 +343,7 @@ private:
 	// To handle volume control
 	int 		_spkr_volume;
 	int 		_mic_volume;
+  int 		_mic_volume_before_mute;
 
 	// To handle firewall
 	int			_firewallPort;
diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp
index ca4bf71d1f..2d2e812765 100644
--- a/src/sipvoiplink.cpp
+++ b/src/sipvoiplink.cpp
@@ -526,9 +526,10 @@ SipVoIPLink::refuse (short id)
 	
   osip_message_t *answer = NULL;
   eXosip_lock();
-  i = eXosip_call_build_answer (getSipCall(id)->getTid(), BUSY_HERE, &answer);
+  // not BUSY.. where decline the invitation!
+  i = eXosip_call_build_answer (getSipCall(id)->getTid(), SIP_DECLINE, &answer);
   if (i == 0) {
-    i = eXosip_call_send_answer (getSipCall(id)->getTid(), BUSY_HERE, answer);
+    i = eXosip_call_send_answer (getSipCall(id)->getTid(), SIP_DECLINE, answer);
   }
   eXosip_unlock();
   return i;
@@ -570,7 +571,7 @@ SipVoIPLink::getEvent (void)
     // Generate id
     id = Manager::instance().generateNewCallId();
     Manager::instance().pushBackNewCall(id, Incoming);
-    _debug("Incoming Call with identifiant %d [cid = %d, did = %d]\n",
+    _debug("Incoming Call with id %d [cid = %d, did = %d]\n",
 	   id, event->cid, event->did);
     _debug("Local audio port: %d\n", _localPort);
 
@@ -737,6 +738,7 @@ SipVoIPLink::getEvent (void)
     default:
       break;
     }
+
     break; 
 
   case EXOSIP_CALL_SERVERFAILURE:
-- 
GitLab