Browse code

cnxcc: removed usage of mi

Federico Cabiddu authored on 04/01/2017 09:27:21
Showing 1 changed files
... ...
@@ -52,7 +52,6 @@
52 52
 #include "../../core/mod_fix.h"
53 53
 #include "../dialog/dlg_load.h"
54 54
 #include "../dialog/dlg_hash.h"
55
-#include "../../core/mi/mi_types.h"
56 55
 #include "../../core/fmsg.h"
57 56
 #include "../../core/rpc.h"
58 57
 #include "../../core/rpc_lookup.h"
... ...
@@ -1029,6 +1028,8 @@ int terminate_call(call_t *call) {
1029 1029
 	sip_msg_t *dmsg = NULL;
1030 1030
 	sip_data_t *data = NULL;
1031 1031
 
1032
+	dlg_cell_t *cell;
1033
+
1032 1034
 	LM_DBG("Got kill signal for call [%.*s] client [%.*s] h_id [%u] h_entry [%u]. Dropping it now\n",
1033 1035
 		call->sip_data.callid.len,
1034 1036
 		call->sip_data.callid.s,
... ...
@@ -1036,64 +1037,30 @@ int terminate_call(call_t *call) {
1036 1036
 		call->client_id.s,
1037 1037
 		call->dlg_h_id,
1038 1038
 		call->dlg_h_entry);
1039
-
1040
-	struct mi_root *root, *result	= NULL;
1041
-	struct mi_node *node, *node1	= NULL;
1042
-	struct mi_cmd *end_dlg_cmd		= NULL;
1043
-
1044
-	if (_data.cs_route_number >= 0) {
1039
+	
1045 1040
 		data = &call->sip_data;
1046
-		if (faked_msg_init_with_dlg_info(&data->callid, &data->from_uri, &data->from_tag,
1047
-					&data->to_uri, &data->to_tag, &dmsg) != 0) {
1048
-			LM_ERR("[%.*s]: error generating faked sip message\n", data->callid.len, data->callid.s);
1049
-			dmsg = NULL;
1050
-		}
1051
-	}
1052
-	root	= init_mi_tree(0, 0, 0);
1053
-	if (root == NULL) {
1054
-		LM_ERR("Error initializing tree to terminate call\n");
1041
+	if (faked_msg_init_with_dlg_info(&data->callid, &data->from_uri, &data->from_tag,
1042
+				&data->to_uri, &data->to_tag, &dmsg) != 0) {
1043
+		LM_ERR("[%.*s]: error generating faked sip message\n", data->callid.len, data->callid.s);
1055 1044
 		goto error;
1056 1045
 	}
1057 1046
 
1058
-	node	= &root->node;
1059
-	node1	= addf_mi_node_child(node, MI_DUP_VALUE, MI_SSTR("h_entry"), "%u", call->dlg_h_entry);
1060
-	if (node1 == NULL) {
1061
-		LM_ERR("Error initializing h_entry node to terminate call\n");
1062
-		goto error;
1047
+	cell = _dlgbinds.get_dlg(dmsg);
1048
+	if (!cell) {
1049
+			LM_ERR("[%.*s]: cannot get dialog\n", data->callid.len, data->callid.s);
1050
+			goto error;
1063 1051
 	}
1064 1052
 
1065
-	node1	= addf_mi_node_child(node, MI_DUP_VALUE, MI_SSTR("h_id"), "%u", call->dlg_h_id);
1066
-	if (node1 == NULL) {
1067
-		LM_ERR("Error initializing dlg_h_id node to terminate call\n");
1068
-		goto error;
1069
-	}
1070
-
1071
-	end_dlg_cmd = lookup_mi_cmd(MI_SSTR("dlg_end_dlg"));
1072
-	if (node == NULL) {
1073
-		LM_ERR("Error initializing dlg_end_dlg command\n");
1074
-		goto error;
1075
-	}
1076
-
1077
-	result	= run_mi_cmd(end_dlg_cmd, root);
1078
-	if (result == NULL) {
1079
-		LM_ERR("Error executing dlg_end_dlg command\n");
1080
-		goto error;
1081
-	}
1082
-
1083
-	if (result->code == 200) {
1053
+	if (!_dlgbinds.terminate_dlg(cell, NULL)) {
1084 1054
 		LM_DBG("dlg_end_dlg sent to call [%.*s]\n", call->sip_data.callid.len, call->sip_data.callid.s);
1085
-		free_mi_tree(root);
1086
-		free_mi_tree(result);
1087 1055
 
1088
-		if(dmsg) __notify_call_termination(dmsg);
1056
+		if (_data.cs_route_number >= 0) 
1057
+			__notify_call_termination(dmsg);
1089 1058
 		return 0;
1090 1059
 	}
1091 1060
 
1092
-	LM_ERR("Error executing dlg_end_dlg command. Return code was [%d]\n", result->code);
1061
+	LM_ERR("Error executing terminate_dlg command");
1093 1062
 error:
1094
-	if (root)
1095
-		free_mi_tree(root);
1096
-
1097 1063
 	return -1;
1098 1064
 }
1099 1065