diff options
-rw-r--r-- | doc/C-API.txt | 16 | ||||
-rw-r--r-- | doc/C-HOWTO.txt | 24 | ||||
-rw-r--r-- | generic/main.c | 14 | ||||
-rw-r--r-- | lib/comm.c | 25 | ||||
-rw-r--r-- | lib/comm.h | 3 | ||||
-rw-r--r-- | tests/Makefile.am | 6 | ||||
-rw-r--r-- | tests/test_fallback.c | 37 |
7 files changed, 8 insertions, 117 deletions
diff --git a/doc/C-API.txt b/doc/C-API.txt index cb16ff7..edf0d56 100644 --- a/doc/C-API.txt +++ b/doc/C-API.txt @@ -121,22 +121,6 @@ Convenience function that calls dapi_connect() and if successful also performs initialization by calling dapi_Init() (see later). -DapiConnection* dapi_namedConnect( const char* name ) ------------------------------------------------------ - -Tries to connect to a named fallback daemon. - -name: name of the fallback daemon -Returns: NULL if failed, opaque connection handle if success. - - -DapiConnection* dapi_namedConnectAndInit( const char* name ) ------------------------------------------------------------- - -Convenience function that calls dapi_namedConnect() and if successful -also performs initialization by calling dapi_Init() (see later). - - void dapi_close( DapiConnection* conn ) --------------------------------------- diff --git a/doc/C-HOWTO.txt b/doc/C-HOWTO.txt index 3425377..bb0fe97 100644 --- a/doc/C-HOWTO.txt +++ b/doc/C-HOWTO.txt @@ -137,29 +137,7 @@ the required functionality. No backend daemon running ------------------------- -A backend daemon should be provided by the desktop environment in which the application is running. -If dapi_connectAndInit() call fails, it is most probably because the daemon is not available. -In such case the application may consider shipping its own fallback daemon. - - -int initializeDapi() - { - my_dapi_connection = dapi_connectAndInit(); - if( my_dapi_connection == NULL ) - { /* failure, try a fallback */ - run_fallback_daemon(); - my_dapi_connection = dapi_namedConnectAndInit( "MyAppFooInc" ); - if( my_dapi_connection == NULL ) - return 0; /* still no luck */ - } - return 1; - } - -This approach allows silently expecting all following calls to succeed and not caring about fallback -code at all. (NOTE: still experimental, not sure if it's worth it) - -The provided generic daemon accepts --dapiname argument that specifies the fallback name it should -use. In this specific case run_fallback_daemon() could run "dapi_generic --dapiname MyAppFooInc". +TODO: fallback daemons don't make sense, the library should try to implement fallbacks Some functionality not available diff --git a/generic/main.c b/generic/main.c index 0b38beb..0fb8a96 100644 --- a/generic/main.c +++ b/generic/main.c @@ -315,29 +315,17 @@ static void processCommand( DapiConnection* conn ) } } -static char bind_name[ 256 ] = ""; - -static void processArgs( int argc, char* argv[] ) - { - if( argc == 3 && strcmp( argv[ 1 ], "--dapiname" ) == 0 ) - { - strncpy( bind_name, argv[ 2 ], 255 ); - bind_name[ 255 ] = '\0'; - } - } - int main( int argc, char* argv[] ) { int i; int mainsock; - processArgs( argc, argv ); dpy = XOpenDisplay( NULL ); if( dpy == NULL ) { fprintf( stderr, "Cannot open X connection!\n" ); return 1; } - mainsock = dapi_namedBindSocket( bind_name ); + mainsock = dapi_bindSocket(); if( mainsock < 0 ) return 2; for(;;) @@ -33,27 +33,22 @@ static void getDisplay( char* ret, int max ) *pos = '\0'; } -static void socketName( char* sock_file, const char* name, int max ) +static void socketName( char* sock_file, int max ) { const char* home; char display[ 256 ]; home = getenv( "HOME" ); getDisplay( display, 255 ); - snprintf( sock_file, max - 1, "%s/.dapi-%s%s%s", home, display, name != NULL ? "-" : "", name ); + snprintf( sock_file, max - 1, "%s/.dapi-%s", home, display ); } DapiConnection* dapi_connect() { - return dapi_namedConnect( "" ); - } - -DapiConnection* dapi_namedConnect( const char* name ) - { char sock_file[ 256 ]; int sock; struct sockaddr_un addr; DapiConnection* ret; - socketName( sock_file, name, 255 ); + socketName( sock_file, 255 ); sock = socket( PF_UNIX, SOCK_STREAM, 0 ); if( sock < 0 ) { @@ -82,15 +77,10 @@ DapiConnection* dapi_namedConnect( const char* name ) int dapi_bindSocket() { - return dapi_namedBindSocket( "" ); - } - -int dapi_namedBindSocket( const char* name ) - { char sock_file[ 256 ]; int sock; struct sockaddr_un addr; - socketName( sock_file, name, 255 ); + socketName( sock_file, 255 ); sock = socket( PF_UNIX, SOCK_STREAM, 0 ); if( sock < 0 ) { @@ -364,12 +354,7 @@ void dapi_windowInfoInitWindow( DapiWindowInfo* winfo, long window ) DapiConnection* dapi_connectAndInit() { - return dapi_namedConnectAndInit( "" ); - } - -DapiConnection* dapi_namedConnectAndInit( const char* name ) - { - DapiConnection* conn = dapi_namedConnect( name ); + DapiConnection* conn = dapi_connect(); if( conn == NULL ) return NULL; if( !dapi_Init( conn )) @@ -8,15 +8,12 @@ extern "C" { typedef struct DapiConnection DapiConnection; DapiConnection* dapi_connect( void ); -DapiConnection* dapi_namedConnect( const char* name ); void dapi_close( DapiConnection* conn ); int dapi_socket( DapiConnection* conn ); DapiConnection* dapi_connectAndInit( void ); -DapiConnection* dapi_namedConnectAndInit( const char* name ); int dapi_bindSocket( void ); -int dapi_namedBindSocket( const char* name ); DapiConnection* dapi_acceptSocket( int sock ); typedef struct DapiWindowInfo diff --git a/tests/Makefile.am b/tests/Makefile.am index 391062a..f894e18 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,5 +1,5 @@ noinst_PROGRAMS = test_comm test_calls test_runasuser test_screensaving test_mailto test_remotefile test_async \ - test_capabilities test_callbacks test_fallback test_addressbook + test_capabilities test_callbacks test_addressbook test_comm_SOURCES = test_comm.c test_comm_LDADD = ../lib/libdapi.la @@ -37,10 +37,6 @@ test_callbacks_SOURCES = test_callbacks.c test_callbacks_LDADD = ../lib/libdapi.la test_callbacks_LDFLAGS = $(all_libraries) -test_fallback_SOURCES = test_fallback.c -test_fallback_LDADD = ../lib/libdapi.la -test_fallback_LDFLAGS = $(all_libraries) - test_addressbook_SOURCES = test_addressbook.c test_addressbook_LDADD = ../lib/libdapi.la test_addressbook_LDFLAGS = $(all_libraries) diff --git a/tests/test_fallback.c b/tests/test_fallback.c deleted file mode 100644 index e4ef3c1..0000000 --- a/tests/test_fallback.c +++ /dev/null @@ -1,37 +0,0 @@ -#include <stdio.h> - -#include <dapi/comm.h> -#include <dapi/calls.h> - -static void test( DapiConnection* conn, const char* txt ) - { - int ord = dapi_ButtonOrder( conn ); - printf( "Order(%s): %d (%s)\n", txt, ord, ord == 0 ? "Failed" : ord == 1 ? "Ok/Cancel" : "Cancel/Ok" ); - dapi_close( conn ); - } - -/* run daemon with --dapiname fallback to test fallbacks */ -int main() - { - DapiConnection* conn = dapi_connectAndInit(); - if( conn != NULL ) - { - printf( "Connected to generic.\n" ); - test( conn, "1" ); - } - else - { - printf( "Connection to generic failed.\n" ); - } - conn = dapi_namedConnectAndInit( "fallback" ); - if( conn != NULL ) - { - printf( "Connected to fallback.\n" ); - test( conn, "2" ); - } - else - { - printf( "Connection to fallback failed.\n" ); - } - return 0; - } |