Changeset 4674

Show
Ignore:
Timestamp:
02/20/07 16:58:53 (2 years ago)
Author:
morris
Message:

Some p7 tests

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • wire/branches/p7/wire/client.c

    r4625 r4674  
    144144 
    145145wi_socket_t                                                     *wr_socket; 
     146wi_p7_socket_t                                          *wr_p7_socket; 
    146147wi_address_t                                            *wr_address; 
    147148 
     
    178179        wr_icon = wi_string_init_with_cstring(wi_string_alloc(), wr_default_icon); 
    179180         
    180         wr_p7_spec = wi_p7_spec_init_with_file(wi_p7_spec_alloc(), WI_STR("protocol.xml")); 
     181        wr_p7_spec = wi_p7_spec_init_with_file(wi_p7_spec_alloc(), WI_STR("wired.xml")); 
    181182     
    182183        if(!wr_p7_spec) 
     
    194195        wi_socket_t                     *socket; 
    195196        wi_p7_socket_t          *p7_socket; 
     197        wi_cipher_t                     *cipher; 
    196198        wi_string_t                     *ip; 
    197199         
     
    213215        } 
    214216         
    215 //      enumerator = wi_array_data_enumerator(addresses); 
    216          
    217 //      while((address = wi_enumerator_next_data(enumerator))) { 
    218         address = wi_array_first_data(addresses); 
     217        enumerator = wi_array_data_enumerator(addresses); 
     218         
     219        while((address = wi_enumerator_next_data(enumerator))) { 
    219220                ip = wi_address_string(address); 
    220221 
     
    223224                wi_address_set_port(address, port); 
    224225                 
    225                 socket = wi_socket_init_with_address(wi_socket_alloc(), address, WI_SOCKET_TCP); 
     226                socket = wi_autorelease(wi_socket_init_with_address(wi_socket_alloc(), address, WI_SOCKET_TCP)); 
    226227                wi_socket_set_interactive(socket, true); 
    227228 
     
    229230                        wr_printf_prefix(WI_STR("Could not connect to %@: %m"), ip); 
    230231 
    231                         goto next; 
    232                 } 
    233                  
    234                 p7_socket = wi_p7_socket_init_with_socket(wi_p7_socket_alloc(), socket, wr_p7_spec); 
    235                  
    236                 if(!wi_p7_socket_connect(p7_socket, 10.0, WI_P7_COMPRESSION_DEFLATE | WI_P7_ENCRYPTION_RSA_AES_256, WI_P7_BINARY, login, password)) { 
     232                        continue; 
     233                } 
     234                 
     235                p7_socket = wi_autorelease(wi_p7_socket_init_with_socket(wi_p7_socket_alloc(), socket, wr_p7_spec)); 
     236                 
     237//              if(!wi_p7_socket_connect(p7_socket, 10.0, WI_P7_ENCRYPTION_RSA_AES_256 | WI_P7_COMPRESSION_DEFLATE, WI_P7_XML, login, password)) { 
     238                if(!wi_p7_socket_connect(p7_socket, 10.0, WI_P7_ENCRYPTION_RSA_AES_256 | WI_P7_COMPRESSION_DEFLATE, WI_P7_BINARY, login, password)) { 
    237239                        wr_printf_prefix(WI_STR("Could not connect to %@: %m"), ip); 
    238240 
    239                         goto next; 
    240                 } 
    241  
    242 /*              wr_printf_prefix(WI_STR("Connected using %@/%@/%u bits, logging in..."), 
    243                         wi_socket_cipher_version(socket), 
    244                         wi_socket_cipher_name(socket), 
    245                         wi_socket_cipher_bits(socket));*/ 
    246                 wr_printf_prefix(WI_STR("Connected, logging in...")); 
     241                        continue; 
     242                } 
     243 
     244                cipher = wi_p7_socket_cipher(p7_socket); 
     245                 
     246                if(cipher) { 
     247                        wr_printf_prefix(WI_STR("Connected using %@/%u bits, logging in..."), 
     248                                wi_cipher_name(cipher), 
     249                                wi_cipher_bits(cipher)); 
     250                } else { 
     251                        wr_printf_prefix(WI_STR("Connected, logging in...")); 
     252                } 
    247253 
    248254                wr_connected    = true; 
     
    252258                wr_password             = wi_retain(password); 
    253259                wr_socket               = wi_retain(socket); 
     260                wr_p7_socket    = wi_retain(p7_socket); 
    254261                wr_address              = wi_retain(address); 
    255262                 
    256263                wr_runloop_add_socket(wr_socket, &wr_runloop_server_callback); 
    257                 wr_send_command(WI_STR("HELLO")); 
    258  
    259 next: 
    260                 wi_release(socket); 
    261                  
    262                 if(wr_connected) 
    263                         ; 
    264 //      } 
     264                 
     265                { 
     266                        wi_p7_message_t *message = wi_p7_message_with_name(WI_STR("wired.info"), wr_p7_socket); 
     267                        wi_p7_message_set_string_for_name(message, WI_STR("wire"), WI_STR("wired.info.application.name")); 
     268                         
     269                        wi_p7_socket_write_message(wr_p7_socket, 0.0, message); 
     270                } 
     271                 
     272                break; 
     273        } 
    265274 
    266275        if(wr_socket) 
     
    273282        wr_runloop_remove_socket(wr_socket); 
    274283        wi_release(wr_socket); 
     284        wi_release(wr_p7_socket); 
    275285 
    276286        if(wr_connected) { 
  • wire/branches/p7/wire/client.h

    r4423 r4674  
    8585 
    8686extern wi_socket_t                                              *wr_socket; 
     87extern wi_p7_socket_t                                   *wr_p7_socket; 
    8788extern wi_address_t                                             *wr_address; 
    8889 
  • wire/branches/p7/wire/main.c

    r4569 r4674  
    342342                         
    343343                        if(interval - ping_interval > 60.0) { 
    344                                 wr_send_command(WI_STR("PING")); 
     344                                wi_p7_message_t         *message; 
     345                                 
     346                                message = wi_p7_message_with_name(WI_STR("wired.ping"), wr_p7_socket); 
     347                                 
     348                                if(!wi_p7_socket_write_message(wr_p7_socket, 10.0, message)) 
     349                                        wr_printf_prefix(WI_STR("write: %m")); 
    345350                                 
    346351                                ping_interval = interval;