Changeset 5e202b0 for protocols/jabber
- Timestamp:
- 2006-09-23T16:18:24Z (18 years ago)
- Branches:
- master
- Children:
- 172a73f1
- Parents:
- d8e0484
- Location:
- protocols/jabber
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/jabber/iq.c
rd8e0484 r5e202b0 107 107 } 108 108 109 presence_announce( gc );109 account_online( gc ); 110 110 } 111 111 else if( strcmp( type, "result" ) == 0 && orig ) -
protocols/jabber/jabber.c
rd8e0484 r5e202b0 111 111 xt_free( jd->xt ); 112 112 113 g_free( jd->away_message ); 113 114 g_free( jd->username ); 114 115 g_free( jd ); … … 128 129 } 129 130 130 /* TODO: For away state handling, implement some list like the one for MSN. */131 131 static GList *jabber_away_states( struct gaim_connection *gc ) 132 132 { 133 GList *l = NULL; 133 static GList *l = NULL; 134 int i; 134 135 135 l = g_list_append( l, (void*) "Online" ); 136 l = g_list_append( l, (void*) "Away" ); 137 l = g_list_append( l, (void*) "Extended Away" ); 138 l = g_list_append( l, (void*) "Do Not Disturb" ); 136 if( l == NULL ) 137 for( i = 0; jabber_away_state_list[i].full_name; i ++ ) 138 l = g_list_append( l, (void*) jabber_away_state_list[i].full_name ); 139 139 140 return ( l );140 return l; 141 141 } 142 142 143 static void jabber_set_away( struct gaim_connection *gc, char *state , char *message )143 static void jabber_set_away( struct gaim_connection *gc, char *state_txt, char *message ) 144 144 { 145 /* For now let's just always set state to "away" and send the message, if available. */ 146 presence_send( gc, NULL, g_strcasecmp( state, "Online" ) == 0 ? NULL : "away", message ); 145 struct jabber_data *jd = gc->proto_data; 146 struct jabber_away_state *state; 147 148 /* Save all this info. We need it, for example, when changing the priority setting. */ 149 state = (void *) jabber_away_state_by_name( state_txt ); 150 jd->away_state = state ? state : (void *) jabber_away_state_list; /* Fall back to "Away" if necessary. */ 151 g_free( jd->away_message ); 152 jd->away_message = ( message && *message ) ? g_strdup( message ) : NULL; 153 154 presence_send( gc, NULL, jd->away_state->code, jd->away_message ); 147 155 } 148 156 -
protocols/jabber/jabber.h
rd8e0484 r5e202b0 39 39 } jabber_flags_t; 40 40 41 /* iq.c */42 xt_status jabber_pkt_iq( struct xt_node *node, gpointer data );43 int jabber_start_iq_auth( struct gaim_connection *gc );44 int jabber_get_roster( struct gaim_connection *gc );45 46 xt_status jabber_pkt_message( struct xt_node *node, gpointer data );47 48 /* presence.c */49 xt_status jabber_pkt_presence( struct xt_node *node, gpointer data );50 int presence_announce( struct gaim_connection *gc );51 int presence_send( struct gaim_connection *gc, char *to, char *show, char *status );52 53 /* jabber_util.c */54 char *set_eval_resprio( set_t *set, char *value );55 char *set_eval_tls( set_t *set, char *value );56 struct xt_node *jabber_make_packet( char *name, char *type, char *to, struct xt_node *children );57 void jabber_cache_packet( struct gaim_connection *gc, struct xt_node *node );58 struct xt_node *jabber_packet_from_cache( struct gaim_connection *gc, char *id );59 60 /* io.c */61 int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node );62 int jabber_write( struct gaim_connection *gc, char *buf, int len );63 gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond );64 gboolean jabber_start_stream( struct gaim_connection *gc );65 void jabber_end_stream( struct gaim_connection *gc );66 67 /* sasl.c */68 xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data );69 xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data );70 xt_status sasl_pkt_result( struct xt_node *node, gpointer data );71 gboolean sasl_supported( struct gaim_connection *gc );72 73 41 struct jabber_data 74 42 { … … 86 54 char *username; /* USERNAME@server */ 87 55 char *server; /* username@SERVER -=> server/domain, not hostname */ 56 struct jabber_away_state *away_state; 57 char *away_message; 88 58 89 59 struct xt_node *node_cache; 90 60 }; 91 61 62 struct jabber_away_state 63 { 64 char code[5]; 65 char *full_name; 66 }; 67 68 /* iq.c */ 69 xt_status jabber_pkt_iq( struct xt_node *node, gpointer data ); 70 int jabber_start_iq_auth( struct gaim_connection *gc ); 71 int jabber_get_roster( struct gaim_connection *gc ); 72 73 xt_status jabber_pkt_message( struct xt_node *node, gpointer data ); 74 75 /* presence.c */ 76 xt_status jabber_pkt_presence( struct xt_node *node, gpointer data ); 77 int presence_send( struct gaim_connection *gc, char *to, char *show, char *status ); 78 79 /* jabber_util.c */ 80 char *set_eval_resprio( set_t *set, char *value ); 81 char *set_eval_tls( set_t *set, char *value ); 82 struct xt_node *jabber_make_packet( char *name, char *type, char *to, struct xt_node *children ); 83 void jabber_cache_packet( struct gaim_connection *gc, struct xt_node *node ); 84 struct xt_node *jabber_packet_from_cache( struct gaim_connection *gc, char *id ); 85 const struct jabber_away_state *jabber_away_state_by_code( char *code ); 86 const struct jabber_away_state *jabber_away_state_by_name( char *name ); 87 88 extern const struct jabber_away_state jabber_away_state_list[]; 89 90 /* io.c */ 91 int jabber_write_packet( struct gaim_connection *gc, struct xt_node *node ); 92 int jabber_write( struct gaim_connection *gc, char *buf, int len ); 93 gboolean jabber_connected_plain( gpointer data, gint source, b_input_condition cond ); 94 gboolean jabber_start_stream( struct gaim_connection *gc ); 95 void jabber_end_stream( struct gaim_connection *gc ); 96 97 /* sasl.c */ 98 xt_status sasl_pkt_mechanisms( struct xt_node *node, gpointer data ); 99 xt_status sasl_pkt_challenge( struct xt_node *node, gpointer data ); 100 xt_status sasl_pkt_result( struct xt_node *node, gpointer data ); 101 gboolean sasl_supported( struct gaim_connection *gc ); 102 92 103 #endif -
protocols/jabber/jabber_util.c
rd8e0484 r5e202b0 92 92 return node; 93 93 } 94 95 const struct jabber_away_state jabber_away_state_list[] = 96 { 97 { "away", "Away" }, 98 { "chat", "Free for Chat" }, 99 { "dnd", "Do not Disturb" }, 100 { "xa", "Extended Away" }, 101 { "", "Online" }, 102 { "", NULL } 103 }; 104 105 const struct jabber_away_state *jabber_away_state_by_code( char *code ) 106 { 107 int i; 108 109 for( i = 0; jabber_away_state_list[i].full_name; i ++ ) 110 if( g_strcasecmp( jabber_away_state_list[i].code, code ) == 0 ) 111 return jabber_away_state_list + i; 112 113 return NULL; 114 } 115 116 const struct jabber_away_state *jabber_away_state_by_name( char *name ) 117 { 118 int i; 119 120 for( i = 0; jabber_away_state_list[i].full_name; i ++ ) 121 if( g_strcasecmp( jabber_away_state_list[i].full_name, name ) == 0 ) 122 return jabber_away_state_list + i; 123 124 return NULL; 125 } -
protocols/jabber/presence.c
rd8e0484 r5e202b0 54 54 } 55 55 56 /* Send the <presence/> tag that finalizes the whole login process, from here57 we'll actually show up as online to our buddies. */58 int presence_announce( struct gaim_connection *gc )59 {60 struct xt_node *node;61 int st;62 63 node = jabber_make_packet( "presence", NULL, NULL, NULL );64 65 st = jabber_write_packet( gc, node );66 67 if( st )68 account_online( gc );69 70 xt_free_node( node );71 return st;72 }73 74 56 int presence_send( struct gaim_connection *gc, char *to, char *show, char *status ) 75 57 { … … 78 60 79 61 node = jabber_make_packet( "presence", NULL, to, NULL ); 80 if( show )62 if( show && *show ) 81 63 xt_add_child( node, xt_new_node( "show", show, NULL ) ); 82 64 if( status )
Note: See TracChangeset
for help on using the changeset viewer.