[asterisk-commits] branch mogorman/asterisk-xmpp r21636 - in
/team/mogorman/asterisk-xmpp: chann...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Apr 19 13:15:01 MST 2006
Author: mogorman
Date: Wed Apr 19 15:15:00 2006
New Revision: 21636
URL: http://svn.digium.com/view/asterisk?rev=21636&view=rev
Log:
hmm almost got outbound working.
Modified:
team/mogorman/asterisk-xmpp/channels/chan_jingle.c
team/mogorman/asterisk-xmpp/include/asterisk/jingle.h
team/mogorman/asterisk-xmpp/res/res_jabber.c
Modified: team/mogorman/asterisk-xmpp/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/channels/chan_jingle.c?rev=21636&r1=21635&r2=21636&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/channels/chan_jingle.c (original)
+++ team/mogorman/asterisk-xmpp/channels/chan_jingle.c Wed Apr 19 15:15:00 2006
@@ -105,7 +105,6 @@
.capabilities = ((AST_FORMAT_MAX_AUDIO << 1) - 1),
.requester = jingle_request,
.send_digit = jingle_digit,
-// .requester = jingle_request_call,
// .devicestate = jingle_devicestate,
// .transfer = jingle_transfer,
.bridge = ast_rtp_bridge,
@@ -205,11 +204,12 @@
{
struct jingle_pvt *tmp = client->p;
struct aji_client *c = client->connection;
- iks *iq, *jingle, *description, /* *payload_ipcmwb, *payload_isac,*/ *payload_red, *payload_audio, *payload_cn;
+ iks *iq, *jingle, *description, *payload_red, *payload_audio, *payload_cn;
int x;
int pref_codec = 0;
int alreadysent = 0;
-
+
+ ast_verbose("EEP %s!\n",client->connection->mid);
iq = iks_new("iq");
jingle = iks_new(GOOGLE_NODE);
description = iks_new("description");
@@ -245,7 +245,7 @@
iks_insert_attrib(iq,"type","set");
// iks_insert_attrib(iq,"from",client->connection->jid->full);
- iks_insert_attrib(iq,"to",p->from);
+ iks_insert_attrib(iq,"to",(p->from)?p->from:client->user);
iks_insert_attrib(iq,"id",client->connection->mid);
ast_aji_increment_mid(client->connection->mid);
@@ -519,10 +519,34 @@
static struct jingle_pvt *jingle_alloc(struct jingle *client, const char *from, const char *sid)
{
- struct jingle_pvt *tmp = client->p;
-
+ struct jingle_pvt *tmp = NULL;
+ struct aji_resource *resources = NULL;
+ char idroster[100];
+
+ if(!sid && !strchr(from,"/")) { /*I started call! */
+ resources=client->buddy->resources;
+ while(resources) {
+ if(resources->jinglecapable)
+ break;
+ resources=resources->next;
+ }
+ if(resources)
+ sprintf(idroster,sizeof(idroster), "%s/%s",client->user,resources->resource);
+ else {
+ ast_log(LOG_ERROR, "no jingle capable clients to talk to.");
+ return NULL;
+ }
+ }
if (!(tmp = ast_calloc(1, sizeof(*tmp)))) {
return NULL;
+ }
+ if (sid) {
+ ast_copy_string(tmp->sid, sid, sizeof(tmp->sid));
+ ast_copy_string(tmp->from, from, sizeof(tmp->from));
+ } else {
+ snprintf(tmp->sid, sizeof(tmp->sid), "%08lx%08lx", ast_random(), ast_random());
+ ast_copy_string(tmp->from, idroster, sizeof(tmp->from));
+ tmp->initiator=1;
}
tmp->rtp = ast_rtp_new_with_bindaddr(sched, io, 1, 0, bindaddr.sin_addr);
tmp->parent = client;
@@ -531,12 +555,7 @@
free(tmp);
return NULL;
}
- ast_copy_string(tmp->from, from, sizeof(tmp->from));
ast_copy_string(tmp->exten, "s", sizeof(tmp->exten));
- if (sid)
- ast_copy_string(tmp->sid, sid, sizeof(tmp->sid));
- else
- snprintf(tmp->sid, sizeof(tmp->sid), "%08lx%08lx", ast_random(), ast_random());
ast_mutex_init(&tmp->lock);
ast_mutex_lock(&jinglelock);
tmp->next = client->p;
@@ -982,45 +1001,53 @@
ast_log(LOG_NOTICE, "XXX Implement jingle sendhtml XXX\n");
return res;
}
+static int jingle_transmit_invite(struct jingle_pvt *p)
+{
+ struct jingle *jingle = NULL;
+ struct aji_client *client = NULL;
+ jingle = p->parent;
+ client = jingle->connection;
+ jingle_accept_call(jingle, p);
+ return 0;
+}
+
+static int jingle_auto_congest(void *nothing)
+{
+ struct jingle_pvt *p = nothing;
+
+ ast_mutex_lock(&p->lock);
+ if (p->owner) {
+ /* XXX fails on possible deadlock */
+ if (!ast_channel_trylock(p->owner)) {
+ ast_log(LOG_NOTICE, "Auto-congesting %s\n", p->owner->name);
+ ast_queue_control(p->owner, AST_CONTROL_CONGESTION);
+ ast_channel_unlock(p->owner);
+ }
+ }
+ ast_mutex_unlock(&p->lock);
+ return 0;
+}
/*! \brief Initiate new call, part of PBX interface
* dest is the dial string */
static int jingle_call(struct ast_channel *ast, char *dest, int timeout)
{
+ ast_verbose("Welcome to disneyland! %s %d\n",dest, timeout);
struct jingle_pvt *p = ast->tech_pvt;
- int res;
- struct ast_var_t *varptr = NULL, *new;
+ struct varshead *headp;
+ struct ast_var_t *current;
size_t len, namelen;
- ast_mutex_lock(&p->lock);
-
-// p->chan->cid.cid_num = ast_strdup(p->owner->cid.cid_num);
-// p->chan->cid.cid_name = ast_strdup(p->owner->cid.cid_name);
-// p->chan->cid.cid_rdnis = ast_strdup(p->owner->cid.cid_rdnis);
-// p->chan->cid.cid_ani = ast_strdup(p->owner->cid.cid_ani);
-//
-// strncpy(p->chan->language, p->owner->language, sizeof(p->chan->language) - 1);
-// strncpy(p->chan->accountcode, p->owner->accountcode, sizeof(p->chan->accountcode) - 1);
-// p->chan->cdrflags = p->owner->cdrflags;
-
- /* copy the channel variables from the incoming channel to the outgoing channel */
- /* Note that due to certain assumptions, they MUST be in the same order */
- AST_LIST_TRAVERSE(&p->owner->varshead, varptr, entries) {
- namelen = strlen(varptr->name);
- len = sizeof(struct ast_var_t) + namelen + strlen(varptr->value) + 2;
- if ((new = ast_calloc(1, len))) {
- memcpy(new, varptr, len);
- new->value = &(new->name[0]) + namelen + 1;
- // AST_LIST_INSERT_TAIL(&p->chan->varshead, new, entries);
- }
- }
-
-// p->launchedpbx = 1;
-
- /* Start switch on sub channel */
-// res = ast_pbx_start(p->chan);
- ast_mutex_unlock(&p->lock);
- return res;
+ p = ast->tech_pvt;
+
+ if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
+ ast_log(LOG_WARNING, "jingle_call called on %s, neither down nor reserved\n", ast->name);
+ return -1;
+ }
+
+ p->jointcapability = p->capability;
+ jingle_transmit_invite(p);
+ return 1;
}
/*! \brief Hangup a call through the jingle proxy channel */
@@ -1084,8 +1111,9 @@
return NULL;
}
p = jingle_alloc(client, to, NULL);
- if (p)
+ if (p) {
chan = jingle_new(client, p, AST_STATE_DOWN, to);
+ }
return chan;
}
@@ -1227,7 +1255,6 @@
#endif
else if (!strcasecmp(var->name, "connection")) {
if((client = ast_aji_get_client(var->value))) {
- // client->jingle=member;
member->connection=client;
iks_filter_add_rule(client->f,jingle_parser, member, IKS_RULE_TYPE, IKS_RULE_FROM_PARTIAL, member->user, IKS_PAK_IQ, IKS_RULE_NS, "http://www.google.com/session", IKS_RULE_DONE);
} else {
@@ -1235,6 +1262,11 @@
}
}
var = var->next;
+ }
+ if(member->connection && member->user)
+ member->buddy= ASTOBJ_CONTAINER_FIND(&member->connection->buddies,member->user);
+ else {
+ ast_log(LOG_ERROR, "No Connection or Username!\n");
}
ast_verbose("LABEL: %s\n member->name %s\n member->user %s\n",label,member->name,member->user);
return 1;
Modified: team/mogorman/asterisk-xmpp/include/asterisk/jingle.h
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/include/asterisk/jingle.h?rev=21636&r1=21635&r2=21636&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/include/asterisk/jingle.h (original)
+++ team/mogorman/asterisk-xmpp/include/asterisk/jingle.h Wed Apr 19 15:15:00 2006
@@ -75,6 +75,7 @@
struct jingle {
ASTOBJ_COMPONENTS(struct jingle);
struct aji_client *connection;
+ struct aji_buddy *buddy;
struct jingle_pvt *p;
struct ast_codec_pref prefs;
int amaflags; /*!< AMA Flags */
Modified: team/mogorman/asterisk-xmpp/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/team/mogorman/asterisk-xmpp/res/res_jabber.c?rev=21636&r1=21635&r2=21636&view=diff
==============================================================================
--- team/mogorman/asterisk-xmpp/res/res_jabber.c (original)
+++ team/mogorman/asterisk-xmpp/res/res_jabber.c Wed Apr 19 15:15:00 2006
@@ -151,6 +151,24 @@
obj =NULL;
}
+
+static iks *jabber_find(iks *node, char *search)
+{
+ ast_verbose("PRETTY!!!\n");
+
+ iks *tmp= node;
+ iks *next = tmp;
+ while(tmp) {
+ while(next)
+ {
+ ast_verbose("PRETTY!!! %s\n",iks_name(next));
+ next=iks_child(next);
+ }
+ tmp=iks_child(tmp);
+ next=tmp;
+ }
+ return NULL;
+}
/*!
* \brief Detects the highest bit in a number.
* \param Number you want to have evaluated.
@@ -835,7 +853,7 @@
int status, priority;
struct aji_buddy *buddy = NULL;
struct aji_resource *tmp = NULL, *last= NULL, *found = NULL;
-
+
buddy = ASTOBJ_CONTAINER_FIND(&client->buddies,pak->from->partial);
if(!buddy)
{
@@ -849,6 +867,14 @@
while(tmp) {
if(!strcasecmp(tmp->resource,pak->from->resource)) {
tmp->status=status;
+ jabber_find(pak->x, NULL);
+ if(iks_find_with_attrib(pak->query, "c", "node", "http://www.google.com/xmpp/client/caps")) {
+ ast_verbose("FOUND IT!!!\n");
+ tmp->jinglecapable=1;
+ } else {
+ ast_verbose("DIDINT FOUND IT!!!\n");
+ tmp->jinglecapable=0;
+ }
if(status == 6) { /* Sign off Destroy resource */
ast_verbose("KILL THE SIGN OFF!\n");
found = tmp;
@@ -912,9 +938,17 @@
ast_copy_string(found->resource, pak->from->resource, sizeof(found->resource));
found->status = status;
found->priority = priority;
+ if(iks_find_attrib(pak->query,"node")) {
+ ast_verbose("FOUND IT!!!\n");
+ found->jinglecapable=1;
+ } else {
+ ast_verbose("DIDINT FOUND IT!!!\n");
+ found->jinglecapable=0;
+ }
found->next = NULL;
last = NULL;
tmp = buddy->resources;
+ jabber_find(pak->x, NULL);
while(tmp) {
if(found->priority > tmp->priority) {
if(last) last->next = found;
More information about the asterisk-commits
mailing list