/*
webchat, an HTML5/websocket chat platform
Copyright (C) 2015
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, version 3 of the License.
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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
*/
#define PRIV_PLAYMEDIA 1 // Play youtube videos
#define PRIV_CLOSECAM 2 // Close frozen, asleep or inappropriate cams
#define PRIV_TOPIC 4 // Set the channel topic
#define PRIV_KICK 8 // Kick or ban trolls/creeps
#define PRIV_SETMODS 16 // Add/remove mods, set privileges
#define PRIV_PASSWORD 32 // Change the channel password (TODO: Override entrance for mods? only some mods?)
#define PRIV_ALL 63
// Idea: privilege to temporarily mod users with e.g. PLAYMEDIA, CLOSECAM, TOPIC and KICK privileges
extern void db_init(void);
extern void db_shutdown(void);
extern char db_findchannel(const char* name, int* id, char** password);
extern char db_finduser(const char* name, int* id, char** password, char** salt);
extern int db_getmod(int channel, int user);
extern char db_setchannelpassword(const char* channel, const char* password);
extern void db_mkhash(const char* password, const char* salt, char output[129]);
extern char db_setuserpassword(const char* user, const char* password);
extern char db_createuser(const char* user, const char* password);
extern char db_addmod(int channel, int user, int privileges);
extern char db_removemod(int channel, int user);
extern char db_changemod(int channel, int user, int privileges);
extern void db_listmods(int channel, void(*modcallback)(int userid, int privileges));
extern char* db_getusername(int userid); // Caller will need to free the returned string
extern char db_createchannel(const char* channel);
extern char db_removechannel(const char* channel);
// TODO: function to remove account too? though this brings up questions about how to deal with sole channel owners