(1) add clutch to the tarball.

(2) on autoconf-based installs, install the clutch files in $(datadir)/transmission/web
(3) new function tr_getClutchDir().  Default implementation follows the XDG spec.
This commit is contained in:
Charles Kerr 2008-07-11 04:07:14 +00:00
parent 2a1f6c8923
commit b37a2cfa23
5 changed files with 156 additions and 38 deletions

View File

@ -31,6 +31,7 @@ SUBDIRS = \
$(WX_DIR)
EXTRA_DIST = \
web \
NEWS \
AUTHORS \
COPYING \
@ -38,10 +39,66 @@ EXTRA_DIST = \
Transmission.xcodeproj/project.pbxproj \
intltool-extract.in \
intltool-merge.in \
intltool-update.in
intltool-update.in
clutchdir = $(datadir)/transmission/web
clutch_DATA = \
web/index.html \
web/LICENSE
clutch_cssdir = $(clutchdir)/stylesheets
clutch_css_DATA = \
web/stylesheets/iphone.css \
web/stylesheets/common.css
clutch_jsdir = $(clutchdir)/javascript
clutch_js_DATA = \
web/javascript/menu.js \
web/javascript/dialog.js \
web/javascript/transmission.js \
web/javascript/transmission.remote.js \
web/javascript/common.js \
web/javascript/torrent.js
clutch_jquerydir = $(clutch_jsdir)/jquery
clutch_jquery_DATA = \
web/javascript/jquery \
web/javascript/jquery/json.min.js \
web/javascript/jquery/jquery.contextmenu.min.js \
web/javascript/jquery/jquery.min.js \
web/javascript/jquery/jquery.form.min.js \
web/javascript/jquery/jquery.transmenu.min.js \
web/javascript/jquery/jquery-dimensions.min.js
clutch_imagesdir = $(clutchdir)/images
clutch_images_DATA = \
web/images/favicon.ico \
web/images/webclip-icon.png
clutch_graphicsdir = $(clutch_imagesdir)/graphics
clutch_graphics_DATA = \
web/images/graphics/browser_firefox.gif \
web/images/graphics/logo.png \
web/images/graphics/chrome.png \
web/images/graphics/iphone_chrome.png \
web/images/graphics/browser_opera.gif \
web/images/graphics/filter_bar.png \
web/images/graphics/transfer_arrows.png \
web/images/graphics/browser_safari.gif
clutch_progressdir = $(clutch_imagesdir)/progress
clutch_progress_DATA = \
web/images/progress/progress.png
clutch_buttonsdir = $(clutch_imagesdir)/buttons
clutch_buttons_DATA = \
web/images/buttons/tab_backgrounds.png \
web/images/buttons/toolbar_buttons.png \
web/images/buttons/info_general.png \
web/images/buttons/torrent_buttons.png \
web/images/buttons/info_activity.png
DISTCLEANFILES = \
intltool-extract \
intltool-merge \
intltool-update

View File

@ -50,6 +50,7 @@
#include <unistd.h> /* getuid getpid close */
#include "transmission.h"
#include "list.h"
#include "platform.h"
#include "utils.h"
@ -504,6 +505,95 @@ tr_getDefaultConfigDir( void )
return s;
}
/***
****
***/
static int
isClutchDir( const char * path )
{
struct stat sb;
char tmp[MAX_PATH_LENGTH];
tr_buildPath( tmp, sizeof( tmp ), path, "javascript", "transmission.js", NULL );
fprintf( stderr, "path is [%s]; testing [%s] for clutch\n", path, tmp );
return !stat( tmp, &sb );
}
const char *
tr_getClutchDir( const tr_session * session UNUSED )
{
static char * s = NULL;
if( !s )
{
char path[MAX_PATH_LENGTH];
if(( s = getenv( "CLUTCH_HOME" )))
{
snprintf( path, sizeof( path ), s );
}
else
{
#ifdef SYS_DARWIN
#error not implemented
#elif defined(WIN32)
#warning hey win32 people is this good or is there a better implementation of the next four lines
char appdata[MAX_PATH_LENGTH];
SHGetFolderPath( NULL, CSIDL_APPDATA, NULL, 0, appdata );
tr_buildPath( path, sizeof( path ),
appdata, "Transmission", NULL );
#else
tr_list *candidates=NULL, *l;
/* XDG_DATA_HOME should be the first in the list of candidates */
s = getenv( "XDG_DATA_HOME" );
if( s && *s )
tr_list_append( &candidates, tr_strdup( s ) );
else {
char tmp[MAX_PATH_LENGTH];
tr_buildPath( tmp, sizeof( tmp ), getHomeDir(), ".local", "share", NULL );
tr_list_append( &candidates, tr_strdup( tmp ) );
}
/* XDG_DATA_DIRS are the backup directories */
s = getenv( "XDG_DATA_DIRS" );
if( !s || !*s )
s = "/usr/local/share/:/usr/share/";
while( s && *s ) {
char * end = strchr( s, ':' );
if( end ) {
tr_list_append( &candidates, tr_strndup( s, end-s ) );
s = end + 1;
} else {
tr_list_append( &candidates, tr_strdup( s ) );
break;
}
}
for( l=candidates; l; l=l->next ) {
tr_buildPath( path, sizeof( path ), l->data, "transmission", "clutch", NULL );
if( isClutchDir( path ) )
break;
*path = '\0';
}
tr_list_free( &candidates, tr_free );
#endif
}
if( !*path )
{
tr_err( _( "Unable to find web interface files" ) );
tr_strlcpy( path, "/dev/null", sizeof( path ) );
}
s = tr_strdup( path );
}
return s;
}
/***
****
***/

View File

@ -44,6 +44,9 @@ const char * tr_getResumeDir ( const struct tr_handle * );
const char * tr_getTorrentDir ( const struct tr_handle * );
const char * tr_getClutchDir ( const struct tr_handle * );
tr_thread* tr_threadNew ( void (*func)(void *), void * arg, const char * name );
int tr_amInThread ( const tr_thread * );

View File

@ -24,6 +24,7 @@
#include "transmission.h"
#include "bencode.h"
#include "platform.h"
#include "rpc.h"
#include "rpc-server.h"
#include "utils.h"
@ -251,13 +252,11 @@ startServer( tr_rpc_server * server )
{
char ports[128];
char passwd[MAX_PATH_LENGTH];
char clutchDir[MAX_PATH_LENGTH];
char * clutchAlias;
const char * clutchDir = tr_getClutchDir( server->session );
char * clutchAlias = tr_strdup_printf( "%s=%s", "/transmission/clutch", clutchDir );
struct timeval tv = tr_timevalMsec( UNUSED_INTERVAL_MSEC );
tr_buildPath( clutchDir, sizeof( clutchDir ), tr_sessionGetConfigDir( server->session ), "clutch", NULL );
clutchAlias = tr_strdup_printf( "%s=%s", "/transmission/clutch", clutchDir );
fprintf( stderr, "clutchAlias is [%s]\n", clutchAlias );
getPasswordFile( server, passwd, sizeof( passwd ) );
if( !server->isPasswordEnabled )
unlink( passwd );

View File

@ -1,31 +0,0 @@
Welcome to the Clutch WebUI for Transmission!
http://clutchbt.com
Clutch Version 0.4
*** CLUTCH REQUIRES PHP 5.2+ WITH SOCKETS AND JSON ENABLED ***
Instructions For Usage:
1. In order to get started, you must also have transmission-daemon.
We suggest you build from the version 1.00 source, as it is the
most stable and complete daemon version available at the time of
this writing.
2. Your httpd / php needs read-write access to the /remote/data
folder, as this is where it will store your preferences. It also
needs read-write to the transmission socket and the folder it is in.
3. Edit the socket.txt file in the above folder to point to your
transmission-daemon socket file. On Linux, this will most likely
be ~/.transmission/daemon/socket , however, you must use ABSOLUTE
paths. Using ~ will not work. Substitute in your home folder.
4. After this, as long as transmission-daemon is running, you should
be able to access the WebUI in the browser of your choice, as long
as it is not Internet Explorer.
Please see #transmission on irc.freenode.net for support, or the
forums at http://forum.transmissionbt.com/
Thank you from the developers for using Transmission and Clutch.