Ignore:
Timestamp:
Oct 26, 2007, 3:43:27 AM (15 years ago)
Author:
joshe
Message:

Add IPC messages to set and retrieve the encryption mode.
Implement encryption mode messages in -daemon and -remote.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/daemon/torrents.c

    r3576 r3578  
    9898static int                 gl_downlimit = -1;
    9999static char                gl_dir[MAXPATHLEN];
     100static tr_encryption_mode  gl_crypto    = TR_ENCRYPTION_PREFERRED;
    100101
    101102RB_GENERATE_STATIC( tortree, tor, idlinks, toridcmp )
     
    466467{
    467468    return gl_dir;
     469}
     470
     471void
     472torrent_set_encryption(tr_encryption_mode mode)
     473{
     474    tr_setEncryptionMode(gl_handle, mode);
     475    gl_crypto = mode;
     476    savestate();
     477}
     478
     479tr_encryption_mode
     480torrent_get_encryption(void)
     481{
     482    return tr_getEncryptionMode(gl_handle);
    468483}
    469484
     
    738753    }
    739754
     755    str = tr_bencDictFind( &top, "encryption-mode" );
     756    if( NULL != str && TYPE_STR == str->type )
     757    {
     758        if(!strcasecmp(str->val.s.s, "preferred"))
     759            gl_crypto = TR_ENCRYPTION_PREFERRED;
     760        else if(!strcasecmp(str->val.s.s, "required"))
     761            gl_crypto = TR_ENCRYPTION_REQUIRED;
     762    }
     763
     764    tr_setEncryptionMode(gl_handle, gl_crypto);
     765
    740766    list = tr_bencDictFind( &top, "torrents" );
    741767    if( NULL == list || TYPE_LIST != list->type )
     
    795821
    796822    tr_bencInit( &top, TYPE_DICT );
    797     if( tr_bencDictReserve( &top, 8 ) )
     823    if( tr_bencDictReserve( &top, 9 ) )
    798824    {
    799825      nomem:
     
    810836    tr_bencInitStr( tr_bencDictAdd( &top, "default-directory" ),
    811837                    gl_dir, -1, 1 );
     838    if(TR_ENCRYPTION_REQUIRED == gl_crypto)
     839        tr_bencInitStr(tr_bencDictAdd(&top, "encryption-mode"), "required", -1, 1);
     840    else
     841        tr_bencInitStr(tr_bencDictAdd(&top, "encryption-mode"), "preferred", -1, 1);
    812842    list = tr_bencDictAdd( &top, "torrents" );
    813843    tr_bencInit( list, TYPE_LIST );
Note: See TracChangeset for help on using the changeset viewer.