From 093fc4d1faae01e759a7da13e75b2da8a4b0e63d Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 13 Nov 2012 07:23:07 -0800 Subject: [PATCH] cleanup --- xwords4/linux/cursesmain.c | 29 ++++------------------------- xwords4/linux/gtkmain.c | 28 +++++++--------------------- xwords4/linux/linuxmain.c | 8 ++++++++ xwords4/linux/linuxmain.h | 2 ++ 4 files changed, 21 insertions(+), 46 deletions(-) diff --git a/xwords4/linux/cursesmain.c b/xwords4/linux/cursesmain.c index 945719aa0..1cebe705d 100644 --- a/xwords4/linux/cursesmain.c +++ b/xwords4/linux/cursesmain.c @@ -1490,25 +1490,15 @@ curses_util_remSelected( XW_UtilCtxt* uc ) } #ifndef XWFEATURE_STANDALONE_ONLY -static void -cursesSendOnClose( XWStreamCtxt* stream, void* closure ) -{ - CursesAppGlobals* globals = (CursesAppGlobals*)closure; - - XP_LOGF( "cursesSendOnClose called" ); - (void)comms_send( globals->cGlobals.game.comms, stream ); -} /* cursesSendOnClose */ - static XWStreamCtxt* curses_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo ) { CursesAppGlobals* globals = (CursesAppGlobals*)uc->closure; LaunchParams* params = globals->cGlobals.params; - XWStreamCtxt* stream = mem_stream_make( MPPARM(uc->mpool) - params->vtMgr, - uc->closure, channelNo, - cursesSendOnClose ); + XWStreamCtxt* stream = mem_stream_make( MPPARM(uc->mpool) params->vtMgr, + &globals->cGlobals, channelNo, + sendOnClose ); return stream; } /* curses_util_makeStreamFromAddr */ #endif @@ -1548,17 +1538,6 @@ setupCursesUtilCallbacks( CursesAppGlobals* globals, XW_UtilCtxt* util ) util->closure = globals; } /* setupCursesUtilCallbacks */ -#ifndef XWFEATURE_STANDALONE_ONLY -static void -sendOnClose( XWStreamCtxt* stream, void* closure ) -{ - CursesAppGlobals* globals = closure; - XP_LOGF( "curses sendOnClose called" ); - XP_ASSERT( !!globals->cGlobals.game.comms ); - comms_send( globals->cGlobals.game.comms, stream ); -} /* sendOnClose */ -#endif - static CursesMenuHandler getHandlerForKey( const MenuList* list, char ch ) { @@ -1875,7 +1854,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params ) server_initClientConnection( g_globals.cGlobals.game.server, mem_stream_make( MEMPOOL params->vtMgr, - &g_globals, + &g_globals.cGlobals, (XP_PlayerAddr)0, sendOnClose ) ); } else { diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index 0567410f7..6b7278f50 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -65,9 +65,6 @@ #include "filestream.h" /* static guint gtkSetupClientSocket( GtkAppGlobals* globals, int sock ); */ -#ifndef XWFEATURE_STANDALONE_ONLY -static void sendOnCloseGTK( XWStreamCtxt* stream, void* closure ); -#endif static void setCtrlsForTray( GtkAppGlobals* globals ); static void new_game( GtkWidget* widget, GtkAppGlobals* globals ); static void new_game_impl( GtkAppGlobals* globals, XP_Bool fireConnDlg ); @@ -508,8 +505,8 @@ createOrLoadObjects( GtkAppGlobals* globals ) #ifndef XWFEATURE_STANDALONE_ONLY } else if ( !isServer ) { XWStreamCtxt* stream = - mem_stream_make( MEMPOOL params->vtMgr, globals, CHANNEL_NONE, - sendOnCloseGTK ); + mem_stream_make( MEMPOOL params->vtMgr, &globals->cGlobals, CHANNEL_NONE, + sendOnClose ); server_initClientConnection( globals->cGlobals.game.server, stream ); #endif @@ -814,11 +811,9 @@ new_game_impl( GtkAppGlobals* globals, XP_Bool fireConnDlg ) if ( isClient ) { XWStreamCtxt* stream = - mem_stream_make( MEMPOOL - globals->cGlobals.params->vtMgr, - globals, - CHANNEL_NONE, - sendOnCloseGTK ); + mem_stream_make( MEMPOOL globals->cGlobals.params->vtMgr, + &globals->cGlobals, CHANNEL_NONE, + sendOnClose ); server_initClientConnection( globals->cGlobals.game.server, stream ); } @@ -1747,8 +1742,8 @@ gtk_util_makeStreamFromAddr(XW_UtilCtxt* uc, XP_PlayerAddr channelNo ) XWStreamCtxt* stream = mem_stream_make( MEMPOOL globals->cGlobals.params->vtMgr, - uc->closure, channelNo, - sendOnCloseGTK ); + &globals->cGlobals, channelNo, + sendOnClose ); return stream; } /* gtk_util_makeStreamFromAddr */ @@ -2270,15 +2265,6 @@ gtk_socket_acceptor( int listener, Acceptor func, CommonGlobals* globals, } } /* gtk_socket_acceptor */ -static void -sendOnCloseGTK( XWStreamCtxt* stream, void* closure ) -{ - GtkAppGlobals* globals = closure; - - XP_LOGF( "sendOnClose called" ); - (void)comms_send( globals->cGlobals.game.comms, stream ); -} /* sendOnClose */ - static void drop_msg_toggle( GtkWidget* toggle, GtkAppGlobals* globals ) { diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index 1dd97388d..82b7d5c04 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -196,6 +196,14 @@ catOnClose( XWStreamCtxt* stream, void* XP_UNUSED(closure) ) free( buffer ); } /* catOnClose */ +void +sendOnClose( XWStreamCtxt* stream, void* closure ) +{ + CommonGlobals* cGlobals = (CommonGlobals*)closure; + XP_LOGF( "%s called with msg of len %d", __func__, stream_getSize(stream) ); + (void)comms_send( cGlobals->game.comms, stream ); +} + void catGameHistory( CommonGlobals* cGlobals ) { diff --git a/xwords4/linux/linuxmain.h b/xwords4/linux/linuxmain.h index bae629d47..44cf263e5 100644 --- a/xwords4/linux/linuxmain.h +++ b/xwords4/linux/linuxmain.h @@ -60,6 +60,8 @@ XP_UCHAR* strFromStream( XWStreamCtxt* stream ); void catGameHistory( CommonGlobals* cGlobals ); void catOnClose( XWStreamCtxt* stream, void* closure ); +void sendOnClose( XWStreamCtxt* stream, void* closure ); + void catFinalScores( const CommonGlobals* cGlobals, XP_S16 quitter ); XP_Bool file_exists( const char* fileName ); XWStreamCtxt* streamFromFile( CommonGlobals* cGlobals, char* name,