ekg2  GIT master
 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 <glib.h>
26 
27 #include "dynstuff.h"
28 #include "sessions.h"
29 #include <stdarg.h>
30 #include <time.h>
31 #include <stdlib.h> /* size_t */
32 #include <sys/types.h> /* off_t */
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 #define EKG_FORMAT_RGB_MASK 0x00ffffffL /* 0x00BBGGRR */
39 #define EKG_FORMAT_R_MASK 0x00ff0000L
40 #define EKG_FORMAT_G_MASK 0x0000ff00L
41 #define EKG_FORMAT_B_MASK 0x000000ffL
42 #define EKG_FORMAT_COLOR 0x01000000L
43 #define EKG_FORMAT_BOLD 0x02000000L
44 #define EKG_FORMAT_ITALIC 0x04000000L
45 #define EKG_FORMAT_UNDERLINE 0x08000000L
46 #define EKG_FORMAT_REVERSE 0x10000000L
47 
48 #define EKG_NO_THEMEBIT 256
49 
50 enum msgack_t {
51  EKG_ACK_DELIVERED = 0, /* message delivered successfully */
52  EKG_ACK_QUEUED, /* message queued for delivery */
53  EKG_ACK_DROPPED, /* message rejected 'permamently' */
54  EKG_ACK_TEMPFAIL, /* temporary delivery failure */
55  EKG_ACK_UNKNOWN, /* delivery status unknown */
56 
57  EKG_ACK_MAX /* we don't want to read after array */
58 };
59 
60 typedef enum {
61  EKG_DISCONNECT_USER = 0, /* user-engaged disconnect */
62  EKG_DISCONNECT_NETWORK, /* network problems */
63  EKG_DISCONNECT_FORCED, /* server forced to disconnect */
64  EKG_DISCONNECT_FAILURE, /* connecting failed */
65  EKG_DISCONNECT_STOPPED /* connecting canceled */
66 } disconnect_t;
67 
68 #define EKG_NO_BEEP 0
69 #define EKG_TRY_BEEP 1
70 
71 typedef enum {
72  /* recv */
73  EKG_MSGCLASS_MESSAGE = 0, /* single message */
74  EKG_MSGCLASS_CHAT, /* chat message */
75  EKG_MSGCLASS_SYSTEM, /* system message */
76  EKG_MSGCLASS_LOG, /* old logged message (used by logsqlite 'last_print_on_open') */
77 
78  EKG_MSGCLASS_NOT2US = 16, /* message is not to us */
79 
80  /* sent */
81  EKG_MSGCLASS_SENT = 32, /* single sent message */
82  EKG_MSGCLASS_SENT_CHAT, /* chat sent message */
83  EKG_MSGCLASS_SENT_LOG, /* old logged message (used by logsqlite 'last_print_on_open') */
84  /* priv */
85  EKG_MSGCLASS_PRIV_STATUS= 64 /* used by logs */
86 } msgclass_t;
87 
88 #ifndef EKG2_WIN32_NOFUNCTION
89 void protocol_init();
90 
91 char *message_print(const char *session, const char *sender, const char **rcpts, const char *text, const guint32 *format,
92  time_t sent, int mclass, const char *seq, int dobeep, int secure);
93 
95 int protocol_disconnected_emit(const session_t *s, const char *reason, int type);
96 int protocol_message_ack_emit(const session_t *s, const char *rcpt, const char *seq, int status);
97 int protocol_message_emit(const session_t *s, const char *uid, char **rcpts, const char *text, const guint32 *format, time_t sent, int mclass, const char *seq, int dobeep, int secure);
98 int protocol_status_emit(const session_t *s, const char *uid, int status, char *descr, time_t when);
99 int protocol_xstate_emit(const session_t *s, const char *uid, int state, int offstate);
100 
101 char *protocol_uid(const char *proto, const char *target); /* XXX ? */
102 #endif
103 
104 typedef enum {
105  DCC_NONE = 0,
109 } dcc_type_t;
110 
111 struct dcc_s;
112 
113 typedef void (*dcc_close_handler_t)(struct dcc_s *);
114 
115 typedef struct dcc_s {
116  struct dcc_s *next;
117 
118  session_t *session; /* ktora sesja? */
119  char *uid; /* z kim połączenie */
120  dcc_type_t type; /* rodzaj połączenia */
121  int id; /* numer połączenia */
122  void *priv; /* dane prywatne pluginu */
123  dcc_close_handler_t close_handler; /* obsługa /dcc close */
124  unsigned int active : 1; /* czy połączono? */
125  time_t started; /* kiedy utworzono? */
126 
127  char *filename; /* nazwa pliku */
128  size_t size; /* rozmiar pliku */
129  off_t offset; /* ile już wykonano */
130 } dcc_t;
131 
132 #ifndef EKG2_WIN32_NOFUNCTION
133 dcc_t *dcc_add(session_t *session, const char *uid, dcc_type_t type, void *priv);
134 int dcc_close(dcc_t *d);
135 
136 int dcc_private_set(dcc_t *, void *);
137 void *dcc_private_get(dcc_t *);
140 const char *dcc_uid_get(dcc_t *);
141 int dcc_id_get(dcc_t *);
142 time_t dcc_started_get(dcc_t *);
143 int dcc_active_set(dcc_t *, int);
144 int dcc_active_get(dcc_t *);
145 int dcc_offset_set(dcc_t *, int);
146 int dcc_offset_get(dcc_t *);
147 int dcc_size_set(dcc_t *, int);
148 int dcc_size_get(dcc_t *);
149 int dcc_filename_set(dcc_t *, const char *);
150 const char *dcc_filename_get(dcc_t *);
152 
153 extern dcc_t *dccs;
154 
155 #endif
156 
157 #ifdef __cplusplus
158 }
159 #endif
160 
161 #endif /* __EKG_PROTOCOL_H */
162 
163 /*
164  * Local Variables:
165  * mode: c
166  * c-file-style: "k&r"
167  * c-basic-offset: 8
168  * indent-tabs-mode: t
169  * End:
170  */