Changes in protocols/nogaim.c [da3b536:dd89a55]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
rda3b536 rdd89a55 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 40 53 static int remove_chat_buddy_silent( struct conversation *b, char *handle ); 41 54 … … 145 158 GSList *get_connections() { return connections; } 146 159 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 else 176 { 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 else 190 { 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 else 199 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 147 237 /* multi.c */ 148 238 … … 269 359 /* Also necessary when we're not away, at least for some of the 270 360 protocols. */ 271 bim_set_away( gc, u->away );361 proto_away( gc, u->away ); 272 362 } 273 363 … … 393 483 else if( gc->user->proto_opt[0] && *gc->user->proto_opt[0] ) 394 484 { 395 char *colon; 396 397 if( ( colon = strchr( gc->user->proto_opt[0], ':' ) ) ) 398 u->host = g_strndup( gc->user->proto_opt[0], 399 colon - gc->user->proto_opt[0] ); 400 else 401 u->host = g_strdup( gc->user->proto_opt[0] ); 402 485 u->host = g_strdup( gc->user->proto_opt[0] ); 403 486 u->user = g_strdup( handle ); 404 487 … … 941 1024 } 942 1025 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 ) 1026 int serv_send_im( irc_t *irc, user_t *u, char *msg, int flags ) 950 1027 { 951 1028 char *buf = NULL; 952 1029 int st; 953 1030 954 if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )1031 if( ( u->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 955 1032 { 956 1033 buf = escape_html( msg ); … … 958 1035 } 959 1036 960 st = gc->prpl->send_im( gc,handle, msg, strlen( msg ), flags );1037 st = ((struct gaim_connection *)u->gc)->prpl->send_im( u->gc, u->handle, msg, strlen( msg ), flags ); 961 1038 g_free( buf ); 962 1039 … … 964 1041 } 965 1042 966 int bim_chat_msg(struct gaim_connection *gc, int id, char *msg )1043 int serv_send_chat( irc_t *irc, struct gaim_connection *gc, int id, char *msg ) 967 1044 { 968 1045 char *buf = NULL; … … 980 1057 return st; 981 1058 } 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 else1001 {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 else1015 {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 else1024 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 }1073 1074 void bim_add_allow( struct gaim_connection *gc, char *handle )1075 {1076 if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL )1077 {1078 gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) );1079 }1080 1081 gc->prpl->add_permit( gc, handle );1082 }1083 1084 void bim_rem_allow( struct gaim_connection *gc, char *handle )1085 {1086 GSList *l;1087 1088 if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) )1089 {1090 g_free( l->data );1091 gc->permit = g_slist_delete_link( gc->permit, l );1092 }1093 1094 gc->prpl->rem_permit( gc, handle );1095 }1096 1097 void bim_add_block( struct gaim_connection *gc, char *handle )1098 {1099 if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL )1100 {1101 gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) );1102 }1103 1104 gc->prpl->add_deny( gc, handle );1105 }1106 1107 void bim_rem_block( struct gaim_connection *gc, char *handle )1108 {1109 GSList *l;1110 1111 if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) )1112 {1113 g_free( l->data );1114 gc->deny = g_slist_delete_link( gc->deny, l );1115 }1116 1117 gc->prpl->rem_deny( gc, handle );1118 }
Note: See TracChangeset
for help on using the changeset viewer.