Index: include/asterisk/jabber.h =================================================================== --- include/asterisk/jabber.h (revision 83398) +++ include/asterisk/jabber.h (working copy) @@ -127,6 +127,8 @@ AST_LIST_HEAD(messages,aji_message) messages; void *jingle; pthread_t thread; + int priority; + enum ikshowtype status; }; struct aji_client_container{ Index: configs/jabber.conf.sample =================================================================== --- configs/jabber.conf.sample (revision 83398) +++ configs/jabber.conf.sample (working copy) @@ -9,10 +9,13 @@ ;; talk.google.com ;username=asterisk@astjab.org/asterisk ;;Username with optional roster. ;secret=blah ;;Password +;priority=1 ;;Resource priority ;port=5222 ;;Port to use defaults to 5222 ;usetls=yes ;;Use tls or not ;usesasl=yes ;;Use sasl or not ;buddy=mogorman@astjab.org ;;Manual addition of buddy to list. +;status=available ;;One of: chat, available, away, + ;; xaway, or dnd ;statusmessage="I am available" ;;Have custom status message for ;;Asterisk. ;timeout=100 ;;Timeout on the message stack. Index: res/res_jabber.c =================================================================== --- res/res_jabber.c (revision 83398) +++ res/res_jabber.c (working copy) @@ -1176,7 +1176,7 @@ } type = iks_find_attrib(pak->x, "type"); if(client->component && type &&!strcasecmp("probe", type)) { - aji_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"), 1, client->statusmessage); + aji_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"), client->status, client->statusmessage); ast_verbose("what i was looking for \n"); } ASTOBJ_WRLOCK(buddy); @@ -1402,7 +1402,7 @@ if(status) iks_delete(status); if(client->component) - aji_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"), 1, client->statusmessage); + aji_set_presence(client, pak->from->full, iks_find_attrib(pak->x, "to"), client->status, client->statusmessage); } if (option_verbose > 4) { switch (pak->subtype) { @@ -1840,7 +1840,7 @@ roster = iks_make_iq(IKS_TYPE_GET, IKS_NS_ROSTER); if(roster) { iks_insert_attrib(roster, "id", "roster"); - aji_set_presence(client, NULL, client->jid->full, 1, client->statusmessage); + aji_set_presence(client, NULL, client->jid->full, client->status, client->statusmessage); iks_send(client->p, roster); } if (roster) @@ -1946,13 +1946,16 @@ iks *presence = iks_make_pres(level, desc); iks *cnode = iks_new("c"); iks *priority = iks_new("priority"); + char priorityS[10]; - iks_insert_cdata(priority, "0", 1); - if (presence && cnode && client) { + if (presence && cnode && client && priority) { if(to) iks_insert_attrib(presence, "to", to); if(from) iks_insert_attrib(presence, "from", from); + snprintf(priorityS, sizeof(priorityS), "%d", client->priority); + iks_insert_cdata(priority, priorityS, strlen(priorityS)); + iks_insert_node(presence, priority); iks_insert_attrib(cnode, "node", "http://www.asterisk.org/xmpp/client/caps"); iks_insert_attrib(cnode, "ver", "asterisk-xmpp"); iks_insert_attrib(cnode, "ext", "voice-v1"); @@ -1965,6 +1968,8 @@ iks_delete(cnode); if (presence) iks_delete(presence); + if (priority) + iks_delete(priority); } /*! @@ -2140,6 +2145,8 @@ AST_LIST_HEAD_INIT(&client->messages); client->component = 0; ast_copy_string(client->statusmessage, "Online and Available", sizeof(client->statusmessage)); + client->priority = 0; + client->status = IKS_SHOW_AVAILABLE; if (flag) { client->authorized = 0; @@ -2177,6 +2184,42 @@ ast_set2_flag(client, ast_true(var->value), AJI_AUTOREGISTER); else if (!strcasecmp(var->name, "buddy")) aji_create_buddy(var->value, client); + else if (!strcasecmp(var->name, "priority")) + client->priority = atoi(var->value); + else if (!strcasecmp(var->name, "status")) { + if (!strcasecmp(var->value, "unavailable")) + client->status = IKS_SHOW_UNAVAILABLE; + else + if (!strcasecmp(var->value, "available") + || !strcasecmp(var->value, "online")) + client->status = IKS_SHOW_AVAILABLE; + else + if (!strcasecmp(var->value, "chat") + || !strcasecmp(var->value, "chatty")) + client->status = IKS_SHOW_CHAT; + else + if (!strcasecmp(var->value, "away")) + client->status = IKS_SHOW_AWAY; + else + if (!strcasecmp(var->value, "xa") + || !strcasecmp(var->value, "xaway")) + client->status = IKS_SHOW_XA; + else + if (!strcasecmp(var->value, "dnd")) + client->status = IKS_SHOW_DND; + else + if (!strcasecmp(var->value, "invisible")) + #ifdef IKS_SHOW_INVISIBLE + client->status = IKS_SHOW_INVISIBLE; + #else + { + ast_log(LOG_WARNING, "Your iksemel doesn't support invisible status: falling back to DND\n"); + client->status = IKS_SHOW_DND; + } + #endif + else + ast_log(LOG_WARNING, "Unknown presence status: %s\n", var->value); + } /* no transport support in this version */ /* else if (!strcasecmp(var->name, "transport")) aji_create_transport(var->value, client);