1309
|
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
2
|
|
3 /*
|
|
4 * $Id: icqevent.h 1319 2000-12-19 10:08:29Z warmenhoven $
|
|
5 *
|
|
6 * $Log$
|
|
7 * Revision 1.1 2000/12/19 10:08:29 warmenhoven
|
|
8 * Yay, new icqlib
|
|
9 *
|
|
10 * Revision 1.2 2000/06/15 18:54:09 bills
|
|
11 * added time attribute and handleEvent function pointer to icq_Event,
|
|
12 * renamed icq_ChatEvent to icq_ChatRequestEvent, renamed icq_FileEvent to
|
|
13 * icq_FileRequestEvent, added icq_URLEvent and related methods
|
|
14 *
|
|
15 * Revision 1.1 2000/06/15 15:27:39 bills
|
|
16 * committed for safekeeping - this code will soon replace stdpackets.c and
|
|
17 * greatly simplify tcphandle.c, as well as reducing code duplication in many
|
|
18 * places. it provides a much more flexible framework for managing events
|
|
19 * and parsing and creating packets
|
|
20 *
|
|
21 */
|
|
22
|
|
23 #ifndef _ICQEVENT_H
|
|
24 #define _ICQEVENT_H
|
|
25
|
|
26 #ifdef HAVE_CONFIG_H
|
|
27 #include <config.h>
|
|
28 #endif
|
|
29
|
|
30 #include <time.h>
|
|
31
|
|
32 #include "icqpacket.h"
|
|
33 #include "tcplink.h"
|
|
34 #include "stdpackets.h"
|
|
35
|
|
36 #define EVENT_DEBUG
|
|
37
|
|
38 #define ICQ_EVENT_MESSAGE ICQ_TCP_MESSAGE
|
|
39 #define ICQ_EVENT_ACK ICQ_TCP_ACK
|
|
40 #define ICQ_EVENT_CANCEL ICQ_TCP_CANCEL
|
|
41
|
|
42 #define ICQ_EVENT_INCOMING 1
|
|
43 #define ICQ_EVENT_OUTGOING 2
|
|
44
|
|
45 typedef struct icq_Event_s {
|
|
46
|
|
47 unsigned long version;
|
|
48 unsigned long id;
|
|
49 unsigned long uin;
|
|
50
|
|
51 int type; /* chat, file, message, url */
|
|
52 int subtype; /* message, ack, or cancel */
|
|
53
|
|
54 int direction;
|
|
55 time_t time;
|
|
56
|
|
57 icq_Packet *(*createPacket)(struct icq_Event_s *, icq_TCPLink *);
|
|
58 void (*handleEvent)(struct icq_Event_s *, ICQLINK *);
|
|
59
|
|
60 #ifdef EVENT_DEBUG
|
|
61 const char *(*eventName)(struct icq_Event_s *);
|
|
62 const char *(*eventDump)(struct icq_Event_s *);
|
|
63 #endif
|
|
64
|
|
65 } icq_Event;
|
|
66
|
|
67 typedef struct icq_MessageEvent_s {
|
|
68
|
|
69 icq_Event event;
|
|
70
|
|
71 char *message; /* must be non-const for url hack */
|
|
72 char *url; /* hack so we can use same structure for url */
|
|
73 int status;
|
|
74 int type;
|
|
75
|
|
76 } icq_MessageEvent;
|
|
77
|
|
78 typedef struct icq_MessageEvent_s icq_URLEvent;
|
|
79
|
|
80 typedef struct icq_ChatRequestEvent_s {
|
|
81
|
|
82 icq_MessageEvent message_event;
|
|
83
|
|
84 int port;
|
|
85
|
|
86 } icq_ChatRequestEvent;
|
|
87
|
|
88 typedef struct icq_FileRequestEvent_s {
|
|
89
|
|
90 icq_MessageEvent message_event;
|
|
91
|
|
92 const char *filename;
|
|
93 unsigned long filesize;
|
|
94 int port;
|
|
95
|
|
96 } icq_FileRequestEvent;
|
|
97
|
|
98 /* generic event functions */
|
|
99 void icq_EventInit(icq_Event *p, int type, int subtype, unsigned long uin,
|
|
100 int version);
|
|
101 icq_Packet *icq_EventCreatePacket(icq_Event *pbase);
|
|
102 void icq_EventParsePacket(icq_Event *pevent, icq_Packet *p);
|
|
103
|
|
104 /* message event functions */
|
|
105 icq_MessageEvent *icq_CreateMessageEvent(int subtype, unsigned long uin,
|
|
106 const char *message);
|
|
107 void icq_MessageEventInit(icq_MessageEvent *p, int type, int subtype,
|
|
108 unsigned long uin, int msgtype, const char *message);
|
|
109 icq_Packet *icq_MessageCreatePacket(icq_Event *pbase, icq_TCPLink *plink);
|
|
110 void icq_MessageParsePacket(icq_Event *pbase, icq_Packet *p);
|
|
111
|
|
112 /* url event functions */
|
|
113 icq_URLEvent *icq_CreateURLEvent(int subtype, unsigned long uin,
|
|
114 const char *message, const char *url);
|
|
115 icq_Packet *icq_URLCreatePacket(icq_Event *pbase, icq_TCPLink *plink);
|
|
116 void icq_URLParsePacket(icq_Event *pbase, icq_Packet *p);
|
|
117
|
|
118 /* chat request event functions */
|
|
119 icq_ChatRequestEvent *icq_ChatRequestEventNew(int subtype,
|
|
120 unsigned long uin, const char *message, int port);
|
|
121 icq_Packet *icq_ChatRequestCreatePacket(icq_Event *pbase,
|
|
122 icq_TCPLink *plink);
|
|
123 void icq_ChatParsePacket(icq_Event *pbase, icq_Packet *p);
|
|
124
|
|
125 /* file request event functions */
|
|
126 icq_FileRequestEvent *icq_FileRequestEventNew(int subtype,
|
|
127 unsigned long uin, const char *message, const char *filename,
|
|
128 unsigned long filesize);
|
|
129 icq_Packet *icq_FileRequestCreatePacket(icq_Event *pbase,
|
|
130 icq_TCPLink *plink);
|
|
131 void icq_FileParsePacket(icq_Event *pbase, icq_Packet *p);
|
|
132
|
|
133 /* main packet parser */
|
|
134 icq_Event *icq_ParsePacket(icq_Packet *p);
|
|
135
|
|
136 #ifdef EVENT_DEBUG
|
|
137 const char *icq_MessageEventName(icq_Event *p);
|
|
138 const char *icq_MessageEventDump(icq_Event *p);
|
|
139 const char *icq_URLEventName(icq_Event *p);
|
|
140 const char *icq_URLEventDump(icq_Event *p);
|
|
141 const char *icq_ChatRequestEventName(icq_Event *p);
|
|
142 const char *icq_ChatRequestEventDump(icq_Event *p);
|
|
143 const char *icq_FileRequestEventName(icq_Event *p);
|
|
144 const char *icq_FileRequestEventDump(icq_Event *p);
|
|
145 const char *icq_EventDump(icq_Event *p);
|
|
146 #endif
|
|
147
|
|
148 #endif /* _ICQEVENT_H */
|