2016-08-26 16:26:33 +02:00
|
|
|
/* -*- compile-command: "make MEMDEBUG=TRUE -j5"; -*- */
|
2013-01-06 01:08:19 +01:00
|
|
|
/*
|
2016-08-26 16:26:33 +02:00
|
|
|
* Copyright 2000 - 2016 by Eric House (xwords@eehouse.org). All rights
|
2013-01-06 01:08:19 +01:00
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GAMESDB_H_
|
|
|
|
#define _GAMESDB_H_
|
|
|
|
|
|
|
|
#include <sqlite3.h>
|
2013-01-06 04:40:29 +01:00
|
|
|
#include <glib.h>
|
2013-01-06 01:08:19 +01:00
|
|
|
|
2013-01-06 04:40:29 +01:00
|
|
|
#include "main.h"
|
2013-01-06 01:08:47 +01:00
|
|
|
#include "comtypes.h"
|
|
|
|
|
2013-01-09 15:30:52 +01:00
|
|
|
typedef struct _GameInfo {
|
|
|
|
XP_UCHAR name[128];
|
|
|
|
XP_UCHAR room[128];
|
2014-11-03 02:25:56 +01:00
|
|
|
XP_UCHAR conn[128];
|
2017-10-21 23:59:10 +02:00
|
|
|
XP_UCHAR relayID[32];
|
2016-12-22 17:57:54 +01:00
|
|
|
#ifdef PLATFORM_GTK
|
2016-08-05 17:29:25 +02:00
|
|
|
GdkPixbuf* snap;
|
2016-12-22 17:57:54 +01:00
|
|
|
#endif
|
2013-12-16 17:06:29 +01:00
|
|
|
XP_U32 gameID;
|
2013-01-09 15:30:52 +01:00
|
|
|
XP_S16 nMoves;
|
|
|
|
XP_Bool gameOver;
|
2016-08-26 16:26:33 +02:00
|
|
|
XP_Bool turnLocal;
|
2013-01-09 15:30:52 +01:00
|
|
|
XP_S16 turn;
|
2015-07-07 05:28:16 +02:00
|
|
|
XP_U16 nTotal;
|
2013-01-09 15:30:52 +01:00
|
|
|
XP_S16 nMissing;
|
2013-07-12 05:01:17 +02:00
|
|
|
XP_U16 seed;
|
2016-07-25 17:28:37 +02:00
|
|
|
XP_U32 lastMoveTime;
|
2013-01-09 15:30:52 +01:00
|
|
|
} GameInfo;
|
|
|
|
|
2013-01-07 17:00:47 +01:00
|
|
|
sqlite3* openGamesDB( const char* dbName );
|
2013-01-06 01:08:19 +01:00
|
|
|
void closeGamesDB( sqlite3* dbp );
|
|
|
|
|
2013-01-06 01:08:47 +01:00
|
|
|
void writeToDB( XWStreamCtxt* stream, void* closure );
|
2015-07-07 05:28:16 +02:00
|
|
|
sqlite3_int64 writeNewGameToDB( XWStreamCtxt* stream, sqlite3* pDb );
|
|
|
|
|
2013-01-09 15:30:52 +01:00
|
|
|
void summarize( CommonGlobals* cGlobals );
|
2013-01-06 01:08:47 +01:00
|
|
|
|
2013-01-06 04:40:29 +01:00
|
|
|
/* Return GSList whose data is (ptrs to) rowids */
|
2013-01-24 16:49:49 +01:00
|
|
|
GSList* listGames( sqlite3* dbp );
|
2017-10-22 18:29:15 +02:00
|
|
|
/* Mapping of relayID -> rowid */
|
|
|
|
GHashTable* getRelayIDsToRowsMap( sqlite3* pDb );
|
2017-10-22 01:05:54 +02:00
|
|
|
|
2013-01-24 16:49:49 +01:00
|
|
|
XP_Bool getGameInfo( sqlite3* dbp, sqlite3_int64 rowid, GameInfo* gib );
|
2013-12-16 17:06:29 +01:00
|
|
|
void getRowsForGameID( sqlite3* dbp, XP_U32 gameID, sqlite3_int64* rowids,
|
|
|
|
int* nRowIDs );
|
2013-01-06 06:01:26 +01:00
|
|
|
XP_Bool loadGame( XWStreamCtxt* stream, sqlite3* pDb, sqlite3_int64 rowid );
|
2015-07-07 05:28:16 +02:00
|
|
|
void saveInviteAddrs( XWStreamCtxt* stream, sqlite3* pDb,
|
|
|
|
sqlite3_int64 rowid );
|
|
|
|
XP_Bool loadInviteAddrs( XWStreamCtxt* stream, sqlite3* pDb,
|
|
|
|
sqlite3_int64 rowid );
|
2013-01-17 06:11:35 +01:00
|
|
|
void deleteGame( sqlite3* pDb, sqlite3_int64 rowid );
|
2013-01-06 04:40:29 +01:00
|
|
|
|
2013-01-16 15:46:33 +01:00
|
|
|
#define KEY_RDEVID "RDEVID"
|
2013-09-15 06:06:14 +02:00
|
|
|
#define KEY_LDEVID "LDEVID"
|
2013-12-12 15:08:56 +01:00
|
|
|
#define KEY_SMSPHONE "SMSPHONE"
|
2013-12-19 17:00:04 +01:00
|
|
|
#define KEY_SMSPORT "SMSPORT"
|
2016-08-06 03:31:17 +02:00
|
|
|
#define KEY_WIN_LOC "WIN_LOC"
|
2013-01-16 15:46:33 +01:00
|
|
|
|
2013-01-19 23:37:49 +01:00
|
|
|
void db_store( sqlite3* dbp, const gchar* key, const gchar* value );
|
2013-01-29 16:42:10 +01:00
|
|
|
XP_Bool db_fetch( sqlite3* dbp, const gchar* key, gchar* buf, gint buflen );
|
2013-01-19 23:37:49 +01:00
|
|
|
void db_remove( sqlite3* dbp, const gchar* key );
|
2013-01-16 15:46:33 +01:00
|
|
|
|
2013-01-06 01:08:19 +01:00
|
|
|
#endif
|