/*
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 .
*/
#include
#include
#include "../libwebsocket/websock.h"
#define use_tls 1
struct channel;
enum bincmd_type
{
bincmd_none,
bincmd_media
};
enum relationtype
{
relation_media=0,
relation_media_receiver
};
struct relation
{
struct user* user;
enum relationtype type;
};
struct user
{
#ifdef use_tls
gnutls_session_t socket;
#else
int* socket;
#endif
int rawsocket;
char handshake;
char* nickname;
char color[7];
struct channel* channel;
enum bincmd_type bincmd; // For multipart commands
struct relation* relations;
unsigned int relationcount;
char broadcasting;
void* firstmedia;
unsigned int firstmedialength;
char httpcam;
char* account;
int modprivileges;
struct sockaddr sockaddr;
struct
{
struct websock_head head;
char* data;
} packet;
};
extern unsigned int usercount;
extern struct user** users;
extern struct user* adduser(int socket, struct sockaddr* addr, socklen_t addrlen);
extern void freeuser(struct user* user);
extern void user_addrelation(struct user* a, struct user* b, enum relationtype type);
extern void user_removerelation(struct user* a, struct user* b, enum relationtype type);
extern void user_removerelations(struct user* user, enum relationtype type);
extern char user_login(struct user* user, const char* username, const char* password);
extern void user_sendmodmsg(struct user* user);