annotate plugins/icq/icqevent.c @ 1522:31c0850f9340

[gaim-migrate @ 1532] this should fix a segfault or two committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 01 Mar 2001 10:05:18 +0000
parents 4c510ca3563f
children 8ed70631ed15
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1309
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 /*
1432
4c510ca3563f [gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1309
diff changeset
4 * $Id: icqevent.c 1442 2001-01-28 01:52:27Z warmenhoven $
1309
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 *
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * $Log$
1432
4c510ca3563f [gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1309
diff changeset
7 * Revision 1.2 2001/01/28 01:52:27 warmenhoven
4c510ca3563f [gaim-migrate @ 1442]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1309
diff changeset
8 * icqlib 1.1.5
1309
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 *
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * Revision 1.2 2000/06/15 18:54:09 bills
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * added time attribute and handleEvent function pointer to icq_Event,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * renamed icq_ChatEvent to icq_ChatRequestEvent, renamed icq_FileEvent to
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * icq_FileRequestEvent, added icq_URLEvent and related methods
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 *
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * Revision 1.1 2000/06/15 15:27:39 bills
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * committed for safekeeping - this code will soon replace stdpackets.c and
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * greatly simplify tcphandle.c, as well as reducing code duplication in many
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * places. it provides a much more flexible framework for managing events
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 * and parsing and creating packets
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 *
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 #include <stdlib.h>
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25 #include "icqevent.h"
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #include "icqbyteorder.h"
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #include <string.h>
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <stdio.h>
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 #define new_event(x, y) y * x = ( y * )malloc(sizeof(y))
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35 /* generic Event - 'header' for each tcp packet */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 void icq_EventInit(icq_Event *p, int type, int subtype, unsigned long uin,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 int version)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 if (!p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 return;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 p->uin=uin;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 p->version=version;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 p->type=type;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 p->subtype=subtype;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 p->direction=ICQ_EVENT_OUTGOING;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 icq_Packet *icq_EventCreatePacket(icq_Event *pbase)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 icq_Packet *p=icq_PacketNew();
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 /* create header for tcp packet */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 icq_PacketAppend32(p, pbase->uin);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 icq_PacketAppend16(p, pbase->version);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 icq_PacketAppend16(p, pbase->subtype);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 icq_PacketAppend16(p, 0x0000);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 icq_PacketAppend32(p, pbase->uin);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 icq_PacketAppend32(p, pbase->type);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 return p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 void icq_EventParsePacket(icq_Event *pevent, icq_Packet *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 /* parse header of tcp packet */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 icq_PacketBegin(p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 (void)icq_PacketRead32(p); /* uin */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 pevent->version=icq_PacketRead16(p); /* max supported tcp version */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 pevent->subtype=icq_PacketRead16(p); /* event subtype */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 (void)icq_PacketRead16(p); /* 0x0000 */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 pevent->uin=icq_PacketRead32(p); /* uin */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 pevent->type=icq_PacketRead16(p); /* event type */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 /* Message Event - extends generic Event */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 icq_MessageEvent *icq_CreateMessageEvent(int subtype, unsigned long uin,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 const char *message)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 new_event(p, icq_MessageEvent);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 icq_Event *pbase=(icq_Event *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 icq_MessageEventInit(p, ICQ_TCP_MSG_MSG, subtype, uin,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 ICQ_TCP_MSG_REAL, message);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 pbase->createPacket=icq_MessageCreatePacket;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 pbase->eventName=icq_MessageEventName;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 pbase->eventDump=icq_MessageEventDump;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 return p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 void icq_MessageEventInit(icq_MessageEvent *p, int type, int subtype,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 unsigned long uin, int msgtype, const char *message)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 icq_EventInit((icq_Event *)p, type, subtype, uin, ICQ_TCP_VER);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 p->type=msgtype;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 p->message=(char *)message;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 p->status=0; /* FIXME */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106 icq_Packet *icq_MessageCreatePacket(icq_Event *pbase, icq_TCPLink *plink)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 icq_MessageEvent *pevent=(icq_MessageEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 /* create header */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 icq_Packet *p=icq_EventCreatePacket(pbase);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 /* append data specific to message event */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 icq_PacketAppendString(p, (char*)pevent->message);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 icq_PacketAppend32(p, plink->socket_address.sin_addr.s_addr);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 /* FIXME: should be RealIp */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 icq_PacketAppend32(p, htonl(plink->icqlink->icq_OurIP));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 icq_PacketAppend32(p, plink->socket_address.sin_port);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 icq_PacketAppend8(p, 0x04);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 icq_PacketAppend16(p, pevent->status);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 icq_PacketAppend16(p, pevent->type);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 return p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 void icq_MessageParsePacket(icq_Event *pbase, icq_Packet *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 icq_MessageEvent *pevent=(icq_MessageEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 /* parse message event data from packet */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 pevent->message=(char *)icq_PacketReadString(p); /* message text */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 (void)icq_PacketRead32(p); /* remote ip */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 (void)icq_PacketRead32(p); /* remote real ip */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 (void)icq_PacketRead32(p); /* remote message port */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 (void)icq_PacketRead8(p); /* tcp flag */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 pevent->status=icq_PacketRead16(p); /* remote user status */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 pevent->type=icq_PacketRead16(p); /* message type */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 const char *icq_MessageEventName(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 if (p->type==ICQ_EVENT_MESSAGE)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 return "message";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 else if (p->type==ICQ_EVENT_ACK)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 return "message ack";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 return "message cancel";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 const char *icq_MessageEventDump(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 static char buf[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 icq_MessageEvent *pevent=(icq_MessageEvent *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 sprintf(buf, ", type=%x, message=\"%10s...\", status=%x",
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 pevent->type, pevent->message, pevent->status);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 return buf;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 /* URL Event - extends message Event */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 icq_URLEvent *icq_CreateURLEvent(int subtype, unsigned long uin,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 const char *message, const char *url)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 char *str=(char *)malloc(strlen(message)+strlen(url)+2);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 icq_Event *pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 icq_URLEvent *p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 strcpy((char*)str, message);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 *(str+strlen(message))=0xFE;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 strcpy((char*)(str+strlen(message)+1), url);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 /* TODO: make sure create message event copies message */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 pbase=(icq_Event *)icq_CreateMessageEvent(subtype, uin, str);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 p=(icq_URLEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 free(str);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 *(p->message+strlen(message))=0x00;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 p->url=p->message+strlen(message)+1;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 pbase->createPacket=icq_URLCreatePacket;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 pbase->eventName=icq_URLEventName;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 pbase->eventDump=icq_URLEventDump;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 return p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 icq_Packet *icq_URLCreatePacket(icq_Event *pbase, icq_TCPLink *plink)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 icq_URLEvent *pevent=(icq_URLEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 icq_Packet *p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 /* hack message string to include url */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 *(pevent->message+strlen(pevent->message))=0xFE;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204 /* create packet */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 p=icq_MessageCreatePacket(pbase, plink);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 /* hack message string to seperate url */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 *(pevent->message+strlen(pevent->message))=0x00;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 return p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213 void icq_URLParsePacket(icq_Event *pbase, icq_Packet *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 char *pfe;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 icq_URLEvent *pevent=(icq_URLEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 /* TODO: make sure messageparsepacket allocates message string
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 * and add a delete event function */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 icq_MessageParsePacket(pbase, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 /* hack message string to seperate url */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 pfe=strchr(pevent->message, '\xFE');
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 *pfe=0;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 /* set url */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 pevent->url=pfe+1;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
231 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 const char *icq_URLEventName(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 if (p->type==ICQ_EVENT_MESSAGE)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235 return "url";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236 else if (p->type==ICQ_EVENT_ACK)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 return "url ack";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239 return "url cancel";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242 const char *icq_URLEventDump(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 static char buf[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 icq_MessageEvent *pevent=(icq_MessageEvent *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 sprintf(buf, ", type=%x, message=\"%10s...\", url=\"%10s...\" status=%x",
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 pevent->type, pevent->message, pevent->url, pevent->status);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 return buf;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 /* Chat Request Event - extends Message Event */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257 icq_ChatRequestEvent *icq_ChatRequestEventNew(int subtype,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 unsigned long uin, const char *message, int port)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 new_event(p, icq_ChatRequestEvent);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261 icq_Event *pbase=(icq_Event *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 icq_MessageEventInit((icq_MessageEvent *)p, ICQ_TCP_MSG_CHAT, subtype,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263 uin, ICQ_TCP_MSG_REAL, message);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 p->port=port;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 pbase->createPacket=icq_ChatRequestCreatePacket;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 pbase->eventName=icq_ChatRequestEventName;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 pbase->eventDump=icq_ChatRequestEventDump;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 return p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 icq_Packet *icq_ChatRequestCreatePacket(icq_Event *pbase,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 icq_TCPLink *plink)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 icq_ChatRequestEvent *pevent=(icq_ChatRequestEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 /* create header and message data */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 icq_Packet *p=icq_MessageCreatePacket(pbase, plink);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 /* append data specific to chat event */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 icq_PacketAppendString(p, 0);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 icq_PacketAppend32(p, htonl(pevent->port));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 icq_PacketAppend32(p, htoicql(pevent->port));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289 return p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 void icq_ChatParsePacket(icq_Event *pbase, icq_Packet *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 icq_ChatRequestEvent *pevent=(icq_ChatRequestEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295 int port;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 /* parse header and message event data */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 icq_MessageParsePacket(pbase, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 /* parse chat event data */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 (void)icq_PacketReadString(p); /* null string */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302 port=icq_PacketRead32(p); /* chat listen port, network order */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 (void)icq_PacketRead32(p); /* chat listen port, intel order */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305 pevent->port=ntohl(port);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 const char *icq_ChatRequestEventName(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 if (p->type==ICQ_EVENT_MESSAGE)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 return "chat request";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 else if (p->type==ICQ_EVENT_ACK) {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 icq_MessageEvent *pevent=(icq_MessageEvent *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 if (pevent->status==ICQ_TCP_STATUS_REFUSE)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 return "chat request refuse";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317 else
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 return "chat request ack";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319 } else if (p->type==ICQ_EVENT_CANCEL)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 return "chat request cancel";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322 return "unknown chat request";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
324
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
325 const char *icq_ChatRequestEventDump(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 static char buf[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328 static char buf2[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329 icq_ChatRequestEvent *pevent=(icq_ChatRequestEvent *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331 strcpy(buf, icq_MessageEventDump(p));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332 sprintf(buf2, ", port=%d", pevent->port);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
333 strcat(buf, buf2);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335 return buf;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 /* File Request Event - builds on Message Event */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 icq_FileRequestEvent *icq_FileRequestEventNew(int subtype,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 unsigned long uin, const char *message, const char *filename,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 unsigned long filesize)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 new_event(p, icq_FileRequestEvent);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 icq_Event *pbase=(icq_Event *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 icq_MessageEventInit((icq_MessageEvent *)p, ICQ_TCP_MSG_FILE, subtype,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 uin, ICQ_TCP_MSG_REAL, message);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349 p->filename=filename;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 p->filesize=filesize;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352 pbase->createPacket=icq_FileRequestCreatePacket;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355 pbase->eventName=icq_FileRequestEventName;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 pbase->eventDump=icq_FileRequestEventDump;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 return p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362 icq_Packet *icq_FileRequestCreatePacket(icq_Event *pbase,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 icq_TCPLink *plink)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 icq_FileRequestEvent *pevent=(icq_FileRequestEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 /* create header and message data */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 icq_Packet *p=icq_MessageCreatePacket(pbase, plink);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
369
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370 /* append file event data */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 icq_PacketAppend32(p, htonl(pevent->port));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372 icq_PacketAppendString(p, pevent->filename);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373 icq_PacketAppend32(p, pevent->filesize);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 icq_PacketAppend32(p, htoicql(pevent->port));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376 return p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
378
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
379 void icq_FileParsePacket(icq_Event *pbase, icq_Packet *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381 icq_FileRequestEvent *pevent=(icq_FileRequestEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382 int port;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384 /* parse header and message data */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385 icq_MessageParsePacket(pbase, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
387 /* parse file event data */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388 port=icq_PacketRead32(p); /* file listen port, network */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
389 pevent->filename=icq_PacketReadString(p); /* filename text */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 pevent->filesize=icq_PacketRead32(p); /* total size */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 (void)icq_PacketRead32(p); /* file listen port, intel */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 pevent->port=ntohl(port);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
394 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
395
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 const char *icq_FileRequestEventName(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 if (p->type==ICQ_EVENT_MESSAGE)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 return "file request";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 else if (p->type==ICQ_EVENT_ACK) {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 icq_MessageEvent *pevent=(icq_MessageEvent *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 if (pevent->status==ICQ_TCP_STATUS_REFUSE)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 return "file request refuse";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 else
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406 return "file request ack";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 } else if (p->type==ICQ_EVENT_CANCEL)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408 return "file request cancel";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410 return "unknown file request";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413 const char *icq_FileRequestEventDump(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415 static char buf[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
416 static char buf2[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
417 icq_FileRequestEvent *pevent=(icq_FileRequestEvent *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
419 strcpy(buf, icq_MessageEventDump(p));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
420 sprintf(buf2, ", port=%d, filename=\"%s\", filesize=%ld", pevent->port,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
421 pevent->filename, pevent->filesize);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
422 strcat(buf, buf2);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
423
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 return buf;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428 /* main packet parser */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430 icq_Event *icq_ParsePacket(icq_Packet *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 /* FIXME */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433 icq_Event *pevent=(icq_Event *)malloc(sizeof(icq_FileRequestEvent));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 pevent->direction=ICQ_EVENT_INCOMING;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435 pevent->time=time(0);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 icq_EventParsePacket(pevent, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 switch(pevent->type) {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441 case ICQ_TCP_MSG_MSG:
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
442 icq_MessageParsePacket(pevent, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 break;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444 case ICQ_TCP_MSG_URL:
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445 icq_URLParsePacket(pevent, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
446 break;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 case ICQ_TCP_MSG_CHAT:
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448 icq_ChatParsePacket(pevent, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 break;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
450 case ICQ_TCP_MSG_FILE:
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451 icq_FileParsePacket(pevent, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452 break;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
453 default:
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 /* FIXME: log */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455 free(pevent);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456 pevent=0;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457 break;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460 /* FIXME: ensure no bytes are remaining */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
461
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
462 return pevent;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
463 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 const char *icq_EventDump(icq_Event *pevent)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
467 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468 static char buf[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
469
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470 sprintf("%s event sent to uin %ld { %s }", (pevent->eventName)(pevent),
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471 pevent->uin, (pevent->eventDump)(pevent) );
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
472
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
473 return buf;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475 #endif