Merged silc_1_0_branch to trunk.
[silc.git] / apps / irssi / src / silc / core / silc-servers.h
1 #ifndef __SILC_SERVER_H
2 #define __SILC_SERVER_H
3
4 #include "chat-protocols.h"
5 #include "servers.h"
6
7 /* returns SILC_SERVER_REC if it's SILC server, NULL if it isn't */
8 #define SILC_SERVER(server) \
9         PROTO_CHECK_CAST(SERVER(server), SILC_SERVER_REC, chat_type, "SILC")
10 #define SILC_SERVER_CONNECT(conn) \
11         PROTO_CHECK_CAST(SERVER_CONNECT(conn), SILC_SERVER_CONNECT_REC, \
12                          chat_type, "SILC")
13 #define IS_SILC_SERVER(server) \
14         (SILC_SERVER(server) ? TRUE : FALSE)
15 #define IS_SILC_SERVER_CONNECT(conn) \
16         (SILC_SERVER_CONNECT(conn) ? TRUE : FALSE)
17
18 /* all strings should be either NULL or dynamically allocated */
19 /* address and nick are mandatory, rest are optional */
20 typedef struct {
21 #include "server-connect-rec.h"
22 } SILC_SERVER_CONNECT_REC;
23
24 typedef struct {
25   SilcClientEntry client_entry;
26   SilcClientConnection conn;
27   SilcUInt32 session_id;
28   char *filepath;
29   bool send;
30
31   long starttime;               /* Start time of transfer */
32   double kps;                   /* Kilos per second */
33   SilcUInt64 offset;            /* Current offset */
34   SilcUInt64 filesize;          /* Total file size */
35   SilcUInt32 percent;           /* Percent of current transmission */
36 } *FtpSession;
37
38 #define STRUCT_SERVER_CONNECT_REC SILC_SERVER_CONNECT_REC
39 typedef struct {
40 #include "server-rec.h"
41
42   SilcDList ftp_sessions;
43   FtpSession current_session;
44   
45   gpointer chanqueries;
46   SilcClientConnection conn;
47   SilcUInt32 umode;
48 } SILC_SERVER_REC;
49
50 SERVER_REC *silc_server_init_connect(SERVER_CONNECT_REC *conn);
51 void silc_server_connect(SERVER_REC *server);
52
53 /* Return a string of all channels in server in server->channels_join() 
54    format */
55 char *silc_server_get_channels(SILC_SERVER_REC *server);
56 void silc_command_exec(SILC_SERVER_REC *server,
57                        const char *command, const char *args);
58 void silc_server_init(void);
59 void silc_server_deinit(void);
60 void silc_server_free_ftp(SILC_SERVER_REC *server,
61                           SilcClientEntry client_entry);
62 bool silc_term_utf8(void);
63
64 int silc_send_msg(SILC_SERVER_REC *server, char *nick, char *msg,
65                   int msg_len, SilcMessageFlags flags);
66 int silc_send_channel(SILC_SERVER_REC *server,
67                       char *channel, char *msg,
68                       SilcMessageFlags flags);
69 #endif