Changeset 68b518d6 for protocols/nogaim.c
- Timestamp:
- 2006-05-26T09:03:38Z (18 years ago)
- Branches:
- master
- Children:
- cdca30b
- Parents:
- 41ca004 (diff), c53911e (diff), 7bfd574 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
protocols/nogaim.c
r41ca004 r68b518d6 36 36 #include <ctype.h> 37 37 38 static char *proto_away_alias[8][5] =39 {40 { "Away from computer", "Away", "Extended away", NULL },41 { "NA", "N/A", "Not available", NULL },42 { "Busy", "Do not disturb", "DND", "Occupied", NULL },43 { "Be right back", "BRB", NULL },44 { "On the phone", "Phone", "On phone", NULL },45 { "Out to lunch", "Lunch", "Food", NULL },46 { "Invisible", "Hidden" },47 { NULL }48 };49 static char *proto_away_alias_find( GList *gcm, char *away );50 51 38 static int remove_chat_buddy_silent( struct conversation *b, char *handle ); 52 39 … … 156 143 GSList *get_connections() { return connections; } 157 144 158 int proto_away( struct gaim_connection *gc, char *away )159 {160 GList *m, *ms;161 char *s;162 163 if( !away ) away = "";164 ms = m = gc->prpl->away_states( gc );165 166 while( m )167 {168 if( *away )169 {170 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 )171 break;172 }173 else174 {175 if( g_strcasecmp( m->data, "Available" ) == 0 )176 break;177 if( g_strcasecmp( m->data, "Online" ) == 0 )178 break;179 }180 m = m->next;181 }182 183 if( m )184 {185 gc->prpl->set_away( gc, m->data, *away ? away : NULL );186 }187 else188 {189 s = proto_away_alias_find( ms, away );190 if( s )191 {192 gc->prpl->set_away( gc, s, away );193 if( set_getint( gc->irc, "debug" ) )194 serv_got_crap( gc, "Setting away state to %s", s );195 }196 else197 gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away );198 }199 200 g_list_free( ms );201 202 return( 1 );203 }204 205 static char *proto_away_alias_find( GList *gcm, char *away )206 {207 GList *m;208 int i, j;209 210 for( i = 0; *proto_away_alias[i]; i ++ )211 {212 for( j = 0; proto_away_alias[i][j]; j ++ )213 if( g_strncasecmp( away, proto_away_alias[i][j], strlen( proto_away_alias[i][j] ) ) == 0 )214 break;215 216 if( !proto_away_alias[i][j] ) /* If we reach the end, this row */217 continue; /* is not what we want. Next! */218 219 /* Now find an entry in this row which exists in gcm */220 for( j = 0; proto_away_alias[i][j]; j ++ )221 {222 m = gcm;223 while( m )224 {225 if( g_strcasecmp( proto_away_alias[i][j], m->data ) == 0 )226 return( proto_away_alias[i][j] );227 m = m->next;228 }229 }230 }231 232 return( NULL );233 }234 235 145 /* multi.c */ 236 146 … … 357 267 /* Also necessary when we're not away, at least for some of the 358 268 protocols. */ 359 proto_away( gc, u->away );269 bim_set_away( gc, u->away ); 360 270 } 361 271 … … 481 391 else if( gc->user->proto_opt[0] && *gc->user->proto_opt[0] ) 482 392 { 483 u->host = g_strdup( gc->user->proto_opt[0] ); 393 char *colon; 394 395 if( ( colon = strchr( gc->user->proto_opt[0], ':' ) ) ) 396 u->host = g_strndup( gc->user->proto_opt[0], 397 colon - gc->user->proto_opt[0] ); 398 else 399 u->host = g_strdup( gc->user->proto_opt[0] ); 400 484 401 u->user = g_strdup( handle ); 485 402 … … 1022 939 } 1023 940 1024 int serv_send_im( irc_t *irc, user_t *u, char *msg, int flags ) 941 942 943 944 /* The plan is to not allow straight calls to prpl functions anymore, but do 945 them all from some wrappers. We'll start to define some down here: */ 946 947 int bim_buddy_msg( struct gaim_connection *gc, char *handle, char *msg, int flags ) 1025 948 { 1026 949 char *buf = NULL; 1027 950 int st; 1028 951 1029 if( ( u->gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) )952 if( ( gc->flags & OPT_CONN_HTML ) && ( g_strncasecmp( msg, "<html>", 6 ) != 0 ) ) 1030 953 { 1031 954 buf = escape_html( msg ); … … 1033 956 } 1034 957 1035 st = ((struct gaim_connection *)u->gc)->prpl->send_im( u->gc, u->handle, msg, strlen( msg ), flags );958 st = gc->prpl->send_im( gc, handle, msg, strlen( msg ), flags ); 1036 959 g_free( buf ); 1037 960 … … 1039 962 } 1040 963 1041 int serv_send_chat( irc_t *irc,struct gaim_connection *gc, int id, char *msg )964 int bim_chat_msg( struct gaim_connection *gc, int id, char *msg ) 1042 965 { 1043 966 char *buf = NULL; … … 1055 978 return st; 1056 979 } 980 981 static char *bim_away_alias_find( GList *gcm, char *away ); 982 983 int bim_set_away( struct gaim_connection *gc, char *away ) 984 { 985 GList *m, *ms; 986 char *s; 987 988 if( !away ) away = ""; 989 ms = m = gc->prpl->away_states( gc ); 990 991 while( m ) 992 { 993 if( *away ) 994 { 995 if( g_strncasecmp( m->data, away, strlen( m->data ) ) == 0 ) 996 break; 997 } 998 else 999 { 1000 if( g_strcasecmp( m->data, "Available" ) == 0 ) 1001 break; 1002 if( g_strcasecmp( m->data, "Online" ) == 0 ) 1003 break; 1004 } 1005 m = m->next; 1006 } 1007 1008 if( m ) 1009 { 1010 gc->prpl->set_away( gc, m->data, *away ? away : NULL ); 1011 } 1012 else 1013 { 1014 s = bim_away_alias_find( ms, away ); 1015 if( s ) 1016 { 1017 gc->prpl->set_away( gc, s, away ); 1018 if( set_getint( gc->irc, "debug" ) ) 1019 serv_got_crap( gc, "Setting away state to %s", s ); 1020 } 1021 else 1022 gc->prpl->set_away( gc, GAIM_AWAY_CUSTOM, away ); 1023 } 1024 1025 g_list_free( ms ); 1026 1027 return( 1 ); 1028 } 1029 1030 static char *bim_away_alias_list[8][5] = 1031 { 1032 { "Away from computer", "Away", "Extended away", NULL }, 1033 { "NA", "N/A", "Not available", NULL }, 1034 { "Busy", "Do not disturb", "DND", "Occupied", NULL }, 1035 { "Be right back", "BRB", NULL }, 1036 { "On the phone", "Phone", "On phone", NULL }, 1037 { "Out to lunch", "Lunch", "Food", NULL }, 1038 { "Invisible", "Hidden" }, 1039 { NULL } 1040 }; 1041 1042 static char *bim_away_alias_find( GList *gcm, char *away ) 1043 { 1044 GList *m; 1045 int i, j; 1046 1047 for( i = 0; *bim_away_alias_list[i]; i ++ ) 1048 { 1049 for( j = 0; bim_away_alias_list[i][j]; j ++ ) 1050 if( g_strncasecmp( away, bim_away_alias_list[i][j], strlen( bim_away_alias_list[i][j] ) ) == 0 ) 1051 break; 1052 1053 if( !bim_away_alias_list[i][j] ) /* If we reach the end, this row */ 1054 continue; /* is not what we want. Next! */ 1055 1056 /* Now find an entry in this row which exists in gcm */ 1057 for( j = 0; bim_away_alias_list[i][j]; j ++ ) 1058 { 1059 m = gcm; 1060 while( m ) 1061 { 1062 if( g_strcasecmp( bim_away_alias_list[i][j], m->data ) == 0 ) 1063 return( bim_away_alias_list[i][j] ); 1064 m = m->next; 1065 } 1066 } 1067 } 1068 1069 return( NULL ); 1070 } 1071 1072 void bim_add_allow( struct gaim_connection *gc, char *handle ) 1073 { 1074 if( g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) 1075 { 1076 gc->permit = g_slist_prepend( gc->permit, g_strdup( handle ) ); 1077 } 1078 1079 gc->prpl->add_permit( gc, handle ); 1080 } 1081 1082 void bim_rem_allow( struct gaim_connection *gc, char *handle ) 1083 { 1084 GSList *l; 1085 1086 if( ( l = g_slist_find_custom( gc->permit, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) 1087 { 1088 g_free( l->data ); 1089 gc->permit = g_slist_delete_link( gc->permit, l ); 1090 } 1091 1092 gc->prpl->rem_permit( gc, handle ); 1093 } 1094 1095 void bim_add_block( struct gaim_connection *gc, char *handle ) 1096 { 1097 if( g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) == NULL ) 1098 { 1099 gc->deny = g_slist_prepend( gc->deny, g_strdup( handle ) ); 1100 } 1101 1102 gc->prpl->add_deny( gc, handle ); 1103 } 1104 1105 void bim_rem_block( struct gaim_connection *gc, char *handle ) 1106 { 1107 GSList *l; 1108 1109 if( ( l = g_slist_find_custom( gc->deny, handle, (GCompareFunc) gc->prpl->cmp_buddynames ) ) ) 1110 { 1111 g_free( l->data ); 1112 gc->deny = g_slist_delete_link( gc->deny, l ); 1113 } 1114 1115 gc->prpl->rem_deny( gc, handle ); 1116 }
Note: See TracChangeset
for help on using the changeset viewer.