Merge branch 'android_branch' into relay_noconn

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.
This commit is contained in:
Eric House 2015-07-11 08:27:24 -07:00
commit 6800c2afe5
7 changed files with 95 additions and 7 deletions

View file

@ -101,8 +101,15 @@ public class GCMIntentService extends GCMBaseIntentService {
if ( null != value ) {
String title = intent.getStringExtra( "title" );
if ( null != title ) {
String teaser = intent.getStringExtra( "teaser" );
if ( null == teaser ) {
teaser = value;
}
Intent alertIntent = GamesListDelegate
.makeAlertIntent( this, value );
int code = value.hashCode() ^ title.hashCode();
Utils.postNotification( context, null, title, value, code );
Utils.postNotification( context, alertIntent, title,
teaser, code );
}
}
}

View file

@ -204,9 +204,9 @@ public class Utils {
Intents is to send a different second param each time,
though the docs say that param's ignored.
*/
PendingIntent pi =
PendingIntent.getActivity( context, Utils.nextRandomInt(), intent,
PendingIntent.FLAG_ONE_SHOT );
PendingIntent pi = null == intent ? null
: PendingIntent.getActivity( context, Utils.nextRandomInt(), intent,
PendingIntent.FLAG_ONE_SHOT );
Notification notification =
new Notification( R.drawable.icon48x48, title,

View file

@ -0,0 +1,35 @@
# -*- mode: makefile; compile-command: "make -f Makefile.CSW12"; -*-
# Copyright 2002 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.
XWLANG=CSW15
LANGCODE=en_US
TARGET_TYPE=WINCE
DICTNOTE = "Submitted by a user, claims equivalence with Collins Scrabble Words 2015"
include ../Makefile.langcommon
SOURCEDICT ?= $(XWDICTPATH)/English/CSW15.txt.gz
$(XWLANG)Main.dict.gz: $(SOURCEDICT) Makefile
zcat $< | tr -d '\r' | awk '{print $$1}' | tr [a-z] [A-Z] | \
grep -e "^[A-Z]\{2,15\}$$" | gzip -c > $@
# Everything but creating of the Main.dict file is inherited from the
# "parent" Makefile.langcommon in the parent directory.
clean: clean_common
rm -f $(XWLANG)Main.dict.gz *.bin $(XWLANG)*.pdb $(XWLANG)*.seb

View file

@ -44,6 +44,7 @@
static DBMgr* s_instance = NULL;
#define MAX_NUM_PLAYERS 4
#define MAX_WAIT_SECONDS (5*60) // five minutes
static int here_less_seed( const char* seeds, int perDeviceSum,
unsigned short seed );
@ -747,6 +748,34 @@ DBMgr::KillGame( const char* const connName, int hid )
execSql( query );
}
void
DBMgr::WaitDBConn( void )
{
int nSeconds = 0;
int toSleep = 1;
for ( ; ; ) {
PGconn* conn = DBMgr::getThreadConn();
if ( !!conn ) {
ConnStatusType status = PQstatus( conn );
if ( CONNECTION_OK == status ) {
break;
}
}
toSleep *= 2;
if ( toSleep > MAX_WAIT_SECONDS ) {
toSleep = MAX_WAIT_SECONDS;
}
(void)sleep( toSleep );
nSeconds += toSleep;
logf( XW_LOGERROR, "%s: waiting for postgres; %d seconds so far", __func__,
nSeconds );
}
logf( XW_LOGERROR, "%s() done", __func__ );
}
void
DBMgr::ClearCIDs( void )
{
@ -1343,7 +1372,12 @@ DBMgr::getThreadConn( void )
params.catf( "port = %d ", port );
conn = PQconnectdb( params.c_str() );
pthread_setspecific( m_conn_key, conn );
if ( CONNECTION_OK == PQstatus( conn ) ) {
pthread_setspecific( m_conn_key, conn );
} else {
PQfinish( conn );
conn = NULL;
}
}
return conn;
}

View file

@ -63,6 +63,8 @@ class DBMgr {
~DBMgr();
void WaitDBConn( void );
void ClearCIDs( void );
void AddNew( const char* cookie, const char* connName, CookieID cid,

View file

@ -14,7 +14,8 @@ def usage():
def sendMsg( devid, msg ):
values = {
'registration_ids': [ devid ],
'data' : { 'title' : 'Msg from Darth2',
'data' : { 'title' : 'Re: CrossWords',
'teaser' : 'Please tap to read in the app',
'msg' : msg,
}
}

View file

@ -1172,6 +1172,7 @@ usage( char* arg0 )
#ifdef DO_HTTP
"\t-w <cport> (localhost port for web interface)\\\n"
#endif
"\t-b (block until postgres connection available)\\\n"
"\t-D (don't become daemon)\\\n"
"\t-F (don't fork and wait to respawn child)\\\n"
"\t-f <conffile> (config file)\\\n"
@ -2029,6 +2030,7 @@ main( int argc, char** argv )
const char* maint_str = NULL;
bool doDaemon = true;
bool doFork = true;
bool doBlock = false;
(void)uptime(); /* force capture of start time */
@ -2040,7 +2042,7 @@ main( int argc, char** argv )
first. */
for ( ; ; ) {
int opt = getopt(argc, argv, "h?c:p:M:m:n:f:l:t:s:u:w:"
int opt = getopt(argc, argv, "bh?c:p:M:m:n:f:l:t:s:u:w:"
"DF" );
if ( opt == -1 ) {
@ -2051,6 +2053,9 @@ main( int argc, char** argv )
case 'h':
usage( argv[0] );
exit( 0 );
case 'b':
doBlock = true;
break;
case 'c':
ctrlport = atoi( optarg );
break;
@ -2201,6 +2206,10 @@ main( int argc, char** argv )
}
#endif
if ( doBlock ) {
DBMgr::Get()->WaitDBConn();
}
if ( -1 != udpport ) {
struct sockaddr_in saddr;
g_udpsock = socket( AF_INET, SOCK_DGRAM, IPPROTO_UDP );