ekg2
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje Grupay Strony
protocol.h
Idź do dokumentacji tego pliku.
1 /* $Id$ */
2 
3 /*
4  * (C) Copyright 2003 Wojtek Kaniewski <wojtekka@irc.pl>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License Version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #ifndef __EKG_PROTOCOL_H
21 #define __EKG_PROTOCOL_H
22 
23 #include "ekg2-config.h"
24 
25 #include "dynstuff.h"
26 #include "sessions.h"
27 #include <stdarg.h>
28 #include <stdint.h>
29 #include <time.h>
30 #include <stdlib.h> /* size_t */
31 #include <sys/types.h> /* off_t */
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #define EKG_FORMAT_RGB_MASK 0x00ffffffL /* 0x00BBGGRR */
38 #define EKG_FORMAT_R_MASK 0x00ff0000L
39 #define EKG_FORMAT_G_MASK 0x0000ff00L
40 #define EKG_FORMAT_B_MASK 0x000000ffL
41 #define EKG_FORMAT_COLOR 0x01000000L
42 #define EKG_FORMAT_BOLD 0x02000000L
43 #define EKG_FORMAT_ITALIC 0x04000000L
44 #define EKG_FORMAT_UNDERLINE 0x08000000L
45 #define EKG_FORMAT_REVERSE 0x10000000L
46 
47 #define EKG_NO_THEMEBIT 256
48 
49 enum msgack_t {
50  EKG_ACK_DELIVERED = 0, /* message delivered successfully */
51  EKG_ACK_QUEUED, /* message queued for delivery */
52  EKG_ACK_DROPPED, /* message rejected 'permamently' */
53  EKG_ACK_TEMPFAIL, /* temporary delivery failure */
54  EKG_ACK_UNKNOWN, /* delivery status unknown */
55 
56  EKG_ACK_MAX /* we don't want to read after array */
57 };
58 
59 typedef enum {
60  EKG_DISCONNECT_USER = 0, /* user-engaged disconnect */
61  EKG_DISCONNECT_NETWORK, /* network problems */
62  EKG_DISCONNECT_FORCED, /* server forced to disconnect */
63  EKG_DISCONNECT_FAILURE, /* connecting failed */
64  EKG_DISCONNECT_STOPPED /* connecting canceled */
65 } disconnect_t;
66 
67 #define EKG_NO_BEEP 0
68 #define EKG_TRY_BEEP 1
69 
70 typedef enum {
71  /* recv */
72  EKG_MSGCLASS_MESSAGE = 0, /* single message */
73  EKG_MSGCLASS_CHAT, /* chat message */
74  EKG_MSGCLASS_SYSTEM, /* system message */
75  EKG_MSGCLASS_LOG, /* old logged message (used by logsqlite 'last_print_on_open') */
76 
77  EKG_MSGCLASS_NOT2US = 16, /* message is not to us */
78 
79  /* sent */
80  EKG_MSGCLASS_SENT = 32, /* single sent message */
81  EKG_MSGCLASS_SENT_CHAT, /* chat sent message */
82  EKG_MSGCLASS_SENT_LOG, /* old logged message (used by logsqlite 'last_print_on_open') */
83  /* priv */
84  EKG_MSGCLASS_PRIV_STATUS= 64 /* used by logs */
85 } msgclass_t;
86 
87 #ifndef EKG2_WIN32_NOFUNCTION
88 void protocol_init();
89 
90 char *message_print(const char *session, const char *sender, const char **rcpts, const char *text, const uint32_t *format,
91  time_t sent, int mclass, const char *seq, int dobeep, int secure);
92 
94 int protocol_disconnected_emit(const session_t *s, const char *reason, int type);
95 int protocol_message_ack_emit(const session_t *s, const char *rcpt, const char *seq, int status);
96 int protocol_message_emit(const session_t *s, const char *uid, char **rcpts, const char *text, const uint32_t *format, time_t sent, int mclass, const char *seq, int dobeep, int secure);
97 int protocol_status_emit(const session_t *s, const char *uid, int status, char *descr, time_t when);
98 int protocol_xstate_emit(const session_t *s, const char *uid, int state, int offstate);
99 
100 char *protocol_uid(const char *proto, const char *target); /* XXX ? */
101 #endif
102 
103 typedef enum {
104  DCC_NONE = 0,
108 } dcc_type_t;
109 
110 struct dcc_s;
111 
112 typedef void (*dcc_close_handler_t)(struct dcc_s *);
113 
114 typedef struct dcc_s {
115  struct dcc_s *next;
116 
117  session_t *session; /* ktora sesja? */
118  char *uid; /* z kim połączenie */
119  dcc_type_t type; /* rodzaj połączenia */
120  int id; /* numer połączenia */
121  void *priv; /* dane prywatne pluginu */
122  dcc_close_handler_t close_handler; /* obsługa /dcc close */
123  unsigned int active : 1; /* czy połączono? */
124  time_t started; /* kiedy utworzono? */
125 
126  char *filename; /* nazwa pliku */
127  size_t size; /* rozmiar pliku */
128  off_t offset; /* ile już wykonano */
129 } dcc_t;
130 
131 #ifndef EKG2_WIN32_NOFUNCTION
132 dcc_t *dcc_add(session_t *session, const char *uid, dcc_type_t type, void *priv);
133 int dcc_close(dcc_t *d);
134 
135 int dcc_private_set(dcc_t *, void *);
136 void *dcc_private_get(dcc_t *);
139 const char *dcc_uid_get(dcc_t *);
140 int dcc_id_get(dcc_t *);
141 time_t dcc_started_get(dcc_t *);
142 int dcc_active_set(dcc_t *, int);
143 int dcc_active_get(dcc_t *);
144 int dcc_offset_set(dcc_t *, int);
145 int dcc_offset_get(dcc_t *);
146 int dcc_size_set(dcc_t *, int);
147 int dcc_size_get(dcc_t *);
148 int dcc_filename_set(dcc_t *, const char *);
149 const char *dcc_filename_get(dcc_t *);
151 
152 extern dcc_t *dccs;
153 
154 #endif
155 
156 #ifdef __cplusplus
157 }
158 #endif
159 
160 #endif /* __EKG_PROTOCOL_H */
161 
162 /*
163  * Local Variables:
164  * mode: c
165  * c-file-style: "k&r"
166  * c-basic-offset: 8
167  * indent-tabs-mode: t
168  * End:
169  */