diff --git a/xwords4/wince/cemain.c b/xwords4/wince/cemain.c index bc492f234..8d1caad25 100755 --- a/xwords4/wince/cemain.c +++ b/xwords4/wince/cemain.c @@ -56,7 +56,7 @@ #include "cesms.h" #include "cesockwr.h" #include "ceresstr.h" -#include "connmgr.h" +#include "ceconnmg.h" #include "dbgutil.h" @@ -1331,7 +1331,7 @@ getOSInfo( CEAppGlobals* globals ) #ifndef XWFEATURE_STANDALONE_ONLY -#ifdef _WIN32_WCE +#if defined _WIN32_WCE && ! defined CEGCC_DOES_CONNMGR # define LOAD_PTR( typ, name ) { \ typ proc; \ proc = (typ)GetProcAddress( hcellDll, TEXT(#name));\ @@ -1537,7 +1537,7 @@ InitInstance(HINSTANCE hInstance, int nCmdShow trapBackspaceKey( hWnd ); -#ifdef _WIN32_WCE +#if defined _WIN32_WCE && ! defined CEGCC_DOES_CONNMGR initConnMgr( globals ); #endif @@ -2145,7 +2145,7 @@ freeGlobals( CEAppGlobals* globals ) } WSACleanup(); -# ifdef _WIN32_WCE +# if defined _WIN32_WCE && ! defined CEGCC_DOES_CONNMGR if ( !!globals->hcellDll ) { FreeLibrary( globals->hcellDll ); globals->hcellDll = NULL; @@ -2315,7 +2315,7 @@ ceCheckHandleFocusKey( CEAppGlobals* globals, WPARAM wParam, LPARAM lParam, /* Sometimes, e.g. after a menu is released, we get KEY_UP not preceeded by KEY_DOWN. Just drop those. */ if ( !keyDown && !globals->keyDown ) { - XP_LOGF( "%s: keyUp not preceeded by keyDown: dropping", __func__ ); + /* drop key; don't log as it happens all the time */ } else { XP_Bool isRepeat = keyDown && ((HIWORD(lParam) & KF_REPEAT) != 0); XP_Key key; @@ -2498,6 +2498,11 @@ WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_ACTIVATE: // Notify shell of our activate message SHHandleWMActivate( hWnd, wParam, lParam, &globals->sai, FALSE ); + if ( !!globals && !!globals->game.board ) { + if ( ceSizeIfFullscreen( globals, globals->hWnd ) ) { + (void)cePositionBoard( globals ); + } + } break; case WM_SETTINGCHANGE: @@ -3263,7 +3268,7 @@ ce_send_proc( const XP_U8* buf, XP_U16 len, const CommsAddrRec* addrp, = ce_sockwrap_new( MPPARM(globals->mpool) globals->hWnd, got_data_proc,sock_state_change, -#ifdef _WIN32_WCE +#if defined _WIN32_WCE && ! defined CEGCC_DOES_CONNMGR &globals->cmProcs, #endif globals ); diff --git a/xwords4/wince/cemain.h b/xwords4/wince/cemain.h index aee8f9362..11f9c2733 100755 --- a/xwords4/wince/cemain.h +++ b/xwords4/wince/cemain.h @@ -28,7 +28,7 @@ #include "util.h" #include "mempool.h" #include "cesockwr.h" -#include "connmgr.h" +#include "ceconnmg.h" #define LCROSSWORDS_DIR_NODBG L"Crosswords" #define CE_GAMEFILE_VERSION1 0x01 /* means draw gets to save/restore */ diff --git a/xwords4/wince/cesockwr.c b/xwords4/wince/cesockwr.c index 6482fbb03..3445ee1ad 100755 --- a/xwords4/wince/cesockwr.c +++ b/xwords4/wince/cesockwr.c @@ -28,7 +28,7 @@ #include "cemain.h" #include "cedebug.h" #include "debhacks.h" -#include "connmgr.h" +#include "ceconnmg.h" /* This object owns all network activity: sending and receiving packets. It @@ -45,8 +45,10 @@ struct CeSocketWrapper { HWND hWnd; DataRecvProc dataProc; StateChangeProc stateProc; -#ifdef _WIN32_WCE +#if defined _WIN32_WCE +# if ! defined CEGCC_DOES_CONNMGR const CMProcs* cmProcs; +# endif HANDLE connMgrHandle; #endif void* closure; @@ -78,6 +80,14 @@ struct CeSocketWrapper { MPSLOT }; +#ifdef _WIN32_WCE +# ifdef CEGCC_DOES_CONNMGR +# define CMCALL(proc) proc +# else +# define CMCALL(proc) (*self->cmProcs->proc) +# endif +#endif + #ifdef DEBUG static const char* ConnState2Str( CeConnState connState ) @@ -275,12 +285,11 @@ openNetwork( CeSocketWrapper* self ) if ( !!self->connMgrHandle ) { /* already have a connection? */ DWORD status; - res = (*self->cmProcs->ConnMgrConnectionStatus)( self->connMgrHandle, - &status ); + res = CMCALL(ConnMgrConnectionStatus)( self->connMgrHandle, &status ); if ( SUCCEEDED(res) && status == CONNMGR_STATUS_CONNECTED ) { stateChanged( self, CE_IPST_NETWORK_OPENED ); } else { - (*self->cmProcs->ConnMgrReleaseConnection)( self->connMgrHandle, 1 ); + CMCALL(ConnMgrReleaseConnection)( self->connMgrHandle, 1 ); self->connMgrHandle = NULL; } } @@ -290,7 +299,7 @@ openNetwork( CeSocketWrapper* self ) HANDLE hand; XP_MEMSET( &cmi, 0, sizeof(cmi) ); - res = (*self->cmProcs->ConnMgrMapURL)( L"http://google.com", + res = CMCALL(ConnMgrMapURL)( L"http://google.com", &cmi.guidDestNet, NULL ); if ( SUCCEEDED(res) ) { cmi.cbSize = sizeof(cmi); @@ -301,7 +310,7 @@ openNetwork( CeSocketWrapper* self ) cmi.hWnd = self->hWnd; cmi.uMsg = XWWM_CONNMGR_EVT; - res = (*self->cmProcs->ConnMgrEstablishConnection)( &cmi, &hand ); + res = CMCALL(ConnMgrEstablishConnection)( &cmi, &hand ); if ( SUCCEEDED(res) ) { self->connMgrHandle = hand; stateChanged( self, CE_IPST_OPENING_NETWORK ); @@ -335,7 +344,7 @@ getHostAddr( CeSocketWrapper* self ) CeSocketWrapper* ce_sockwrap_new( MPFORMAL HWND hWnd, DataRecvProc dataCB, StateChangeProc stateCB, -#ifdef _WIN32_WCE +#if defined _WIN32_WCE && ! defined CEGCC_DOES_CONNMGR const CMProcs* cmProcs, #endif void* closure ) @@ -348,7 +357,7 @@ ce_sockwrap_new( MPFORMAL HWND hWnd, DataRecvProc dataCB, self->hWnd = hWnd; self->dataProc = dataCB; self->stateProc = stateCB; -#ifdef _WIN32_WCE +#if defined _WIN32_WCE && ! defined CEGCC_DOES_CONNMGR self->cmProcs = cmProcs; #endif self->closure = closure; @@ -370,7 +379,7 @@ ce_sockwrap_delete( CeSocketWrapper* self ) #ifdef _WIN32_WCE if ( !!self->connMgrHandle ) { - (*self->cmProcs->ConnMgrReleaseConnection)( self->connMgrHandle, 1 ); + CMCALL(ConnMgrReleaseConnection)( self->connMgrHandle, 1 ); self->connMgrHandle = NULL; } #endif @@ -545,10 +554,42 @@ ce_sockwrap_event( CeSocketWrapper* self, WPARAM wParam, LPARAM lParam ) } /* ce_sockwrap_event */ #ifdef _WIN32_WCE +#ifdef DEBUG +static const char* +CMStatus2Str( WPARAM status ) +{ +#define CASESTR(s) case (s): return #s + switch( status ) { + CASESTR( CONNMGR_STATUS_CONNECTED ); + CASESTR( CONNMGR_STATUS_NOPATHTODESTINATION ); + CASESTR( CONNMGR_STATUS_CONNECTIONCANCELED ); + CASESTR( CONNMGR_STATUS_CONNECTIONLINKFAILED ); + CASESTR( CONNMGR_STATUS_CONNECTIONDISABLED ); + CASESTR( CONNMGR_STATUS_AUTHENTICATIONFAILED ); + CASESTR( CONNMGR_STATUS_PHONEOFF ); + CASESTR( CONNMGR_STATUS_UNKNOWN ); + CASESTR( CONNMGR_STATUS_DISCONNECTED ); + CASESTR( CONNMGR_STATUS_CONNECTIONFAILED ); + CASESTR( CONNMGR_STATUS_WAITINGFORPATH ); + CASESTR( CONNMGR_STATUS_WAITINGFORPHONE ); + CASESTR( CONNMGR_STATUS_EXCLUSIVECONFLICT ); + CASESTR( CONNMGR_STATUS_WAITINGCONNECTION ); + CASESTR( CONNMGR_STATUS_WAITINGFORRESOURCE ); + CASESTR( CONNMGR_STATUS_WAITINGFORNETWORK ); + CASESTR( CONNMGR_STATUS_WAITINGDISCONNECTION ); + CASESTR( CONNMGR_STATUS_WAITINGCONNECTIONABORT ); + CASESTR( CONNMGR_STATUS_NOPATHWITHPROPERTY ); + } +#undef CASESTR + XP_ASSERT(0); + return ""; +} +#endif + void ce_connmgr_event( CeSocketWrapper* self, WPARAM wParam, ConnMgrErr* userErr ) { - XP_LOGF( "%s: wParam=%x", __func__, wParam ); + XP_LOGF( "%s: wParam=%s", __func__, CMStatus2Str(wParam) ); *userErr = CONN_ERR_NONE; @@ -563,14 +604,17 @@ ce_connmgr_event( CeSocketWrapper* self, WPARAM wParam, ConnMgrErr* userErr ) case CONNMGR_STATUS_CONNECTIONLINKFAILED: case CONNMGR_STATUS_CONNECTIONDISABLED: case CONNMGR_STATUS_AUTHENTICATIONFAILED: - (*self->cmProcs->ConnMgrReleaseConnection)( self->connMgrHandle, 1 ); + /* Do I want to release, or keep it around for status messages + later? */ + //(*self->cmProcs->ConnMgrReleaseConnection)( self->connMgrHandle, 1 ); + //self->connMgrHandle = NULL; stateChanged( self, CE_IPST_START ); - self->connMgrHandle = NULL; *userErr = CONN_ERR_NONET; break; /* Error the user can fix.... */ case CONNMGR_STATUS_PHONEOFF: + closeConnection( self ); *userErr = CONN_ERR_PHONE_OFF; break; diff --git a/xwords4/wince/cesockwr.h b/xwords4/wince/cesockwr.h index 8139d8d8d..eb8147237 100755 --- a/xwords4/wince/cesockwr.h +++ b/xwords4/wince/cesockwr.h @@ -23,7 +23,7 @@ #include "comms.h" #include "mempool.h" -#include "connmgr.h" +#include "ceconnmg.h" typedef enum { CE_IPST_START @@ -51,7 +51,7 @@ typedef void (*StateChangeProc)( void* closure, CeConnState oldState, CeSocketWrapper* ce_sockwrap_new( MPFORMAL HWND hWnd, DataRecvProc dataCB, StateChangeProc stateCB, -#ifdef _WIN32_WCE +#if defined _WIN32_WCE && ! defined CEGCC_DOES_CONNMGR const CMProcs* cmProcs, #endif void* globals ); diff --git a/xwords4/wince/ceutil.c b/xwords4/wince/ceutil.c index c094142dd..6c9dfa56e 100755 --- a/xwords4/wince/ceutil.c +++ b/xwords4/wince/ceutil.c @@ -302,12 +302,15 @@ ceSize( CEAppGlobals* globals, HWND hWnd, XP_Bool fullScreen ) rect.bottom - rect.top, TRUE ); } /* ceSize */ -void +XP_Bool ceSizeIfFullscreen( CEAppGlobals* globals, HWND hWnd ) { - if ( globals->appPrefs.fullScreen != ceIsFullScreen(globals, hWnd) ) { + XP_Bool resized = globals->appPrefs.fullScreen + != ceIsFullScreen(globals, hWnd); + if ( resized ) { ceSize( globals, hWnd, globals->appPrefs.fullScreen ); } + return resized; } static XP_Bool diff --git a/xwords4/wince/ceutil.h b/xwords4/wince/ceutil.h index 3810fdd73..c976235e5 100755 --- a/xwords4/wince/ceutil.h +++ b/xwords4/wince/ceutil.h @@ -96,9 +96,9 @@ void ceSetLeftSoftkey( CEAppGlobals* globals, XP_U16 id ); XP_Bool ceGetExeDir( wchar_t* buf, XP_U16 bufLen ); #if defined _WIN32_WCE -void ceSizeIfFullscreen( CEAppGlobals* globals, HWND hWnd ); +XP_Bool ceSizeIfFullscreen( CEAppGlobals* globals, HWND hWnd ); #else -# define ceSizeIfFullscreen( globals, hWnd ) +# define ceSizeIfFullscreen( globals, hWnd ) XP_FALSE #endif #ifdef OVERRIDE_BACKKEY diff --git a/xwords4/wince/connmgr.h b/xwords4/wince/connmgr.h deleted file mode 100644 index b3dffd567..000000000 --- a/xwords4/wince/connmgr.h +++ /dev/null @@ -1,182 +0,0 @@ -/* -*-mode: C; fill-column: 77; c-basic-offset: 4; -*- */ -/* - * 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 - * as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - */ - -/* This should eventually be contributed to cegcc. Everything it in comes - * from MSDN - */ -#ifndef _CONNMGR_H_ -#define _CONNMGR_H_ - -#include - -/* from http://hi.baidu.com/53_54/blog/index/1 */ - -#ifndef S_OK -# define S_OK 0 -#endif -#ifndef CONNMGR_PARAM_GUIDDESTNET -# define CONNMGR_PARAM_GUIDDESTNET 0x1 -#endif -#ifndef CONNMGR_FLAG_PROXY_HTTP -# define CONNMGR_FLAG_PROXY_HTTP 0x1 -#endif -#ifndef CONNMGR_PRIORITY_USERINTERACTIVE -# define CONNMGR_PRIORITY_USERINTERACTIVE 0x08000 -#endif -#ifndef CONNMGR_STATUS_CONNECTED -# define CONNMGR_STATUS_CONNECTED 0x10 -#endif - - -#if 0 -/* from http://www.dotnet247.com/247reference/msgs/53/267570.aspx */ -public const uint CONNMGR_STATUS_UNKNOWN = 0x00; // Unknown status -public const uint CONNMGR_STATUS_CONNECTED = 0x10; // Connection is up -public const uint CONNMGR_STATUS_DISCONNECTED = 0x20; // Connection is disconnected -public const uint CONNMGR_STATUS_CONNECTIONFAILED = 0x21; // Connection failed and cannot not be reestablished -public const uint CONNMGR_STATUS_CONNECTIONCANCELED = 0x22; // User aborted connection -public const uint CONNMGR_STATUS_CONNECTIONDISABLED = 0x23; // Connection is ready to connect but disabled -public const uint CONNMGR_STATUS_NOPATHTODESTINATION = 0x24; // No path could be found to destination -public const uint CONNMGR_STATUS_WAITINGFORPATH = 0x25; // Waiting for a path to the destination -public const uint CONNMGR_STATUS_WAITINGFORPHONE = 0x26; // Voice call is in progress -public const uint CONNMGR_STATUS_WAITINGCONNECTION = 0x40; // Attempting to connect -public const uint CONNMGR_STATUS_WAITINGFORRESOURCE = 0x41; // Resource is in use by another connection -public const uint CONNMGR_STATUS_WAITINGFORNETWORK = 0x42; // No path could be found to destination -public const uint CONNMGR_STATUS_WAITINGDISCONNECTION = 0x80; // Connection is being brought down -public const uint CONNMGR_STATUS_WAITINGCONNECTIONABORT = 0x81; // Aborting connection attempt -#endif - -/* -A bunch of these constants are from: -http://74.125.155.132/search?q=cache:fZImjloe6fsJ:download.microsoft.com/download/6/B/C/6BC8CDA8-9035-43AC-AFB8-B5B7DC550949/OCS%25202007%2520R2%2520Technical%2520Reference%2520for%2520Clients.doc+define+CONNMGR_STATUS_PHONEOFF&cd=1&hl=en&ct=clnk&gl=us&client=iceweasel-a -*/ - -/* this URL provides the following definitions -http://technet.microsoft.com/en-us/library/dd637175%28office.13%29.aspx - -CONNMGR_STATUS_CONNECTIONLINKFAILED(0x2A) -CONNMGR_STATUS_CONNECTIONFAILED(0x21) -CONNMGR_STATUS_EXCLUSIVECONFLICT(0x28) -CONNMGR_STATUS_NOPATHTODESTINATION(0x24) -CONNMGR_STATUS_CONNECTIONCANCELED(0x22) -CONNMGR_STATUS_WAITINGFORPATH(0x25) -CONNMGR_STATUS_PHONEOFF(0x27) -CONNMGR_STATUS_WAITINGFORPHONE(0x26) -CONNMGR_STATUS_AUTHENTICATIONFAILED(0x2B) -CONNMGR_STATUS_NOPATHWITHPROPERTY(0x2C) -CONNMGR_STATUS_UNKNOWN( 0X00) -*/ -#ifndef CONNMGR_STATUS_UNKNOWN -# define CONNMGR_STATUS_UNKNOWN 0x00 -#endif -#ifndef CONNMGR_STATUS_CONNECTED -# define CONNMGR_STATUS_CONNECTED 0x10 -#endif -// CONNMGR_STATUS_SUSPENDED -#ifndef CONNMGR_STATUS_DISCONNECTED -# define CONNMGR_STATUS_DISCONNECTED 0x20 -#endif -#ifndef CONNMGR_STATUS_CONNECTIONFAILED -# define CONNMGR_STATUS_CONNECTIONFAILED 0x21 -#endif -#ifndef CONNMGR_STATUS_CONNECTIONCANCELED -# define CONNMGR_STATUS_CONNECTIONCANCELED 0x22 -#endif -#ifndef CONNMGR_STATUS_CONNECTIONDISABLED -# define CONNMGR_STATUS_CONNECTIONDISABLED 0x23 -#endif -#ifndef CONNMGR_STATUS_NOPATHTODESTINATION -# define CONNMGR_STATUS_NOPATHTODESTINATION 0x24 -#endif -#ifndef CONNMGR_STATUS_WAITINGFORPATH -# define CONNMGR_STATUS_WAITINGFORPATH 0x25 -#endif -#ifndef CONNMGR_STATUS_WAITINGFORPHONE -# define CONNMGR_STATUS_WAITINGFORPHONE 0x26 -#endif -#ifndef CONNMGR_STATUS_PHONEOFF -# define CONNMGR_STATUS_PHONEOFF 0x27 -#endif -#ifndef CONNMGR_STATUS_EXCLUSIVECONFLICT -# define CONNMGR_STATUS_EXCLUSIVECONFLICT 0x28 -#endif -// CONNMGR_STATUS_NORESOURCES -#ifndef CONNMGR_STATUS_CONNECTIONLINKFAILED -# define CONNMGR_STATUS_CONNECTIONLINKFAILED 0x2A -#endif -#ifndef CONNMGR_STATUS_AUTHENTICATIONFAILED -# define CONNMGR_STATUS_AUTHENTICATIONFAILED 0x2B -#endif -#ifndef CONNMGR_STATUS_WAITINGCONNECTION -# define CONNMGR_STATUS_WAITINGCONNECTION 0x40 -#endif -#ifndef CONNMGR_STATUS_WAITINGFORRESOURCE -# define CONNMGR_STATUS_WAITINGFORRESOURCE 0x41 -#endif -#ifndef CONNMGR_STATUS_WAITINGFORNETWORK -# define CONNMGR_STATUS_WAITINGFORNETWORK 0x42 -#endif -#ifndef CONNMGR_STATUS_WAITINGDISCONNECTION -# define CONNMGR_STATUS_WAITINGDISCONNECTION 0x80 -#endif -#ifndef CONNMGR_STATUS_WAITINGCONNECTIONABORT -# define CONNMGR_STATUS_WAITINGCONNECTIONABORT 0x81 -#endif -#ifndef CONNMGR_STATUS_NOPATHWITHPROPERTY -# define CONNMGR_STATUS_NOPATHWITHPROPERTY 0x2C -#endif - -typedef struct _CONNMGR_CONNECTIONINFO { - DWORD cbSize; - DWORD dwParams; - DWORD dwFlags; - DWORD dwPriority; - BOOL bExclusive; - BOOL bDisabled; - GUID guidDestNet; - HWND hWnd; - UINT uMsg; - LPARAM lParam; - ULONG ulMaxCost; - ULONG ulMinRcvBw; - ULONG ulMaxConnLatency; -} CONNMGR_CONNECTIONINFO; - -/* procptr typedefs since we're loading by name */ -typedef HRESULT (*ConnMgrRegisterForStatusChangeNotificationProc)( BOOL, HWND ); - -/* Returns S_OK if successful or returns an error code if the function call - failed.*/ -typedef HRESULT (*ConnMgrEstablishConnectionProc)( CONNMGR_CONNECTIONINFO*, - HANDLE* ); -typedef HRESULT (*ConnMgrConnectionStatusProc)( HANDLE, DWORD* ); - -typedef HRESULT (*ConnMgrMapURLProc)( LPTSTR, GUID*, DWORD* ); - -typedef HRESULT (*ConnMgrReleaseConnectionProc)( HANDLE, LONG ); - -typedef struct _CMProcs { - ConnMgrEstablishConnectionProc ConnMgrEstablishConnection; - ConnMgrConnectionStatusProc ConnMgrConnectionStatus; - ConnMgrMapURLProc ConnMgrMapURL; - ConnMgrReleaseConnectionProc ConnMgrReleaseConnection; -} CMProcs; - -#endif