aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilmer van der Gaast <wilmer@gaast.net>2007-07-01 14:08:47 +0100
committerWilmer van der Gaast <wilmer@gaast.net>2007-07-01 14:08:47 +0100
commit40ef702d3e500eb38d7410114ace54e8a70b151e (patch)
treefdbd49c24d69d822afe9a41d282524bde2627359
parent7bf4326f7a9b2a2aec8b292ecbc876d4349d2624 (diff)
Less copy-pasting in the service discovery reply and added MUC support to
that list. And adding some const stuff in the xmltree functions.
-rw-r--r--protocols/jabber/iq.c27
-rw-r--r--protocols/jabber/xmltree.c8
-rw-r--r--protocols/jabber/xmltree.h8
3 files changed, 21 insertions, 22 deletions
diff --git a/protocols/jabber/iq.c b/protocols/jabber/iq.c
index e5c5dde2..4738817a 100644
--- a/protocols/jabber/iq.c
+++ b/protocols/jabber/iq.c
@@ -98,26 +98,25 @@ xt_status jabber_pkt_iq( struct xt_node *node, gpointer data )
}
else if( strcmp( s, XMLNS_DISCOVER ) == 0 )
{
+ const char *features[] = { XMLNS_VERSION,
+ XMLNS_TIME,
+ XMLNS_CHATSTATES,
+ XMLNS_MUC,
+ NULL };
+ const char **f;
+
c = xt_new_node( "identity", NULL, NULL );
xt_add_attr( c, "category", "client" );
xt_add_attr( c, "type", "pc" );
xt_add_attr( c, "name", "BitlBee" );
xt_add_child( reply, c );
- c = xt_new_node( "feature", NULL, NULL );
- xt_add_attr( c, "var", XMLNS_VERSION );
- xt_add_child( reply, c );
-
- c = xt_new_node( "feature", NULL, NULL );
- xt_add_attr( c, "var", XMLNS_TIME );
- xt_add_child( reply, c );
-
- c = xt_new_node( "feature", NULL, NULL );
- xt_add_attr( c, "var", XMLNS_CHATSTATES );
- xt_add_child( reply, c );
-
- /* Later this can be useful to announce things like
- MUC support. */
+ for( f = features; *f; f ++ )
+ {
+ c = xt_new_node( "feature", NULL, NULL );
+ xt_add_attr( c, "var", *f );
+ xt_add_child( reply, c );
+ }
}
else
{
diff --git a/protocols/jabber/xmltree.c b/protocols/jabber/xmltree.c
index 7a165a1e..b1edd55d 100644
--- a/protocols/jabber/xmltree.c
+++ b/protocols/jabber/xmltree.c
@@ -441,7 +441,7 @@ void xt_free( struct xt_parser *xt )
/* To find a node's child with a specific name, pass the node's children
list, not the node itself! The reason you have to do this by hand: So
that you can also use this function as a find-next. */
-struct xt_node *xt_find_node( struct xt_node *node, char *name )
+struct xt_node *xt_find_node( struct xt_node *node, const char *name )
{
while( node )
{
@@ -454,7 +454,7 @@ struct xt_node *xt_find_node( struct xt_node *node, char *name )
return node;
}
-char *xt_find_attr( struct xt_node *node, char *key )
+char *xt_find_attr( struct xt_node *node, const char *key )
{
int i;
@@ -523,7 +523,7 @@ void xt_add_child( struct xt_node *parent, struct xt_node *child )
}
}
-void xt_add_attr( struct xt_node *node, char *key, char *value )
+void xt_add_attr( struct xt_node *node, const char *key, const char *value )
{
int i;
@@ -550,7 +550,7 @@ void xt_add_attr( struct xt_node *node, char *key, char *value )
node->attr[i].value = g_strdup( value );
}
-int xt_remove_attr( struct xt_node *node, char *key )
+int xt_remove_attr( struct xt_node *node, const char *key )
{
int i, last;
diff --git a/protocols/jabber/xmltree.h b/protocols/jabber/xmltree.h
index 70850c1d..b8b61641 100644
--- a/protocols/jabber/xmltree.h
+++ b/protocols/jabber/xmltree.h
@@ -86,12 +86,12 @@ void xt_print( struct xt_node *node );
struct xt_node *xt_dup( struct xt_node *node );
void xt_free_node( struct xt_node *node );
void xt_free( struct xt_parser *xt );
-struct xt_node *xt_find_node( struct xt_node *node, char *name );
-char *xt_find_attr( struct xt_node *node, char *key );
+struct xt_node *xt_find_node( struct xt_node *node, const char *name );
+char *xt_find_attr( struct xt_node *node, const char *key );
struct xt_node *xt_new_node( char *name, char *text, struct xt_node *children );
void xt_add_child( struct xt_node *parent, struct xt_node *child );
-void xt_add_attr( struct xt_node *node, char *key, char *value );
-int xt_remove_attr( struct xt_node *node, char *key );
+void xt_add_attr( struct xt_node *node, const char *key, const char *value );
+int xt_remove_attr( struct xt_node *node, const char *key );
#endif