Relay a MESSAGE to a SIP client */
| 276 | |
| 277 | /* Relay a MESSAGE to a SIP client */ |
| 278 | int xmpp_send_sip_msg(char *from, char *to, char *msg) |
| 279 | { |
| 280 | str msg_type = { "MESSAGE", 7 }; |
| 281 | str hdr, fromstr, tostr, msgstr; |
| 282 | char buf[512]; |
| 283 | char buf_from[256]; |
| 284 | |
| 285 | ENC_SIP_URI(fromstr, buf_from, from); |
| 286 | |
| 287 | hdr.s = buf; |
| 288 | hdr.len = snprintf(buf, sizeof(buf), |
| 289 | "Content-type: text/plain" CRLF "Contact: %s" CRLF, from); |
| 290 | |
| 291 | tostr.s = uri_xmpp2sip(to, &tostr.len); |
| 292 | if(tostr.s == NULL) { |
| 293 | LM_ERR("Failed to translate xmpp uri to sip uri\n"); |
| 294 | return -1; |
| 295 | } |
| 296 | |
| 297 | msgstr.s = msg; |
| 298 | msgstr.len = strlen(msg); |
| 299 | |
| 300 | return run_tm_api(&tmb, t_request, |
| 301 | &msg_type, /* Type of the message */ |
| 302 | 0, /* Request-URI */ |
| 303 | &tostr, /* To */ |
| 304 | &fromstr, /* From */ |
| 305 | &hdr, /* Optional headers */ |
| 306 | &msgstr, /* Message body */ |
| 307 | (outbound_proxy.s)?&outbound_proxy:NULL,/* Outbound proxy*/ |
| 308 | 0, /* Callback function */ |
| 309 | 0, |
| 310 | 0 /* Callback parameter */ |
| 311 | ); |
| 312 | } |
| 313 | |
| 314 | |
| 315 | /*********************************************************************************/ |
no test coverage detected