annotate plugins/icq/icqevent.c @ 1971:7fbd745756c0

[gaim-migrate @ 1981] i thought i fixed this already committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Thu, 07 Jun 2001 07:36:03 +0000
parents 8ed70631ed15
children 7b3f1eb1ef7d
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 /*
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
4 * Copyright (C) 1998-2001, Denis V. Dmitrienko <denis@null.net> and
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
5 * Bill Soudan <soudan@kde.org>
1309
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 *
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
7 * This program is free software; you can redistribute it and/or modify
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
8 * it under the terms of the GNU General Public License as published by
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
9 * the Free Software Foundation; either version 2 of the License, or
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
10 * (at your option) any later version.
1309
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 *
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
12 * This program is distributed in the hope that it will be useful,
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
15 * GNU General Public License for more details.
1309
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 *
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
17 * You should have received a copy of the GNU General Public License
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
18 * along with this program; if not, write to the Free Software
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
1309
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 *
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
21 */
1309
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
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
25 #include "icqlib.h" /* for icqbyteorder.h ?! */
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
26 #include "icqbyteorder.h"
1309
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #include "icqevent.h"
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <string.h>
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <stdio.h>
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 #define new_event(x, y) y * x = ( y * )malloc(sizeof(y))
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 /* generic Event - 'header' for each tcp packet */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 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
39 int version)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 if (!p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 return;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 p->uin=uin;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45 p->version=version;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 p->type=type;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 p->subtype=subtype;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 p->direction=ICQ_EVENT_OUTGOING;
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 icq_Packet *icq_EventCreatePacket(icq_Event *pbase)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 icq_Packet *p=icq_PacketNew();
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 /* create header for tcp packet */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 icq_PacketAppend32(p, pbase->uin);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 icq_PacketAppend16(p, pbase->version);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 icq_PacketAppend16(p, pbase->subtype);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 icq_PacketAppend16(p, 0x0000);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 icq_PacketAppend32(p, pbase->uin);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 icq_PacketAppend32(p, pbase->type);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 return p;
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 void icq_EventParsePacket(icq_Event *pevent, icq_Packet *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 /* parse header of tcp packet */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 icq_PacketBegin(p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 (void)icq_PacketRead32(p); /* uin */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 pevent->version=icq_PacketRead16(p); /* max supported tcp version */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 pevent->subtype=icq_PacketRead16(p); /* event subtype */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 (void)icq_PacketRead16(p); /* 0x0000 */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 pevent->uin=icq_PacketRead32(p); /* uin */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 pevent->type=icq_PacketRead16(p); /* event type */
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 /* Message Event - extends generic Event */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 icq_MessageEvent *icq_CreateMessageEvent(int subtype, unsigned long uin,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 const char *message)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 new_event(p, icq_MessageEvent);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 icq_Event *pbase=(icq_Event *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 icq_MessageEventInit(p, ICQ_TCP_MSG_MSG, subtype, uin,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 ICQ_TCP_MSG_REAL, message);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 pbase->createPacket=icq_MessageCreatePacket;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 pbase->eventName=icq_MessageEventName;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 pbase->eventDump=icq_MessageEventDump;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 return p;
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 void icq_MessageEventInit(icq_MessageEvent *p, int type, int subtype,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 unsigned long uin, int msgtype, const char *message)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 icq_EventInit((icq_Event *)p, type, subtype, uin, ICQ_TCP_VER);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 p->type=msgtype;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 p->message=(char *)message;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 p->status=0; /* FIXME */
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 icq_Packet *icq_MessageCreatePacket(icq_Event *pbase, icq_TCPLink *plink)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 icq_MessageEvent *pevent=(icq_MessageEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 /* create header */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 icq_Packet *p=icq_EventCreatePacket(pbase);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 /* append data specific to message event */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 icq_PacketAppendString(p, (char*)pevent->message);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 icq_PacketAppend32(p, plink->socket_address.sin_addr.s_addr);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 /* FIXME: should be RealIp */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 icq_PacketAppend32(p, htonl(plink->icqlink->icq_OurIP));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 icq_PacketAppend32(p, plink->socket_address.sin_port);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 icq_PacketAppend8(p, 0x04);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 icq_PacketAppend16(p, pevent->status);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 icq_PacketAppend16(p, pevent->type);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 return p;
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 void icq_MessageParsePacket(icq_Event *pbase, icq_Packet *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 icq_MessageEvent *pevent=(icq_MessageEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 /* parse message event data from packet */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 pevent->message=(char *)icq_PacketReadString(p); /* message text */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 (void)icq_PacketRead32(p); /* remote ip */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 (void)icq_PacketRead32(p); /* remote real ip */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 (void)icq_PacketRead32(p); /* remote message port */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 (void)icq_PacketRead8(p); /* tcp flag */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 pevent->status=icq_PacketRead16(p); /* remote user status */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 pevent->type=icq_PacketRead16(p); /* message type */
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 const char *icq_MessageEventName(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 if (p->type==ICQ_EVENT_MESSAGE)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 return "message";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 else if (p->type==ICQ_EVENT_ACK)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 return "message ack";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 return "message cancel";
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 const char *icq_MessageEventDump(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 static char buf[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 icq_MessageEvent *pevent=(icq_MessageEvent *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 sprintf(buf, ", type=%x, message=\"%10s...\", status=%x",
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 pevent->type, pevent->message, pevent->status);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 return buf;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 /* URL Event - extends message Event */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 icq_URLEvent *icq_CreateURLEvent(int subtype, unsigned long uin,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 const char *message, const char *url)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 char *str=(char *)malloc(strlen(message)+strlen(url)+2);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 icq_Event *pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 icq_URLEvent *p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 strcpy((char*)str, message);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 *(str+strlen(message))=0xFE;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 strcpy((char*)(str+strlen(message)+1), url);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 /* TODO: make sure create message event copies message */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 pbase=(icq_Event *)icq_CreateMessageEvent(subtype, uin, str);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 p=(icq_URLEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 free(str);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 *(p->message+strlen(message))=0x00;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 p->url=p->message+strlen(message)+1;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 pbase->createPacket=icq_URLCreatePacket;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 pbase->eventName=icq_URLEventName;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 pbase->eventDump=icq_URLEventDump;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193 return p;
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197 icq_Packet *icq_URLCreatePacket(icq_Event *pbase, icq_TCPLink *plink)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 icq_URLEvent *pevent=(icq_URLEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 icq_Packet *p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 /* hack message string to include url */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 *(pevent->message+strlen(pevent->message))=0xFE;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 /* create packet */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206 p=icq_MessageCreatePacket(pbase, plink);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 /* hack message string to seperate url */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 *(pevent->message+strlen(pevent->message))=0x00;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211 return p;
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 void icq_URLParsePacket(icq_Event *pbase, icq_Packet *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 char *pfe;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 icq_URLEvent *pevent=(icq_URLEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 /* TODO: make sure messageparsepacket allocates message string
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 * and add a delete event function */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221 icq_MessageParsePacket(pbase, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 /* hack message string to seperate url */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 pfe=strchr(pevent->message, '\xFE');
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 *pfe=0;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 /* set url */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228 pevent->url=pfe+1;
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 const char *icq_URLEventName(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235 if (p->type==ICQ_EVENT_MESSAGE)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236 return "url";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 else if (p->type==ICQ_EVENT_ACK)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238 return "url ack";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 return "url cancel";
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 const char *icq_URLEventDump(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245 static char buf[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 icq_MessageEvent *pevent=(icq_MessageEvent *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248 sprintf(buf, ", type=%x, message=\"%10s...\", url=\"%10s...\" status=%x",
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 pevent->type, pevent->message, pevent->url, pevent->status);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 return buf;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253 #endif
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 /* Chat Request Event - extends Message Event */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 icq_ChatRequestEvent *icq_ChatRequestEventNew(int subtype,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 unsigned long uin, const char *message, int port)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261 new_event(p, icq_ChatRequestEvent);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 icq_Event *pbase=(icq_Event *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263 icq_MessageEventInit((icq_MessageEvent *)p, ICQ_TCP_MSG_CHAT, subtype,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 uin, ICQ_TCP_MSG_REAL, message);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 p->port=port;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 pbase->createPacket=icq_ChatRequestCreatePacket;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 pbase->eventName=icq_ChatRequestEventName;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 pbase->eventDump=icq_ChatRequestEventDump;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 return p;
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 icq_Packet *icq_ChatRequestCreatePacket(icq_Event *pbase,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 icq_TCPLink *plink)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 icq_ChatRequestEvent *pevent=(icq_ChatRequestEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 /* create header and message data */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 icq_Packet *p=icq_MessageCreatePacket(pbase, plink);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 /* append data specific to chat event */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 icq_PacketAppendString(p, 0);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 icq_PacketAppend32(p, htonl(pevent->port));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288 icq_PacketAppend32(p, htoicql(pevent->port));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 return p;
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293 void icq_ChatParsePacket(icq_Event *pbase, icq_Packet *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295 icq_ChatRequestEvent *pevent=(icq_ChatRequestEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 int port;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 /* parse header and message event data */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 icq_MessageParsePacket(pbase, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 /* parse chat event data */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302 (void)icq_PacketReadString(p); /* null string */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 port=icq_PacketRead32(p); /* chat listen port, network order */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 (void)icq_PacketRead32(p); /* chat listen port, intel order */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 pevent->port=ntohl(port);
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 const char *icq_ChatRequestEventName(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 if (p->type==ICQ_EVENT_MESSAGE)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 return "chat request";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314 else if (p->type==ICQ_EVENT_ACK) {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 icq_MessageEvent *pevent=(icq_MessageEvent *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 if (pevent->status==ICQ_TCP_STATUS_REFUSE)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317 return "chat request refuse";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 else
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319 return "chat request ack";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 } else if (p->type==ICQ_EVENT_CANCEL)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
321 return "chat request cancel";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
322
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
323 return "unknown chat request";
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
326 const char *icq_ChatRequestEventDump(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
327 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
328 static char buf[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
329 static char buf2[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
330 icq_ChatRequestEvent *pevent=(icq_ChatRequestEvent *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
331
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
332 strcpy(buf, icq_MessageEventDump(p));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
333 sprintf(buf2, ", port=%d", pevent->port);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
334 strcat(buf, buf2);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336 return buf;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340 /* File Request Event - builds on Message Event */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 icq_FileRequestEvent *icq_FileRequestEventNew(int subtype,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 unsigned long uin, const char *message, const char *filename,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 unsigned long filesize)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 new_event(p, icq_FileRequestEvent);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 icq_Event *pbase=(icq_Event *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 icq_MessageEventInit((icq_MessageEvent *)p, ICQ_TCP_MSG_FILE, subtype,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349 uin, ICQ_TCP_MSG_REAL, message);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 p->filename=filename;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351 p->filesize=filesize;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 pbase->createPacket=icq_FileRequestCreatePacket;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 pbase->eventName=icq_FileRequestEventName;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357 pbase->eventDump=icq_FileRequestEventDump;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 return p;
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 icq_Packet *icq_FileRequestCreatePacket(icq_Event *pbase,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 icq_TCPLink *plink)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 icq_FileRequestEvent *pevent=(icq_FileRequestEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 /* create header and message data */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
369 icq_Packet *p=icq_MessageCreatePacket(pbase, plink);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 /* append file event data */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372 icq_PacketAppend32(p, htonl(pevent->port));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373 icq_PacketAppendString(p, pevent->filename);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 icq_PacketAppend32(p, pevent->filesize);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375 icq_PacketAppend32(p, htoicql(pevent->port));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 return p;
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
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
380 void icq_FileParsePacket(icq_Event *pbase, icq_Packet *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
381 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
382 icq_FileRequestEvent *pevent=(icq_FileRequestEvent *)pbase;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
383 int port;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
384
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
385 /* parse header and message data */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
386 icq_MessageParsePacket(pbase, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
387
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
388 /* parse file event data */
1912
8ed70631ed15 [gaim-migrate @ 1922]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 1432
diff changeset
389 pevent->port=ntohl(icq_PacketRead32(p)); /* file listen port, network */
1309
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
390 pevent->filename=icq_PacketReadString(p); /* filename text */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
391 pevent->filesize=icq_PacketRead32(p); /* total size */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
392 (void)icq_PacketRead32(p); /* file listen port, intel */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
393 }
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 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
396 const char *icq_FileRequestEventName(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
397 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
398 if (p->type==ICQ_EVENT_MESSAGE)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 return "file request";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 else if (p->type==ICQ_EVENT_ACK) {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 icq_MessageEvent *pevent=(icq_MessageEvent *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 if (pevent->status==ICQ_TCP_STATUS_REFUSE)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 return "file request refuse";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 else
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 return "file request ack";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406 } else if (p->type==ICQ_EVENT_CANCEL)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 return "file request cancel";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 return "unknown file request";
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410 }
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 const char *icq_FileRequestEventDump(icq_Event *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414 static char buf[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415 static char buf2[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
416 icq_FileRequestEvent *pevent=(icq_FileRequestEvent *)p;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
417
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418 strcpy(buf, icq_MessageEventDump(p));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
419 sprintf(buf2, ", port=%d, filename=\"%s\", filesize=%ld", pevent->port,
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
420 pevent->filename, pevent->filesize);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
421 strcat(buf, buf2);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
422
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
423 return buf;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 #endif
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427 /* main packet parser */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429 icq_Event *icq_ParsePacket(icq_Packet *p)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 /* FIXME */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 icq_Event *pevent=(icq_Event *)malloc(sizeof(icq_FileRequestEvent));
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433 pevent->direction=ICQ_EVENT_INCOMING;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 pevent->time=time(0);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 icq_EventParsePacket(pevent, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 switch(pevent->type) {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440 case ICQ_TCP_MSG_MSG:
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441 icq_MessageParsePacket(pevent, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
442 break;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 case ICQ_TCP_MSG_URL:
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444 icq_URLParsePacket(pevent, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445 break;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
446 case ICQ_TCP_MSG_CHAT:
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
447 icq_ChatParsePacket(pevent, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
448 break;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
449 case ICQ_TCP_MSG_FILE:
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
450 icq_FileParsePacket(pevent, p);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
451 break;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
452 default:
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
453 /* FIXME: log */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
454 free(pevent);
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
455 pevent=0;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
456 break;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457 }
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 /* FIXME: ensure no bytes are remaining */
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
461 return pevent;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
462 }
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 #ifdef EVENT_DEBUG
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 const char *icq_EventDump(icq_Event *pevent)
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 {
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
467 static char buf[255];
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
469 sprintf("%s event sent to uin %ld { %s }", (pevent->eventName)(pevent),
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470 pevent->uin, (pevent->eventDump)(pevent) );
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
472 return buf;
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
473 }
0a766047b4fd [gaim-migrate @ 1319]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 #endif