summaryrefslogtreecommitdiff
path: root/data.h
blob: 68a4b9b670f352292ea5cca7fe44ed3831b705f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef DATA_H
#define DATA_H

// https://www.rfc-editor.org/rfc/rfc6121#section-2.1.2.5
typedef enum {
	SUB_NONE,
	SUB_TO,
	SUB_FROM,
	SUB_BOTH
} subscription_t;

typedef struct _message_t {
	char* content;
	char* sender_jid;
	char* recipient_jid;
	struct _message_t* next;
	void* widget;
} message_t;

typedef struct _chat_t {
	char* jid;
	message_t* messages;
	void* widget;
} chat_t;

typedef struct _roster_item_t {
	char* name;  // could be NULL
	char* jid;
	subscription_t sub;
	chat_t* chat;
	struct _roster_item_t* next;
	void* widget;
} roster_item_t;

void data_add_roster_item(const char* jid, const char* subscription,
                          const char* name);
void data_add_incoming_message(const char* sender_jid, const char* content);
void data_add_outgoing_message(const char* sender_jid, const char* content,
                               chat_t* chat);
#endif