Browse code

sbc:dsm: conditions for call leg status

Stefan Sayer authored on 11/03/2014 14:38:57
Showing 3 changed files
... ...
@@ -117,6 +117,22 @@ MOD_CONDITIONEXPORT_BEGIN(MOD_CLS_NAME) {
117 117
   if (cmd == "sbc.isOnHold")
118 118
     return new SBCIsOnHoldCondition(params, false);
119 119
 
120
+  if (cmd == "sbc.isDisconnected")
121
+    return new SBCIsDisconnectedCondition(params, false);
122
+
123
+  if (cmd == "sbc.isNoReply")
124
+    return new SBCIsNoReplyCondition(params, false);
125
+
126
+  if (cmd == "sbc.isRinging")
127
+    return new SBCIsRingingCondition(params, false);
128
+
129
+  if (cmd == "sbc.isConnected")
130
+    return new SBCIsConnectedCondition(params, false);
131
+
132
+  if (cmd == "sbc.isDisconnecting")
133
+    return new SBCIsDisconnectingCondition(params, false);
134
+
135
+
120 136
 } MOD_CONDITIONEXPORT_END
121 137
 
122 138
 
... ...
@@ -150,6 +166,28 @@ MATCH_CONDITION_START(SBCIsOnHoldCondition) {
150 166
   return res;
151 167
 } MATCH_CONDITION_END;
152 168
 
169
+#define DEF_CALLSTATUS_COND(cond_name, cond_desc, call_status)		\
170
+									\
171
+  MATCH_CONDITION_START(cond_name) {					\
172
+    SBCCallLeg* call_leg = dynamic_cast<SBCCallLeg*>(sess);		\
173
+    if (NULL == call_leg) {						\
174
+      DBG("script writer error: DSM condition used without call leg\n"); \
175
+      return false;							\
176
+    }									\
177
+									\
178
+    bool b = call_leg->getCallStatus() == call_status;			\
179
+    bool res = inv ^ b;							\
180
+    DBG("SBC: " cond_desc " == %s (res = %s)\n",			\
181
+	b ? "true":"false", res ? "true":"false");			\
182
+    return res;								\
183
+  } MATCH_CONDITION_END
184
+
185
+
186
+DEF_CALLSTATUS_COND(SBCIsDisconnectedCondition, "sbc.isDisconnected", CallLeg::Disconnected);
187
+DEF_CALLSTATUS_COND(SBCIsNoReplyCondition, "sbc.isNoReply", CallLeg::NoReply);
188
+DEF_CALLSTATUS_COND(SBCIsRingingCondition, "sbc.isRinging", CallLeg::Ringing);
189
+DEF_CALLSTATUS_COND(SBCIsConnectedCondition, "sbc.isConnected", CallLeg::Connected);
190
+DEF_CALLSTATUS_COND(SBCIsDisconnectingCondition, "sbc.isDisconnecting", CallLeg::Disconnecting);
153 191
 
154 192
 #define ACTION_GET_PROFILE			\
155 193
   SBCCallProfile* profile = NULL;					\
... ...
@@ -47,6 +47,12 @@ DEF_ACTION_1P(MODSBCActionGetCallStatus);
47 47
 DEF_SCCondition(SBCIsALegCondition);
48 48
 DEF_SCCondition(SBCIsOnHoldCondition);
49 49
 
50
+DEF_SCCondition(SBCIsDisconnectedCondition);
51
+DEF_SCCondition(SBCIsNoReplyCondition);
52
+DEF_SCCondition(SBCIsRingingCondition);
53
+DEF_SCCondition(SBCIsConnectedCondition);
54
+DEF_SCCondition(SBCIsDisconnectingCondition);
55
+
50 56
 DEF_ACTION_2P(MODSBCActionB2BRelayReliable);
51 57
 DEF_ACTION_2P(MODSBCActionAddCallee);
52 58
 
... ...
@@ -144,10 +144,13 @@ Conditions
144 144
 ----------
145 145
 call leg events (don't work in non-call SBC DSMs)
146 146
 
147
-sbc.isALeg
147
+sbc.isALeg   - is A leg of the call
148 148
 
149
-sbc.isOnHold
149
+sbc.isOnHold -  is on hold
150 150
 
151
+sbc.isDisconnected() / sbc.isNoReply() / sbc.isRinging() / sbc.isConnected() / sbc.isDisconnecting()
152
+  call leg status
153
+ 
151 154
 Actions
152 155
 -------
153 156
 sbc.profileSet(profile_variable, value)    - set SBC profile options
... ...
@@ -177,7 +180,8 @@ sbc.putOnHold()                    - put this call leg on hold
177 180
 
178 181
 sbc.resumeHeld()                   - resume from hold
179 182
 
180
-sbc.getSBCCallStatus(varname)      - get sbc call status into $varname
183
+sbc.getSBCCallStatus(varname)      - get sbc call status into $varname:
184
+                                     Disconnected/NoReply/Ringing/Connected/Disconnecting/Unknown
181 185
 
182 186
 sbc.relayReliableEvent(paramlist, processed_paramlist, unprocessed_paramlist) - relay reliable Event
183 187
   if processed (#processed=true in other leg), event is sent back with processed_paramlist parameters,