Merge branch 'android_branch' of github.com:eehouse/xwords into android_branch

This commit is contained in:
Eric House 2017-10-12 21:15:08 -07:00
commit fd3220c1c2
8 changed files with 47 additions and 47 deletions

View file

@ -15,7 +15,7 @@ before_script:
- export TERM=dumb
- curl -L http://dl.google.com/android/ndk/android-ndk-r10e-linux-x86_64.bin -O
- chmod u+x android-ndk-r10e-linux-x86_64.bin
- ./android-ndk-r10e-linux-x86_64.bin > /dev/null
- "./android-ndk-r10e-linux-x86_64.bin > /dev/null"
- rm android-ndk-r10e-linux-x86_64.bin
- export ANDROID_NDK_HOME=`pwd`/android-ndk-r10e
- export LOCAL_ANDROID_NDK_HOME="$ANDROID_NDK_HOME"
@ -23,17 +23,18 @@ before_script:
- export PATH=$PATH:${ANDROID_NDK_HOME}
- cd xwords4/android/
before_install:
- openssl aes-256-cbc -K $encrypted_b9c66bb79572_key -iv $encrypted_b9c66bb79572_iv
-in xwords4/android/id_rsa_uploader.enc -out /tmp/id_rsa_uploader -d
- openssl aes-256-cbc -K $encrypted_8436f2891714_key -iv $encrypted_8436f2891714_iv
-in id_rsa_uploader.enc -out /tmp/id_rsa_uploader -d
- chmod 600 \/tmp\/id_rsa_uploader
- sudo apt-get -qq update
- sudo apt-get install -y python-lxml imagemagick
script:
- ./gradlew -PuseCrashlytics assXw4dDeb
- scp -o "StrictHostKeyChecking no" -i /tmp/id_rsa_uploader -d app/build/outputs/apk/*.apk uploader@eehouse.org:XW4D_UPLOAD
- "./gradlew -PuseCrashlytics assXw4dDeb"
- scp -o "StrictHostKeyChecking no" -i /tmp/id_rsa_uploader -d app/build/outputs/apk/*.apk
uploader@eehouse.org:XW4D_UPLOAD
notifications:
email:
recipients:
- xwords@eehouse.org
on_success: never
on_success: always
on_failure: always

BIN
id_rsa_uploader.enc Normal file

Binary file not shown.

View file

@ -114,7 +114,7 @@ def md5Checksums( sums, filePath ):
if filePath in sums:
result = sums[filePath]
else:
logging.debug( "opening %s" % (k_filebase + "and_wordlists/" + filePath))
# logging.debug( "opening %s" % (k_filebase + "and_wordlists/" + filePath))
try:
file = open( k_filebase + "and_wordlists/" + filePath, 'rb' )
md5 = hashlib.md5()
@ -145,7 +145,7 @@ def openShelf():
if not k_SUMS in s_shelf: s_shelf[k_SUMS] = {}
if not k_COUNT in s_shelf: s_shelf[k_COUNT] = 0
s_shelf[k_COUNT] += 1
logging.debug( "Count now %d" % s_shelf[k_COUNT] )
# logging.debug( "Count now %d" % s_shelf[k_COUNT] )
def closeShelf():
global s_shelf
@ -560,15 +560,13 @@ def getUpdates( req, params ):
result[k_DICTS] = dictsResult
# Let's not upgrade strings at the same time as we're upgrading the app
if appResult:
logging.debug( 'skipping xlation upgrade because app being updated' )
elif k_XLATEINFO in asJson and k_NAME in asJson and k_STRINGSHASH in asJson:
xlateResult = getXlate( asJson[k_XLATEINFO], asJson[k_NAME], asJson[k_STRINGSHASH] )
if xlateResult:
logging.debug( xlateResult )
result[k_XLATEINFO] = xlateResult;
else:
logging.debug( "NOT FOUND xlate info" )
# if appResult:
# logging.debug( 'skipping xlation upgrade because app being updated' )
# elif k_XLATEINFO in asJson and k_NAME in asJson and k_STRINGSHASH in asJson:
# xlateResult = getXlate( asJson[k_XLATEINFO], asJson[k_NAME], asJson[k_STRINGSHASH] )
# if xlateResult:
# logging.debug( xlateResult )
# result[k_XLATEINFO] = xlateResult;
result = json.dumps( result )
# logging.debug( result )

View file

@ -1015,10 +1015,10 @@ DBMgr::CountStoredMessages( DevIDRelay relayID )
}
void
DBMgr::StoreMessage( DevIDRelay devID, const uint8_t* const buf,
DBMgr::StoreMessage( DevIDRelay destDevID, const uint8_t* const buf,
int len )
{
clearHasNoMessages( devID );
clearHasNoMessages( destDevID );
size_t newLen;
const char* fmt = "INSERT INTO " MSGS_TABLE " "
@ -1027,13 +1027,13 @@ DBMgr::StoreMessage( DevIDRelay devID, const uint8_t* const buf,
StrWPF query;
if ( m_useB64 ) {
gchar* b64 = g_base64_encode( buf, len );
query.catf( fmt, "msg64", devID, "", b64, len );
query.catf( fmt, "msg64", destDevID, "", b64, len );
g_free( b64 );
} else {
uint8_t* bytes = PQescapeByteaConn( getThreadConn(), buf,
len, &newLen );
assert( NULL != bytes );
query.catf( fmt, "msg", devID, "E", bytes, len );
query.catf( fmt, "msg", destDevID, "E", bytes, len );
PQfreemem( bytes );
}
@ -1042,15 +1042,15 @@ DBMgr::StoreMessage( DevIDRelay devID, const uint8_t* const buf,
}
void
DBMgr::StoreMessage( const char* const connName, int hid,
DBMgr::StoreMessage( const char* const connName, int destHid,
const uint8_t* buf, int len )
{
clearHasNoMessages( connName, hid );
clearHasNoMessages( connName, destHid );
DevIDRelay devID = getDevID( connName, hid );
DevIDRelay devID = getDevID( connName, destHid );
if ( DEVID_NONE == devID ) {
logf( XW_LOGERROR, "%s: warning: devid not found for connName=%s, "
"hid=%d", __func__, connName, hid );
"hid=%d", __func__, connName, destHid );
} else {
clearHasNoMessages( devID );
}
@ -1066,7 +1066,7 @@ DBMgr::StoreMessage( const char* const connName, int hid,
StrWPF query;
if ( m_useB64 ) {
gchar* b64 = g_base64_encode( buf, len );
query.catf( fmt, "msg64", connName, hid, devID, hid, connName,
query.catf( fmt, "msg64", connName, destHid, devID, destHid, connName,
"", b64, len );
query.catf( " WHERE NOT EXISTS (SELECT 1 FROM " MSGS_TABLE
@ -1074,14 +1074,14 @@ DBMgr::StoreMessage( const char* const connName, int hid,
#ifdef HAVE_STIME
" AND stime='epoch'"
#endif
" );", connName, hid, b64 );
" );", connName, destHid, b64 );
g_free( b64 );
} else {
uint8_t* bytes = PQescapeByteaConn( getThreadConn(), buf,
len, &newLen );
assert( NULL != bytes );
query.catf( fmt, "msg", connName, hid, devID, hid, connName,
query.catf( fmt, "msg", connName, destHid, devID, destHid, connName,
"E", bytes, len );
PQfreemem( bytes );
}

View file

@ -137,8 +137,9 @@ class DBMgr {
/* message storage -- different DB */
int CountStoredMessages( const char* const connName );
int CountStoredMessages( DevIDRelay relayID );
void StoreMessage( DevIDRelay relayID, const uint8_t* const buf, int len );
void StoreMessage( const char* const connName, int hid,
void StoreMessage( DevIDRelay destRelayID, const uint8_t* const buf,
int len );
void StoreMessage( const char* const connName, int destHid,
const uint8_t* const buf, int len );
void GetStoredMessages( DevIDRelay relayID, vector<MsgInfo>& msgs );
void GetStoredMessages( const char* const connName, HostID hid,

View file

@ -760,15 +760,15 @@ send_havemsgs( const AddrInfo* addr )
class MsgClosure {
public:
MsgClosure( DevIDRelay devid, const vector<uint8_t>* packet,
MsgClosure( DevIDRelay dest, const vector<uint8_t>* packet,
OnMsgAckProc proc, void* procClosure )
{
m_devid = devid;
m_destDevID = dest;
m_packet = *packet;
m_proc = proc;
m_procClosure = procClosure;
}
DevIDRelay m_devid;
DevIDRelay m_destDevID;
vector<uint8_t> m_packet;
OnMsgAckProc m_proc;
void* m_procClosure;
@ -779,21 +779,21 @@ onPostedMsgAcked( bool acked, uint32_t packetID, void* data )
{
MsgClosure* mc = (MsgClosure*)data;
if ( !acked ) {
DBMgr::Get()->StoreMessage( mc->m_devid, mc->m_packet.data(),
DBMgr::Get()->StoreMessage( mc->m_destDevID, mc->m_packet.data(),
mc->m_packet.size() );
}
if ( NULL != mc->m_proc ) {
(*mc->m_proc)( acked, mc->m_devid, packetID, mc->m_procClosure );
(*mc->m_proc)( acked, mc->m_destDevID, packetID, mc->m_procClosure );
}
delete mc;
}
static bool
post_or_store( DevIDRelay devid, vector<uint8_t>& packet, uint32_t packetID,
post_or_store( DevIDRelay destDevID, vector<uint8_t>& packet, uint32_t packetID,
OnMsgAckProc proc, void* procClosure )
{
const AddrInfo::AddrUnion* addru = DevMgr::Get()->get( devid );
const AddrInfo::AddrUnion* addru = DevMgr::Get()->get( destDevID );
bool canSendNow = !!addru;
bool sent = false;
@ -805,20 +805,20 @@ post_or_store( DevIDRelay devid, vector<uint8_t>& packet, uint32_t packetID,
sent = 0 < send_packet_via_udp_impl( packet, sock, dest_addr );
if ( sent ) {
MsgClosure* mc = new MsgClosure( devid, &packet,
MsgClosure* mc = new MsgClosure( destDevID, &packet,
proc, procClosure );
UDPAckTrack::setOnAck( onPostedMsgAcked, packetID, (void*)mc );
}
}
}
if ( !sent ) {
DBMgr::Get()->StoreMessage( devid, packet.data(), packet.size() );
DBMgr::Get()->StoreMessage( destDevID, packet.data(), packet.size() );
}
return sent;
}
bool
post_message( DevIDRelay devid, const char* message, OnMsgAckProc proc,
post_message( DevIDRelay destDevID, const char* message, OnMsgAckProc proc,
void* procClosure )
{
vector<uint8_t> packet;
@ -830,7 +830,7 @@ post_message( DevIDRelay devid, const char* message, OnMsgAckProc proc,
assemble_packet( packet, &packetID, XWPDEV_ALERT, lenbuf, lenlen,
message, len, NULL );
return post_or_store( devid, packet, packetID, proc, procClosure );
return post_or_store( destDevID, packet, packetID, proc, procClosure );
}
void

View file

@ -28,7 +28,7 @@ make_db() {
exit 1
fi
createdb $DBNAME
cat | psql $DBNAME --file - <<EOF
cat <<-EOF | psql $DBNAME --file -
create or replace function sum_array( DECIMAL [] )
returns decimal
as \$\$
@ -40,7 +40,7 @@ from generate_series(
\$\$ language sql immutable;
EOF
cat | psql $DBNAME --file - <<EOF
cat <<-EOF | psql $DBNAME --file -
CREATE TABLE games (
cid integer
,room VARCHAR(32)
@ -62,7 +62,7 @@ cid integer
);
EOF
cat | psql $DBNAME --file - <<EOF
cat <<-EOF | psql $DBNAME --file -
CREATE TABLE msgs (
id SERIAL
,connName VARCHAR(64)
@ -78,7 +78,7 @@ id SERIAL
);
EOF
cat | psql $DBNAME --file - <<EOF
cat <<-EOF | psql $DBNAME --file -
CREATE TABLE devices (
id INTEGER UNIQUE PRIMARY KEY
,devTypes INTEGER[]

View file

@ -52,8 +52,8 @@ void send_havemsgs( const AddrInfo* addr );
typedef void (*OnMsgAckProc)( bool acked, DevIDRelay devid, uint32_t packetID,
void* data );
bool post_message( DevIDRelay devid, const char* message, OnMsgAckProc proc,
void* data );
bool post_message( DevIDRelay destDevID, const char* message,
OnMsgAckProc proc, void* data );
void post_upgrade( DevIDRelay devid );
time_t uptime(void);