readability improvments #1, #2, #3, #4. (muks)

This commit is contained in:
Charles Kerr 2008-08-12 13:51:11 +00:00
parent 74be26b29e
commit c75c512ff1
8 changed files with 81 additions and 84 deletions

View File

@ -521,7 +521,7 @@ parseCommandLine( int argc, const char ** argv )
case 'v': verify = 1; break;
case 'w': downloadDir = optarg; break;
case 910: encryptionMode = TR_ENCRYPTION_REQUIRED; break;
case 911: encryptionMode = TR_PLAINTEXT_PREFERRED; break;
case 911: encryptionMode = TR_CLEAR_PREFERRED; break;
case 912: encryptionMode = TR_ENCRYPTION_PREFERRED; break;
case TR_OPT_UNK: torrentPath = optarg; break;
default: return 1;

View File

@ -315,7 +315,7 @@ getCryptoProvide( const tr_handshake * handshake )
provide |= CRYPTO_PROVIDE_CRYPTO;
break;
case TR_PLAINTEXT_PREFERRED:
case TR_CLEAR_PREFERRED:
provide |= CRYPTO_PROVIDE_CRYPTO | CRYPTO_PROVIDE_PLAINTEXT;
break;
}
@ -340,7 +340,7 @@ getCryptoSelect( const tr_handshake * handshake, uint32_t crypto_provide )
choices[nChoices++] = CRYPTO_PROVIDE_PLAINTEXT;
break;
case TR_PLAINTEXT_PREFERRED:
case TR_CLEAR_PREFERRED:
choices[nChoices++] = CRYPTO_PROVIDE_PLAINTEXT;
choices[nChoices++] = CRYPTO_PROVIDE_CRYPTO;
break;
@ -1040,7 +1040,7 @@ tr_handshakeNew( tr_peerIo * io,
if( tr_peerIoIsIncoming( handshake->io ) )
setReadState( handshake, AWAITING_HANDSHAKE );
else if( encryptionMode != TR_PLAINTEXT_PREFERRED )
else if( encryptionMode != TR_CLEAR_PREFERRED )
sendYa( handshake );
else {
int msgSize;

View File

@ -942,7 +942,7 @@ sendLtepHandshake( tr_peermsgs * msgs )
pex = 1;
tr_bencInitDict( &val, 4 );
tr_bencDictAddInt( &val, "e", msgs->handle->encryptionMode != TR_PLAINTEXT_PREFERRED );
tr_bencDictAddInt( &val, "e", msgs->handle->encryptionMode != TR_CLEAR_PREFERRED );
tr_bencDictAddInt( &val, "p", tr_sessionGetPeerPort( msgs->handle ) );
tr_bencDictAddStr( &val, "v", TR_NAME " " USERAGENT_PREFIX );
m = tr_bencDictAddDict( &val, "m", 1 );

View File

@ -568,7 +568,7 @@ sessionSet( tr_handle * h, tr_benc * args_in, tr_benc * args_out UNUSED )
if( !strcmp( str, "required" ) )
tr_sessionSetEncryption( h, TR_ENCRYPTION_REQUIRED );
else if( !strcmp( str, "tolerated" ) )
tr_sessionSetEncryption( h, TR_PLAINTEXT_PREFERRED );
tr_sessionSetEncryption( h, TR_CLEAR_PREFERRED );
else
tr_sessionSetEncryption( h, TR_ENCRYPTION_PREFERRED );
}
@ -627,7 +627,7 @@ sessionGet( tr_handle * h, tr_benc * args_in UNUSED, tr_benc * args_out )
tr_bencDictAddInt( d, "speed-limit-down-enabled",
tr_sessionIsSpeedLimitEnabled( h, TR_DOWN ) );
switch( tr_sessionGetEncryption( h ) ) {
case TR_PLAINTEXT_PREFERRED: str = "tolerated"; break;
case TR_CLEAR_PREFERRED: str = "tolerated"; break;
case TR_ENCRYPTION_REQUIRED: str = "required"; break;
default: str = "preferred"; break;
}

View File

@ -94,7 +94,7 @@ tr_sessionSetEncryption( tr_session * session, tr_encryption_mode mode )
assert( session );
assert( mode==TR_ENCRYPTION_PREFERRED
|| mode==TR_ENCRYPTION_REQUIRED
|| mode==TR_PLAINTEXT_PREFERRED );
|| mode==TR_CLEAR_PREFERRED );
session->encryptionMode = mode;
}
@ -171,35 +171,35 @@ loadBlocklists( tr_session * session )
static void metainfoLookupRescan( tr_handle * h );
tr_handle *
tr_sessionInitFull( const char * configDir,
const char * tag,
const char * downloadDir,
int isPexEnabled,
int isPortForwardingEnabled,
int publicPort,
int encryptionMode,
int isUploadLimitEnabled,
int uploadLimit,
int isDownloadLimitEnabled,
int downloadLimit,
int globalPeerLimit,
int messageLevel,
int isMessageQueueingEnabled,
int isBlocklistEnabled,
int peerSocketTOS,
int rpcIsEnabled,
int rpcPort,
const char * rpcACL,
int rpcAuthIsEnabled,
const char * rpcUsername,
const char * rpcPassword,
int proxyIsEnabled,
const char * proxy,
int proxyPort,
tr_proxy_type proxyType,
int proxyAuthIsEnabled,
const char * proxyUsername,
const char * proxyPassword )
tr_sessionInitFull( const char * configDir,
const char * tag,
const char * downloadDir,
int isPexEnabled,
int isPortForwardingEnabled,
int publicPort,
tr_encryption_mode encryptionMode,
int isUploadLimitEnabled,
int uploadLimit,
int isDownloadLimitEnabled,
int downloadLimit,
int globalPeerLimit,
int messageLevel,
int isMessageQueueingEnabled,
int isBlocklistEnabled,
int peerSocketTOS,
int rpcIsEnabled,
int rpcPort,
const char * rpcACL,
int rpcAuthIsEnabled,
const char * rpcUsername,
const char * rpcPassword,
int proxyIsEnabled,
const char * proxy,
int proxyPort,
tr_proxy_type proxyType,
int proxyAuthIsEnabled,
const char * proxyUsername,
const char * proxyPassword )
{
tr_handle * h;
char filename[MAX_PATH_LENGTH];
@ -209,9 +209,6 @@ tr_sessionInitFull( const char * configDir,
signal( SIGPIPE, SIG_IGN );
#endif
if( configDir == NULL )
configDir = tr_getDefaultConfigDir( );
tr_msgInit( );
tr_setMessageLevel( messageLevel );
tr_setMessageQueuing( isMessageQueueingEnabled );
@ -230,6 +227,8 @@ tr_sessionInitFull( const char * configDir,
h->proxyUsername = tr_strdup( proxyUsername );
h->proxyPassword = tr_strdup( proxyPassword );
if( configDir == NULL )
configDir = tr_getDefaultConfigDir( );
tr_setConfigDir( h, configDir );
tr_netInit(); /* must go before tr_eventInit */

View File

@ -143,6 +143,13 @@ tr_proxy_type;
/** @see tr_sessionInitFull */
#define TR_DEFAULT_PROXY_PASSWORD NULL
typedef enum
{
TR_CLEAR_PREFERRED,
TR_ENCRYPTION_PREFERRED,
TR_ENCRYPTION_REQUIRED
}
tr_encryption_mode;
/**
* @brief Start a libtransmission session.
@ -183,7 +190,7 @@ tr_proxy_type;
* #TR_DEFAULT_PORT is the default.
*
* @param encryptionMode
* Must be one of #TR_PLAINTEXT_PREFERRED,
* Must be one of #TR_CLEAR_PREFERRED,
* #TR_ENCRYPTION_PREFERRED, or #TR_ENCRYPTION_REQUIRED.
*
* @param isUploadLimitEnabled
@ -192,7 +199,7 @@ tr_proxy_type;
*
* @param uploadLimit
* The speed limit to use for the entire session when
* "isUploadLimitEnabled" is true.
* "isUploadLimitEnabled" is true. Units are KiB/s.
*
* @param isDownloadLimitEnabled
* If true, libtransmission will limit the entire
@ -200,7 +207,7 @@ tr_proxy_type;
*
* @param downloadLimit
* The speed limit to use for the entire session when
* "isDownloadLimitEnabled" is true.
* "isDownloadLimitEnabled" is true. Units are KiB/s.
*
* @param peerLimit
* The maximum number of peer connections allowed in a session.
@ -239,35 +246,35 @@ tr_proxy_type;
* @see TR_DEFAULT_RPC_ACL
* @see tr_sessionClose()
*/
tr_handle * tr_sessionInitFull( const char * configDir,
const char * tag,
const char * downloadDir,
int isPexEnabled,
int isPortForwardingEnabled,
int publicPort,
int encryptionMode,
int isUploadLimitEnabled,
int uploadLimit,
int isDownloadLimitEnabled,
int downloadLimit,
int peerLimit,
int messageLevel,
int isMessageQueueingEnabled,
int isBlocklistEnabled,
int peerSocketTOS,
int rpcIsEnabled,
int rpcPort,
const char * rpcAccessControlList,
int rpcPasswordIsEnabled,
const char * rpcUsername,
const char * rpcPassword,
int proxyIsEnabled,
const char * proxy,
int proxyPort,
tr_proxy_type proxyType,
int proxyAuthIsEnabled,
const char * proxyUsername,
const char * proxyPassword );
tr_handle * tr_sessionInitFull( const char * configDir,
const char * tag,
const char * downloadDir,
int isPexEnabled,
int isPortForwardingEnabled,
int publicPort,
tr_encryption_mode encryptionMode,
int isUploadLimitEnabled,
int uploadLimit,
int isDownloadLimitEnabled,
int downloadLimit,
int peerLimit,
int messageLevel,
int isMessageQueueingEnabled,
int isBlocklistEnabled,
int peerSocketTOS,
int rpcIsEnabled,
int rpcPort,
const char * rpcAccessControlList,
int rpcPasswordIsEnabled,
const char * rpcUsername,
const char * rpcPassword,
int proxyIsEnabled,
const char * proxy,
int proxyPort,
tr_proxy_type proxyType,
int proxyAuthIsEnabled,
const char * proxyUsername,
const char * proxyPassword );
/** @brief Shorter form of tr_sessionInitFull()
@ -476,14 +483,6 @@ void tr_sessionSetPexEnabled( tr_session *, int isEnabled );
int tr_sessionIsPexEnabled( const tr_session * );
typedef enum
{
TR_PLAINTEXT_PREFERRED,
TR_ENCRYPTION_PREFERRED,
TR_ENCRYPTION_REQUIRED
}
tr_encryption_mode;
tr_encryption_mode tr_sessionGetEncryption( tr_session * );
void tr_sessionSetEncryption( tr_session *, tr_encryption_mode mode );

View File

@ -444,7 +444,7 @@
- (void) setEncryptionMode: (id) sender
{
tr_sessionSetEncryption(fHandle, [fDefaults boolForKey: @"EncryptionPrefer"] ?
([fDefaults boolForKey: @"EncryptionRequire"] ? TR_ENCRYPTION_REQUIRED : TR_ENCRYPTION_PREFERRED) : TR_PLAINTEXT_PREFERRED);
([fDefaults boolForKey: @"EncryptionRequire"] ? TR_ENCRYPTION_REQUIRED : TR_ENCRYPTION_PREFERRED) : TR_CLEAR_PREFERRED);
}
- (void) setBlocklistEnabled: (id) sender
@ -1008,7 +1008,7 @@
{
//encryption
tr_encryption_mode encryptionMode = tr_sessionGetEncryption(fHandle);
[fDefaults setBool: encryptionMode != TR_PLAINTEXT_PREFERRED forKey: @"EncryptionPrefer"];
[fDefaults setBool: encryptionMode != TR_CLEAR_PREFERRED forKey: @"EncryptionPrefer"];
[fDefaults setBool: encryptionMode == TR_ENCRYPTION_REQUIRED forKey: @"EncryptionRequire"];
//download directory

View File

@ -758,7 +758,6 @@ iframe#torrent_upload_frame {
}
div#prefs_container label {
line-height: 25px;
vertical-align: middle;
display: block;
}
@ -1025,4 +1024,4 @@ div#jqContextMenu ul {
opacity: .98;
-webkit-box-shadow: 0 10px 25px rgba(0,0,0,0.4);
-webkit-border-radius: 5px;
}
}