Changeset 4eb4c0f for protocols/jabber
- Timestamp:
- 2008-02-16T17:15:31Z (17 years ago)
- Branches:
- master
- Children:
- fd9fa52
- Parents:
- 8961950 (diff), ca60550 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- protocols/jabber
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/Makefile
r8961950 r4eb4c0f 18 18 all: jabber_mod.o 19 19 check: all 20 lcov: 20 lcov: check 21 21 gcov: 22 22 gcov *.c -
protocols/jabber/conference.c
r8961950 r4eb4c0f 37 37 xt_add_attr( node, "xmlns", XMLNS_MUC ); 38 38 node = jabber_make_packet( "presence", NULL, roomjid, node ); 39 if( password ) 40 xt_add_child( node, xt_new_node( "password", password, NULL ) ); 39 41 jabber_cache_add( ic, node, jabber_chat_join_failed ); 40 42 … … 122 124 struct jabber_chat *jc = c->data; 123 125 struct xt_node *node; 126 127 jc->flags |= JCFLAG_MESSAGE_SENT; 124 128 125 129 node = xt_new_node( "body", message, NULL ); … … 295 299 struct xt_node *subject = xt_find_node( node->children, "subject" ); 296 300 struct xt_node *body = xt_find_node( node->children, "body" ); 297 struct groupchat *chat = NULL; 301 struct groupchat *chat = bud ? jabber_chat_by_jid( ic, bud->bare_jid ) : NULL; 302 struct jabber_chat *jc = chat ? chat->data : NULL; 298 303 char *s; 299 304 300 if( bud == NULL )305 if( bud == NULL || ( jc && ~jc->flags & JCFLAG_MESSAGE_SENT && bud == jc->me ) ) 301 306 { 302 307 char *nick; … … 346 351 return; 347 352 } 348 else if( ( chat = jabber_chat_by_jid( ic, bud->bare_jid ) )== NULL )353 else if( chat == NULL ) 349 354 { 350 355 /* How could this happen?? We could do kill( self, 11 ) -
protocols/jabber/iq.c
r8961950 r4eb4c0f 92 92 else if( strcmp( s, XMLNS_DISCOVER ) == 0 ) 93 93 { 94 const char *features[] = { XMLNS_VERSION, 94 const char *features[] = { XMLNS_DISCOVER, 95 XMLNS_VERSION, 95 96 XMLNS_TIME, 96 97 XMLNS_CHATSTATES, -
protocols/jabber/jabber.h
r8961950 r4eb4c0f 49 49 typedef enum 50 50 { 51 JBFLAG_PROBED_XEP85 = 1, 51 JBFLAG_PROBED_XEP85 = 1, /* Set this when we sent our probe packet to make 52 52 sure it gets sent only once. */ 53 JBFLAG_DOES_XEP85 = 2, 53 JBFLAG_DOES_XEP85 = 2, /* Set this when the resource seems to support 54 54 XEP85 (typing notification shite). */ 55 JBFLAG_IS_CHATROOM = 4, 55 JBFLAG_IS_CHATROOM = 4, /* It's convenient to use this JID thingy for 56 56 groupchat state info too. */ 57 JBFLAG_IS_ANONYMOUS = 8, 57 JBFLAG_IS_ANONYMOUS = 8, /* For anonymous chatrooms, when we don't have 58 58 have a real JID. */ 59 59 } jabber_buddy_flags_t; 60 61 typedef enum 62 { 63 JCFLAG_MESSAGE_SENT = 1, /* Set this after sending the first message, so 64 we can detect echoes/backlogs. */ 65 } jabber_chat_flags_t; 60 66 61 67 struct jabber_data … … 95 101 struct jabber_cache_entry 96 102 { 103 time_t saved_at; 97 104 struct xt_node *node; 98 105 jabber_cache_event func; … … 140 147 #define JABBER_PACKET_ID "BeeP" 141 148 #define JABBER_CACHED_ID "BeeC" 149 150 /* The number of seconds to keep cached packets before garbage collecting 151 them. This gc is done on every keepalive (every minute). */ 152 #define JABBER_CACHE_MAX_AGE 600 142 153 143 154 /* RFC 392[01] stuff */ … … 161 172 #define XMLNS_MUC "http://jabber.org/protocol/muc" /* XEP-0045 */ 162 173 #define XMLNS_MUC_USER "http://jabber.org/protocol/muc#user"/* XEP-0045 */ 174 #define XMLNS_CAPS "http://jabber.org/protocol/caps" /* XEP-0115 */ 163 175 164 176 /* iq.c */ -
protocols/jabber/jabber_util.c
r8961950 r4eb4c0f 142 142 entry->node = node; 143 143 entry->func = func; 144 entry->saved_at = time( NULL ); 144 145 g_hash_table_insert( jd->node_cache, xt_find_attr( node, "id" ), entry ); 145 146 } … … 163 164 { 164 165 struct jabber_data *jd = ic->proto_data; 165 166 g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, NULL ); 167 } 168 169 gboolean jabber_cache_clean_entry( gpointer key, gpointer entry_, gpointer nullpointer ) 166 time_t threshold = time( NULL ) - JABBER_CACHE_MAX_AGE; 167 168 g_hash_table_foreach_remove( jd->node_cache, jabber_cache_clean_entry, &threshold ); 169 } 170 171 gboolean jabber_cache_clean_entry( gpointer key, gpointer entry_, gpointer threshold_ ) 170 172 { 171 173 struct jabber_cache_entry *entry = entry_; 172 struct xt_node *node = entry->node; 173 174 if( node->flags & XT_SEEN ) 175 return TRUE; 176 else 177 { 178 node->flags |= XT_SEEN; 179 return FALSE; 180 } 174 time_t *threshold = threshold_; 175 176 return entry->saved_at < *threshold; 181 177 } 182 178 -
protocols/jabber/presence.c
r8961950 r4eb4c0f 29 29 char *from = xt_find_attr( node, "from" ); 30 30 char *type = xt_find_attr( node, "type" ); /* NULL should mean the person is online. */ 31 struct xt_node *c ;31 struct xt_node *c, *cap; 32 32 struct jabber_buddy *bud, *send_presence = NULL; 33 33 int is_chat = 0; … … 76 76 else 77 77 bud->priority = 0; 78 79 if( bud && ( cap = xt_find_node( node->children, "c" ) ) && 80 ( s = xt_find_attr( cap, "xmlns" ) ) && strcmp( s, XMLNS_CAPS ) == 0 ) 81 { 82 /* This <presence> stanza includes an XEP-0115 83 capabilities part. Not too interesting, but we can 84 see if it has an ext= attribute. */ 85 s = xt_find_attr( cap, "ext" ); 86 if( s && ( strstr( s, "cstates" ) || strstr( s, "chatstate" ) ) ) 87 bud->flags |= JBFLAG_DOES_XEP85; 88 89 /* This field can contain more information like xhtml 90 support, but we don't support that ourselves. 91 Officially the ext= tag was deprecated, but enough 92 clients do send it. 93 94 (I'm aware that this is not the right way to use 95 this field.) See for an explanation of ext=: 96 http://www.xmpp.org/extensions/attic/xep-0115-1.3.html*/ 97 } 78 98 79 99 if( is_chat ) … … 186 206 { 187 207 struct jabber_data *jd = ic->proto_data; 188 struct xt_node *node ;208 struct xt_node *node, *cap; 189 209 char *show = jd->away_state->code; 190 210 char *status = jd->away_message; … … 199 219 xt_add_child( node, xt_new_node( "status", status, NULL ) ); 200 220 221 /* This makes the packet slightly bigger, but clients interested in 222 capabilities can now cache the discovery info. This reduces the 223 usual post-login iq-flood. See XEP-0115. At least libpurple and 224 Trillian seem to do this right. */ 225 cap = xt_new_node( "c", NULL, NULL ); 226 xt_add_attr( cap, "xmlns", XMLNS_CAPS ); 227 xt_add_attr( cap, "node", "http://bitlbee.org/xmpp/caps" ); 228 xt_add_attr( cap, "ver", BITLBEE_VERSION ); /* The XEP wants this hashed, but nobody's doing that. */ 229 xt_add_child( node, cap ); 230 201 231 st = jabber_write_packet( ic, node ); 202 232 -
protocols/jabber/sasl.c
r8961950 r4eb4c0f 21 21 * * 22 22 \***************************************************************************/ 23 24 #include <ctype.h> 23 25 24 26 #include "jabber.h" … … 107 109 } 108 110 109 static char *sasl_get_part( char *data, char *field ) 111 /* Non-static function, but not mentioned in jabber.h because it's for internal 112 use, just that the unittest should be able to reach it... */ 113 char *sasl_get_part( char *data, char *field ) 110 114 { 111 115 int i, len; 112 116 113 117 len = strlen( field ); 118 119 while( isspace( *data ) || *data == ',' ) 120 data ++; 114 121 115 122 if( g_strncasecmp( data, field, len ) == 0 && data[len] == '=' ) … … 129 136 } 130 137 131 /* If we got a comma, we got a new field. Check it. */ 132 if( data[i] == ',' && 133 g_strncasecmp( data + i + 1, field, len ) == 0 && 134 data[i+len+1] == '=' ) 138 /* If we got a comma, we got a new field. Check it, 139 find the next key after it. */ 140 if( data[i] == ',' ) 135 141 { 136 i += len + 2; 137 break; 142 while( isspace( data[i] ) || data[i] == ',' ) 143 i ++; 144 145 if( g_strncasecmp( data + i, field, len ) == 0 && 146 data[i+len] == '=' ) 147 { 148 i += len + 1; 149 break; 150 } 138 151 } 139 152 }
Note: See TracChangeset
for help on using the changeset viewer.