telephony/net/asterisk-11.x-chan-dongle/patches/001-add-send-ussd.patch

65 lines
1.8 KiB
Diff

--- a/app.c
+++ b/app.c
@@ -114,7 +114,44 @@ static int app_send_sms_exec (attribute_
return !status;
}
+static int app_send_ussd_exec (attribute_unused struct ast_channel* channel, const char* data)
+{
+ char* parse;
+ const char* msg;
+ int status;
+ void * msgid;
+ AST_DECLARE_APP_ARGS (args,
+ AST_APP_ARG (device);
+ AST_APP_ARG (ussd);
+ );
+
+ if (ast_strlen_zero (data))
+ {
+ return -1;
+ }
+
+ parse = ast_strdupa (data);
+
+ AST_STANDARD_APP_ARGS (args, parse);
+
+ if (ast_strlen_zero (args.device))
+ {
+ ast_log (LOG_ERROR, "NULL device for ussd -- USSD will not be sent\n");
+ return -1;
+ }
+
+ if (ast_strlen_zero (args.ussd))
+ {
+ ast_log (LOG_ERROR, "NULL ussd command -- USSD will not be sent\n");
+ return -1;
+ }
+
+ msg = send_ussd(args.device, args.ussd, &status, &msgid);
+ if(!status)
+ ast_log (LOG_ERROR, "[%s] %s with id %p\n", args.device, msg, msgid);
+ return !status;
+}
static const struct dongle_application
{
@@ -144,7 +181,15 @@ static const struct dongle_application
" Message - text of the message\n"
" Validity - Validity period in minutes\n"
" Report - Boolean flag for report request\n"
- }
+ },
+ {
+ "DongleSendUSSD",
+ app_send_ussd_exec,
+ "DongleSendUSSD(Device,USSD)",
+ "DongleSendUSSD(Device,USSD)\n"
+ " Device - Id of device from dongle.conf\n"
+ " USSD - ussd command\n"
+ }
};
#if ASTERISK_VERSION_NUM >= 10800