mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-30 08:34:16 +01:00
supply in linux client, and look for and store on relay, os version
This commit is contained in:
parent
1cf676e86b
commit
c115752852
5 changed files with 25 additions and 16 deletions
|
@ -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 );
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue