Module: sems
Branch: master
Commit: e904822b2c154c900694a97a207dcd12453d6a7f
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=e904822b2c154c900694a97a207dcd12453d6a7f

Author: Raphael Coeffic <[email protected]>
Committer: Raphael Coeffic <[email protected]>
Date:   Mon Feb 20 10:32:57 2012 +0100

multi-mime: dialog API changes

---

 core/AmSipDialog.cpp |   61 ++++++++++++++++++++++---------------------------
 core/AmSipDialog.h   |   29 ++++++++---------------
 2 files changed, 37 insertions(+), 53 deletions(-)

diff --git a/core/AmSipDialog.cpp b/core/AmSipDialog.cpp
index 2ef5b2c..585de88 100644
--- a/core/AmSipDialog.cpp
+++ b/core/AmSipDialog.cpp
@@ -689,20 +689,18 @@ string AmSipDialog::getRoute()
 int AmSipDialog::reply(const AmSipRequest& req,
                       unsigned int  code,
                       const string& reason,
-                      const string& content_type,
-                      const string& body,
+                      const AmMimeBody* body,
                       const string& hdrs,
                       int flags)
 {
   return reply(AmSipTransaction(req.method,req.cseq,req.tt),
-              code,reason,content_type,body,hdrs,flags);
+              code,reason,body,hdrs,flags);
 }
 
 int AmSipDialog::reply(const AmSipTransaction& t,
                       unsigned int  code,
                       const string& reason,
-                      const string& content_type,
-                      const string& body,
+                      const AmMimeBody* body,
                       const string& hdrs,
                       int flags)
 {
@@ -727,8 +725,9 @@ int AmSipDialog::reply(const AmSipTransaction& t,
   reply.hdrs = m_hdrs;
   reply.cseq = t.cseq;
   reply.cseq_method = t.method;
-  reply.content_type = content_type;
-  reply.body = body;
+
+  if(body != NULL)
+    reply.body = *body;
 
   if (!flags&SIP_FLAGS_VERBATIM) {
     // add Signature
@@ -825,7 +824,7 @@ int AmSipDialog::bye(const string& hdrs, int flags)
 
       if (status != Disconnecting) {
        status = Disconnected;
-       return sendRequest("BYE", "", "", hdrs, flags);
+       return sendRequest("BYE", NULL, hdrs, flags);
       } else {
        return 0;
       }
@@ -864,12 +863,11 @@ int AmSipDialog::bye(const string& hdrs, int flags)
 }
 
 int AmSipDialog::reinvite(const string& hdrs,  
-                         const string& content_type,
-                         const string& body,
+                         const AmMimeBody* body,
                          int flags)
 {
   if(status == Connected) {
-    return sendRequest("INVITE", content_type, body, hdrs, flags);
+    return sendRequest("INVITE", body, hdrs, flags);
   }
   else {
     DBG("reinvite(): we are not connected "
@@ -880,11 +878,10 @@ int AmSipDialog::reinvite(const string& hdrs,
 }
 
 int AmSipDialog::invite(const string& hdrs,  
-                       const string& content_type,
-                       const string& body)
+                       const AmMimeBody* body)
 {
   if(status == Disconnected) {
-    int res = sendRequest("INVITE", content_type, body, hdrs);
+    int res = sendRequest("INVITE", body, hdrs);
     DBG("TODO: is status already 'trying'? status=%s\n",getStatusStr());
     //status = Trying;
     return res;
@@ -897,8 +894,7 @@ int AmSipDialog::invite(const string& hdrs,
   return -1;
 }
 
-int AmSipDialog::update(const string &cont_type, 
-                        const string &body, 
+int AmSipDialog::update(const AmMimeBody* body, 
                         const string &hdrs)
 {
   switch(status){
@@ -907,7 +903,7 @@ int AmSipDialog::update(const string &cont_type,
   case Trying:
   case Proceeding:
   case Early:
-    return sendRequest(SIP_METH_UPDATE, cont_type, body, hdrs);
+    return sendRequest(SIP_METH_UPDATE, body, hdrs);
 
   default:
   case Cancelling:
@@ -927,7 +923,7 @@ int AmSipDialog::refer(const string& refer_to,
     string hdrs = SIP_HDR_COLSP(SIP_HDR_REFER_TO) + refer_to + CRLF;
     if (expires>=0) 
       hdrs+= SIP_HDR_COLSP(SIP_HDR_EXPIRES) + int2str(expires) + CRLF;
-    return sendRequest("REFER", "", "", hdrs);
+    return sendRequest("REFER", NULL, hdrs);
   }
   else {
     DBG("refer(): we are not Connected."
@@ -958,7 +954,7 @@ int AmSipDialog::transfer(const string& target)
       hdrs = PARAM_HDR ": " "Transfer-RR=\"" + route + "\""+CRLF;
     }
                                
-    int ret = tmp_d.sendRequest("REFER","","",hdrs);
+    int ret = tmp_d.sendRequest("REFER",NULL,hdrs);
     if(!ret){
       uac_trans.insert(tmp_d.uac_trans.begin(),
                       tmp_d.uac_trans.end());
@@ -975,8 +971,7 @@ int AmSipDialog::transfer(const string& target)
 }
 
 int AmSipDialog::prack(const AmSipReply &reply1xx,
-                       const string &cont_type, 
-                       const string &body, 
+                       const AmMimeBody* body, 
                        const string &hdrs)
 {
   switch(status) {
@@ -999,7 +994,7 @@ int AmSipDialog::prack(const AmSipReply &reply1xx,
           int2str(reply1xx.rseq) + " " + 
           int2str(reply1xx.cseq) + " " + 
           reply1xx.cseq_method + CRLF;
-  return sendRequest(SIP_METH_PRACK, cont_type, body, h);
+  return sendRequest(SIP_METH_PRACK, body, h);
 }
 
 int AmSipDialog::cancel()
@@ -1029,12 +1024,11 @@ int AmSipDialog::cancel()
 }
 
 int AmSipDialog::sendRequest(const string& method, 
-                            const string& content_type,
-                            const string& body,
+                            const AmMimeBody* body,
                             const string& hdrs,
                             int flags)
 {
-  int ret = sendRequest(method,content_type,body,hdrs,flags,cseq);
+  int ret = sendRequest(method,body,hdrs,flags,cseq);
   if (ret < 0)
     return ret;
 
@@ -1046,8 +1040,7 @@ int AmSipDialog::sendRequest(const string& method,
 
 
 int AmSipDialog::sendRequest(const string& method, 
-                            const string& content_type,
-                            const string& body,
+                            const AmMimeBody* body,
                             const string& hdrs,
                             int flags,
                             unsigned int req_cseq)
@@ -1085,9 +1078,10 @@ int AmSipDialog::sendRequest(const string& method,
 
   req.route = getRoute();
 
-  req.content_type = content_type;
-  req.body = body;
-  DBG("req.body = '%s'\n", req.body.c_str());
+  if(body != NULL) {
+    req.body = *body;
+    //DBG("req.body = '%s'\n", req.body.c_str());
+  }
 
   if (offeranswer_enabled && oa.onRequestOut(req))
     return -1;
@@ -1126,8 +1120,7 @@ int AmSipDialog::drop()
 }
 
 int AmSipDialog::send_200_ack(unsigned int inv_cseq,
-                             const string& content_type,
-                             const string& body,
+                             const AmMimeBody* body,
                              const string& hdrs,
                              int flags)
 {
@@ -1170,8 +1163,8 @@ int AmSipDialog::send_200_ack(unsigned int inv_cseq,
 
   req.route = getRoute();
 
-  req.content_type = content_type;
-  req.body = body;
+  if(body != NULL)
+    req.body = *body;
 
   if (offeranswer_enabled && oa.onRequestOut(req))
     return -1;
diff --git a/core/AmSipDialog.h b/core/AmSipDialog.h
index e78d0ff..42e8250 100644
--- a/core/AmSipDialog.h
+++ b/core/AmSipDialog.h
@@ -116,8 +116,7 @@ private:
 
   /** @return 0 on success */
   int sendRequest(const string& method, 
-                 const string& content_type,
-                 const string& body,
+                 const AmMimeBody* body,
                  const string& hdrs,
                  int flags,
                  unsigned int req_cseq);
@@ -226,8 +225,7 @@ private:
   int reply(const AmSipRequest& req,
            unsigned int  code, 
            const string& reason,
-           const string& content_type = "",
-           const string& body = "",
+           const AmMimeBody* body = NULL,
            const string& hdrs = "",
            int flags = 0);
 
@@ -235,22 +233,19 @@ private:
   int reply(const AmSipTransaction& t,
            unsigned int  code, 
            const string& reason,
-           const string& content_type = "",
-           const string& body = "",
+           const AmMimeBody* body = NULL,
            const string& hdrs = "",
            int flags = 0);
 
   /** @return 0 on success */
   int sendRequest(const string& method, 
-                 const string& content_type = "",
-                 const string& body = "",
+                 const AmMimeBody* body = NULL,
                  const string& hdrs = "",
                  int flags = 0);
 
   /** @return 0 on success */
   int send_200_ack(unsigned int inv_cseq,
-                  const string& content_type = "",
-                  const string& body = "",
+                  const AmMimeBody* body = NULL,
                   const string& hdrs = "",
                   int flags = 0);
     
@@ -262,25 +257,21 @@ private:
 
   /** @return 0 on success */
   int prack(const AmSipReply &reply1xx,
-            const string &cont_type, 
-            const string &body, 
+           const AmMimeBody* body,
             const string &hdrs);
 
   /** @return 0 on success */
-  int update(const string &cont_type, 
-            const string &body, 
+  int update(const AmMimeBody* body, 
             const string &hdrs);
 
   /** @return 0 on success */
-  int reinvite(const string& hdrs,  
-              const string& content_type,
-              const string& body,
+  int reinvite(const string& hdrs,
+              const AmMimeBody* body,
               int flags = 0);
 
   /** @return 0 on success */
   int invite(const string& hdrs,  
-            const string& content_type,
-            const string& body);
+            const AmMimeBody* body);
 
   /** @return 0 on success */
   int refer(const string& refer_to,

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to