Antonio Gallo ha scritto:
> The new app will simply return doing nothing if the channell has not yet 
> answered.

Here is the patch working for me on asterisk 1.4.8.
Let me know if this is usefull or not for CallWeaver too.

--- chan_sip.c.orig     2007-07-12 22:42:08.000000000 +0200
+++ chan_sip.c  2007-07-23 13:00:42.000000000 +0200
@@ -1387,6 +1387,7 @@
  static int function_sipchaninfo_read(struct ast_channel *chan, char 
*cmd, char *data, char *buf, size_t len);
  static int sip_dtmfmode(struct ast_channel *chan, void *data);
  static int sip_addheader(struct ast_channel *chan, void *data);
+static int sip_osd(struct ast_channel *chan, void *data);
  static int sip_do_reload(enum channelreloadreason reason);
  static int sip_reload(int fd, int argc, char *argv[]);
  static int acf_channel_read(struct ast_channel *chan, char *funcname, 
char *preparse, char *buf, size_t buflen);
@@ -17166,6 +17167,11 @@
  "Adding the wrong headers may jeopardize the SIP dialog.\n"
  "Always returns 0\n";

+static char *app_siposd = "SIPOSD";
+static char *synopsis_siposd = "Add a SIP OSD";
+static char *descrip_siposd = ""
+"  SIPOSD(Text)\n"
+"Adds a SIP OSD.\n";

  /*! \brief Set the DTMFmode for an outbound SIP call (application) */
  static int sip_dtmfmode(struct ast_channel *chan, void *data)
@@ -17590,6 +17596,7 @@
         /* Register dialplan applications */
         ast_register_application(app_dtmfmode, sip_dtmfmode, 
synopsis_dtmfmode, descrip_dtmfmode);
         ast_register_application(app_sipaddheader, sip_addheader, 
synopsis_sipaddheader, descrip_sipaddheader);
+       ast_register_application(app_siposd, sip_osd, synopsis_siposd, 
descrip_siposd);

         /* Register dialplan functions */
         ast_custom_function_register(&sip_header_function);
@@ -17689,6 +17696,69 @@
         return 0;
  }

+/*
+ * AGX's patch: SIPOSD
+ */
+static int sip_sendtext2(struct ast_channel *ast, const char *text, 
const char *disp) {
+       struct sip_request req;
+       struct sip_pvt *p = ast->tech_pvt;
+       int debug = sip_debug_test_pvt(p);
+       int res = 0;
+       //
+       debug = TRUE;
+       if (debug) ast_verbose("sip_sendtext2: starting '%s' on %s\n", 
text, ast->name);
+       if (!p) return -1;
+       if (ast_strlen_zero(text)) return 0;
+       if (debug) ast_verbose("sip_sendtext2: Really sending text %s on 
%s\n", text, ast->name);
+       //transmit_message_with_text(p, text);
+       reqprep(&req, p, SIP_MESSAGE, 0, 1);
+       //add_text(&req, text);
+       add_header(&req, "Content-Type", "text/plain");
+       add_header(&req, "Content-Disposition", disp );
+       add_header_contentLength(&req, strlen(text));
+       add_line(&req, text);
+       res = send_request(p, &req, XMIT_RELIABLE, p->ocseq);
+       return 0;
+}
+
+static int sip_osd(struct ast_channel *chan, void *data) {
+       int res = 0;
+       struct sip_pvt *p = NULL;
+       char *inbuf = (char *) data;
+       // check params
+       if (ast_strlen_zero(inbuf)) {
+               ast_log(LOG_WARNING, "sip_osd: application requires the 
argument TEXT\n");
+               return -1;
+       }
+       ast_channel_lock(chan);
+
+       if (chan->tech != &sip_tech && chan->tech != &sip_tech_info) {
+               ast_log(LOG_WARNING, "sip_osd: Call this application 
only on SIP incoming calls\n");
+               ast_channel_unlock(chan);
+               return 0;
+       }
+       if (chan->_state != AST_STATE_UP) {
+               ast_log(LOG_WARNING, "sip_osd: channel is NOT YET 
answered!\n");
+               ast_channel_unlock(chan);
+               return 0;
+       }
+       p = chan->tech_pvt;
+       if (!p) {
+               ast_log(LOG_WARNING, "sip_osd: P IS NULL\n");
+               ast_channel_unlock(chan);
+               return 0;
+       }
+       ast_channel_unlock(chan);
+       //res = ast_sendtext(chan, args.text);
+       //ast_sendtext(struct ast_channel *chan, const char *text)
+       /* Stop if we're a zombie or need a soft hangup */
+       if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || 
ast_check_hangup(chan)) return -1;
+       CHECK_BLOCKING(chan);
+       res = sip_sendtext2(chan, inbuf, "desktop");
+       ast_clear_flag(chan, AST_FLAG_BLOCKING);
+       return res;
+}
+
  AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Session 
Initiation Protocol (SIP)",
                 .load = load_module,
                 .unload = unload_module,

_______________________________________________
Callweaver-dev mailing list
[email protected]
http://lists.callweaver.org/mailman/listinfo/callweaver-dev

Reply via email to