提交 3a32d9e5 authored 作者: Anthony Minessale's avatar Anthony Minessale

Presence and Chat Gateway Code

This is some brand new stuff to gateway chat/presence/audio from one protocol to another
So far it only works between google/jingle and SIP

All I had to test the SIP end was X-Lite and Eyebeam and GoogleTalk on the jingle end.

With this setup registered X-Lite's can chat with each other and call each other 
as well as X-Lite to GoogleTalk and GoogleTalk to X-Lite audio calls.

Chat May also be done between X-Lite and jabber 

You'll also need a jabber server configured for component login so you can interface.
We have only tested with jabberd2 so far.

Configure DNS so srv records for jabber for your subdomain (fs.mydomain.com in the example)
so the jabber records are pointed at your jabber server.

RELEVANT CONFIGS

<!-- Brian has no jingle support so send calls to him over to his iax url -->
<extension name="bkw">
  <condition field="destination_number" expression="^jingle\+brian@agents.cylynx.com$">
    <action application="bridge" data="iax/guest@brianwest.homeunix.org/9184290404"/>
  </condition>
</extension>

<!-- Assumption is made here that both sip and jingle have the same profile/domain name as documented below -->

<extension name="jingle2sip">
  <condition field="source" expression="mod_dingaling"/>
  <condition field="destination_number" expression="^sip\+([^\@]+)\@(.*)$">
    <action application="bridge" data="sofia/$2/$1%$2"/>
  </condition>
</extension>

<extension name="sip2jingle">
  <condition field="source" expression="mod_sofia"/>
  <condition field="destination_number" expression="^jingle\+([^\@]+)\@(.*)$">
    <action application="bridge" data="dingaling/sip+${sip_fromuser}@${sip_fromhost}/$1@$2"/>
  </condition>
</extension>


<configuration name="sofia.conf" description="sofia Endpoint">
  <global_settings>
    <param name="log-level" value="0"/>
  </global_settings>

  <profiles>
    <profile name="fs.mydomain.com">
      <registrations/>
      <settings>
	<param name="debug" value="1"/>
	<param name="rfc2833-pt" value="101"/>
	<param name="sip-port" value="5060"/>
	<param name="dialplan" value="XML"/>
	<param name="dtmf-duration" value="100"/>
	<param name="codec-prefs" value="PCMU"/>
	<param name="codec-ms" value="20"/>
	<param name="accept-blind-reg" value="true"/>
	<param name="manage-presence" value="true"/>
	<!--<param name="full-id-in-dialplan" value="true"/>-->
	<!--<param name="auth-calls" value="true"/>-->
	<!--<param name="auth-all-packets" value="true"/>-->
	<param name="use-rtp-timer" value="true"/>
	<param name="rtp-timer-name" value="soft"/>
	<param name="rtp-ip" value="100.200.100.200"/>
	<param name="sip-ip" value="fs.mydomain.com"/>
      </settings>
    </profile>
  </profiles>

</configuration>


<configuration name="dingaling.conf" description="XMPP Jingle Endpoint">
  <settings>
    <param name="debug" value="0"/>
    <param name="codec-prefs" value="PCMU"/>
  </settings>

  <profile type="component">
    <param name="name" value="fs.mydomain.com"/>
    <param name="password" value="secret"/>
    <param name="dialplan" value="XML"/>
    <param name="rtp-ip" value="208.64.200.42"/>
    <param name="server" value="jabber.freeswitch.org:5347"/>
    <!-- disable to trade async for more calls -->
    <param name="use-rtp-timer" value="true"/>
    <param name="exten" value="_auto_"/>
    <!--<param name="vad" value="both"/>-->
  </profile>

</configuration>



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@3115 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 e70a025a
......@@ -113,8 +113,8 @@
</configuration>
<configuration name="sofia.conf" description="sofia Endpoint">
<profiles>
<profile name="test">
<profile>
<profile name="mydomain1.com">
<registrations>
<!-- <registration name="asterlink">
<param name="register-scheme" value="Digest"/>
......@@ -138,7 +138,7 @@
<param name="use-rtp-timer" value="true"/>
<param name="rtp-timer-name" value="soft"/>
<param name="rtp-ip" value="192.168.1.20"/>
<param name="sip-ip" value="192.168.1.20"/>
<param name="sip-ip" value="mydomain1.com"/>
<!-- this lets anything register -->
<!-- comment the next line and uncomment one or both of the other 2 lines for call authentication -->
......@@ -268,10 +268,12 @@
<param name="debug" value="0"/>
<param name="codec-prefs" value="PCMU"/>
</settings>
<!-- *NOTE* your resource (after the /) MUST contain the string "talk" (upper or lower case is ok) -->
<!-- *NOTE* as of May 2 2006 you must set"auto-login" to"true" if you want to be able to auto-login on startup"/> -->
<interface>
<param name="name" value="jingle"/>
<!-- *NOTE* change <x-profile></x-profile> to <profile></profile> to enable -->
<!-- Client Profile (Original mode) -->
<x-profile type="client">
<param name="name" value="mydomain.com"/>
<param name="login" value="myjid@myserver.com/talk"/>
<param name="password" value="mypass"/>
<param name="dialplan" value="XML"/>
......@@ -296,7 +298,23 @@
<!-- <param name="vad" value="in"/> -->
<!-- <param name="vad" value="out"/> -->
<param name="vad" value="both"/>
</interface>
</x-profile>
<!-- Component (Server to Server Login) -->
<x-profile type="component">
<!-- All traffic for *@sub.mydomain.com will come to you -->
<param name="name" value="sub.mydomain.com"/>
<param name="password" value="secret"/>
<param name="dialplan" value="XML"/>
<param name="rtp-ip" value="208.64.200.42"/>
<param name="server" value="jabber.server.org:5347"/>
<!-- disable to trade async for more calls -->
<param name="use-rtp-timer" value="true"/>
<!-- "_auto_" means the extension will be automaticly set to the called jid -->
<param name="exten" value="_auto_"/>
<!--<param name="vad" value="both"/>-->
</x-profile>
</configuration>
<configuration name="xml_rpc.conf" description="XML RPC">
......
......@@ -712,7 +712,7 @@ static int on_presence(void *user_data, ikspak *pak)
if (!type || (type && strcasecmp(type, "probe"))) {
if (handle->session_callback) {
handle->session_callback(handle, NULL, signal, to, from, status ? status : "n/a", show ? show : "n/a");
handle->session_callback(handle, NULL, signal, to, id, status ? status : "n/a", show ? show : "n/a");
}
}
......@@ -720,7 +720,7 @@ static int on_presence(void *user_data, ikspak *pak)
return IKS_FILTER_EAT;
}
static void do_presence(ldl_handle_t *handle, char *from, char *to, char *type, char *message)
static void do_presence(ldl_handle_t *handle, char *from, char *to, char *type, char *rpid, char *message)
{
iks *pres;
char buf[512];
......@@ -743,21 +743,28 @@ static void do_presence(ldl_handle_t *handle, char *from, char *to, char *type,
iks_insert_attrib(pres, "type", type);
}
if (rpid) {
if ((tag = iks_insert (pres, "show"))) {
iks_insert_cdata(tag, rpid, 0);
}
}
if (message) {
if (message) {
if ((tag = iks_insert (pres, "status"))) {
iks_insert_cdata(tag, message ? message : "", 0);
if ((tag = iks_insert(pres, "c"))) {
iks_insert_attrib(tag, "node", "http://www.freeswitch.org/xmpp/client/caps");
iks_insert_attrib(tag, "ver", "1.0.0.1");
iks_insert_attrib(tag, "ext", "sidebar voice-v1");
iks_insert_attrib(tag, "client", "libdingaling2");
iks_insert_attrib(tag, "xmlns", "http://jabber.org/protocol/caps");
}
iks_insert_cdata(tag, message, 0);
}
}
if (message || rpid) {
if ((tag = iks_insert(pres, "c"))) {
iks_insert_attrib(tag, "node", "http://www.freeswitch.org/xmpp/client/caps");
iks_insert_attrib(tag, "ver", "1.0.0.1");
iks_insert_attrib(tag, "ext", "sidebar voice-v1");
iks_insert_attrib(tag, "client", "libdingaling");
iks_insert_attrib(tag, "xmlns", "http://jabber.org/protocol/caps");
}
}
apr_queue_push(handle->queue, pres);
}
}
......@@ -1559,9 +1566,9 @@ void *ldl_handle_get_private(ldl_handle_t *handle)
return handle->private_info;
}
void ldl_handle_send_presence(ldl_handle_t *handle, char *from, char *to, char *type, char *message)
void ldl_handle_send_presence(ldl_handle_t *handle, char *from, char *to, char *type, char *rpid, char *message)
{
do_presence(handle, from, to, type, message);
do_presence(handle, from, to, type, rpid, message);
}
void ldl_handle_send_msg(ldl_handle_t *handle, char *from, char *to, char *subject, char *body)
......
......@@ -369,9 +369,10 @@ void ldl_session_send_msg(ldl_session_t *session, char *subject, char *body);
\param from the from address
\param to the to address
\param type the type of presence
\param rpid data for the icon
\param message a status message
*/
void ldl_handle_send_presence(ldl_handle_t *handle, char *from, char *to, char *type, char *message);
void ldl_handle_send_presence(ldl_handle_t *handle, char *from, char *to, char *type, char *rpid, char *message);
/*!
\brief Send a message
......
......@@ -94,6 +94,11 @@ static void perform_substitution(pcre *re, int match_count, char *data, char *fi
for (x = 0; x < (len-1) && x < strlen(data);) {
if (data[x] == '$') {
x++;
if (!(data[x] > 47 && data[x] < 58)) {
substituted[y++] = data[x-1];
continue;
}
while (data[x] > 47 && data[x] < 58) {
index[z++] = data[x];
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论