(trunk libT) #2911 "requirement of javascript/transmission.js for webinterface unnecessary" -- implemented in trunk for 2.00
This commit is contained in:
parent
fb03c00d1a
commit
1357a75d40
|
@ -516,10 +516,10 @@ tr_getDefaultDownloadDir( void )
|
|||
***/
|
||||
|
||||
static int
|
||||
isClutchDir( const char * path )
|
||||
isWebClientDir( const char * path )
|
||||
{
|
||||
struct stat sb;
|
||||
char * tmp = tr_buildPath( path, "javascript", "transmission.js", NULL );
|
||||
char * tmp = tr_buildPath( path, "index.html", NULL );
|
||||
const int ret = !stat( tmp, &sb );
|
||||
tr_inf( _( "Searching for web interface file \"%s\"" ), tmp );
|
||||
tr_free( tmp );
|
||||
|
@ -527,7 +527,7 @@ isClutchDir( const char * path )
|
|||
}
|
||||
|
||||
const char *
|
||||
tr_getClutchDir( const tr_session * session UNUSED )
|
||||
tr_getWebClientDir( const tr_session * session UNUSED )
|
||||
{
|
||||
static char * s = NULL;
|
||||
|
||||
|
@ -556,12 +556,12 @@ tr_getClutchDir( const tr_session * session UNUSED )
|
|||
|
||||
s = tr_buildPath( appString, "Contents", "Resources", "web", NULL );
|
||||
|
||||
if( !isClutchDir( s ) ) {
|
||||
if( !isWebClientDir( s ) ) {
|
||||
tr_free( s );
|
||||
|
||||
/* Fallback to the Application Support folder */
|
||||
s = tr_buildPath( tr_sessionGetConfigDir( session ), "web", NULL );
|
||||
if( !isClutchDir( s ) ) {
|
||||
if( !isWebClientDir( s ) ) {
|
||||
tr_free( s );
|
||||
s = NULL;
|
||||
}
|
||||
|
@ -579,7 +579,7 @@ tr_getClutchDir( const tr_session * session UNUSED )
|
|||
/* First, we should check personal AppData/Transmission/Web */
|
||||
SHGetFolderPath( NULL, CSIDL_COMMON_APPDATA, NULL, 0, dir );
|
||||
s = tr_buildPath( dir, "Transmission", "Web", NULL );
|
||||
if( !isClutchDir( s ) ) {
|
||||
if( !isWebClientDir( s ) ) {
|
||||
tr_free( s );
|
||||
s = NULL;
|
||||
}
|
||||
|
@ -589,7 +589,7 @@ tr_getClutchDir( const tr_session * session UNUSED )
|
|||
/* check personal AppData */
|
||||
SHGetFolderPath( NULL, CSIDL_APPDATA, NULL, 0, dir );
|
||||
s = tr_buildPath( dir, "Transmission", "Web", NULL );
|
||||
if( !isClutchDir( s ) ) {
|
||||
if( !isWebClientDir( s ) ) {
|
||||
tr_free( s );
|
||||
s = NULL;
|
||||
}
|
||||
|
@ -599,7 +599,7 @@ tr_getClutchDir( const tr_session * session UNUSED )
|
|||
/* check calling module place */
|
||||
GetModuleFileName( GetModuleHandle( NULL ), dir, sizeof( dir ) );
|
||||
s = tr_buildPath( dirname( dir ), "Web", NULL );
|
||||
if( !isClutchDir( s ) ) {
|
||||
if( !isWebClientDir( s ) ) {
|
||||
tr_free( s );
|
||||
s = NULL;
|
||||
}
|
||||
|
@ -643,7 +643,7 @@ tr_getClutchDir( const tr_session * session UNUSED )
|
|||
/* walk through the candidates & look for a match */
|
||||
for( l=candidates; l; l=l->next ) {
|
||||
char * path = tr_buildPath( l->data, "transmission", "web", NULL );
|
||||
const int found = isClutchDir( path );
|
||||
const int found = isWebClientDir( path );
|
||||
if( found ) {
|
||||
s = path;
|
||||
break;
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
* @brief invoked by tr_sessionInit() to set up the locations of the resume, torrent, and clutch directories.
|
||||
* @see tr_getResumeDir()
|
||||
* @see tr_getTorrentDir()
|
||||
* @see tr_getClutchDir()
|
||||
* @see tr_getWebClientDir()
|
||||
*/
|
||||
void tr_setConfigDir( tr_session * session, const char * configDir );
|
||||
|
||||
|
@ -51,8 +51,8 @@ const char * tr_getResumeDir( const tr_session * );
|
|||
/** @brief return the directory where .torrent files are stored */
|
||||
const char * tr_getTorrentDir( const tr_session * );
|
||||
|
||||
/** @brief return the directory where Clutch's web ui files are kept */
|
||||
const char * tr_getClutchDir( const tr_session * );
|
||||
/** @brief return the directory where the Web Client's web ui files are kept */
|
||||
const char * tr_getWebClientDir( const tr_session * );
|
||||
|
||||
/** @} */
|
||||
|
||||
|
|
|
@ -286,7 +286,7 @@ mimetype_guess( const char * path )
|
|||
const char * suffix;
|
||||
const char * mime_type;
|
||||
} types[] = {
|
||||
/* these are just the ones we need for serving clutch... */
|
||||
/* these are the ones we need for serving the web client's files... */
|
||||
{ "css", "text/css" },
|
||||
{ "gif", "image/gif" },
|
||||
{ "html", "text/html" },
|
||||
|
@ -439,14 +439,14 @@ serve_file( struct evhttp_request * req,
|
|||
}
|
||||
|
||||
static void
|
||||
handle_clutch( struct evhttp_request * req,
|
||||
struct tr_rpc_server * server )
|
||||
handle_web_client( struct evhttp_request * req,
|
||||
struct tr_rpc_server * server )
|
||||
{
|
||||
const char * clutchDir = tr_getClutchDir( server->session );
|
||||
const char * webClientDir = tr_getWebClientDir( server->session );
|
||||
|
||||
assert( !strncmp( req->uri, "/transmission/web/", 18 ) );
|
||||
|
||||
if( !clutchDir || !*clutchDir )
|
||||
if( !webClientDir || !*webClientDir )
|
||||
{
|
||||
send_simple_response( req, HTTP_NOTFOUND,
|
||||
"<p>Couldn't find Transmission's web interface files!</p>"
|
||||
|
@ -474,7 +474,7 @@ handle_clutch( struct evhttp_request * req,
|
|||
else
|
||||
{
|
||||
char * filename = tr_strdup_printf( "%s%s%s",
|
||||
clutchDir,
|
||||
webClientDir,
|
||||
TR_PATH_DELIMITER_STR,
|
||||
subpath && *subpath ? subpath : "index.html" );
|
||||
serve_file( req, server, filename );
|
||||
|
@ -618,7 +618,7 @@ handle_request( struct evhttp_request * req, void * arg )
|
|||
}
|
||||
else if( !strncmp( req->uri, "/transmission/web/", 18 ) )
|
||||
{
|
||||
handle_clutch( req, server );
|
||||
handle_web_client( req, server );
|
||||
}
|
||||
else if( !strncmp( req->uri, "/transmission/upload", 20 ) )
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue