Changeset 4683
- Timestamp:
- 02/22/07 18:02:10 (2 years ago)
- Files:
-
- wired/branches/p7/wired/chats.c (modified) (4 diffs)
- wired/branches/p7/wired/clients.c (modified) (1 diff)
- wired/branches/p7/wired/clients.h (modified) (2 diffs)
- wired/branches/p7/wired/commands.c (modified) (8 diffs)
- wired/branches/p7/wired/main.c (modified) (3 diffs)
- wired/branches/p7/wired/messages.c (added)
- wired/branches/p7/wired/messages.h (added)
- wired/branches/p7/wired/server.c (modified) (4 diffs)
- wired/branches/p7/wired/server.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wired/branches/p7/wired/chats.c
r4576 r4683 227 227 228 228 void wd_chat_add_client(wd_chat_t *chat, wd_client_t *client) { 229 wd_broadcast(chat, 302, WI_STR("%u%c%u%c%u%c%u%c%u%c%#@%c%#@%c%#@%c%#@%c%#@%c%#@"),229 /* wd_broadcast(chat, 302, WI_STR("%u%c%u%c%u%c%u%c%u%c%#@%c%#@%c%#@%c%#@%c%#@%c%#@"), 230 230 chat->cid, WD_FIELD_SEPARATOR, 231 231 client->uid, WD_FIELD_SEPARATOR, … … 238 238 client->host, WD_FIELD_SEPARATOR, 239 239 client->status, WD_FIELD_SEPARATOR, 240 client->image); 240 client->image);*/ 241 241 242 242 wi_array_wrlock(chat->clients); … … 274 274 while((client = wi_enumerator_next_data(enumerator))) { 275 275 if(client->state == WD_CLIENT_STATE_LOGGED_IN) { 276 wd_reply(310, WI_STR("%u%c%u%c%u%c%u%c%u%c%#@%c%#@%c%#@%c%#@%c%#@%c%#@"),276 /* wd_reply(310, WI_STR("%u%c%u%c%u%c%u%c%u%c%#@%c%#@%c%#@%c%#@%c%#@%c%#@"), 277 277 chat->cid, WD_FIELD_SEPARATOR, 278 278 client->uid, WD_FIELD_SEPARATOR, … … 285 285 client->host, WD_FIELD_SEPARATOR, 286 286 client->status, WD_FIELD_SEPARATOR, 287 client->image); 287 client->image);*/ 288 288 } 289 289 } wired/branches/p7/wired/clients.c
r4596 r4683 204 204 wi_release(client->version); 205 205 wi_release(client->status); 206 wi_release(client->i mage);206 wi_release(client->icon); 207 207 208 208 wi_release(client->socket_lock); wired/branches/p7/wired/clients.h
r4596 r4683 58 58 wi_socket_t *socket; 59 59 wi_p7_socket_t *p7_socket; 60 wi_p7_message_t *message; 60 61 61 62 wi_lock_t *flag_lock; 62 63 wd_uid_t uid; 63 64 wd_client_state_t state; 64 w d_icon_ticon;65 wi_data_t *icon; 65 66 wi_boolean_t idle; 66 67 wi_boolean_t admin; … … 75 76 wi_string_t *version; 76 77 wi_string_t *status; 77 78 wi_string_t *image;79 78 80 79 wi_time_interval_t login_time; wired/branches/p7/wired/commands.c
r4675 r4683 222 222 wd_client_t *client = argument; 223 223 wi_string_t *string; 224 wi_p7_message_t *message;225 224 wi_socket_state_t state; 226 225 wi_uinteger_t i = 0; … … 253 252 } 254 253 255 /*wd_client_lock_socket(client);254 wd_client_lock_socket(client); 256 255 string = wi_socket_read_to_string(client->socket, 0.0, WI_STR(WD_MESSAGE_SEPARATOR_STR)); 257 256 wd_client_unlock_socket(client); … … 264 263 } 265 264 266 wd_parse_command(string);*/ 267 268 wd_client_lock_socket(client); 269 message = wi_p7_socket_read_message(client->p7_socket, 0.0); 270 wd_client_unlock_socket(client); 271 272 if(!message) { 273 wi_log_info(WI_STR("Could not read from %@: %m"), client->ip); 274 275 break; 276 } 277 278 wi_log_info(WI_STR("read %@"), message); 265 wd_parse_command(string); 279 266 280 267 if(++i % 10 == 0) … … 941 928 942 929 static void wd_cmd_icon(wi_array_t *arguments) { 943 wd_client_t *client = wd_client();930 /* wd_client_t *client = wd_client(); 944 931 wd_icon_t icon; 945 932 946 933 icon = wi_string_uint32(WI_ARRAY(arguments, 0)); 947 934 948 /* set icon if changed */949 935 if(client->icon != icon) { 950 936 client->icon = icon; … … 954 940 } 955 941 956 /* copy custom icon if changed */957 942 if(wi_array_count(arguments) > 1) { 958 943 wi_release(client->image); … … 964 949 client->image); 965 950 } 966 } 951 }*/ 967 952 } 968 953 … … 1035 1020 idle = wi_date_iso8601_string(wi_date_with_time_interval(peer->idle_time)); 1036 1021 1037 wd_reply(308, WI_STR("%u%c%u%c%u%c%u%c%#@%c%#@%c%#@%c%#@%c%#@%c%#@%c%u%c%#@%c%#@%c%#@%c%#@%c%#@%c%#@"),1022 /* wd_reply(308, WI_STR("%u%c%u%c%u%c%u%c%#@%c%#@%c%#@%c%#@%c%#@%c%#@%c%u%c%#@%c%#@%c%#@%c%#@%c%#@%c%#@"), 1038 1023 peer->uid, WD_FIELD_SEPARATOR, 1039 1024 peer->idle, WD_FIELD_SEPARATOR, … … 1052 1037 uploads, WD_FIELD_SEPARATOR, 1053 1038 peer->status, WD_FIELD_SEPARATOR, 1054 peer->image); 1039 peer->image);*/ 1055 1040 } 1056 1041 wired/branches/p7/wired/main.c
r4568 r4683 43 43 #include "files.h" 44 44 #include "main.h" 45 #include "messages.h" 45 46 #include "news.h" 46 47 #include "server.h" … … 117 118 118 119 case 'D': 119 wd_daemonize = false;120 wd_daemonize = false; 120 121 wi_log_stderr = true; 121 122 break; … … 189 190 wd_clients_init(); 190 191 wd_files_init(); 192 wd_messages_init(); 191 193 wd_news_init(); 192 194 wd_tempbans_init(); wired/branches/p7/wired/server.c
r4675 r4683 66 66 static wi_socket_context_t *wd_transfer_socket_context; 67 67 68 static wi_p7_spec_t *wd_p7_spec;69 68 static wi_rsa_t *wd_rsa; 69 70 wi_p7_spec_t *wd_p7_spec; 70 71 71 72 wi_string_t *wd_banner; … … 190 191 if(!wd_p7_spec) 191 192 wi_log_err(WI_STR("Could not load wired.xml: %m")); 192 193 wi_p7_spec_t *p7_spec = wi_p7_spec_init_with_file(wi_p7_spec_alloc(), WI_STR("wired2.xml"));194 195 wi_log_info(WI_STR("compatible = %d"), wi_p7_spec_is_compatible_with_spec(wd_p7_spec, p7_spec));196 197 wi_release(p7_spec);198 193 } 199 194 … … 262 257 void wd_ssl_init(void) { 263 258 wd_rsa = wi_rsa_init_with_bits(wi_rsa_alloc(), 1024); 264 265 /* wi_p7_cipher_t *cipher = wi_p7_cipher_init_with_random_key(wi_p7_cipher_alloc(), WI_P7_CIPHER_AES_256);266 267 wi_log_info(WI_STR("cipher = %@"), cipher);268 269 if(!cipher)270 wi_log_err(WI_STR("%m"));271 272 wi_string_t *string0 = WI_STR("a");273 274 wi_log_info(WI_STR("string0 = %@"), string0);275 276 wi_data_t *data0 = wi_string_data(string0);277 278 wi_log_info(WI_STR("data0 = %@"), data0);279 280 wi_data_t *data1 = wi_p7_cipher_encrypt_data(cipher, data0);281 282 wi_log_info(WI_STR("data1 = %@"), data1);283 284 wi_data_t *data2 = wi_p7_cipher_decrypt_data(cipher, data1);285 286 if(!data2)287 wi_log_err(WI_STR("%m"));288 289 wi_log_info(WI_STR("data2 = %@"), data2);290 291 wi_string_t *string1 = wi_string_with_data(data2);292 293 wi_log_info(WI_STR("string1 = %@"), string1);294 295 wi_release(cipher);*/296 259 } 297 260 … … 464 427 #pragma mark - 465 428 429 void wd_reply_message(wd_client_t *client, wi_p7_message_t *message) { 430 wi_p7_uint32_t transaction; 431 432 if(message != client->message) { 433 if(wi_p7_message_get_uint32_for_name(client->message, &transaction, WI_STR("wired.transaction"))) 434 wi_p7_message_set_uint32_for_name(message, transaction, WI_STR("wired.transaction")); 435 } 436 437 wd_client_lock_socket(client); 438 wi_p7_socket_write_message(client->p7_socket, 0.0, message); 439 wd_client_unlock_socket(client); 440 } 441 442 443 444 void wd_reply_error2(wd_client_t *client, wi_p7_enum_t error) { 445 wi_p7_message_t *message; 446 447 message = wi_p7_message_with_name(WI_STR("wired.error"), client->p7_socket); 448 wi_p7_message_set_enum_for_name(message, error, WI_STR("wired.error.code")); 449 450 wd_reply_message(client, message); 451 } 452 453 454 455 void wd_broadcast_message(wd_chat_t *chat, wi_p7_message_t *message) { 456 wi_enumerator_t *enumerator; 457 wd_client_t *client; 458 459 wi_array_rdlock(chat->clients); 460 461 enumerator = wi_array_data_enumerator(chat->clients); 462 463 while((client = wi_enumerator_next_data(enumerator))) { 464 if(client->state == WD_CLIENT_STATE_LOGGED_IN) 465 wd_reply_message(client, message); 466 } 467 468 wi_array_unlock(chat->clients); 469 } 470 471 472 466 473 void wd_reply(uint32_t n, wi_string_t *fmt, ...) { 467 474 wd_client_t *client = wd_client(); wired/branches/p7/wired/server.h
r4508 r4683 51 51 void wd_ssl_init(void); 52 52 53 void wd_reply_message(wd_client_t *, wi_p7_message_t *); 54 void wd_reply_error2(wd_client_t *, wi_p7_enum_t); 55 void wd_broadcast_message(wd_chat_t *, wi_p7_message_t *); 53 56 void wd_reply(uint32_t, wi_string_t *, ...); 54 57 void wd_reply_error(void); … … 57 60 58 61 62 extern wi_p7_spec_t *wd_p7_spec; 63 59 64 extern wi_string_t *wd_banner; 60 65
