- Timestamp:
- 2006-05-23T07:45:14Z (19 years ago)
- Branches:
- master
- Children:
- da3b536
- Parents:
- 73cf7fd
- Location:
- protocols
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
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.