Merge branch 'relay_proxy' of ssh://xwords.git.sourceforge.net/gitroot/xwords/xwords into relay_proxy

This commit is contained in:
eehouse@eehouse.org 2010-11-05 05:10:24 -07:00 committed by Andy2
commit 64cc199e1a
13 changed files with 81 additions and 50 deletions

View file

@ -21,8 +21,8 @@
to come from a domain that you own or have control over. --> to come from a domain that you own or have control over. -->
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.eehouse.android.xw4" package="org.eehouse.android.xw4"
android:versionCode="9" android:versionCode="10"
android:versionName="4.4 beta 16" android:versionName="4.4 beta 17"
> >
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.INTERNET" />

View file

@ -6,27 +6,49 @@
</head> </head>
<body> <body>
<b>Crosswords 4.4 beta 16 release</b> <b>Crosswords 4.4 beta 17 release</b>
<p>This is a <em>another</em> quick bug-fix release while I continue <p>This release changes how networked games are created, configured
work on the new relay connection code -- which is coming along, and connect with each other. It tries to make the process simpler and
BTW. Please email if you're willing to comment on an early version.</p> should mean it's much more likely to succeed. I've also scattered
"new user hints" around the app, dialogs with tips that you can
dismiss with a "Do not show again" button when you don't need to see
that hint again.</p>
<ul>Bugs fixed: <p>I'm breaking from tradition and not listing bugs fixed or features
<li>Dictionary download could be routed to Browser if you weren't careful or added here -- because there have been well over 300 separate changes
your phone maker hard-coded the type. Now it always routes to Crosswords. committed since the last beta. Instead I'll outline how you get
(Thanks B.S.)</li> started with a two-player networked game.</p>
</ul>
<ul>(Still) coming soon <p>Assume you and a friend each have Crosswords on an Android phone.
<li>builtin hints and help, starting with the Game Settings You both need to
screen</li> <ul>
<li>Launch Crosswords and tap the "Add networked game" button on
your device</li>
<li>rewrite of gameplay via relay to make connecting easier (no <li>When the game appears, long-tap it and choose "Game settings..."
host/guest stuff or requirement that both be online at the same from the menu</li>
time) and allow closed game to receive moves.</li>
<li>Agree on a "room name" -- let's say it's "andy" --and enter it
in the "New room name" text box.</li>
<li>Scroll to the bottom of the window and tap the "Play game" button</li>
<li>Wait as your phones connect. You'll see a status message and
maybe a "new user hint", then the status icon in the upper-right
will go all-green and boards on both phones will get tiles</li>
<li>Now the first player makes a move, commits it, and it shows up
on the other device. Rinse, lather, repeat.</li>
<li>The "relay" server stores moves it receives until it can deliver
them. If you have a bunch of networked games going, choose the
"Check server" menu on the main list-of-games screen. It will
redraw all games for which there are waiting messages. You can then
open them and they will sync up.</li>
</ul> </ul>
</p>
<p>Please remember that this is beta software. Letting me know (at <p>Please remember that this is beta software. Letting me know (at
eehouse@eehouse.org) what's broken and what features you'd most like eehouse@eehouse.org) what's broken and what features you'd most like

View file

@ -190,8 +190,6 @@
<string name="summary_sort_tiles">Ordena el faristol en agafar noves fitxes</string> <string name="summary_sort_tiles">Ordena el faristol en agafar noves fitxes</string>
<string name="ringer_zoom">Zoom amb els botons de volum</string> <string name="ringer_zoom">Zoom amb els botons de volum</string>
<string name="ringer_zoom_summary">Apropa o allunya el tauler fent servir les tecles de volum.</string> <string name="ringer_zoom_summary">Apropa o allunya el tauler fent servir les tecles de volum.</string>
<string name="click_launches">Clic per a jugar</string>
<string name="click_launches_summary">obre la partida en fer-hi clic al llistat de partides, en compte d\'obrir un menú d\'opcions</string>
<string name="hide_title">Amaga la capçalera</string> <string name="hide_title">Amaga la capçalera</string>
<string name="hide_title_summary">Permet que el tauler sigui una mica més gran</string> <string name="hide_title_summary">Permet que el tauler sigui una mica més gran</string>
@ -266,7 +264,6 @@
<string name="tab_bluetooth">Bluetooth (en desenvolupament)</string> <string name="tab_bluetooth">Bluetooth (en desenvolupament)</string>
<string name="msg_relay_waiting">Esteu connectat al repetidor. S\'està esperant a %d jugador/s.</string> <string name="msg_relay_waiting">Esteu connectat al repetidor. S\'està esperant a %d jugador/s.</string>
<string name="msg_relay_all_here">Ja hi són tots els jugadors.</string>
<string name="title_relay_status">Estat de la connexió.</string> <string name="title_relay_status">Estat de la connexió.</string>
<string name="relay_alert">Error en la connexió</string> <string name="relay_alert">Error en la connexió</string>

View file

@ -237,7 +237,6 @@
<string name="tab_bluetooth">Bluetooth (připravuje se)</string> <string name="tab_bluetooth">Bluetooth (připravuje se)</string>
<string name="msg_relay_waiting">Připojen na relay. Čekám na %d hráče.</string> <string name="msg_relay_waiting">Připojen na relay. Čekám na %d hráče.</string>
<string name="msg_relay_all_here">Všichni hráči jsou zde.</string>
<string name="title_relay_status">Stav připojení.</string> <string name="title_relay_status">Stav připojení.</string>
<string name="relay_alert">Chyba připojení</string> <string name="relay_alert">Chyba připojení</string>

View file

@ -235,7 +235,6 @@
<string name="tab_bluetooth">Bluetooth (pripravuje sa)</string> <string name="tab_bluetooth">Bluetooth (pripravuje sa)</string>
<string name="msg_relay_waiting">Pripojený na relay. Čakám na %d hráčov.</string> <string name="msg_relay_waiting">Pripojený na relay. Čakám na %d hráčov.</string>
<string name="msg_relay_all_here">Všetci hráči sú tu.</string>
<string name="title_relay_status">Stav pripojenia.</string> <string name="title_relay_status">Stav pripojenia.</string>
<string name="relay_alert">Chyba pripojenia</string> <string name="relay_alert">Chyba pripojenia</string>

View file

@ -144,6 +144,9 @@ public class CommsTransport extends Thread implements TransportProcs {
try { try {
m_socketChannel = SocketChannel.open(); m_socketChannel = SocketChannel.open();
m_socketChannel.configureBlocking( false ); m_socketChannel.configureBlocking( false );
Utils.logf( "connecting to %s:%d",
m_addr.ip_relay_hostName,
m_addr.ip_relay_port );
InetSocketAddress isa InetSocketAddress isa
= new InetSocketAddress( m_addr.ip_relay_hostName, = new InetSocketAddress( m_addr.ip_relay_hostName,
m_addr.ip_relay_port ); m_addr.ip_relay_port );

View file

@ -39,7 +39,7 @@ public class FirstRunDialog {
private static final String HIDDEN_PREFS = "xwprefs_hidden"; private static final String HIDDEN_PREFS = "xwprefs_hidden";
private static final String SHOWN_VERSION_KEY = "SHOWN_VERSION_KEY"; private static final String SHOWN_VERSION_KEY = "SHOWN_VERSION_KEY";
static void show( Context context, boolean skipCheck ) static boolean show( Context context, boolean skipCheck )
{ {
int thisVersion = 0; int thisVersion = 0;
int shownVersion = 0; int shownVersion = 0;
@ -61,7 +61,8 @@ public class FirstRunDialog {
shownVersion = prefs.getInt( SHOWN_VERSION_KEY, 0 ); shownVersion = prefs.getInt( SHOWN_VERSION_KEY, 0 );
} }
if ( skipCheck || shownVersion < thisVersion ) { boolean isUpgrade = shownVersion < thisVersion;
if ( skipCheck || isUpgrade ) {
showDialog( context ); showDialog( context );
if ( !skipCheck ) { if ( !skipCheck ) {
@ -70,6 +71,7 @@ public class FirstRunDialog {
editor.commit(); editor.commit();
} }
} }
return isUpgrade;
} }
private static void showDialog( Context context ) private static void showDialog( Context context )

View file

@ -64,10 +64,11 @@ public class GamesList extends XWListActivity
m_handler = new Handler(); m_handler = new Handler();
PreferenceManager.setDefaultValues( this, R.xml.xwprefs, false );
setContentView(R.layout.game_list); setContentView(R.layout.game_list);
boolean isUpgrade = FirstRunDialog.show( this, false );
PreferenceManager.setDefaultValues( this, R.xml.xwprefs, isUpgrade );
// setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT); // setDefaultKeyMode(DEFAULT_KEYS_SHORTCUT);
registerForContextMenu( getListView() ); registerForContextMenu( getListView() );
@ -97,8 +98,6 @@ public class GamesList extends XWListActivity
m_adapter = new GameListAdapter( this ); m_adapter = new GameListAdapter( this );
setListAdapter( m_adapter ); setListAdapter( m_adapter );
FirstRunDialog.show( this, false );
RelayReceiver.RestartTimer( this ); RelayReceiver.RestartTimer( this );
} }

View file

@ -23,5 +23,5 @@ package org.eehouse.android.xw4;
public interface XWConstants { public interface XWConstants {
public static final String GAME_EXTN = ".xwg"; public static final String GAME_EXTN = ".xwg";
public static final String DICT_EXTN = ".xwd"; public static final String DICT_EXTN = ".xwd";
public static final String VERSION_STR = "4.4 beta 16"; public static final String VERSION_STR = "4.4 beta 17";
} }

View file

@ -1653,8 +1653,8 @@ comms_checkComplete( const CommsAddrRec* addr )
XP_Bool XP_Bool
comms_canChat( const CommsCtxt* const comms ) comms_canChat( const CommsCtxt* const comms )
{ {
XP_Bool canChat = COMMS_CONN_RELAY == comms_getConType( comms ) XP_Bool canChat = comms_isConnected( comms )
&& COMMS_RELAYSTATE_CONNECTED <= comms->r.relayState; && comms->connID != 0;
LOG_RETURNF( "%s", canChat?"true":"false" ); LOG_RETURNF( "%s", canChat?"true":"false" );
return canChat; return canChat;
} }

View file

@ -528,7 +528,8 @@ server_initClientConnection( ServerCtxt* server, XWStreamCtxt* stream )
static void static void
sendChatTo( ServerCtxt* server, XP_U16 devIndex, const XP_UCHAR const* msg ) sendChatTo( ServerCtxt* server, XP_U16 devIndex, const XP_UCHAR const* msg )
{ {
XWStreamCtxt* stream = messageStreamWithHeader( server, devIndex, XWPROTO_CHAT ); XWStreamCtxt* stream = messageStreamWithHeader( server, devIndex,
XWPROTO_CHAT );
stringToStream( stream, msg ); stringToStream( stream, msg );
stream_destroy( stream ); stream_destroy( stream );
} }
@ -545,7 +546,8 @@ sendChatToClientsExcept( ServerCtxt* server, XP_U16 skip,
} }
} }
void server_sendChat( ServerCtxt* server, const XP_UCHAR const* msg ) void
server_sendChat( ServerCtxt* server, const XP_UCHAR const* msg )
{ {
if ( server->vol.gi->serverRole == SERVER_ISCLIENT ) { if ( server->vol.gi->serverRole == SERVER_ISCLIENT ) {
sendChatTo( server, SERVER_DEVICE, msg ); sendChatTo( server, SERVER_DEVICE, msg );

View file

@ -503,6 +503,7 @@ createOrLoadObjects( GtkAppGlobals* globals )
#endif #endif
server_do( globals->cGlobals.game.server ); server_do( globals->cGlobals.game.server );
disenable_buttons( globals );
} /* createOrLoadObjects */ } /* createOrLoadObjects */
/* Create a new backing pixmap of the appropriate size and set up contxt to /* Create a new backing pixmap of the appropriate size and set up contxt to
@ -880,18 +881,6 @@ handle_resend( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
} }
} /* handle_resend */ } /* handle_resend */
#ifdef XWFEATURE_CHAT
static void
handle_chat( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
{
gchar* msg = gtkGetChatMessage( globals );
if ( NULL != msg ) {
server_sendChat( globals->cGlobals.game.server, msg );
g_free( msg );
}
}
#endif
#ifdef DEBUG #ifdef DEBUG
static void static void
handle_commstats( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals ) handle_commstats( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
@ -992,10 +981,6 @@ makeMenus( GtkAppGlobals* globals, int XP_UNUSED(argc),
#ifndef XWFEATURE_STANDALONE_ONLY #ifndef XWFEATURE_STANDALONE_ONLY
(void)createAddItem( fileMenu, "Resend", (void)createAddItem( fileMenu, "Resend",
GTK_SIGNAL_FUNC(handle_resend), globals ); GTK_SIGNAL_FUNC(handle_resend), globals );
# ifdef XWFEATURE_CHAT
(void)createAddItem( fileMenu, "Send Chat",
GTK_SIGNAL_FUNC(handle_chat), globals );
# endif
# ifdef DEBUG # ifdef DEBUG
(void)createAddItem( fileMenu, "Stats", (void)createAddItem( fileMenu, "Stats",
GTK_SIGNAL_FUNC(handle_commstats), globals ); GTK_SIGNAL_FUNC(handle_commstats), globals );
@ -1024,6 +1009,10 @@ disenable_buttons( GtkAppGlobals* globals )
XP_Bool canToggle = board_canTogglePending( globals->cGlobals.game.board ); XP_Bool canToggle = board_canTogglePending( globals->cGlobals.game.board );
gtk_widget_set_sensitive( globals->toggle_undo_button, canToggle ); gtk_widget_set_sensitive( globals->toggle_undo_button, canToggle );
XP_Bool canChat = !!globals->cGlobals.game.comms
&& comms_canChat( globals->cGlobals.game.comms );
gtk_widget_set_sensitive( globals->chat_button, canChat );
} }
static gboolean static gboolean
@ -1172,6 +1161,18 @@ handle_zoomout_button( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
} }
} /* handle_done_button */ } /* handle_done_button */
#ifdef XWFEATURE_CHAT
static void
handle_chat_button( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals )
{
gchar* msg = gtkGetChatMessage( globals );
if ( NULL != msg ) {
server_sendChat( globals->cGlobals.game.server, msg );
g_free( msg );
}
}
#endif
static void static void
scroll_value_changed( GtkAdjustment *adj, GtkAppGlobals* globals ) scroll_value_changed( GtkAdjustment *adj, GtkAppGlobals* globals )
{ {
@ -1788,7 +1789,11 @@ makeVerticalBar( GtkAppGlobals* globals, GtkWidget* XP_UNUSED(window) )
gtk_box_pack_start( GTK_BOX(vbox), button, FALSE, TRUE, 0 ); gtk_box_pack_start( GTK_BOX(vbox), button, FALSE, TRUE, 0 );
button = makeShowButtonFromBitmap( globals, "../done.xpm", "-", button = makeShowButtonFromBitmap( globals, "../done.xpm", "-",
G_CALLBACK(handle_zoomout_button) ); G_CALLBACK(handle_zoomout_button) );
globals->zoomout_button = button; #ifdef XWFEATURE_CHAT
button = makeShowButtonFromBitmap( globals, "", "chat",
G_CALLBACK(handle_chat_button) );
globals->chat_button = button;
#endif
gtk_box_pack_start( GTK_BOX(vbox), button, FALSE, TRUE, 0 ); gtk_box_pack_start( GTK_BOX(vbox), button, FALSE, TRUE, 0 );
gtk_widget_show( vbox ); gtk_widget_show( vbox );

View file

@ -91,6 +91,9 @@ typedef struct GtkAppGlobals {
GtkWidget* zoomin_button; GtkWidget* zoomin_button;
GtkWidget* zoomout_button; GtkWidget* zoomout_button;
GtkWidget* toggle_undo_button; GtkWidget* toggle_undo_button;
#ifdef XWFEATURE_CHAT
GtkWidget* chat_button;
#endif
EngineCtxt* engine; EngineCtxt* engine;