From 4698b835e8315ee439b3e186d6e23cef21264153 Mon Sep 17 00:00:00 2001 From: ehouse Date: Sun, 4 Jan 2009 00:00:45 +0000 Subject: [PATCH] Fix to compile with relay enabled and not STANDALONE_ONLY. Verified that win32 build can open games saved by previous version, but nothing else (e.g. use of network or even dialogs to set up relay connection parameters.) --- xwords4/wince/Makefile | 12 ++++++++---- xwords4/wince/cecondlg.c | 16 ++++++++-------- xwords4/wince/cecondlg.h | 4 +++- xwords4/wince/ceginfo.c | 11 +++++++---- xwords4/wince/cemain.c | 6 +++--- xwords4/wince/cesockwr.c | 23 +++++++++++++---------- xwords4/wince/cesockwr.h | 5 +++-- xwords4/wince/xwords4.rc | 2 +- 8 files changed, 46 insertions(+), 33 deletions(-) diff --git a/xwords4/wince/Makefile b/xwords4/wince/Makefile index 8c2e6b7fb..9aa51829e 100644 --- a/xwords4/wince/Makefile +++ b/xwords4/wince/Makefile @@ -1,4 +1,6 @@ # -*- compile-command: "make TARGET_OS=wince DEBUG=TRUE"; -*- +# Copyright 2002-2009 by Eric House (xwords@eehouse.org). All rights +# reserved. # This Makefile is meant to allow building Crosswords for PocketPC and # Windows using Linux. As of March 2006, it compiles and runs on @@ -48,7 +50,7 @@ HAVE_COMMCTRL = 1 ifeq ($(TARGET_OS),wince) # BLUETOOTH = -DXWFEATURE_BLUETOOTH -# RELAY = -DXWFEATURE_RELAY -DCOMMS_HEARTBEAT +RELAY = -DXWFEATURE_RELAY CC = ${CE_ARCH}-gcc WINDRES = ${CE_ARCH}-windres STRIP = ${CE_ARCH}-strip @@ -57,7 +59,8 @@ CELIBS = -L/usr/arm-wince-pe/lib else CELIBS = -L${CEOPT_ROOT}/${CE_ARCH}/lib/ -lws2 endif -STANDALONE = -DXWFEATURE_STANDALONE_ONLY +#STANDALONE = -DXWFEATURE_STANDALONE_ONLY +STANDALONE = -DPREV_WAS_STANDALONE_ONLY COLOR_SEL = -DMY_COLOR_SEL CFLAGS += -D_WIN32_WCE=0x0400 -D_WIN32_IE=0x0400 -DUNDER_CE \ $(STANDALONE) $(USE_RAW_MINGW) -DDRAW_LINK_DIRECT \ @@ -74,9 +77,10 @@ CFLAGS += -DCANT_DO_CMDBAR endif else # ifeq ($(TARGET_OS),wince) ifeq ($(TARGET_OS),win32) -STANDALONE = -DXWFEATURE_STANDALONE_ONLY +#STANDALONE = -DXWFEATURE_STANDALONE_ONLY +STANDALONE = -DPREV_WAS_STANDALONE_ONLY #BLUETOOTH = -DXWFEATURE_BLUETOOTH -#RELAY = -DXWFEATURE_RELAY +RELAY = -DXWFEATURE_RELAY CC = i586-mingw32msvc-gcc WINDRES = i586-mingw32msvc-windres STRIP = i586-mingw32msvc-strip diff --git a/xwords4/wince/cecondlg.c b/xwords4/wince/cecondlg.c index 6392f2a24..f6e7f2b9d 100755 --- a/xwords4/wince/cecondlg.c +++ b/xwords4/wince/cecondlg.c @@ -1,6 +1,7 @@ /* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ /* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. + * Copyright 2005-2009 by Eric House (xwords@eehouse.org). All rights + * reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -176,13 +177,12 @@ ConnsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) ceControlsFromAddrRec( hDlg, state ); - ceDlgSetup( &state->dlgState, hDlg, DLG_STATE_NONE ); + ceDlgSetup( &state->dlgHdr, hDlg, DLG_STATE_NONE ); result = TRUE; } else { state = (CeConnDlgState*)GetWindowLongPtr( hDlg, GWL_USERDATA ); if ( !!state ) { - CEAppGlobals* globals = state->dlgHdr.globals; if ( message == WM_COMMAND ) { XP_U16 id = LOWORD(wParam); @@ -207,10 +207,10 @@ ConnsDlg( HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam ) state->userCancelled = id == IDCANCEL; result = TRUE; } - } else if ( message == WM_VSCROLL ) { - if ( !IS_SMARTPHONE(globals) ) { - ceDoDlgScroll( hDlg, wParam ); - } +/* } else if ( message == WM_VSCROLL ) { */ +/* if ( !IS_SMARTPHONE(globals) ) { */ +/* ceDoDlgScroll( hDlg, wParam ); */ +/* } */ } } } @@ -225,7 +225,7 @@ WrapConnsDlg( HWND hDlg, CEAppGlobals* globals, const CommsAddrRec* addrRec, XP_Bool result; XP_MEMSET( state, 0, sizeof( *state ) ); - state->globals = globals; + state->dlgHdr.globals = globals; state->role = role; XP_MEMCPY( &state->addrRec, addrRec, sizeof(state->addrRec) ); diff --git a/xwords4/wince/cecondlg.h b/xwords4/wince/cecondlg.h index 5601b041b..ff9d0ca2b 100755 --- a/xwords4/wince/cecondlg.h +++ b/xwords4/wince/cecondlg.h @@ -1,6 +1,7 @@ /* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ /* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. + * Copyright 2005-2009 by Eric House (xwords@eehouse.org). All rights + * reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -22,6 +23,7 @@ #include "comms.h" #include "cemain.h" +#include "ceutil.h" typedef struct CeConnDlgState { CeDlgHdr dlgHdr; diff --git a/xwords4/wince/ceginfo.c b/xwords4/wince/ceginfo.c index cab818a6f..2461f463a 100755 --- a/xwords4/wince/ceginfo.c +++ b/xwords4/wince/ceginfo.c @@ -1,6 +1,6 @@ /* -*-mode: C; fill-column: 77; c-basic-offset: 4; compile-command: "make TARGET_OS=wince DEBUG=TRUE"; -*- */ /* - * Copyright 2002-2008 by Eric House (xwords@eehouse.org). All rights + * Copyright 2002-2009 by Eric House (xwords@eehouse.org). All rights * reserved. * * This program is free software; you can redistribute it and/or @@ -165,6 +165,9 @@ loadFromGameInfo( GameInfoState* state ) XP_U16 i; CEAppGlobals* globals = state->dlgHdr.globals; CurGameInfo* gi = &globals->gameInfo; +#ifndef XWFEATURE_STANDALONE_ONLY + HWND hDlg = state->dlgHdr.hDlg; +#endif #if defined XWFEATURE_RELAY || defined XWFEATURE_BLUETOOTH wchar_t* roles[] = { L"Standalone", L"Host", L"Guest" }; @@ -334,11 +337,11 @@ static void handleConnOptionsButton( HWND hDlg, CEAppGlobals* globals, DeviceRole role, GameInfoState* state ) { - CeConnDlgState state; + CeConnDlgState dlgState; if ( WrapConnsDlg( hDlg, globals, &state->prefsPrefs.addrRec, - role, &state ) ) { - XP_MEMCPY( &state->prefsPrefs.addrRec, &state.addrRec, + role, &dlgState ) ) { + XP_MEMCPY( &state->prefsPrefs.addrRec, &dlgState.addrRec, sizeof(state->prefsPrefs.addrRec) ); state->addrChanged = XP_TRUE; } diff --git a/xwords4/wince/cemain.c b/xwords4/wince/cemain.c index fec0e330a..400602db9 100755 --- a/xwords4/wince/cemain.c +++ b/xwords4/wince/cemain.c @@ -1,6 +1,7 @@ /* -*- fill-column: 77; compile-command: "make -j TARGET_OS=wince DEBUG=TRUE" -*- */ /* - * Copyright 2002-2008 by Eric House (xwords@eehouse.org). All rights reserved. + * Copyright 2002-2009 by Eric House (xwords@eehouse.org). All rights + * reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -2855,7 +2856,6 @@ ce_send_proc( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addr, if ( !globals->socketWrap ) { globals->socketWrap = ce_sockwrap_new( MPPARM(globals->mpool) - addr->conType, got_data_proc, globals ); } @@ -3158,7 +3158,7 @@ ce_util_setTimer( XW_UtilCtxt* uc, XWTimerReason why, case TIMER_TIMERTICK: howLong = 1000; /* 1 second */ break; -#if defined RELAY_HEARTBEAT || defined COMMS_HEARTBEAT +#if defined XWFEATURE_RELAY || defined COMMS_HEARTBEAT case TIMER_HEARTBEAT: howLong = when * 1000; break; diff --git a/xwords4/wince/cesockwr.c b/xwords4/wince/cesockwr.c index a13fb93ed..01c82c4f9 100755 --- a/xwords4/wince/cesockwr.c +++ b/xwords4/wince/cesockwr.c @@ -1,6 +1,7 @@ /* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ /* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. + * Copyright 2005-2009 by Eric House (xwords@eehouse.org). All rights + * reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -20,6 +21,7 @@ #include "cesockwr.h" #include "cemain.h" +#include "cedebug.h" #include "debhacks.h" #include @@ -90,10 +92,11 @@ queue_packet( CeSocketWrapper* self, XP_U8* packet, XP_U16 len ) self->packets[self->nPackets] = packet; self->lens[self->nPackets] = len; ++self->nPackets; - XP_LOGF( "there are now %d packets on send queue", self->nPackets ); + XP_LOGF( "there are now %d packets on send queue", + self->nPackets ); /* signal the writer thread */ - DH(SetEvent)( self->queueAddEvent ); + SetEvent( self->queueAddEvent ); success = XP_TRUE; } @@ -152,7 +155,7 @@ static XP_Bool sendAll( CeSocketWrapper* self, XP_U8* buf, XP_U16 len ) { for ( ; ; ) { - int nSent = MS(send)( self->socket, buf, len, 0 ); /* flags? */ + int nSent = send( self->socket, (char*)buf, len, 0 ); /* flags? */ if ( nSent == SOCKET_ERROR ) { return XP_FALSE; } else if ( nSent == len ) { @@ -216,8 +219,9 @@ connectSocket( CeSocketWrapper* self ) self->connState = CE_IP_CONNECTED; self->socket = sock; - /* Let the reader thread know there's now a socket to listen on */ - DH(SetEvent)( self->socketConnEvent ); + /* Let the reader thread know there's now a socket to listen + on */ + SetEvent( self->socketConnEvent ); } else { logLastError( "connect" ); @@ -280,7 +284,7 @@ WriterThreadProc( LPVOID lpParameter ) /* Should this happen sooner? What if other thread signals in the meantime? */ - DH(ResetEvent)( self->queueAddEvent ); + ResetEvent( self->queueAddEvent ); } ExitThread(0); /* docs say to exit this way */ @@ -307,7 +311,7 @@ read_bytes_blocking( CeSocketWrapper* self, XP_U8* buf, XP_U16 len ) if ( sres == 0 ) { break; } else if ( sres == 1 && FD_ISSET( self->socket, &readSet ) ) { - int nRead = MS(recv)( self->socket, buf, len, 0 ); + int nRead = MS(recv)( self->socket, (char*)buf, len, 0 ); if ( nRead > 0 ) { XP_LOGF( "read %d bytes", nRead ); XP_ASSERT( nRead <= len ); @@ -361,8 +365,7 @@ ReaderThreadProc( LPVOID lpParameter ) CeSocketWrapper* -ce_sockwrap_new( MPFORMAL CommsConnType conType, DataRecvProc proc, - void* closure ) +ce_sockwrap_new( MPFORMAL DataRecvProc proc, void* closure ) { CeSocketWrapper* self = XP_MALLOC( mpool, sizeof(*self) ); XP_MEMSET( self, 0, sizeof(*self) ); diff --git a/xwords4/wince/cesockwr.h b/xwords4/wince/cesockwr.h index 068599589..75b41cad9 100755 --- a/xwords4/wince/cesockwr.h +++ b/xwords4/wince/cesockwr.h @@ -1,6 +1,7 @@ /* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ /* - * Copyright 2005 by Eric House (xwords@eehouse.org). All rights reserved. + * Copyright 2005-2009 by Eric House (xwords@eehouse.org). All rights + * reserved. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -27,7 +28,7 @@ typedef struct CeSocketWrapper CeSocketWrapper; /* forward */ typedef void (*DataRecvProc)( XP_U8* data, XP_U16 len, void* closure ); -CeSocketWrapper* ce_sockwrap_new( MPFORMAL CommsConnType conType, DataRecvProc proc, void* closure ); +CeSocketWrapper* ce_sockwrap_new( MPFORMAL DataRecvProc proc, void* closure ); void ce_sockwrap_delete( CeSocketWrapper* self ); XP_U16 ce_sockwrap_send( CeSocketWrapper* self, const XP_U8* buf, XP_U16 len, diff --git a/xwords4/wince/xwords4.rc b/xwords4/wince/xwords4.rc index 34c4a0b11..b26b4c211 100755 --- a/xwords4/wince/xwords4.rc +++ b/xwords4/wince/xwords4.rc @@ -922,7 +922,7 @@ BEGIN IDS_CANCEL "Cancel" IDS_OK "Ok" IDS_DONE "Done" - IDS_ABOUT "Crosswords 4.2rc1 (rev " SVN_REV ") "\ + IDS_ABOUT "Crosswords 4.4a1 (rev " SVN_REV ") "\ "for Windows Mobile. Copyright 1998-2008 by "\ "Eric House. This software is released under the GNU "\ "Public License.\r\r"\