From c115752852802fc554127be4b4716977fd5b1157 Mon Sep 17 00:00:00 2001 From: Eric House Date: Sat, 7 Sep 2013 16:17:07 -0700 Subject: [PATCH] supply in linux client, and look for and store on relay, os version --- xwords4/linux/relaycon.c | 1 + xwords4/relay/dbmgr.cpp | 22 +++++++++++++--------- xwords4/relay/dbmgr.h | 5 +++-- xwords4/relay/xwrelay.cpp | 12 +++++++----- xwords4/relay/xwrelay.sh | 1 + 5 files changed, 25 insertions(+), 16 deletions(-) diff --git a/xwords4/linux/relaycon.c b/xwords4/linux/relaycon.c index 6916da722..0e2335c79 100644 --- a/xwords4/linux/relaycon.c +++ b/xwords4/linux/relaycon.c @@ -92,6 +92,7 @@ relaycon_reg( LaunchParams* params, const XP_UCHAR* devID, DevIDType typ ) INITIAL_CLIENT_VERS ); indx += addVLIStr( &tmpbuf[indx], sizeof(tmpbuf) - indx, SVN_REV ); indx += addVLIStr( &tmpbuf[indx], sizeof(tmpbuf) - indx, "linux box" ); + indx += addVLIStr( &tmpbuf[indx], sizeof(tmpbuf) - indx, "linux version" ); sendIt( storage, tmpbuf, indx ); } diff --git a/xwords4/relay/dbmgr.cpp b/xwords4/relay/dbmgr.cpp index 31eeeec78..4737958f5 100644 --- a/xwords4/relay/dbmgr.cpp +++ b/xwords4/relay/dbmgr.cpp @@ -340,7 +340,8 @@ DBMgr::AllDevsAckd( const char* const connName ) // already there. DevIDRelay DBMgr::RegisterDevice( const DevID* host, int clientVersion, - const char* const desc, const char* const model ) + const char* const desc, const char* const model, + const char* const osVers ) { DevIDRelay devID; assert( host->m_devIDType != ID_TYPE_NONE ); @@ -367,15 +368,15 @@ DBMgr::RegisterDevice( const DevID* host, int clientVersion, } while ( DEVID_NONE == devID ); const char* command = "INSERT INTO " DEVICES_TABLE - " (id, devType, devid, clntVers, versDesc, model)" - " VALUES( $1, $2, $3, $4, $5, $6 )"; - int nParams = 6; + " (id, devType, devid, clntVers, versDesc, model, osvers)" + " VALUES( $1, $2, $3, $4, $5, $6, $7 )"; + int nParams = 7; char* paramValues[nParams]; char buf[1024]; formatParams( paramValues, nParams, - "%d"DELIM"%d"DELIM"%s"DELIM"%d"DELIM"%s"DELIM"%s", + "%d"DELIM"%d"DELIM"%s"DELIM"%d"DELIM"%s"DELIM"%s"DELIM"%s", buf, sizeof(buf), devID, host->m_devIDType, - devidStr, clientVersion, desc, model ); + devidStr, clientVersion, desc, model, osVers ); PGresult* result = PQexecParams( getThreadConn(), command, nParams, NULL, @@ -396,13 +397,13 @@ DBMgr::RegisterDevice( const DevID* host, int clientVersion, DevIDRelay DBMgr::RegisterDevice( const DevID* host ) { - return RegisterDevice( host, 0, NULL, NULL ); + return RegisterDevice( host, 0, NULL, NULL, NULL ); } bool DBMgr::UpdateDevice( DevIDRelay relayID, int clientVersion, const char* const desc, const char* const model, - bool check ) + const char* const osVers, bool check ) { bool exists = !check; if ( !exists ) { @@ -420,6 +421,9 @@ DBMgr::UpdateDevice( DevIDRelay relayID, int clientVersion, if ( NULL != model && '\0' != model[0] ) { query.printf( ", model='%s'", model ); } + if ( NULL != osVers && '\0' != osVers[0] ) { + query.printf( ", osvers='%s'", osVers ); + } query.printf( " WHERE id = %d", relayID ); execSql( query ); } @@ -429,7 +433,7 @@ DBMgr::UpdateDevice( DevIDRelay relayID, int clientVersion, bool DBMgr::UpdateDevice( DevIDRelay relayID ) { - return UpdateDevice( relayID, 0, NULL, NULL, false ); + return UpdateDevice( relayID, 0, NULL, NULL, NULL, false ); } HostID diff --git a/xwords4/relay/dbmgr.h b/xwords4/relay/dbmgr.h index 95c982f6b..c0d5c8538 100644 --- a/xwords4/relay/dbmgr.h +++ b/xwords4/relay/dbmgr.h @@ -88,10 +88,11 @@ class DBMgr { DevIDRelay RegisterDevice( const DevID* host ); DevIDRelay RegisterDevice( const DevID* host, int clientVersion, - const char* const desc, const char* const model ); + const char* const desc, const char* const model, + const char* const osVers ); bool UpdateDevice( DevIDRelay relayID, int clientVersion, const char* const desc, const char* const model, - bool check ); + const char* const osVers, bool check ); HostID AddDevice( const char* const connName, HostID curID, int clientVersion, int nToAdd, unsigned short seed, const AddrInfo* addr, diff --git a/xwords4/relay/xwrelay.cpp b/xwords4/relay/xwrelay.cpp index 5ac91338e..6ab66005c 100644 --- a/xwords4/relay/xwrelay.cpp +++ b/xwords4/relay/xwrelay.cpp @@ -1484,7 +1484,7 @@ addRegID( uint8_t* ptr, DevIDRelay relayID ) static void registerDevice( const DevID* devID, const AddrInfo* addr, int clientVers, - string& devDesc, string& model ) + string& devDesc, string& model, string& osVers ) { DevIDRelay relayID; DBMgr* dbMgr = DBMgr::Get(); @@ -1494,7 +1494,7 @@ registerDevice( const DevID* devID, const AddrInfo* addr, int clientVers, if ( ID_TYPE_RELAY == devID->m_devIDType ) { // known to us; just update the time relayID = devID->asRelayID(); if ( dbMgr->UpdateDevice( relayID, clientVers, devDesc.c_str(), - model.c_str(), true ) ) { + model.c_str(), osVers.c_str(), true ) ) { int nMsgs = dbMgr->CountStoredMessages( relayID ); if ( 0 < nMsgs ) { send_havemsgs( addr ); @@ -1507,7 +1507,7 @@ registerDevice( const DevID* devID, const AddrInfo* addr, int clientVers, } } else { relayID = dbMgr->RegisterDevice( devID, clientVers, devDesc.c_str(), - model.c_str() ); + model.c_str(), osVers.c_str() ); } if ( DBMgr::DEVID_NONE != relayID ) { @@ -1629,11 +1629,13 @@ handle_udp_packet( UdpThreadClosure* utc ) uint16_t clientVers; string devDesc; string model; + string osVers; if ( getNetShort( &ptr, end, &clientVers ) && getVLIString( &ptr, end, devDesc ) - && getVLIString( &ptr, end, model ) ) { + && getVLIString( &ptr, end, model ) + && getVLIString( &ptr, end, osVers ) ) { registerDevice( &devID, utc->addr(), clientVers, - devDesc, model ); + devDesc, model, osVers ); } } break; diff --git a/xwords4/relay/xwrelay.sh b/xwords4/relay/xwrelay.sh index a3652548a..a7af5aa03 100755 --- a/xwords4/relay/xwrelay.sh +++ b/xwords4/relay/xwrelay.sh @@ -86,6 +86,7 @@ id INTEGER UNIQUE PRIMARY KEY ,versDesc TEXT ,devid TEXT ,model TEXT +,osvers TEXT ,ctime TIMESTAMP DEFAULT CURRENT_TIMESTAMP ,mtime TIMESTAMP ,unreg BOOLEAN DEFAULT FALSE