[asterisk-commits] phsultan: trunk r84939 - in /trunk: configs/ include/asterisk/ res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Oct 7 11:28:26 CDT 2007
Author: phsultan
Date: Sun Oct 7 11:28:25 2007
New Revision: 84939
URL: http://svn.digium.com/view/asterisk?view=rev&rev=84939
Log:
Make the status and priority configurable.
Closes issue #10785, patch by Luke-Jr, thanks!
Modified:
trunk/configs/jabber.conf.sample
trunk/include/asterisk/jabber.h
trunk/res/res_jabber.c
Modified: trunk/configs/jabber.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/jabber.conf.sample?view=diff&rev=84939&r1=84938&r2=84939
==============================================================================
--- trunk/configs/jabber.conf.sample (original)
+++ trunk/configs/jabber.conf.sample Sun Oct 7 11:28:25 2007
@@ -9,10 +9,13 @@
;; talk.google.com
;username=asterisk at 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 at 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.
Modified: trunk/include/asterisk/jabber.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/jabber.h?view=diff&rev=84939&r1=84938&r2=84939
==============================================================================
--- trunk/include/asterisk/jabber.h (original)
+++ trunk/include/asterisk/jabber.h Sun Oct 7 11:28:25 2007
@@ -155,6 +155,8 @@
AST_LIST_HEAD(messages,aji_message) messages;
void *jingle;
pthread_t thread;
+ int priority;
+ enum ikshowtype status;
};
struct aji_client_container{
Modified: trunk/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/trunk/res/res_jabber.c?view=diff&rev=84939&r1=84938&r2=84939
==============================================================================
--- trunk/res/res_jabber.c (original)
+++ trunk/res/res_jabber.c Sun Oct 7 11:28:25 2007
@@ -1279,7 +1279,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);
@@ -1499,7 +1499,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);
}
switch (pak->subtype) {
@@ -1948,7 +1948,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)
@@ -2036,13 +2036,16 @@
iks *presence = iks_make_pres(level, desc);
iks *cnode = iks_new("c");
iks *priority = iks_new("priority");
-
- iks_insert_cdata(priority, "0", 1);
- if (presence && cnode && client) {
+ char priorityS[10];
+
+ 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");
@@ -2055,6 +2058,8 @@
iks_delete(cnode);
if (presence)
iks_delete(presence);
+ if (priority)
+ iks_delete(priority);
}
/*!
@@ -2330,6 +2335,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;
@@ -2367,6 +2374,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);
More information about the asterisk-commits
mailing list