Browse code

apps/dsm/mod_dlg: new action dlg.deleteReplyBodyPart(content_type) - added also dlg.addReplyBodyPart to Readme

Juha Heinanen authored on 08/05/2014 11:56:50
Showing 3 changed files
... ...
@@ -59,6 +59,7 @@ MOD_ACTIONEXPORT_BEGIN(MOD_CLS_NAME) {
59 59
   DEF_CMD("dlg.relayError", DLGB2BRelayErrorAction);
60 60
 
61 61
   DEF_CMD("dlg.addReplyBodyPart", DLGAddReplyBodyPartAction);
62
+  DEF_CMD("dlg.deleteReplyBodyPart", DLGDeleteReplyBodyPartAction);
62 63
 
63 64
 } MOD_ACTIONEXPORT_END;
64 65
 
... ...
@@ -549,3 +550,20 @@ EXEC_ACTION_START(DLGAddReplyBodyPartAction) {
549 550
   DBG("added to reply body part %s='%s'\n",
550 551
       content_type.c_str(), body_part.c_str());
551 552
 } EXEC_ACTION_END;
553
+
554
+EXEC_ACTION_START(DLGDeleteReplyBodyPartAction) {
555
+  DSMMutableSipReply* sip_reply;
556
+
557
+  AVarMapT::iterator it = sc_sess->avar.find(DSM_AVAR_REPLY);
558
+  if (it == sc_sess->avar.end() ||
559
+      !isArgAObject(it->second) ||
560
+      !(sip_reply = dynamic_cast<DSMMutableSipReply*>(it->second.asObject()))) {
561
+    throw DSMException("dlg", "cause", "no reply");
562
+  }
563
+
564
+  if (sip_reply->mutable_reply->body.deletePart(arg)) {
565
+    INFO("failed to delete reply body part '%s'\n", arg.c_str());
566
+  } else {
567
+    INFO("deleted reply body part '%s'\n", arg.c_str());
568
+  }
569
+} EXEC_ACTION_END;
... ...
@@ -55,4 +55,6 @@ DEF_ACTION_2P(DLGReferAction);
55 55
 DEF_ACTION_2P(DLGB2BRelayErrorAction);
56 56
 
57 57
 DEF_ACTION_2P(DLGAddReplyBodyPartAction);
58
+DEF_ACTION_1P(DLGDeleteReplyBodyPartAction);
59
+
58 60
 #endif
... ...
@@ -89,6 +89,10 @@ Request/Reply Body handling in sipRequest/sipReply events:
89 89
 actions (applicable only in sipRequest/sipReply event handling blocks):
90 90
 dlg.getRequestBody(content_type, dstvar)  - get body of content_type in $dstvar
91 91
 dlg.getReplyBody(content_type, dstvar)    - get body of content_type in $dstvar
92
+dlg.addReplyBodyPart(content_type, payload) - add new body part possibly
93
+  converting the resulting body to multipart
94
+dlg.deleteReplyBodyPart(content_type) - delete body part from multipart
95
+  body possibly converting the resulting body to singlepart
92 96
 
93 97
 conditions: 
94 98
   dlg.replyHasContentType(content_type) and dlg.requestHasContentType(content_type)