From 279b089a52beba99515e379c151c883c6198a5aa Mon Sep 17 00:00:00 2001
From: yanmorin <yanmorin>
Date: Wed, 2 Nov 2005 21:20:17 +0000
Subject: [PATCH] Add message text handling

---
 src/gui/guiframework.h           |  1 +
 src/gui/server/guiserverimpl.cpp |  5 +++++
 src/gui/server/guiserverimpl.h   |  4 +---
 src/managerimpl.cpp              | 11 +++++++++++
 src/managerimpl.h                |  2 ++
 src/sipvoiplink.cpp              |  1 +
 6 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/src/gui/guiframework.h b/src/gui/guiframework.h
index 2912b6d17b..6b46a9bc81 100644
--- a/src/gui/guiframework.h
+++ b/src/gui/guiframework.h
@@ -38,6 +38,7 @@ public:
 	virtual void peerAnsweredCall (CALLID id) = 0;
 	virtual void peerRingingCall (CALLID id) = 0;
 	virtual void peerHungupCall (CALLID id) = 0;
+  virtual void incomingMessage(const std::string& message) = 0;
 	virtual void displayStatus (const std::string& status) = 0;
 	virtual void displayConfigError (const std::string& error) = 0;
 	virtual void displayTextMessage (CALLID id, const std::string& message) = 0;
diff --git a/src/gui/server/guiserverimpl.cpp b/src/gui/server/guiserverimpl.cpp
index fd9f22f2ae..2a6625b6a4 100644
--- a/src/gui/server/guiserverimpl.cpp
+++ b/src/gui/server/guiserverimpl.cpp
@@ -323,6 +323,11 @@ GUIServerImpl::incomingCall (CALLID id, const std::string& accountId, const std:
   return 0;
 }
 
+void
+GUIServerImpl::incomingMessage(const std::string& message) {
+  _requestManager.sendResponse(ResponseMessage("030", _getEventsSequenceId, message));
+}
+
 void  
 GUIServerImpl::peerAnsweredCall (CALLID id) 
 {
diff --git a/src/gui/server/guiserverimpl.h b/src/gui/server/guiserverimpl.h
index b5822bdfbd..836dc28657 100644
--- a/src/gui/server/guiserverimpl.h
+++ b/src/gui/server/guiserverimpl.h
@@ -38,10 +38,8 @@ public:
   // exec loop
   int exec(void);
 
-  // Reimplementation of virtual functions
-  // TODO: remove incomingCall with one parameter
-	int incomingCall (CALLID id);
   int incomingCall(CALLID id, const std::string& accountId, const std::string& from);
+  void incomingMessage(const std::string& message);
 
 	void peerAnsweredCall (CALLID id);
 	void peerRingingCall (CALLID id);
diff --git a/src/managerimpl.cpp b/src/managerimpl.cpp
index 4acb2c3791..63aca562cf 100644
--- a/src/managerimpl.cpp
+++ b/src/managerimpl.cpp
@@ -744,6 +744,17 @@ ManagerImpl::incomingCall (CALLID id, const std::string& name, const std::string
   return _gui->incomingCall(id, accountId, from);
 }
 
+/**
+ * SipEvent Thread
+ * for outgoing message, send by SipEvent
+ */
+void 
+ManagerImpl::incomingMessage(const std::string& message) {
+  if (_gui) {
+    _gui->incomingMessage(message);
+  }
+}
+
 /**
  * SipEvent Thread
  * for outgoing call, send by SipEvent
diff --git a/src/managerimpl.h b/src/managerimpl.h
index d210d6eee4..5cb69410d1 100644
--- a/src/managerimpl.h
+++ b/src/managerimpl.h
@@ -150,6 +150,8 @@ public:
   void peerAnsweredCall (CALLID id);
   int peerRingingCall (CALLID id);
   int peerHungupCall (CALLID id);
+  void incomingMessage(const std::string& message);
+
   void displayTextMessage (CALLID id, const std::string& message);
   void displayErrorText (CALLID id, const std::string& message);
   void displayError (const std::string& error);
diff --git a/src/sipvoiplink.cpp b/src/sipvoiplink.cpp
index 8b44fef49b..4f7cc7579b 100644
--- a/src/sipvoiplink.cpp
+++ b/src/sipvoiplink.cpp
@@ -972,6 +972,7 @@ SipVoIPLink::getEvent (void)
               strcmp(c_t->subtype,"plain") == 0
             ) {
             _debug("  Text body: %s\n", body->body);
+            Manager::instance().incomingMessage(body->body);
           }
         }
       }
-- 
GitLab