[asterisk-commits] kharwell: branch kharwell/pimp_my_sip r382554 - in /team/kharwell/pimp_my_sip...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed Mar 6 17:58:47 CST 2013
Author: kharwell
Date: Wed Mar 6 17:58:43 2013
New Revision: 382554
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=382554
Log:
in dialog send/recv should be available now - need to test
Modified:
team/kharwell/pimp_my_sip/channels/chan_gulp.c
team/kharwell/pimp_my_sip/res/res_sip.c
team/kharwell/pimp_my_sip/res/res_sip_messaging.c
Modified: team/kharwell/pimp_my_sip/channels/chan_gulp.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_my_sip/channels/chan_gulp.c?view=diff&rev=382554&r1=382553&r2=382554
==============================================================================
--- team/kharwell/pimp_my_sip/channels/chan_gulp.c (original)
+++ team/kharwell/pimp_my_sip/channels/chan_gulp.c Wed Mar 6 17:58:43 2013
@@ -699,6 +699,24 @@
/*! \brief Function called by core to send text on Gulp session */
static int gulp_sendtext(struct ast_channel *ast, const char *text)
{
+ struct ast_sip_body body = {
+ .type = "text",
+ .subtype = "plain",
+ .body_text = text
+ };
+
+ struct ast_sip_session *session = ast_channel_tech_pvt(ast);
+
+ /* NOT ast_strlen_zero, because a zero-length message is specifically
+ * allowed by RFC 3428 (See section 10, Examples) */
+ if (!text) {
+ return 0;
+ }
+
+ if (ast_sip_send_request("MESSAGE", &body, session->inv_session->dlg, NULL) != PJ_SUCCESS) {
+ ast_log(LOG_ERROR, "Could not send text MESSAGE request\n");
+ }
+
return 0;
}
Modified: team/kharwell/pimp_my_sip/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_my_sip/res/res_sip.c?view=diff&rev=382554&r1=382553&r2=382554
==============================================================================
--- team/kharwell/pimp_my_sip/res/res_sip.c (original)
+++ team/kharwell/pimp_my_sip/res/res_sip.c Wed Mar 6 17:58:43 2013
@@ -23,6 +23,7 @@
/* Needed for SUBSCRIBE, NOTIFY, and PUBLISH method definitions */
#include "pjsip_simple.h"
#include "pjlib.h"
+#include "pjsua-lib/pjsua.h"
#include "asterisk/res_sip.h"
#include "res_sip/include/res_sip_private.h"
@@ -194,7 +195,7 @@
/* PJSIP doesn't know about the INFO method, so we have to define it ourselves */
const pjsip_method pjsip_info_method = {PJSIP_OTHER_METHOD, {"INFO", 4} };
-const pjsip_method pjsip_message_method = {PJSIP_OTHER_METHOD, { "MESSAGE", 7 } };
+const pjsip_method pjsip_message_method = {PJSIP_OTHER_METHOD, {"MESSAGE", 7} };
static struct {
const char *method;
Modified: team/kharwell/pimp_my_sip/res/res_sip_messaging.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/pimp_my_sip/res/res_sip_messaging.c?view=diff&rev=382554&r1=382553&r2=382554
==============================================================================
--- team/kharwell/pimp_my_sip/res/res_sip_messaging.c (original)
+++ team/kharwell/pimp_my_sip/res/res_sip_messaging.c Wed Mar 6 17:58:43 2013
@@ -55,7 +55,7 @@
* \param context The context to use
* \param exten The extension to use
*/
-static enum pjsip_status_code get_destination(pjsip_rx_data *rdata, const char *context, char *exten)
+static enum pjsip_status_code get_destination(const pjsip_rx_data *rdata, const char *context, char *exten)
{
pjsip_uri *ruri = rdata->msg_info.msg->line.req.uri;
pjsip_sip_uri *sip_ruri;
@@ -81,7 +81,7 @@
*
* \param rdata The SIP request
*/
-static enum pjsip_status_code check_content_type(pjsip_rx_data *rdata)
+static enum pjsip_status_code check_content_type(const pjsip_rx_data *rdata)
{
if (pj_strcmp2(&rdata->msg_info.msg->body->content_type.type, "text") ||
pj_strcmp2(&rdata->msg_info.msg->body->content_type.subtype, "plain")) {
@@ -96,7 +96,7 @@
* \param rdata The SIP request
* \param msg The msg structure to copy headers into
*/
-static int headers_to_vars(pjsip_rx_data *rdata, struct ast_msg *msg)
+static int headers_to_vars(const pjsip_rx_data *rdata, struct ast_msg *msg)
{
char buf[MAX_HDR_SIZE];
int res = 0;
@@ -129,7 +129,7 @@
int res;
char buf[MAX_BODY_SIZE];
pjsip_uri *uri;
- char *field;
+ const char *field;
pjsip_status_code code;
struct ast_sip_endpoint *endpt = ast_pjsip_rdata_get_endpoint(rdata);
@@ -149,8 +149,12 @@
/* from header */
uri = pjsip_uri_get_uri(rdata->msg_info.from->uri);
pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, uri, buf, sizeof(buf)-1);
- /* /todo check to see if name is in front */
- res |= ast_msg_set_from(msg, "<%s>", buf);
+ field = pj_strbuf(&((pjsip_name_addr*)rdata->msg_info.from->uri)->display);
+ if (field) {
+ res |= ast_msg_set_from(msg, "\"%s\" <%s>", field, buf);
+ } else {
+ res |= ast_msg_set_from(msg, "<%s>", buf);
+ }
/* contact header */
field = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL);
@@ -164,6 +168,11 @@
rdata->msg_info.msg->body->print_body(rdata->msg_info.msg->body, buf, sizeof(buf)-1);
res |= ast_msg_set_body(msg, "%s", buf);
+ /* endpoint name */
+ if (endpt->id.name.valid) {
+ res |= ast_msg_set_var(msg, "SIP_PEERNAME", endpt->id.name.str);
+ }
+
res |= headers_to_vars(rdata, msg);
if (res) {
@@ -171,10 +180,6 @@
return PJSIP_SC_INTERNAL_SERVER_ERROR;
}
return PJSIP_SC_OK;
-
- /* if (!ast_strlen_zero(p->peername)) { */
- /* res |= ast_msg_set_var(msg, "SIP_PEERNAME", p->peername); */
- /* } */
}
/*!
@@ -446,9 +451,13 @@
return 0;
}
+/* static int outgoing_request(struct ast_sip_session *session, pjsip_tx_data *tdata) */
+/* { */
+/* } */
+
static struct ast_sip_session_supplement messaging_supplement = {
.method = "MESSAGE",
- .incoming_request = incoming_request
+ .incoming_request = incoming_request,
/* .outgoing_request = outgoing_request */
};
@@ -494,57 +503,3 @@
.unload = unload_module,
.load_pri = AST_MODPRI_APP_DEPEND,
);
-
- /* pjsip_endpoint *ep = ast_sip_get_pjsip_endpoint(); */
- /* pj_status_t status; */
- /* pjsip_tx_data tx_data; */
- /* pjsip_im_data im_data; */
-
- /* pjsip_method msg_method = { PJSIP_OTHER_METHOD, { "MESSAGE", 7 } }; */
-
- /* status = pjsip_endpt_create_request(endpt, &msg_method, */
- /* pj_str(to), /\* target uri *\/ */
- /* pj_str(from), /\* URL to put in From header *\/ */
- /* pj_str(to), /\* URL to put in To header *\/ */
- /* NULL, /\* Contact header value*\/ */
- /* NULL, /\* use random callid *\/ */
- /* -1, /\* use random CSeq *\/, */
- /* pj_str(ast_msg_get_body(msg)), */
- /* &tx_data); /\* pointer to receive transmit data *\/ */
-
- /* if (status != PJ_SUCCESS) { */
- /* ast_log(LOG_ERROR, "Unable to create request - %d %.*s\n", status.code, */
- /* (int)pj_strlen(&status.reason), pj_strbuf(&status.reason)); */
- /* return status; */
- /* } */
-
- /* /\* add an accept header *\/ */
- /* /\* pjsip_msg_add_hdr(data->msg, *\/ */
- /* /\* (pjsip_hdr*)pjsua_im_create_accept(data->pool)); *\/ */
-
- /* im_data = PJ_POOL_ZALLOC_T(tx_data->pool, pjsua_im_data); */
- /* im_data->call_id = PJSUA_INVALID_ID; */
-
- /* pj_strdup_with_null(tx_data->pool, &im_data->to, pj_str(to)); */
- /* pj_strdup_with_null(tx_data->pool, &im_data->body, */
- /* pj_str(ast_msg_get_body(msg))); */
-
- /* im_data->user_data = NULL; */
-
- /* tx_data->msg->body = pjsip_msg_body_create(tdata->pool, "text", "plain", */
- /* im_data->body); */
-
- /* if (!tx_data->msg->body) { */
- /* ast_log(LOG_ERROR, "Unable to create message body\n") */
- /* return PJ_ENOMEM; */
- /* } */
-
- /* add_msg_headers(tx_data, msg); */
-
- /* status = pjsip_endpt_send_request(endpt, tx_data, -1, NULL, NULL); */
-
- /* if (status != PJ_SUCCESS) { */
- /* ast_log(LOG_ERROR, "Unable to send request - %d %.*s\n", status.code, */
- /* (int)pj_strlen(&status.reason), pj_strbuf(&status.reason)); */
- /* return status; */
- /* } */
More information about the asterisk-commits
mailing list