Added SILC Thread Queue API
[runtime.git] / apps / irssi / src / core / chat-protocols.h
1 #ifndef __CHAT_PROTOCOLS_H
2 #define __CHAT_PROTOCOLS_H
3
4 struct _CHAT_PROTOCOL_REC {
5         int id;
6
7         unsigned int not_initialized:1;
8         unsigned int case_insensitive:1;
9
10         char *name;
11         char *fullname;
12         char *chatnet;
13
14         CHATNET_REC *(*create_chatnet) (void);
15         SERVER_SETUP_REC *(*create_server_setup) (void);
16         CHANNEL_SETUP_REC *(*create_channel_setup) (void);
17         SERVER_CONNECT_REC *(*create_server_connect) (void);
18         void (*destroy_server_connect) (SERVER_CONNECT_REC *);
19
20         SERVER_REC *(*server_init_connect) (SERVER_CONNECT_REC *);
21         void (*server_connect) (SERVER_REC *);
22         CHANNEL_REC *(*channel_create) (SERVER_REC *, const char *,
23                                         const char *, int);
24         QUERY_REC *(*query_create) (const char *, const char *, int);
25 };
26
27 extern GSList *chat_protocols;
28
29 #define PROTO_CHECK_CAST(object, cast, type_field, id) \
30         ((cast *) chat_protocol_check_cast(object, \
31                                 offsetof(cast, type_field), id))
32 void *chat_protocol_check_cast(void *object, int type_pos, const char *id);
33
34 #define CHAT_PROTOCOL(object) \
35         ((object) == NULL ? chat_protocol_get_default() : \
36         chat_protocol_find_id((object)->chat_type))
37
38 /* Register new chat protocol. */
39 CHAT_PROTOCOL_REC *chat_protocol_register(CHAT_PROTOCOL_REC *rec);
40
41 /* Unregister chat protocol. */
42 void chat_protocol_unregister(const char *name);
43
44 /* Find functions */
45 int chat_protocol_lookup(const char *name);
46 CHAT_PROTOCOL_REC *chat_protocol_find(const char *name);
47 CHAT_PROTOCOL_REC *chat_protocol_find_id(int id);
48 CHAT_PROTOCOL_REC *chat_protocol_find_net(GHashTable *optlist);
49
50 /* Default chat protocol to use */
51 void chat_protocol_set_default(CHAT_PROTOCOL_REC *rec);
52 CHAT_PROTOCOL_REC *chat_protocol_get_default(void);
53
54 /* Return "unknown chat protocol" record. Used when protocol name is
55    specified but it isn't registered yet. */
56 CHAT_PROTOCOL_REC *chat_protocol_get_unknown(const char *name);
57
58 void chat_protocols_init(void);
59 void chat_protocols_deinit(void);
60
61 #endif