ekg2  GIT master
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 *);
151 dcc_type_t dcc_type_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  */
Definition: protocol.h:76
dcc_type_t type
Definition: protocol.h:120
int dcc_offset_set(dcc_t *, int)
Definition: protocol.c:1063
int dcc_offset_get(dcc_t *)
Definition: protocol.c:1063
Definition: sessions.h:127
Definition: protocol.h:107
size_t size
Definition: protocol.h:128
Definition: protocol.h:51
dcc_close_handler_t close_handler
Definition: protocol.h:123
Definition: protocol.h:74
Definition: protocol.h:73
unsigned int active
Definition: protocol.h:124
Definition: ekg_hash_benchmark.c:47
Definition: protocol.h:63
Definition: protocol.h:81
void(* dcc_close_handler_t)(struct dcc_s *)
Definition: protocol.h:113
off_t offset
Definition: protocol.h:129
char * uid
Definition: protocol.h:119
Definition: protocol.h:54
int dcc_filename_set(dcc_t *, const char *)
Definition: protocol.c:1062
session_t * session
Definition: protocol.h:118
Definition: protocol.h:75
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)
Definition: protocol.c:861
Definition: protocol.h:85
time_t started
Definition: protocol.h:125
Definition: protocol.h:53
int protocol_xstate_emit(const session_t *s, const char *uid, int state, int offstate)
Definition: protocol.c:979
int protocol_disconnected_emit(const session_t *s, const char *reason, int type)
Definition: protocol.c:236
dcc_type_t dcc_type_get(dcc_t *)
Definition: protocol.c:1070
void * dcc_private_get(dcc_t *)
Definition: protocol.c:1067
const char * dcc_filename_get(dcc_t *)
Definition: protocol.c:1062
msgack_t
Definition: protocol.h:50
disconnect_t
Definition: protocol.h:60
void * priv
Definition: protocol.h:122
Definition: protocol.h:62
int protocol_message_ack_emit(const session_t *s, const char *rcpt, const char *seq, int status)
Definition: protocol.c:926
guint32 sender
Definition: sniff_gg.h:166
struct dcc_s dcc_t
dcc_t * dccs
Definition: protocol.c:40
Definition: protocol.h:52
Definition: protocol.h:57
Definition: protocol.h:83
int dcc_id_get(dcc_t *)
Definition: protocol.c:1066
Definition: protocol.h:108
char * message_print(const char *session, const char *sender, const char **rcpts, const char *text, const guint32 *format, time_t sent, int mclass, const char *seq, int dobeep, int secure)
Definition: protocol.c:511
Definition: protocol.h:115
Definition: protocol.h:106
int dcc_close(dcc_t *d)
Definition: protocol.c:1052
int dcc_size_get(dcc_t *)
Definition: protocol.c:1064
int dcc_size_set(dcc_t *, int)
Definition: protocol.c:1064
dcc_t * dcc_add(session_t *session, const char *uid, dcc_type_t type, void *priv)
Definition: protocol.c:1019
void protocol_init()
Definition: protocol.c:67
Definition: protocol.h:55
Definition: protocol.h:65
Definition: protocol.h:105
char * filename
Definition: protocol.h:127
int protocol_status_emit(const session_t *s, const char *uid, int status, char *descr, time_t when)
Definition: protocol.c:492
int id
Definition: protocol.h:121
Definition: protocol.h:78
Definition: protocol.h:64
int dcc_close_handler_set(dcc_t *, dcc_close_handler_t)
Definition: protocol.c:1061
int dcc_active_set(dcc_t *, int)
Definition: protocol.c:1069
int dcc_active_get(dcc_t *)
Definition: protocol.c:1069
const char * dcc_uid_get(dcc_t *)
Definition: protocol.c:1065
#define s
msgclass_t
Definition: protocol.h:71
dcc_type_t
Definition: protocol.h:104
dcc_close_handler_t dcc_close_handler_get(dcc_t *)
Definition: protocol.c:1061
char * protocol_uid(const char *proto, const char *target)
Definition: protocol.c:994
int dcc_private_set(dcc_t *, void *)
Definition: protocol.c:1067
Definition: protocol.h:82
int protocol_connected_emit(const session_t *s)
Definition: protocol.c:295
Definition: protocol.h:61
time_t dcc_started_get(dcc_t *)
Definition: protocol.c:1068
struct dcc_s * next
Definition: protocol.h:116
guint32 seq
Definition: sniff_gg.h:167