Changeset 226fce1
- Timestamp:
- 2006-05-23T07:45:14Z (18 years ago)
- Branches:
- master
- Children:
- da3b536
- Parents:
- 73cf7fd
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
irc.c
r73cf7fd r226fce1 1011 1011 else if( c && c->gc && c->gc->prpl ) 1012 1012 { 1013 return( serv_send_chat( irc,c->gc, c->id, s ) );1013 return( bim_chat_msg( c->gc, c->id, s ) ); 1014 1014 } 1015 1015 … … 1021 1021 user_t *u = data; 1022 1022 1023 /* Shouldn't happen, but just to be sure. */ 1024 if( u->sendbuf_len < 2 ) 1025 return FALSE; 1026 1023 1027 u->sendbuf[u->sendbuf_len-2] = 0; /* Cut off the last newline */ 1024 serv_send_im( u->gc->irc, u, u->sendbuf, u->sendbuf_flags );1028 bim_buddy_msg( u->gc, u->handle, u->sendbuf, u->sendbuf_flags ); 1025 1029 1026 1030 g_free( u->sendbuf ); … … 1030 1034 u->sendbuf_flags = 0; 1031 1035 1032 return ( FALSE );1036 return FALSE; 1033 1037 } 1034 1038 … … 1043 1047 if( u->sendbuf_len > 0 && u->sendbuf_flags != flags) 1044 1048 { 1045 / /Flush the buffer1049 /* Flush the buffer */ 1046 1050 g_source_remove( u->sendbuf_timer ); 1047 1051 buddy_send_handler_delayed( u ); … … 1051 1055 { 1052 1056 u->sendbuf_len = strlen( msg ) + 2; 1053 u->sendbuf = g_new (char, u->sendbuf_len );1057 u->sendbuf = g_new( char, u->sendbuf_len ); 1054 1058 u->sendbuf[0] = 0; 1055 1059 u->sendbuf_flags = flags; … … 1058 1062 { 1059 1063 u->sendbuf_len += strlen( msg ) + 1; 1060 u->sendbuf = g_renew 1064 u->sendbuf = g_renew( char, u->sendbuf, u->sendbuf_len ); 1061 1065 } 1062 1066 … … 1074 1078 else 1075 1079 { 1076 serv_send_im( irc, u, msg, flags );1080 bim_buddy_msg( u->gc, u->handle, msg, flags ); 1077 1081 } 1078 1082 } -
irc_commands.c
r73cf7fd r226fce1 448 448 449 449 if( gc && gc->flags & OPT_LOGGED_IN ) 450 proto_away( gc, u->away );450 bim_set_away( gc, u->away ); 451 451 } 452 452 } -
protocols/nogaim.c
r73cf7fd r226fce1 38 38 #include <ctype.h> 39 39 40 static char *proto_away_alias[8][5] =41 {42 { "Away from computer", "Away", "Extended away", NULL },43 { "NA", "N/A", "Not available", NULL },44 { "Busy", "Do not disturb", "DND", "Occupied", NULL },45 { "Be right back", "BRB", NULL },46 { "On the phone", "Phone", "On phone", NULL },47 { "Out to lunch", "Lunch", "Food", NULL },48 { "Invisible", "Hidden" },49 { NULL }50 };51 static char *proto_away_alias_find( GList *gcm, char *away );52 53 40 static int remove_chat_buddy_silent( struct conversation *b, char *handle ); 54 41 … … 158 145 GSList *get_connections() { return connections; } 159 146 160 int proto_away( struct gaim_connection *gc, char *away )161 {162 GList *m, *ms;163 char *s;164 165 if( !away ) away = "";166 ms = m = gc->prpl->away_states( gc );167 168 while( m )169 {170 if( *away )171 {172 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 )173 break;174 }175 else176 {177 if( g_strcasecmp( m->data, "Available" ) == 0 )178 break;179 if( g_strcasecmp( m->data, "Online" ) == 0 )180 break;181 }182 m = m->next;183 }184 185 if( m )186 {187 gc->prpl->set_away( gc, m->data, *away ? away : NULL );188 }189 else190 {191 s = proto_away_alias_find( ms, away );192 if( s )193 {194 gc->prpl->set_away( gc, s, away );195 if( set_getint( gc->irc, "debug" ) )196 serv_got_crap( gc, "Setting away state to %s", s );197 }198 else199 gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );200 }201 202 g_list_free( ms );203 204 return( 1 );205 }206 207 static char *proto_away_alias_find( GList *gcm, char *away )208 {209 GList *m;210 int i, j;211 212 for( i = 0; *proto_away_alias[i]; i ++ )213 {214 for( j = 0; proto_away_alias[i][j]; j ++ )215 if( g_strncasecmp( away, proto_away_alias[i][j], strlen( proto_away_alias[i][j] ) ) == 0 )216 break;217 218 if( !proto_away_alias[i][j] ) /* If we reach the end, this row */219 continue; /* is not what we want. Next! */220 221 /* Now find an entry in this row which exists in gcm */222 for( j = 0; proto_away_alias[i][j]; j ++ )223 {224 m = gcm;225 while( m )226 {227 if( g_strcasecmp( proto_away_alias[i][j], m->data ) == 0 )228 return( proto_away_alias[i][j] );229 m = m->next;230 }231 }232 }233 234 return( NULL );235 }236 237 147 /* multi.c */ 238 148 … … 359 269 /* Also necessary when we're not away, at least for some of the 360 270 protocols. */ 361 proto_away( gc, u->away );271 bim_set_away( gc, u->away ); 362 272 } 363 273 … … 1031 941 } 1032 942 1033 int serv_send_im( irc_t *irc, user_t *u, char *msg, int flags ) 943 944 945 946 /* The plan is to not allow straight calls to prpl functions anymore, but do 947 them all from some wrappers. We'll start to define some down here: */ 948 949 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags ) 1034 950 { 1035 951 char *buf = NULL; 1036 952 int st; 1037 953 1038 if( ( u->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )954 if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 1039 955 { 1040 956 buf = escape_html( msg ); … … 1042 958 } 1043 959 1044 st = ((struct gaim_connection *)u->gc)->prpl->send_im( u->gc, u->handle, msg, strlen( msg ), flags );960 st = gc->prpl->send_im( gc, handle, msg, strlen( msg ), flags ); 1045 961 g_free( buf ); 1046 962 … … 1048 964 } 1049 965 1050 int serv_send_chat( irc_t *irc,struct gaim_connection *gc, int id, char *msg )966 int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ) 1051 967 { 1052 968 char *buf = NULL; … … 1064 980 return st; 1065 981 } 982 983 static char *bim_away_alias_find( GList *gcm, char *away ); 984 985 int bim_set_away( struct gaim_connection *gc, char *away ) 986 { 987 GList *m, *ms; 988 char *s; 989 990 if( !away ) away = ""; 991 ms = m = gc->prpl->away_states( gc ); 992 993 while( m ) 994 { 995 if( *away ) 996 { 997 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) 998 break; 999 } 1000 else 1001 { 1002 if( g_strcasecmp( m->data, "Available" ) == 0 ) 1003 break; 1004 if( g_strcasecmp( m->data, "Online" ) == 0 ) 1005 break; 1006 } 1007 m = m->next; 1008 } 1009 1010 if( m ) 1011 { 1012 gc->prpl->set_away( gc, m->data, *away ? away : NULL ); 1013 } 1014 else 1015 { 1016 s = bim_away_alias_find( ms, away ); 1017 if( s ) 1018 { 1019 gc->prpl->set_away( gc, s, away ); 1020 if( set_getint( gc->irc, "debug" ) ) 1021 serv_got_crap( gc, "Setting away state to %s", s ); 1022 } 1023 else 1024 gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); 1025 } 1026 1027 g_list_free( ms ); 1028 1029 return( 1 ); 1030 } 1031 1032 static char *bim_away_alias_list[8][5] = 1033 { 1034 { "Away from computer", "Away", "Extended away", NULL }, 1035 { "NA", "N/A", "Not available", NULL }, 1036 { "Busy", "Do not disturb", "DND", "Occupied", NULL }, 1037 { "Be right back", "BRB", NULL }, 1038 { "On the phone", "Phone", "On phone", NULL }, 1039 { "Out to lunch", "Lunch", "Food", NULL }, 1040 { "Invisible", "Hidden" }, 1041 { NULL } 1042 }; 1043 1044 static char *bim_away_alias_find( GList *gcm, char *away ) 1045 { 1046 GList *m; 1047 int i, j; 1048 1049 for( i = 0; *bim_away_alias_list[i]; i ++ ) 1050 { 1051 for( j = 0; bim_away_alias_list[i][j]; j ++ ) 1052 if( g_strncasecmp( away, bim_away_alias_list[i][j], strlen( bim_away_alias_list[i][j] ) ) == 0 ) 1053 break; 1054 1055 if( !bim_away_alias_list[i][j] ) /* If we reach the end, this row */ 1056 continue; /* is not what we want. Next! */ 1057 1058 /* Now find an entry in this row which exists in gcm */ 1059 for( j = 0; bim_away_alias_list[i][j]; j ++ ) 1060 { 1061 m = gcm; 1062 while( m ) 1063 { 1064 if( g_strcasecmp( bim_away_alias_list[i][j], m->data ) == 0 ) 1065 return( bim_away_alias_list[i][j] ); 1066 m = m->next; 1067 } 1068 } 1069 } 1070 1071 return( NULL ); 1072 } -
protocols/nogaim.h
r73cf7fd r226fce1 194 194 195 195 /* nogaim.c */ 196 int serv_send_im(irc_t *irc, user_t *u, char *msg, int flags); 197 int serv_send_chat(irc_t *irc, struct gaim_connection *gc, int id, char *msg ); 196 int bim_set_away( struct gaim_connection *gc, char *away ); 197 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags ); 198 int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ); 198 199 199 200 void nogaim_init(); 200 int proto_away( struct gaim_connection *gc, char *away );201 201 char *set_eval_away_devoice( irc_t *irc, set_t *set, char *value ); 202 202
Note: See TracChangeset
for help on using the changeset viewer.