annotate src/protocols/zephyr/zephyr.c @ 9912:f6a1054e2bdc

[gaim-migrate @ 10804] " shadow pointed that zephyr_strip_foreign_realm wasn't being consistently used (searches for foo would fail when foo@DEFAULTREALM was in the buddy list), and that this could cause problems. Also, zephyr_strip_foreign_realm was really badly named (it should be zephyr_strip_local_realm). Here's a fix for both those issues, against current cvs." --Arun A Tharuvai committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Mon, 30 Aug 2004 01:52:59 +0000
parents 4f1fcf5efaf9
children e74eb0d11f86
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 /*
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 * gaim
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 * Copyright (C) 1998-2001, Mark Spencer <markster@marko.net>
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * Some code borrowed from GtkZephyr, by
7084
0909ebf6fb28 [gaim-migrate @ 7649]
Christian Hammond <chipx86@chipx86.com>
parents: 7070
diff changeset
7 * Jag/Sean Dilda <agrajag@linuxpower.org>/<smdilda@unity.ncsu.edu>
0909ebf6fb28 [gaim-migrate @ 7649]
Christian Hammond <chipx86@chipx86.com>
parents: 7070
diff changeset
8 * http://gtkzephyr.linuxpower.org/
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 *
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
10 * Some code borrowed from kzephyr, by
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
11 * Chris Colohan <colohan+@cs.cmu.edu>
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
12 *
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * This program is free software; you can redistribute it and/or modify
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 * it under the terms of the GNU General Public License as published by
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * the Free Software Foundation; either version 2 of the License, or
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * (at your option) any later version.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * This program is distributed in the hope that it will be useful,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 * GNU General Public License for more details.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 * You should have received a copy of the GNU General Public License
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 * along with this program; if not, write to the Free Software
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 *
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
27
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
28 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
29 /* XXX eww */
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
30 #include "src/internal.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
32 #include "accountopt.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
33 #include "debug.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
34 #include "notify.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
35 #include "prpl.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
36 #include "server.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
37 #include "util.h"
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
38 #include "cmds.h"
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
39 #include "privacy.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
40
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
41 #include "zephyr.h"
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
42 #include "internal.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
43
8386
143d0b29ba82 [gaim-migrate @ 9114]
Mark Doliner <mark@kingant.net>
parents: 8354
diff changeset
44 #include <strings.h>
143d0b29ba82 [gaim-migrate @ 9114]
Mark Doliner <mark@kingant.net>
parents: 8354
diff changeset
45
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
46 #define ZEPHYR_FALLBACK_CHARSET "ISO-8859-1"
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
47
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
48 /* these are deliberately high, since most people don't send multiple "PING"s */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
49 #define ZEPHYR_TYPING_SEND_TIMEOUT 15
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
50 #define ZEPHYR_TYPING_RECV_TIMEOUT 10
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
51 #define ZEPHYR_FD_READ 0
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
52 #define ZEPHYR_FD_WRITE 1
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
53
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 extern Code_t ZGetLocations(ZLocations_t *, int *);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 extern Code_t ZSetLocation(char *);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 extern Code_t ZUnsetLocation();
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
57 extern Code_t ZGetSubscriptions(ZSubscription_t *, int*);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 typedef struct _zframe zframe;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 typedef struct _zephyr_triple zephyr_triple;
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
61 typedef struct _zephyr_account zephyr_account;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
62 typedef struct _parse_tree parse_tree;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
64 typedef enum {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
65 GAIM_ZEPHYR_NONE, /* Non-kerberized ZEPH0.2 */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
66 GAIM_ZEPHYR_KRB4, /* ZEPH0.2 w/ KRB4 support */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
67 GAIM_ZEPHYR_TZC, /* tzc executable proxy */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
68 GAIM_ZEPHYR_INTERGALACTIC_KRB4, /* Kerberized ZEPH0.3 */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
69 } zephyr_connection_type;
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
70
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
71 struct _zephyr_account {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
72 GaimAccount* account;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
73 char *username;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
74 char *realm;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
75 char *encoding;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
76 char* galaxy; /* not yet useful */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
77 char* krbtkfile; /* not yet useful */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
78 guint32 nottimer;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
79 guint32 loctimer;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
80 GList *pending_zloc_names;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
81 GSList *subscrips;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
82 int last_id;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
83 unsigned short port;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
84 char ourhost[HOST_NAME_MAX + 1];
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
85 char ourhostcanon[HOST_NAME_MAX + 1];
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
86 zephyr_connection_type connection_type;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
87 int totzc[2];
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
88 int fromtzc[2];
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
89 char *exposure;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
90 pid_t tzc_pid;
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
91 };
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
92
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
93 #define MAXCHILDREN 20
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
94
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
95 struct _parse_tree {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
96 gchar* contents;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
97 parse_tree *children[MAXCHILDREN];
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
98 int num_children;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
99 };
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
100
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
101 parse_tree null_parse_tree = {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
102 "",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
103 {},
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
104 0,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
105 };
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
106
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
107 #define use_none(zephyr) ((zephyr->connection_type == GAIM_ZEPHYR_NONE)?1:0)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
108 #define use_krb4(zephyr) ((zephyr->connection_type == GAIM_ZEPHYR_KRB4)?1:0)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
109 #define use_tzc(zephyr) ((zephyr->connection_type == GAIM_ZEPHYR_TZC)?1:0)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
110
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
111 #define use_zeph02(zephyr) ( (zephyr->connection_type == GAIM_ZEPHYR_NONE)?1: ((zephyr->connection_type == GAIM_ZEPHYR_KRB4)?1:0))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
112
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 /* struct I need for zephyr_to_html */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 struct _zframe {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 /* true for everything but @color, since inside the parens of that one is
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
116 * the color. */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 gboolean has_closer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 /* </i>, </font>, </b>, etc. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 char *closing;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 /* text including the opening html thingie. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 GString *text;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 struct _zframe *enclosing;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 struct _zephyr_triple {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 char *class;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 char *instance;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 char *recipient;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 char *name;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 gboolean open;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 int id;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 #define z_call(func) if (func != ZERR_NONE)\
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 #define z_call_r(func) if (func != ZERR_NONE)\
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 return TRUE;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
138
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 #define z_call_s(func, err) if (func != ZERR_NONE) {\
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
140 gaim_connection_error(gc, err);\
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 return;\
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
144
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
145 Code_t zephyr_subscribe_to(zephyr_account* zephyr, char* class, char *instance, char *recipient, char* galaxy) {
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
146
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
147 if (use_tzc(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
148 /* ((tzcfodder . subscribe) ("class" "instance" "recipient")) */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
149 gchar *zsubstr = g_strdup_printf("((tzcfodder . subscribe) (\"%s\" \"%s\" \"%s\"))\n",class,instance,recipient);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
150 write(zephyr->totzc[ZEPHYR_FD_WRITE],zsubstr,strlen(zsubstr));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
151 g_free(zsubstr);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
152 return ZERR_NONE;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
153 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
154 else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
155 if (use_zeph02(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
156 ZSubscription_t sub;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
157 sub.zsub_class = class;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
158 sub.zsub_classinst = instance;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
159 sub.zsub_recipient = recipient;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
160 return ZSubscribeTo(&sub,1,0);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
161 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
162 /* This should not happen */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
163 return -1;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
164 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
165 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
166 return -1;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
167 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
168
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
169 char *local_zephyr_normalize(zephyr_account* zephyr,const char *);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
170 static const char *zephyr_normalize(const GaimAccount *, const char *);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
171 static void zephyr_chat_set_topic(GaimConnection * gc, int id, const char *topic);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
172 char* zephyr_tzc_deescape_str(const char *message);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
173
9912
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
174 char *zephyr_strip_local_realm(zephyr_account* zephyr,const char* user){
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
175 /*
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
176 Takes in a username of the form username or username@realm
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
177 and returns:
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
178 username, if there is no realm, or the realm is the local realm
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
179 or:
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
180 username@realm if there is a realm and it is foreign
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
181 */
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
182 char *tmp = g_strdup(user);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
183 char *at = strchr(tmp,'@');
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
184 if (at && !g_ascii_strcasecmp(at+1,zephyr->realm)) {
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
185 /* We're passed in a username of the form user@users-realm */
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
186 char* tmp2;
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
187 *at = '\0';
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
188 tmp2 = g_strdup(tmp);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
189 g_free(tmp);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
190 return tmp2;
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
191 }
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
192 else {
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
193 /* We're passed in a username of the form user or user@foreign-realm */
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
194 return tmp;
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
195 }
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
196 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 /* this is so bad, and if Zephyr weren't so fucked up to begin with I
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 * wouldn't do this. but it is so i will. */
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
200
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
201 /* just for debugging */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 static void handle_unknown(ZNotice_t notice)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 {
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
204 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_packet: %s\n", notice.z_packet);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
205 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_version: %s\n", notice.z_version);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
206 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_kind: %d\n", (int)(notice.z_kind));
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
207 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_class: %s\n", notice.z_class);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
208 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_class_inst: %s\n", notice.z_class_inst);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
209 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_opcode: %s\n", notice.z_opcode);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
210 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_sender: %s\n", notice.z_sender);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
211 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_recipient: %s\n", notice.z_recipient);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
212 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_message: %s\n", notice.z_message);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
213 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_message_len: %d\n", notice.z_message_len);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 }
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
215
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
217 static zephyr_triple *new_triple(zephyr_account *zephyr,const char *c, const char *i, const char *r)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 zephyr_triple *zt;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
220
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221 zt = g_new0(zephyr_triple, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 zt->class = g_strdup(c);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 zt->instance = g_strdup(i);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 zt->recipient = g_strdup(r);
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
225 zt->name = g_strdup_printf("%s,%s,%s", c, i?i:"", r?r:"");
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
226 zt->id = ++(zephyr->last_id);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 zt->open = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228 return zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
231 static void free_triple(zephyr_triple * zt)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 g_free(zt->class);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 g_free(zt->instance);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235 g_free(zt->recipient);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236 g_free(zt->name);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 g_free(zt);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
240 /* returns true if zt1 is a subset of zt2. This function is used to
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
241 determine whether a zephyr sent to zt1 should be placed in the chat
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
242 with triple zt2
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
243
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
244 zt1 is a subset of zt2
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
245 iff. the classnames are identical ignoring case
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
246 AND. the instance names are identical (ignoring case), or zt2->instance is *.
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
247 AND. the recipient names are identical
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
248 */
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
249
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
250 static gboolean triple_subset(zephyr_triple * zt1, zephyr_triple * zt2)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
252
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
253 if (!zt2)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
254 gaim_debug_error("zephyr","zt2 doesn't exist\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
255 if (!zt1)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
256 gaim_debug_error("zephyr","zt1 doesn't exist\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
257 if (!(zt1->class))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
258 gaim_debug_error("zephyr","zt1c doesn't exist\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
259 if (!(zt1->instance))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
260 gaim_debug_error("zephyr","zt1i doesn't exist\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
261 if (!(zt1->recipient))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
262 gaim_debug_error("zephyr","zt1r doesn't exist\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
263 if (!(zt2->class))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
264 gaim_debug_error("zephyr","zt2c doesn't exist\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
265 if (!(zt2->recipient))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
266 gaim_debug_error("zephyr","zt2r doesn't exist\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
267 if (!(zt2->instance))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
268 gaim_debug_error("zephyr","zt2i doesn't exist\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
269
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
270
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
271 if (g_ascii_strcasecmp(zt2->class, zt1->class)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
274 if (g_ascii_strcasecmp(zt2->instance, zt1->instance) && g_ascii_strcasecmp(zt2->instance, "*")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 }
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
277 if (g_ascii_strcasecmp(zt2->recipient, zt1->recipient)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 }
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
280 gaim_debug_info("zephyr","<%s,%s,%s> is in <%s,%s,%s>\n",zt1->class,zt1->instance,zt1->recipient,zt2->class,zt2->instance,zt2->recipient);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
284 static zephyr_triple *find_sub_by_triple(zephyr_account *zephyr,zephyr_triple * zt)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 zephyr_triple *curr_t;
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
287 GSList *curr = zephyr->subscrips;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
288
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289 while (curr) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 curr_t = curr->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 if (triple_subset(zt, curr_t))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 return curr_t;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293 curr = curr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
298 static zephyr_triple *find_sub_by_id(zephyr_account *zephyr,int id)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 zephyr_triple *zt;
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
301 GSList *curr = zephyr->subscrips;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
302
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 while (curr) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 zt = curr->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305 if (zt->id == id)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 return zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307 curr = curr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
312 /*
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
313 Converts strings to utf-8 if necessary using user specified encoding
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
314 */
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
315
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
316 static gchar *zephyr_recv_convert(GaimConnection *gc,gchar *string, int len)
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
317 {
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
318 gchar *utf8;
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
319 GError *err = NULL;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
320 zephyr_account *zephyr = gc->proto_data;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
321 if (g_utf8_validate(string, len, NULL)) {
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
322 return g_strdup(string);
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
323 } else {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
324 utf8 = g_convert(string, len, "UTF-8", zephyr->encoding, NULL, NULL, &err);
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
325 if (err) {
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
326 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "recv conversion error: %s\n", err->message);
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
327 utf8 = g_strdup(_("(There was an error converting this message. Check the 'Encoding' option in the Account Editor)"));
8954
c60f82d78dea [gaim-migrate @ 9727]
Luke Schierer <lschiere@pidgin.im>
parents: 8950
diff changeset
328 g_error_free(err);
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
329 }
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
330
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
331 return utf8;
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
332 }
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
333 }
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
334
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
335 /* utility macros that are useful for zephyr_to_html */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
336
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
337 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<'))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
338 #define IS_CLOSER(c) ((c == '}') || (c == ']') || (c == ')') || (c == '>'))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
340 /* This parses HTML formatting (put out by one of the gtkimhtml widgets
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
341 And converts it to zephyr formatting.
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
342 It currently deals properly with <b>, <br>, <i>, <font face=...>, <font color=...>,
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
343 It ignores <font back=...>
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
344 It does
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
345 <font size = "1 or 2" -> @small
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
346 3 or 4 @medium()
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
347 5,6, or 7 @large()
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
348 <a href is dealt with by ignoring the description and outputting the link
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
349 */
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
350
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
351 static char *html_to_zephyr(const char *message)
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
352 {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
353 int len, cnt, retcount;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
354 char *ret;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
355
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
356 len = strlen(message);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
357 if (!len)
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
358 return g_strdup("");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
359
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
360 ret = g_new0(char, len * 3);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
361
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
362 bzero(ret, len * 3);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
363 retcount = 0;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
364 cnt = 0;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
365 gaim_debug_info("zephyr","html received %s\n",message);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
366 while (cnt <= len) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
367 if (message[cnt] == '<') {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
368 if (!g_ascii_strncasecmp(message + cnt + 1, "i>", 2)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
369 strncpy(ret + retcount, "@i(", 3);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
370 cnt += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
371 retcount += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
372 } else if (!g_ascii_strncasecmp(message + cnt + 1, "b>", 2)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
373 strncpy(ret + retcount, "@b(", 3);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
374 cnt += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
375 retcount += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
376 } else if (!g_ascii_strncasecmp(message + cnt + 1, "br>", 3)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
377 strncpy(ret + retcount, "\n", 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
378 cnt += 4;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
379 retcount += 1;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
380 } else if (!g_ascii_strncasecmp(message + cnt + 1, "a href=\"mailto:", 15)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
381 cnt += 16;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
382 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
383 ret[retcount] = message[cnt];
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
384 retcount++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
385 cnt++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
386 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
387 cnt += 2;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
388 /* ignore descriptive string */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
389 while (g_ascii_strncasecmp(message + cnt, "</a>", 4) != 0) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
390 cnt++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
391 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
392 cnt += 4;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
393 } else if (!g_ascii_strncasecmp(message + cnt + 1, "a href=\"", 8)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
394 cnt += 9;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
395 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
396 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
397 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
398 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
399 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
400 cnt += 2;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
401 /* ignore descriptive string */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
402 while (g_ascii_strncasecmp(message + cnt, "</a>", 4) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
403 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
404 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
405 cnt += 4;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
406 } else if (!g_ascii_strncasecmp(message + cnt + 1, "font", 4)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
407 cnt += 5;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
408 while (!g_ascii_strncasecmp(message + cnt, " ", 1))
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
409 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
410 if (!g_ascii_strncasecmp(message + cnt, "color=\"", 7)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
411 cnt += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
412 strncpy(ret + retcount, "@color(", 7);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
413 retcount += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
414 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
415 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
416 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
417 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
418 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
419 ret[retcount] = ')';
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
420 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
421 cnt += 2;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
422 } else if (!g_ascii_strncasecmp(message + cnt, "face=\"", 6)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
423 cnt += 6;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
424 strncpy(ret + retcount, "@font(", 6);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
425 retcount += 6;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
426 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
427 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
428 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
429 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
430 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
431 ret[retcount] = ')';
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
432 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
433 cnt += 2;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
434 } else if (!g_ascii_strncasecmp(message + cnt, "size=\"", 6)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
435 cnt += 6;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
436 if ((message[cnt] == '1') || (message[cnt] == '2')) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
437 strncpy(ret + retcount, "@small(", 7);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
438 retcount += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
439 } else if ((message[cnt] == '3')
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
440 || (message[cnt] == '4')) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
441 strncpy(ret + retcount, "@medium(", 8);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
442 retcount += 8;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
443 } else if ((message[cnt] == '5')
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
444 || (message[cnt] == '6')
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
445 || (message[cnt] == '7')) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
446 strncpy(ret + retcount, "@large(", 7);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
447 retcount += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
448 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
449 cnt += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
450 } else {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
451 /* Drop all unrecognized/misparsed font tags */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
452 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
453 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
454 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
455 cnt += 2;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
456 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
457 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/i>", 3)
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
458 || !g_ascii_strncasecmp(message + cnt + 1, "/b>", 3)) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
459 cnt += 4;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
460 ret[retcount] = ')';
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
461 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
462 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/font>", 6)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
463 cnt += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
464 strncpy(ret + retcount, "@font(fixed)", 12);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
465 retcount += 12;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
466 } else {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
467 /* Catch all for all unrecognized/misparsed <foo> tage */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
468 while (g_ascii_strncasecmp(message + cnt, ">", 1) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
469 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
470 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
471 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
472 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
473 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
474 } else {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
475 /* Duh */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
476 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
477 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
478 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
479 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
480 }
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
481 gaim_debug_info("zephyr","zephyr outputted %s\n",ret);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
482 return ret;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
483 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
484
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
485 /* this parses zephyr formatting and converts it to html. For example, if
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 * you pass in "@{@color(blue)@i(hello)}" you should get out
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487 * "<font color=blue><i>hello</i></font>". */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
488 static char *zephyr_to_html(char *message)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
489 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
490 int len, cnt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
491 zframe *frames, *curr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
492 char *ret;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
493
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494 frames = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
495 frames->text = g_string_new("");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
496 frames->enclosing = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497 frames->closing = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498 frames->has_closer = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
500 len = strlen(message);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501 cnt = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
502 while (cnt <= len) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
503 if (message[cnt] == '@') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 zframe *new_f;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
505 char *buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
506 int end;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
507
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
508 for (end = 1; (cnt + end) <= len && !IS_OPENER(message[cnt + end])
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
509 && !IS_CLOSER(message[cnt + end]); end++);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
510 buf = g_new0(char, end);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
511
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
512 if (end) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
513 g_snprintf(buf, end, "%s", message + cnt + 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
514 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
515 if (!g_ascii_strcasecmp(buf, "italic") || !g_ascii_strcasecmp(buf, "i")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
517 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518 new_f->text = g_string_new("<i>");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
519 new_f->closing = "</i>";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
521 frames = new_f;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
522 cnt += end + 1; /* cnt points to char after opener */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
523 } else if (!g_ascii_strcasecmp(buf, "small")) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
524 new_f = g_new(zframe, 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
525 new_f->enclosing = frames;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
526 new_f->text = g_string_new("<font size=\"1\">");
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
527 new_f->closing = "</font>";
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
528 frames = new_f;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
529 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
530 } else if (!g_ascii_strcasecmp(buf, "medium")) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
531 new_f = g_new(zframe, 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
532 new_f->enclosing = frames;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
533 new_f->text = g_string_new("<font size=\"3\">");
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
534 new_f->closing = "</font>";
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
535 frames = new_f;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
536 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
537 } else if (!g_ascii_strcasecmp(buf, "large")) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
538 new_f = g_new(zframe, 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
539 new_f->enclosing = frames;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
540 new_f->text = g_string_new("<font size=\"7\">");
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
541 new_f->closing = "</font>";
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
542 frames = new_f;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
543 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
544 } else if (!g_ascii_strcasecmp(buf, "bold")
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
545 || !g_ascii_strcasecmp(buf, "b")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
546 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
547 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
548 new_f->text = g_string_new("<b>");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
549 new_f->closing = "</b>";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
550 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
551 frames = new_f;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
552 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
553 } else if (!g_ascii_strcasecmp(buf, "font")) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
554 cnt += end + 1;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
555 new_f = g_new(zframe, 1);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
556 new_f->enclosing = frames;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
557 new_f->text = g_string_new("<font face=");
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
558 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
559 g_string_append_c(new_f->text, message[cnt]);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
560 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
561 cnt++; /* point to char after closer */
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
562 g_string_append_c(new_f->text, '>');
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
563 new_f->closing = "</font>";
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
564 new_f->has_closer = FALSE;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
565 frames = new_f;
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
566 } else if (!g_ascii_strcasecmp(buf, "color")) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
567 cnt += end + 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
568 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
569 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
570 new_f->text = g_string_new("<font color=");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
571 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
572 g_string_append_c(new_f->text, message[cnt]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
573 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
574 cnt++; /* point to char after closer */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
575 g_string_append_c(new_f->text, '>');
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
576 new_f->closing = "</font>";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
577 new_f->has_closer = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
578 frames = new_f;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
579 } else if (!g_ascii_strcasecmp(buf, "")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
580 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
581 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
582 new_f->text = g_string_new("");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
583 new_f->closing = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
584 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
585 frames = new_f;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
586 cnt += end + 1; /* cnt points to char after opener */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
587 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
588 if ((cnt + end) > len) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
589 g_string_append_c(frames->text, '@');
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
590 cnt++;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
591 } else if (IS_CLOSER(message[cnt + end])) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
592 /* We have @chars..closer . This is
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
593 merely a sequence of chars that isn't a formatting tag
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
594 */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
595 int tmp = cnt;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
596
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
597 while (tmp <= cnt + end) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
598 g_string_append_c(frames->text, message[tmp]);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
599 tmp++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
600 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
601 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
602 } else {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
603 /* unrecognized thingie. act like it's not there, but we
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
604 * still need to take care of the corresponding closer,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
605 * make a frame that does nothing. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
606 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
608 new_f->text = g_string_new("");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
609 new_f->closing = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
610 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
611 frames = new_f;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
612 cnt += end + 1; /* cnt points to char after opener */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
613 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
614 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
615 } else if (IS_CLOSER(message[cnt])) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
616 zframe *popped;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
617 gboolean last_had_closer;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
618
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
619 if (frames->enclosing) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
620 do {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
621 popped = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
622 frames = frames->enclosing;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
623 g_string_append(frames->text, popped->text->str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
624 g_string_append(frames->text, popped->closing);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
625 g_string_free(popped->text, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
626 last_had_closer = popped->has_closer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
627 g_free(popped);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
628 } while (frames && frames->enclosing && !last_had_closer);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
629 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
630 g_string_append_c(frames->text, message[cnt]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
631 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
632 cnt++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
633 } else if (message[cnt] == '\n') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
634 g_string_append(frames->text, "<br>");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
635 cnt++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
636 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
637 g_string_append_c(frames->text, message[cnt++]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
638 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
639 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
640 /* go through all the stuff that they didn't close */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
641 while (frames->enclosing) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
642 curr = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
643 g_string_append(frames->enclosing->text, frames->text->str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
644 g_string_append(frames->enclosing->text, frames->closing);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
645 g_string_free(frames->text, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
646 frames = frames->enclosing;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
647 g_free(curr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
648 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
649 ret = frames->text->str;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
650 g_string_free(frames->text, FALSE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
651 g_free(frames);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
652 return ret;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
653 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
654
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
655 static gboolean pending_zloc(zephyr_account *zephyr,char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 GList *curr;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
658
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
659 for (curr = zephyr->pending_zloc_names; curr != NULL; curr = curr->next) {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
660 char* normalized_who = local_zephyr_normalize(zephyr,who);
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
661 if (!g_ascii_strcasecmp(normalized_who, (char *)curr->data)) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
662 g_free((char *)curr->data);
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
663 zephyr->pending_zloc_names = g_list_remove(zephyr->pending_zloc_names, curr->data);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
664 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
665 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
666 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
667 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
668 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
669
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
670 /* Called when the server notifies us a message couldn't get sent */
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
671
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
672 static void message_failed(GaimConnection *gc, ZNotice_t notice, struct sockaddr_in from)
8559
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
673 {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
674 if (g_ascii_strcasecmp(notice.z_class, "message")) {
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
675 gchar* chat_failed = g_strdup_printf(_("Unable send to chat %s,%s,%s"),notice.z_class,notice.z_class_inst,notice.z_recipient);
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
676 gaim_notify_error(gc,"",chat_failed,NULL);
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
677 g_free(chat_failed);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
678 } else {
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
679 gaim_notify_error(gc, notice.z_recipient, _("User is offline"), NULL);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
680 }
8559
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
681 }
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
682
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
683 static void handle_message(GaimConnection *gc,ZNotice_t notice, struct sockaddr_in from)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
684 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
685 zephyr_account* zephyr = gc->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
686
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
687 if (!g_ascii_strcasecmp(notice.z_class, LOGIN_CLASS)) {
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
688 /* well, we'll be updating in 20 seconds anyway, might as well ignore this. */
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
689 } else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) {
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
690 if (!g_ascii_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
691 int nlocs;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
692 char *user;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
693 GaimBuddy *b;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
694 /* XXX add real error reporting */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
695 if (ZParseLocations(&notice, NULL, &nlocs, &user) != ZERR_NONE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
696 return;
8435
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
697
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
698 if ((b = gaim_find_buddy(gc->account, user)) == NULL) {
9912
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
699 char* stripped_user = zephyr_strip_local_realm(zephyr,user);
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
700 b = gaim_find_buddy(gc->account,stripped_user);
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
701 g_free(stripped_user);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
702 }
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
703 if ((b && pending_zloc(zephyr,b->name)) || pending_zloc(zephyr,user)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
704 ZLocations_t locs;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
705 int one = 1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
706 GString *str = g_string_new("");
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
707
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
708 g_string_append_printf(str, _("<b>User:</b> %s<br>"), b ? b->name : user);
8435
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
709 if (b && b->alias)
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
710 g_string_append_printf(str, _("<b>Alias:</b> %s<br>"), b->alias);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
711 if (!nlocs) {
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
712 g_string_append_printf(str, _("<br>Hidden or not logged-in"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
713 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
714 for (; nlocs > 0; nlocs--) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
715 /* XXX add real error reporting */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
716 ZGetLocations(&locs, &one);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
717 g_string_append_printf(str, _("<br>At %s since %s"), locs.host, locs.time);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
718 }
9797
62eb9fe24692 [gaim-migrate @ 10665]
Luke Schierer <lschiere@pidgin.im>
parents: 9775
diff changeset
719 gaim_notify_userinfo(gc, b ? b->name : user, NULL, _("Buddy Information"), NULL,
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
720 str->str, NULL, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
721 g_string_free(str, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
722 } else
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
723 serv_got_update(gc, b->name, nlocs, 0, 0, 0, 0);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
724
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
725 g_free(user);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
726 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
727 } else {
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
728 char *buf, *buf2, *buf3;
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
729 char *send_inst;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
730 GaimConversation *gconv1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
731 GaimConvChat *gcc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
732 char *ptr = notice.z_message + strlen(notice.z_message) + 1;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
733 int len;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
734 char *sendertmp = g_strdup_printf("%s", zephyr->username);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
735 int signature_length = strlen(notice.z_message);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
736 int message_has_no_body = 0;
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
737 GaimConvImFlags flags = 0;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
738 gchar *tmpescape;
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
739
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
740 /* Need to deal with 0 length messages to handle typing notification (OPCODE) ping messages */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
741 /* One field zephyrs would have caused gaim to crash */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
742 if ( (notice.z_message_len == 0) || (signature_length >= notice.z_message_len - 1)) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
743 message_has_no_body = 1;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
744 len = 0;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
745 gaim_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
746 buf3 = g_strdup("");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
747
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
748 } else {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
749 len = notice.z_message_len - ( signature_length +1);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
750 gaim_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
751 buf = g_malloc(len + 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
752 g_snprintf(buf, len + 1, "%s", ptr);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
753 g_strchomp(buf);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
754 tmpescape = gaim_escape_html(buf);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
755 g_free(buf);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
756 buf2 = zephyr_to_html(tmpescape);
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
757 buf3 = zephyr_recv_convert(gc,buf2, strlen(buf2));
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
758 g_free(buf2);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
759 g_free(tmpescape);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
760 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
761
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
762 if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL")
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
763 && !g_ascii_strcasecmp(notice.z_recipient,zephyr->username)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
764 gchar* stripped_sender;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
765 if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:"))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
766 flags |= GAIM_CONV_IM_AUTO_RESP;
9912
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
767 stripped_sender = zephyr_strip_local_realm(zephyr,notice.z_sender);
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
768
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
769 if (!g_ascii_strcasecmp(notice.z_opcode,"PING"))
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
770 serv_got_typing(gc,stripped_sender,ZEPHYR_TYPING_RECV_TIMEOUT, GAIM_TYPING);
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
771 else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
772 /* Based on the values of
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
773 account->permit_deny,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
774 account->permit, account>deny , and
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
775 the buddylist */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
776
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
777 GSList* l;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
778 gboolean in_deny;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
779
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
780 switch (gc->account->perm_deny) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
781 case GAIM_PRIVACY_ALLOW_ALL:
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
782 in_deny = 0; break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
783 case GAIM_PRIVACY_DENY_ALL:
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
784 in_deny = 1; break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
785 case GAIM_PRIVACY_ALLOW_USERS: /* See if stripped_sender is in gc->account->permit and allow appropriately */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
786 in_deny = 1;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
787 for(l=gc->account->permit;l!=NULL;l=l->next) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
788 if (!gaim_utf8_strcasecmp(stripped_sender, gaim_normalize(gc->account, (char *)l->data))) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
789 in_deny=0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
790 break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
791 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
792 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
793 break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
794 case GAIM_PRIVACY_DENY_USERS: /* See if stripped_sender is in gc->account->deny and deny if so */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
795 in_deny = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
796 for(l=gc->account->deny;l!=NULL;l=l->next) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
797 if (!gaim_utf8_strcasecmp(stripped_sender, gaim_normalize(gc->account, (char *)l->data))) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
798 in_deny=1;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
799 break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
800 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
801 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
802 break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
803 case GAIM_PRIVACY_ALLOW_BUDDYLIST:
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
804 in_deny = 1;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
805 if (gaim_find_buddy(gc->account,stripped_sender)!=NULL) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
806 in_deny = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
807 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
808 break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
809 default:
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
810 in_deny=0; break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
811 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
812
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
813 if (!in_deny) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
814 serv_got_im(gc, stripped_sender, buf3, flags, time(NULL));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
815 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
816 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
817
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
818 g_free(stripped_sender);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
819 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
820 zephyr_triple *zt1, *zt2;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
821 gchar *send_inst_utf8;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
822 zephyr_account *zephyr = gc->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
823 zt1 = new_triple(gc->proto_data,notice.z_class, notice.z_class_inst, notice.z_recipient);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
824 zt2 = find_sub_by_triple(gc->proto_data,zt1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
825 if (!zt2) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
826 /* This is a server supplied subscription */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
827 zephyr->subscrips = g_slist_append(zephyr->subscrips, new_triple(zephyr,zt1->class,zt1->instance,zt1->recipient));
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
828 zt2 = find_sub_by_triple(gc->proto_data,zt1);
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
829 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
830
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
831 if (!zt2->open) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
832 zt2->open = TRUE;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
833 serv_got_joined_chat(gc, zt2->id, zt2->name);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
834 zephyr_chat_set_topic(gc,zt2->id,notice.z_class_inst);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
835 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
836 g_free(sendertmp); /* fix memory leak? */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
837 /* If the person is in the default Realm, then strip the
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
838 Realm from the sender field */
9912
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
839 sendertmp = zephyr_strip_local_realm(zephyr,notice.z_sender);
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
840 send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
841 send_inst_utf8 = zephyr_recv_convert(gc,send_inst, strlen(send_inst));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
842 if (!send_inst_utf8) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
843 gaim_debug(GAIM_DEBUG_ERROR, "zephyr","send_inst %s became null\n", send_inst);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
844 send_inst_utf8 = "malformed instance";
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
845 }
9912
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
846
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
847 serv_got_chat_in(gc, zt2->id, send_inst_utf8, 0, buf3, time(NULL));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
848 g_free(send_inst);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
849 gconv1 = gaim_find_conversation_with_account(zt2->name, gc->account);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
850 gcc = gaim_conversation_get_chat_data(gconv1);
9912
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
851
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
852 if (!gaim_conv_chat_find_user(gcc, sendertmp)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
853 /* force interpretation in network byte order */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
854 unsigned char *addrs = (unsigned char *)&(notice.z_sender_addr.s_addr);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
855 gchar* ipaddr = g_strdup_printf("%hhd.%hhd.%hhd.%hhd", (unsigned char)addrs[0],
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
856 (unsigned char)addrs[1], (unsigned char)addrs[2],
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
857 (unsigned char) addrs[3]);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
858
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
859 gaim_conv_chat_add_user(gcc, sendertmp, ipaddr, GAIM_CBFLAGS_NONE, TRUE);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
860 g_free(ipaddr); /* fix memory leak? */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
861
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
862 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
863 g_free(sendertmp);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
864 g_free(send_inst_utf8);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
865
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
866 free_triple(zt1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
867 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
868 g_free(buf3);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
869
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
870 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
871 }
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
872 int free_parse_tree(parse_tree* tree) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
873 if (!tree) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
874 return 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
875 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
876 else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
877 int i;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
878 if (tree->children) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
879 for(i=0;i<tree->num_children;i++){
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
880 if (tree->children[i]) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
881 free_parse_tree(tree->children[i]);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
882 g_free(tree->children[i]);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
883 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
884 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
885 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
886 if ((tree != &null_parse_tree) && (tree->contents != NULL))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
887 g_free(tree->contents);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
888
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
889 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
890 return 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
891 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
892
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
893 parse_tree *tree_child(parse_tree* tree,int index) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
894 if (index < tree->num_children) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
895 return tree->children[index];
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
896 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
897 return &null_parse_tree;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
898 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
899 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
900
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
901 parse_tree *find_node(parse_tree* ptree,gchar* key)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
902 {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
903 gchar* tc = tree_child(ptree,0)->contents;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
904
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
905 if (!ptree || ! key)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
906 return &null_parse_tree;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
907
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
908 if (ptree->num_children > 0 && tc && !strcasecmp(tc, key)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
909 return ptree;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
910 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
911 parse_tree *result = &null_parse_tree;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
912 int i;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
913 for(i = 0; i < ptree->num_children; i++) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
914 result = find_node(ptree->children[i],key);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
915 if(result != &null_parse_tree) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
916 break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
917 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
918 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
919 return result;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
920 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
921 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
922
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
923 parse_tree *parse_buffer(gchar* source, gboolean do_parse) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
924
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
925 parse_tree *ptree = g_new0(parse_tree,1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
926 ptree->contents = NULL;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
927 ptree->num_children=0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
928 if (do_parse) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
929 unsigned int p = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
930 while(p < strlen(source)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
931 unsigned int end;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
932 gchar *newstr;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
933
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
934 /* Eat white space: */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
935 if(g_ascii_isspace(source[p]) || source[p] == '\001') {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
936 p++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
937 continue;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
938 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
939
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
940 /* Skip comments */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
941 if(source[p] == ';') {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
942 while(source[p] != '\n' && p < strlen(source)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
943 p++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
944 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
945 continue;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
946 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
947
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
948 if(source[p] == '(') {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
949 int nesting = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
950 gboolean in_quote = FALSE;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
951 gboolean escape_next = FALSE;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
952 p++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
953 end = p;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
954 while(!(source[end] == ')' && nesting == 0 && !in_quote) && end < strlen(source)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
955 if(!escape_next) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
956 if(source[end] == '\\') {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
957 escape_next = TRUE;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
958 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
959 if(!in_quote) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
960 if(source[end] == '(') {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
961 nesting++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
962 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
963 if(source[end] == ')') {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
964 nesting--;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
965 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
966 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
967 if(source[end] == '"') {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
968 in_quote = !in_quote;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
969 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
970 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
971 escape_next = FALSE;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
972 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
973 end++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
974 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
975 do_parse = TRUE;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
976
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
977 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
978 gchar end_char;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
979 if(source[p] == '"') {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
980 end_char = '"';
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
981 p++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
982 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
983 end_char = ' ';
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
984 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
985 do_parse = FALSE;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
986
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
987 end = p;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
988 while(source[end] != end_char && end < strlen(source)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
989 if(source[end] == '\\')
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
990 end++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
991 end++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
992 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
993 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
994 newstr = g_new0(gchar, end+1-p);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
995 strncpy(newstr,source+p,end-p);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
996 if (ptree->num_children < MAXCHILDREN) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
997 /* In case we surpass maxchildren, ignore this */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
998 ptree->children[ptree->num_children++] = parse_buffer( newstr, do_parse);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
999 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1000 gaim_debug_error("zephyr","too many children in tzc output. skipping\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1001 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1002 g_free(newstr);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1003 p = end + 1;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1004 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1005 return ptree;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1006 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1007 /* XXX does this have to be strdup'd */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1008 ptree->contents = g_strdup(source);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1009 return ptree;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1010 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1011 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1012
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1013 parse_tree *read_from_tzc(zephyr_account* zephyr){
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1014 struct timeval tv;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1015 fd_set rfds;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1016 int bufsize = 2048;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1017 char *buf = (char *)calloc(bufsize, 1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1018 char *bufcur = buf;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1019 int selected = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1020 parse_tree *incoming_msg;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1021
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1022 FD_ZERO(&rfds);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1023 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1024 tv.tv_sec = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1025 tv.tv_usec = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1026 incoming_msg=NULL;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1027
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1028 while (select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1029 selected = 1;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1030 read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1031 bufcur++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1032 if ((bufcur - buf) > (bufsize - 1)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1033 if ((buf = realloc(buf, bufsize * 2)) == NULL) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1034 gaim_debug_error("zephyr","Ran out of memory");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1035 exit(-1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1036 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1037 bufcur = buf + bufsize;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1038 bufsize *= 2;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1039 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1040 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1041 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1042 *bufcur = '\0';
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1043
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1044 if (selected) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1045 incoming_msg = parse_buffer(buf,TRUE);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1046 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1047 free(buf);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1048 return incoming_msg;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1049 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1050
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1051 static gint check_notify_tzc(gpointer data)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1052 {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1053 GaimConnection *gc = (GaimConnection *)data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1054 zephyr_account* zephyr = gc->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1055 parse_tree *newparsetree = read_from_tzc(zephyr);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1056 struct sockaddr_in from;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1057 if (newparsetree != NULL) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1058 gchar *spewtype;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1059 if ( (spewtype = tree_child(find_node(newparsetree,"tzcspew"),2)->contents) ) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1060 if (!g_ascii_strncasecmp(spewtype,"message",7)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1061 ZNotice_t notice;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1062 parse_tree *msgnode = tree_child(find_node(newparsetree,"message"),2);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1063 parse_tree *bodynode = tree_child(msgnode,1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1064 /* char *zsig = g_strdup(" "); */ /* gaim doesn't care about zsigs */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1065 char *msg = zephyr_tzc_deescape_str(bodynode->contents);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1066 size_t bufsize = strlen(msg) + 3;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1067 char *buf = g_new0(char,bufsize);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1068 g_snprintf(buf,1+strlen(msg)+2," %c%s",'\0',msg);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1069 bzero((char *)&notice, sizeof(notice));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1070 notice.z_kind = ACKED;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1071 notice.z_port = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1072 notice.z_opcode = tree_child(find_node(newparsetree,"opcode"),2)->contents;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1073 notice.z_class = zephyr_tzc_deescape_str(tree_child(find_node(newparsetree,"class"),2)->contents);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1074 notice.z_class_inst = tree_child(find_node(newparsetree,"instance"),2)->contents;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1075 notice.z_recipient = local_zephyr_normalize(zephyr,tree_child(find_node(newparsetree,"recipient"),2)->contents);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1076 notice.z_sender = local_zephyr_normalize(zephyr,tree_child(find_node(newparsetree,"sender"),2)->contents);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1077 notice.z_default_format = "Class $class, Instance $instance:\n" "To: @bold($recipient) at $time $date\n" "From: @bold($1) <$sender>\n\n$2";
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1078 notice.z_message_len = strlen(msg) + 3;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1079 notice.z_message = buf;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1080 handle_message(gc,notice,from);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1081 g_free(msg);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1082 /* g_free(zsig); */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1083 g_free(buf);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1084 /* free_parse_tree(msgnode);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1085 free_parse_tree(bodynode);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1086 g_free(msg);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1087 g_free(zsig);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1088 g_free(buf);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1089 */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1090 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1091 else if (!g_ascii_strncasecmp(spewtype,"zlocation",9)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1092 /* check_loc or zephyr_zloc respectively */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1093 /* XXX fix */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1094 char *user;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1095 GaimBuddy *b;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1096 int nlocs = 0;
9912
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1097 parse_tree *locations;
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1098 gchar *locval;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1099 user = tree_child(find_node(newparsetree,"user"),2)->contents;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1100
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1101 if ((b = gaim_find_buddy(gc->account, user)) == NULL) {
9912
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1102 gchar *stripped_user = zephyr_strip_local_realm(zephyr,user);
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1103 b = gaim_find_buddy(gc->account, stripped_user);
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1104 g_free(stripped_user);
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1105 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1106 locations = find_node(newparsetree,"locations");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1107 locval = tree_child(tree_child(tree_child(tree_child(locations,2),0),0),2)->contents;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1108
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1109 if (!locval || !g_ascii_strcasecmp(locval," ") || (strlen(locval) == 0)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1110 nlocs = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1111 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1112 nlocs = 1;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1113 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1114
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1115 if ((b && pending_zloc(zephyr,b->name)) || pending_zloc(zephyr,user) || pending_zloc(zephyr,local_zephyr_normalize(zephyr,user))){
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1116 GString *str = g_string_new("");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1117
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1118 g_string_append_printf(str, _("<b>User:</b> %s<br>"), b ? b->name : user);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1119 if (b && b->alias)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1120 g_string_append_printf(str, _("<b>Alias:</b> %s<br>"), b->alias);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1121
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1122 if (!nlocs) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1123 g_string_append_printf(str, _("<br>Hidden or not logged-in"));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1124 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1125 g_string_append_printf(str, _("<br>At %s since %s"),
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1126 tree_child(tree_child(tree_child(tree_child(locations,2),0),0),2)->contents,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1127 tree_child(tree_child(tree_child(tree_child(locations,2),0),2),2)->contents);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1128 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1129
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1130 gaim_notify_userinfo(gc, b ? b->name : user, NULL, _("Buddy Information"), NULL,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1131 str->str, NULL, NULL);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1132 g_string_free(str, TRUE);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1133 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1134 serv_got_update(gc, b->name, nlocs, 0, 0, 0, 0);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1135 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1136 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1137 else if (!g_ascii_strncasecmp(spewtype,"subscribed",10)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1138 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1139 else if (!g_ascii_strncasecmp(spewtype,"start",5)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1140 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1141 else if (!g_ascii_strncasecmp(spewtype,"error",5)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1142 /* XXX handle */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1143 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1144 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1145 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1146 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1147 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1148
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1149 free_parse_tree(newparsetree);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1150 return TRUE;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1151 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1152
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1153 static gint check_notify_zeph02(gpointer data)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1154 {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1155 /* XXX add real error reporting */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1156 GaimConnection *gc = (GaimConnection*) data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1157 while (ZPending()) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1158 ZNotice_t notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1159 struct sockaddr_in from;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1160 /* XXX add real error reporting */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1161
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1162 z_call_r(ZReceiveNotice(&notice, &from));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1163
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1164 switch (notice.z_kind) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1165 case UNSAFE:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1166 case UNACKED:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1167 case ACKED:
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1168 handle_message(gc,notice, from);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1169 break;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1170 case SERVACK:
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1171 if (!(g_ascii_strcasecmp(notice.z_message, ZSRVACK_NOTSENT))) {
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1172 message_failed(gc,notice, from);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1173 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1174 break;
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1175 case CLIENTACK:
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1176 gaim_debug_error("zephyr", "Client ack received\n");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1177 default:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1178 /* we'll just ignore things for now */
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1179 handle_unknown(notice);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1180 gaim_debug_error("zephyr", "Unhandled notice.\n");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1181 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1182 }
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1183 /* XXX add real error reporting */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1184 ZFreeNotice(&notice);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1185 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1186
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1187 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1188 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1189
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1190 static gint check_loc(gpointer data)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1191 {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1192 GaimBlistNode *gnode, *cnode, *bnode;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1193 ZAsyncLocateData_t ald;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1194 GaimConnection *gc = (GaimConnection *)data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1195 zephyr_account *zephyr = gc->proto_data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1196
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1197 if (use_zeph02(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1198 ald.user = NULL;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1199 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1200 ald.version = NULL;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1201 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1202
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1203 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1204 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1205 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1206 for (cnode = gnode->child; cnode; cnode = cnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1207 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1208 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1209 for (bnode = cnode->child; bnode; bnode = bnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1210 GaimBuddy *b = (GaimBuddy *) bnode;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1211
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1212 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1213 continue;
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1214 if (b->account->gc == gc) {
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7126
diff changeset
1215 const char *chk;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1216
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1217 chk = local_zephyr_normalize(zephyr,b->name);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1218 gaim_debug_info("zephyr","chk: %s b->name %s\n",chk,b->name);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1219 /* XXX add real error reporting */
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1220 /* doesn't matter if this fails or not; we'll just move on to the next one */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1221 if (use_zeph02(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1222 #ifdef WIN32
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1223 int numlocs;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1224 int one=1;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1225 ZLocateUser(chk,&numlocs,ZAUTH);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1226 if (numlocs) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1227 int i;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1228 for(i=0;i<numlocs;i++) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1229 ZGetLocations(&locations,&one);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1230 serv_got_update(gc,b->name,1,0,0,0,0);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1231 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1232 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1233 #else
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1234 ZRequestLocations(chk, &ald, UNACKED, ZAUTH);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1235 g_free(ald.user);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1236 g_free(ald.version);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1237 #endif /* WIN32 */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1238 } else
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1239 if (use_tzc(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1240 gchar *zlocstr = g_strdup_printf("((tzcfodder . zlocate) \"%s\")\n",chk);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1241 write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,strlen(zlocstr));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1242 g_free(zlocstr);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1243 }
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1244 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1245 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1246 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1247 }
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1248
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1249 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1250 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1251
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1252 static char *get_exposure_level()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1253 {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1254 /* XXX add real error reporting */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1255 char *exposure = ZGetVariable("exposure");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1256
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1257 if (!exposure)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1258 return EXPOSE_REALMVIS;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1259 if (!g_ascii_strcasecmp(exposure, EXPOSE_NONE))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1260 return EXPOSE_NONE;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1261 if (!g_ascii_strcasecmp(exposure, EXPOSE_OPSTAFF))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1262 return EXPOSE_OPSTAFF;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1263 if (!g_ascii_strcasecmp(exposure, EXPOSE_REALMANN))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1264 return EXPOSE_REALMANN;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1265 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETVIS))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1266 return EXPOSE_NETVIS;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1267 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETANN))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1268 return EXPOSE_NETANN;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1269 return EXPOSE_REALMVIS;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1270 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1271
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1272 static void strip_comments(char *str)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1273 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1274 char *tmp = strchr(str, '#');
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1275
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1276 if (tmp)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1277 *tmp = '\0';
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1278 g_strchug(str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1279 g_strchomp(str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1280 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1281
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1282 static void zephyr_inithosts(zephyr_account *zephyr)
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1283 {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1284 /* XXX This code may not be Win32 clean */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1285 struct hostent *hent;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1286
9802
acf175d9f79b [gaim-migrate @ 10670]
Mark Doliner <mark@kingant.net>
parents: 9797
diff changeset
1287 if (gethostname(zephyr->ourhost, sizeof(zephyr->ourhost)) == -1) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1288 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "unable to retrieve hostname, %%host%% and %%canon%% will be wrong in subscriptions and have been set to unknown\n");
9802
acf175d9f79b [gaim-migrate @ 10670]
Mark Doliner <mark@kingant.net>
parents: 9797
diff changeset
1289 g_strlcpy(zephyr->ourhost, "unknown", sizeof(zephyr->ourhost));
9803
4d9d4940454b [gaim-migrate @ 10671]
Mark Doliner <mark@kingant.net>
parents: 9802
diff changeset
1290 g_strlcpy(zephyr->ourhostcanon, "unknown", sizeof(zephyr->ourhostcanon));
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1291 return;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1292 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1293
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1294 if (!(hent = gethostbyname(zephyr->ourhost))) {
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1295 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "unable to resolve hostname, %%canon%% will be wrong in subscriptions.and has been set to the value of %%host%%, %s\n",zephyr->ourhost);
9803
4d9d4940454b [gaim-migrate @ 10671]
Mark Doliner <mark@kingant.net>
parents: 9802
diff changeset
1296 g_strlcpy(zephyr->ourhostcanon, zephyr->ourhost, sizeof(zephyr->ourhostcanon));
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1297 return;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1298 }
9802
acf175d9f79b [gaim-migrate @ 10670]
Mark Doliner <mark@kingant.net>
parents: 9797
diff changeset
1299
acf175d9f79b [gaim-migrate @ 10670]
Mark Doliner <mark@kingant.net>
parents: 9797
diff changeset
1300 g_strlcpy(zephyr->ourhostcanon, hent->h_name, sizeof(zephyr->ourhostcanon));
acf175d9f79b [gaim-migrate @ 10670]
Mark Doliner <mark@kingant.net>
parents: 9797
diff changeset
1301
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1302 return;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1303 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1304
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1305 static void process_zsubs(zephyr_account *zephyr)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1306 {
9802
acf175d9f79b [gaim-migrate @ 10670]
Mark Doliner <mark@kingant.net>
parents: 9797
diff changeset
1307 /* Loads zephyr chats "(subscriptions) from ~/.zephyr.subs, and
acf175d9f79b [gaim-migrate @ 10670]
Mark Doliner <mark@kingant.net>
parents: 9797
diff changeset
1308 registers (subscribes to) them on the server */
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1309
9802
acf175d9f79b [gaim-migrate @ 10670]
Mark Doliner <mark@kingant.net>
parents: 9797
diff changeset
1310 /* XXX deal with unsubscriptions */
acf175d9f79b [gaim-migrate @ 10670]
Mark Doliner <mark@kingant.net>
parents: 9797
diff changeset
1311 /* XXX deal with punts */
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1312
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1313 FILE *f;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1314 gchar *fname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1315 gchar buff[BUFSIZ];
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1316
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
1317 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1318 f = fopen(fname, "r");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1319 if (f) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1320 char **triple;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1321 char *recip;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1322 char *z_class;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1323 char *z_instance;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1324 char *z_galaxy = NULL;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1325
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1326 while (fgets(buff, BUFSIZ, f)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1327 strip_comments(buff);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1328 if (buff[0]) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1329 triple = g_strsplit(buff, ",", 3);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1330 if (triple[0] && triple[1]) {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1331 char *tmp = g_strdup_printf("%s", zephyr->username);
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1332 char *atptr;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1333
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1334 z_class = triple[0];
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1335 z_instance = triple[1];
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1336 if (triple[2] == NULL) {
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1337 recip = g_malloc0(1);
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1338 } else if (!g_ascii_strcasecmp(triple[2], "%me%")) {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1339 recip = g_strdup_printf("%s", zephyr->username);
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1340 } else if (!g_ascii_strcasecmp(triple[2], "*")) {
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1341 /* wildcard
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1342 * form of class,instance,* */
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1343 recip = g_malloc0(1);
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1344 } else if (!g_ascii_strcasecmp(triple[2], tmp)) {
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1345 /* form of class,instance,aatharuv@ATHENA.MIT.EDU */
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1346 recip = g_strdup(triple[2]);
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1347 } else if ((atptr = strchr(triple[2], '@')) != NULL) {
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1348 /* form of class,instance,*@ANDREW.CMU.EDU
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1349 * class,instance,@ANDREW.CMU.EDU
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1350 * If realm is local realm, blank recipient, else
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1351 * @REALM-NAME
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1352 */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1353 char *realmat = g_strdup_printf("@%s",zephyr->realm);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1354
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1355 if (!g_ascii_strcasecmp(atptr, realmat))
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1356 recip = g_malloc0(1);
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1357 else
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1358 recip = g_strdup(atptr);
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1359 g_free(realmat);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1360 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1361 recip = g_strdup(triple[2]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1362 }
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
1363 g_free(tmp);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1364
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1365 if (!g_ascii_strcasecmp(triple[0],"%host%")) {
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1366 z_class = g_strdup(zephyr->ourhost);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1367 } else if (!g_ascii_strcasecmp(triple[0],"%canon%")) {
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1368 z_class = g_strdup(zephyr->ourhostcanon);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1369 } else {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1370 z_class = g_strdup(triple[0]);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1371 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1372
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1373 if (!g_ascii_strcasecmp(triple[1],"%host%")) {
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1374 z_instance = g_strdup(zephyr->ourhost);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1375 } else if (!g_ascii_strcasecmp(triple[1],"%canon%")) {
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1376 z_instance = g_strdup(zephyr->ourhostcanon);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1377 } else {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1378 z_instance = g_strdup(triple[1]);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1379 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1380
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1381 /* There should be some sort of error report listing classes that couldn't be subbed to.
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1382 Not important right now though */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1383
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1384 if (zephyr_subscribe_to(zephyr,z_class, z_instance, recip,z_galaxy) != ZERR_NONE) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1385
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1386 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Couldn't subscribe to %s, %s, %s\n", z_class,z_instance,recip);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1387 }
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1388
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1389 zephyr->subscrips = g_slist_append(zephyr->subscrips, new_triple(zephyr,z_class,z_instance,recip));
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1390 /* g_hash_table_destroy(sub_hash_table); */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1391 g_free(z_instance);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1392 g_free(z_class);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1393 g_free(recip);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1394 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1395 g_strfreev(triple);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1396 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1397 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1398 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1399 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1400
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1401 static void process_anyone(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1402 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1403 FILE *fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1404 gchar buff[BUFSIZ], *filename;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1405 GaimGroup *g;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1406 GaimBuddy *b;
4775
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
1407
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
1408 if (!(g = gaim_find_group(_("Anyone")))) {
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
1409 g = gaim_group_new(_("Anyone"));
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
1410 gaim_blist_add_group(g, NULL);
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
1411 }
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1412
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
1413 filename = g_strconcat(gaim_home_dir(), "/.anyone", NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1414 if ((fd = fopen(filename, "r")) != NULL) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1415 while (fgets(buff, BUFSIZ, fd)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1416 strip_comments(buff);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4682
diff changeset
1417 if (buff[0]) {
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1418 if (!(b = gaim_find_buddy(gc->account, buff))) {
9912
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1419 char *stripped_user = zephyr_strip_local_realm(gc->proto_data,buff);
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1420 gaim_debug_info("zephyr","stripped_user %s\n",stripped_user);
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1421 if (!(b = gaim_find_buddy(gc->account,stripped_user))){
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1422 b = gaim_buddy_new(gc->account, stripped_user, NULL);
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1423 gaim_blist_add_buddy(b, NULL, g, NULL);
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1424 }
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1425 g_free(stripped_user);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1426 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1427 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1428 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1429 fclose(fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1430 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1431 g_free(filename);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1432 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1433
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1434 static void zephyr_login(GaimAccount * account)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1435 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1436 GaimConnection *gc;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1437 zephyr_account *zephyr;
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1438
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1439 gc = gaim_account_get_connection(account);
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1440 gc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_URLDESC;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1441 gc->proto_data = zephyr=g_new0(zephyr_account,1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1442 zephyr->account = account;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1443 zephyr->exposure = g_strdup(gaim_account_get_string(gc->account, "exposure_level", EXPOSE_REALMVIS));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1444
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1445 if (gaim_account_get_bool(gc->account,"use_tzc",0)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1446 zephyr->connection_type = GAIM_ZEPHYR_TZC;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1447 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1448 zephyr->connection_type = GAIM_ZEPHYR_KRB4;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1449 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1450
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1451 zephyr->encoding = (char *)gaim_account_get_string(gc->account, "encoding", ZEPHYR_FALLBACK_CHARSET);
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1452 gaim_connection_update_progress(gc, _("Connecting"), 0, 8);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1453
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1454 /* XXX z_call_s should actually try to report the com_err determined error */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1455 if (use_tzc(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1456 pid_t pid;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1457 /* gaim_connection_error(gc,"tzc not supported yet"); */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1458 if ((pipe(zephyr->totzc) != 0) || (pipe(zephyr->fromtzc) != 0)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1459 gaim_debug_error("zephyr", "pipe creation failed. killing\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1460 exit(-1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1461 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1462
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1463 pid = fork();
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1464
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1465 if (pid == -1) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1466 gaim_debug_error("zephyr", "forking failed\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1467 exit(-1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1468 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1469 if (pid == 0) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1470 unsigned int i=0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1471 gboolean found_ps = FALSE;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1472 gchar ** tzc_cmd_array = g_strsplit(gaim_account_get_string(gc->account,"tzc_command","/usr/bin/tzc -e %s")," ",0);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1473 if (close(1) == -1) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1474 gaim_debug_error("zephyr", "stdout couldn't be closed. dying\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1475 exit(-1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1476 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1477 if (dup2(zephyr->fromtzc[1], 1) == -1) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1478 gaim_debug_error("zephyr", "dup2 of stdout failed \n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1479 exit(-1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1480 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1481 if (close(zephyr->fromtzc[1]) == -1) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1482 gaim_debug_error("zephyr", "closing of piped stdout failed\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1483 exit(-1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1484 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1485 if (close(0) == -1) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1486 gaim_debug_error("zephyr", "stdin couldn't be closed. dying\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1487 exit(-1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1488 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1489 if (dup2(zephyr->totzc[0], 0) == -1) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1490 gaim_debug_error("zephyr", "dup2 of stdin failed \n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1491 exit(-1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1492 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1493 if (close(zephyr->totzc[0]) == -1) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1494 gaim_debug_error("zephyr", "closing of piped stdin failed\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1495 exit(-1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1496 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1497 /* tzc_command should really be of the form
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1498 path/to/tzc -e %s
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1499 or
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1500 ssh username@hostname pathtotzc -e %s
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1501 -- this should not require a password, and ideally should be kerberized ssh --
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1502 or
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1503 fsh username@hostname pathtotzc -e %s
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1504 */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1505 while(tzc_cmd_array[i] != NULL){
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1506 if (!g_strncasecmp(tzc_cmd_array[i],"%s",2)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1507 /* fprintf(stderr,"replacing %%s with %s\n",zephyr->exposure); */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1508 tzc_cmd_array[i] = g_strdup(zephyr->exposure);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1509 found_ps = TRUE;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1510
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1511 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1512 /* fprintf(stderr,"keeping %s\n",tzc_cmd_array[i]); */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1513 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1514 i++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1515 }
8645
47f647dd2ac3 [gaim-migrate @ 9397]
Mark Doliner <mark@kingant.net>
parents: 8644
diff changeset
1516
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1517 if (!found_ps) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1518 gaim_connection_error(gc,"Tzc command needs %s to set the exposure\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1519 return;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1520 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1521
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1522 execvp(tzc_cmd_array[0], tzc_cmd_array);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1523 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1524 else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1525 fd_set rfds;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1526 int bufsize = 2048;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1527 char *buf = (char *)calloc(bufsize, 1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1528 char *bufcur = buf;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1529 struct timeval tv;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1530 char *ptr;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1531 int parenlevel=0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1532 char* tempstr;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1533 int tempstridx;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1534
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1535 zephyr->tzc_pid = pid;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1536 /* wait till we have data to read from ssh */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1537 FD_ZERO(&rfds);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1538 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1539
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1540 tv.tv_sec = 10;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1541 tv.tv_usec = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1542
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1543 gaim_debug_info("zephyr", "about to read from tzc\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1544
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1545 select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, NULL);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1546
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1547 FD_ZERO(&rfds);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1548 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1549 while (select(zephyr->fromtzc[ZEPHYR_FD_READ] + 1, &rfds, NULL, NULL, &tv)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1550 read(zephyr->fromtzc[ZEPHYR_FD_READ], bufcur, 1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1551 bufcur++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1552 if ((bufcur - buf) > (bufsize - 1)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1553 if ((buf = realloc(buf, bufsize * 2)) == NULL) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1554 exit(-1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1555 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1556 bufcur = buf + bufsize;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1557 bufsize *= 2;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1558 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1559 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1560 FD_ZERO(&rfds);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1561 FD_SET(zephyr->fromtzc[ZEPHYR_FD_READ], &rfds);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1562 tv.tv_sec = 10;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1563 tv.tv_usec = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1564
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1565 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1566 /* fprintf(stderr, "read from tzc\n"); */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1567 *bufcur = '\0';
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1568 ptr = buf;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1569
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1570 /* ignore all tzcoutput till we've received the first (*/
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1571 while (ptr < bufcur && (*ptr !='(')) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1572 ptr++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1573 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1574 if (ptr >=bufcur) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1575 gaim_connection_error(gc,"invalid output by tzc (or bad parsing code)");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1576 return;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1577 }
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1578
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1579 while(ptr < bufcur) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1580 if (*ptr == '(') {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1581 parenlevel++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1582 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1583 else if (*ptr == ')') {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1584 parenlevel--;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1585 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1586 gaim_debug_info("zephyr","tzc parenlevel is %d\n",parenlevel);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1587 switch (parenlevel) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1588 case 0:
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1589 break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1590 case 1:
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1591 /* Search for next beginning (, or for the ending */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1592 ptr++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1593 while((*ptr != '(') && (*ptr != ')') && (ptr <bufcur))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1594 ptr++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1595 if (ptr >= bufcur)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1596 gaim_debug_error("zephyr","tzc parsing error\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1597 break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1598 case 2:
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1599 /* You are probably at
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1600 (foo . bar ) or (foo . "bar") or (foo . chars) or (foo . numbers) or (foo . () )
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1601 Parse all the data between the first and last f, and move past )
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1602 */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1603 tempstr = g_malloc0(20000);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1604 tempstridx=0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1605 while(parenlevel >1) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1606 ptr++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1607 if (*ptr == '(')
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1608 parenlevel++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1609 if (*ptr == ')')
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1610 parenlevel--;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1611 if (parenlevel > 1) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1612 tempstr[tempstridx++]=*ptr;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1613 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1614 ptr++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1615 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1616 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1617 gaim_debug_info("zephyr","tempstr parsed\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1618 /* tempstr should now be a tempstridx length string containing all characters
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1619 from that after the first ( to the one before the last paren ). */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1620 /* We should have the following possible lisp strings but we don't care
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1621 (tzcspew . start) (version . "something") (pid . number)*/
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1622 /* We care about 'zephyrid . "username@REALM.NAME"' and 'exposure . "SOMETHING"' */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1623 tempstridx=0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1624 if (!g_ascii_strncasecmp(tempstr,"zephyrid",8)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1625 gchar* username = g_malloc0(100);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1626 int username_idx=0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1627 char *realm;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1628 gaim_debug_info("zephyr","zephyrid found\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1629 tempstridx+=8;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1630 while(tempstr[tempstridx] !='"' && tempstridx < 20000)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1631 tempstridx++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1632 tempstridx++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1633 while(tempstr[tempstridx] !='"' && tempstridx < 20000)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1634 username[username_idx++]=tempstr[tempstridx++];
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1635
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1636 zephyr->username = g_strdup_printf("%s",username);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1637 if ((realm = strchr(username,'@')))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1638 zephyr->realm = g_strdup_printf("%s",realm+1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1639 else
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1640 zephyr->realm = g_strdup("local-realm");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1641
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1642 g_free(username);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1643 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1644 gaim_debug_info("zephyr", "something that's not zephyr id found %s\n",tempstr);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1645 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1646
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1647 /* We don't care about anything else yet */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1648 g_free(tempstr);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1649 break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1650 default:
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1651 gaim_debug_info("zephyr","parenlevel is not 1 or 2\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1652 /* This shouldn't be happening */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1653 break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1654 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1655 if (parenlevel==0)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1656 break;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1657 } /* while (ptr < bufcur) { */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1658 gaim_debug_info("zephyr", "tzc startup done\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1659 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1660 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1661 else if ( use_zeph02(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1662 z_call_s(ZInitialize(), "Couldn't initialize zephyr");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1663 z_call_s(ZOpenPort(&(zephyr->port)), "Couldn't open port");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1664 z_call_s(ZSetLocation((char *)zephyr->exposure), "Couldn't set location");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1665
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1666 zephyr->username = g_strdup(ZGetSender());
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1667 zephyr->realm = g_strdup(ZGetRealm());
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1668 gaim_debug_info("zephyr","realm: %s\n",zephyr->realm);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1669 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1670 else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1671 gaim_connection_error(gc,"Only ZEPH0.2 supported currently");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1672 return;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1673 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1674 gaim_debug_info("zephyr","does it get here\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1675 gaim_debug_info("zephyr"," realm: %s username:%s\n", zephyr->realm, zephyr->username);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1676
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1677 /* For now */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1678 zephyr->galaxy = NULL;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1679 zephyr->krbtkfile = NULL;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1680 zephyr_inithosts(zephyr);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1681
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1682 if (zephyr_subscribe_to(zephyr,"MESSAGE","PERSONAL",zephyr->username,NULL) != ZERR_NONE) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1683 /* XXX don't translate this yet. It could be written better */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1684 /* XXX error messages could be handled with more detail */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1685 gaim_notify_error(account->gc, NULL,
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1686 "Unable to subscribe to messages", "Unable to subscribe to initial messages");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1687 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1688 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1689
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1690 gaim_connection_set_state(gc, GAIM_CONNECTED);
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1691 process_anyone(gc);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1692 process_zsubs(zephyr);
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1693 serv_finish_login(gc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1694
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1695 if (use_zeph02(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1696 zephyr->nottimer = gaim_timeout_add(100, check_notify_zeph02, gc);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1697 } else if (use_tzc(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1698 zephyr->nottimer = gaim_timeout_add(100, check_notify_tzc, gc);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1699 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1700 zephyr->loctimer = gaim_timeout_add(20000, check_loc, gc);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1701
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1702 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1703
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1704 static void write_zsubs(zephyr_account *zephyr)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1705 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1706 /* Exports subscription (chat) list back to
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1707 * .zephyr.subs
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1708 * XXX deal with %host%, %canon%, unsubscriptions, and negative subscriptions (punts?)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1709 */
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1710
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1711 GSList *s = zephyr->subscrips;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1712 zephyr_triple *zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1713 FILE *fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1714 char *fname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1715
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1716 char **triple;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1717
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
1718 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1719 fd = fopen(fname, "w");
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1720
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1721 if (!fd) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1722 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1723 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1724 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1725
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1726 while (s) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1727 char *zclass, *zinst, *zrecip;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1728 zt = s->data;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1729 triple = g_strsplit(zt->name, ",", 3);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1730
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1731 /* deal with classes */
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1732 if (!g_ascii_strcasecmp(triple[0],zephyr->ourhost)) {
9775
4c1a1be8ce33 [gaim-migrate @ 10643]
Mark Doliner <mark@kingant.net>
parents: 9754
diff changeset
1733 zclass = g_strdup("%host%");
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1734 } else if (!g_ascii_strcasecmp(triple[0],zephyr->ourhostcanon)) {
9775
4c1a1be8ce33 [gaim-migrate @ 10643]
Mark Doliner <mark@kingant.net>
parents: 9754
diff changeset
1735 zclass = g_strdup("%canon%");
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1736 } else {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1737 zclass = g_strdup(triple[0]);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1738 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1739
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1740 /* deal with instances */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1741
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1742 if (!g_ascii_strcasecmp(triple[1],zephyr->ourhost)) {
9775
4c1a1be8ce33 [gaim-migrate @ 10643]
Mark Doliner <mark@kingant.net>
parents: 9754
diff changeset
1743 zinst = g_strdup("%host%");
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1744 } else if (!g_ascii_strcasecmp(triple[1],zephyr->ourhostcanon)) {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1745 zinst = g_strdup("%canon%");;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1746 } else {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1747 zinst = g_strdup(triple[1]);
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1748 }
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1749
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1750 /* deal with recipients */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1751 if (triple[2] == NULL) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1752 zrecip = g_strdup("*");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1753 } else if (!g_ascii_strcasecmp(triple[2],"")){
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1754 zrecip = g_strdup("*");
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1755 } else if (!g_ascii_strcasecmp(triple[2], zephyr->username)) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1756 zrecip = g_strdup("%me%");
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1757 } else {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1758 zrecip = g_strdup(triple[2]);
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1759 }
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1760
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1761 fprintf(fd, "%s,%s,%s\n",zclass,zinst,zrecip);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1762
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1763 g_free(zclass);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1764 g_free(zinst);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1765 g_free(zrecip);
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1766 g_free(triple);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1767 s = s->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1768 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1769 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1770 fclose(fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1771 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1772
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1773 static void write_anyone(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1774 {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1775 GaimBlistNode *gnode, *cnode, *bnode;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1776 GaimBuddy *b;
9912
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1777 char *fname;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1778 FILE *fd;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1779 zephyr_account* zephyr = gc->proto_data;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
1780 fname = g_strdup_printf("%s/.anyone", gaim_home_dir());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1781 fd = fopen(fname, "w");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1782 if (!fd) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1783 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1784 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1785 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1786
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1787 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1788 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1789 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1790 for (cnode = gnode->child; cnode; cnode = cnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1791 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1792 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1793 for (bnode = cnode->child; bnode; bnode = bnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1794 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1795 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1796 b = (GaimBuddy *) bnode;
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1797 if (b->account == gc->account) {
9912
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1798 gchar *stripped_user = zephyr_strip_local_realm(zephyr,b->name);
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1799 fprintf(fd, "%s\n", stripped_user);
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
1800 g_free(stripped_user);
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1801 }
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1802 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1803 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1804 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1805
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1806 fclose(fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1807 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1808 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1809
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1810 static void zephyr_close(GaimConnection * gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1811 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1812 GList *l;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1813 GSList *s;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1814 zephyr_account *zephyr = gc->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1815 pid_t tzc_pid = zephyr->tzc_pid;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1816
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1817 l = zephyr->pending_zloc_names;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1818 while (l) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1819 g_free((char *)l->data);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1820 l = l->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1821 }
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1822 g_list_free(zephyr->pending_zloc_names);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1823
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1824 if (gaim_account_get_bool(gc->account, "write_anyone", FALSE))
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1825 write_anyone(gc);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1826
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1827 if (gaim_account_get_bool(gc->account, "write_zsubs", FALSE))
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1828 write_zsubs(gc->proto_data);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1829
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1830 s = zephyr->subscrips;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1831 while (s) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1832 free_triple((zephyr_triple *) s->data);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1833 s = s->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1834 }
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1835 g_slist_free(zephyr->subscrips);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1836
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1837 if (zephyr->nottimer)
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1838 gaim_timeout_remove(zephyr->nottimer);
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1839 zephyr->nottimer = 0;
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1840 if (zephyr->loctimer)
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1841 gaim_timeout_remove(zephyr->loctimer);
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1842 zephyr->loctimer = 0;
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1843 gc = NULL;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1844 if (use_zeph02(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1845 z_call(ZCancelSubscriptions(0));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1846 z_call(ZUnsetLocation());
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1847 z_call(ZClosePort());
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1848 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1849 /* assume tzc */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1850 if (kill(tzc_pid,SIGTERM) == -1) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1851 int err=errno;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1852 if (err==EINVAL) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1853 gaim_debug_error("zephyr","An invalid signal was specified when killing tzc\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1854 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1855 else if (err==ESRCH) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1856 gaim_debug_error("zephyr","Tzc's pid didn't exist while killing tzc\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1857 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1858 else if (err==EPERM) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1859 gaim_debug_error("zephyr","gaim didn't have permission to kill tzc\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1860 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1861 else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1862 gaim_debug_error("zephyr","miscellaneous error while attempting to close tzc\n");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1863 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1864 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1865 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1866 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1867
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1868 static int zephyr_send_message(zephyr_account *zephyr,char* zclass, char* instance, char* recipient, const char *im,
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1869 const char *sig, char *opcode) ;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1870
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1871 const char * zephyr_get_signature()
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1872 {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1873 /* XXX add zephyr error reporting */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1874 const char * sig =ZGetVariable("zwrite-signature");
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1875 if (!sig) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1876 sig = g_get_real_name();
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1877 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1878 return sig;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1879 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1880
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1881 static int zephyr_chat_send(GaimConnection * gc, int id, const char *im)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1882 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1883 zephyr_triple *zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1884 const char *sig;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1885 GaimConversation *gconv1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1886 GaimConvChat *gcc;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1887 char *inst;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1888 char *recipient;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1889 zephyr_account *zephyr = gc->proto_data;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1890
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1891 zt = find_sub_by_id(gc->proto_data,id);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1892 if (!zt)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1893 /* this should never happen. */
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
1894 return -EINVAL;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1895
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1896 sig = zephyr_get_signature();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1897
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
1898 gconv1 = gaim_find_conversation_with_account(zt->name, gc->account);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1899 gcc = gaim_conversation_get_chat_data(gconv1);
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1900
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1901 if (!(inst = (char *)gaim_conv_chat_get_topic(gcc)))
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1902 inst = g_strdup("PERSONAL");
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1903
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1904 if (!g_ascii_strcasecmp(zt->recipient, "*"))
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1905 recipient = local_zephyr_normalize(zephyr,"");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1906 else
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1907 recipient = local_zephyr_normalize(zephyr,zt->recipient);
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1908
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1909 zephyr_send_message(zephyr,zt->class,inst,recipient,im,sig,"");
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
1910 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1911 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1912
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1913
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1914 static int zephyr_send_im(GaimConnection * gc, const char *who, const char *im, GaimConvImFlags flags)
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1915 {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1916 const char *sig;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1917 zephyr_account *zephyr = gc->proto_data;
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
1918 if (flags & GAIM_CONV_IM_AUTO_RESP)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1919 sig = "Automated reply:";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1920 else {
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1921 sig = zephyr_get_signature();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1922 }
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1923 zephyr_send_message(zephyr,"MESSAGE","PERSONAL",local_zephyr_normalize(zephyr,who),im,sig,"");
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1924
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1925 return 1;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1926 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1927
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1928 /* Munge the outgoing zephyr so that any quotes or backslashes are
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1929 escaped and do not confuse tzc: */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1930
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1931 char* zephyr_tzc_escape_msg(const char *message)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1932 {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1933 int pos = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1934 int pos2 = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1935 char *newmsg;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1936
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1937 if (message && (strlen(message) > 0)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1938 newmsg = g_new0(char,1+strlen(message)*2);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1939 while(pos < strlen(message)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1940 if (message[pos]=='\\') {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1941 newmsg[pos2]='\\';
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1942 newmsg[pos2+1]='\\';
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1943 pos2+=2;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1944 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1945 else if (message[pos]=='"') {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1946 newmsg[pos2]='\\';
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1947 newmsg[pos2+1]='"';
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1948 pos2+=2;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1949 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1950 else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1951 newmsg[pos2] = message[pos];
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1952 pos2++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1953 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1954 pos++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1955 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1956 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1957 newmsg = g_strdup("");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1958 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1959 /* fprintf(stderr,"newmsg %s message %s\n",newmsg,message); */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1960 return newmsg;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1961 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1962
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1963 char* zephyr_tzc_deescape_str(const char *message)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1964 {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1965 int pos = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1966 int pos2 = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1967 char *newmsg;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1968
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1969 if (message && (strlen(message) > 0)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1970 newmsg = g_new0(char,strlen(message)+1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1971 while(pos < strlen(message)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1972 if (message[pos]=='\\') {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1973 pos++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1974 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1975 newmsg[pos2] = message[pos];
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1976 pos++;pos2++;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1977 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1978 newmsg[pos2]='\0';
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1979 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1980 newmsg = g_strdup("");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1981 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1982
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1983 return newmsg;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1984 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1985
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1986 static int zephyr_send_message(zephyr_account *zephyr,char* zclass, char* instance, char* recipient, const char *im,
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1987 const char *sig, char *opcode)
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1988 {
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1989
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1990 /* (From the tzc source)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1991 * emacs sends something of the form:
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1992 * ((class . "MESSAGE")
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1993 * (auth . t)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1994 * (recipients ("PERSONAL" . "bovik") ("test" . ""))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1995 * (sender . "bovik")
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1996 * (message . ("Harry Bovik" "my zgram"))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1997 * )
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1998 */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
1999 char *html_buf;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2000 char *html_buf2;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2001 html_buf = html_to_zephyr(im);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2002 html_buf2 = gaim_unescape_html(html_buf);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2003
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2004 if(use_tzc(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2005 char* zsendstr;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2006 /* CMU cclub tzc doesn't grok opcodes for now */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2007 char* tzc_sig = zephyr_tzc_escape_msg(sig);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2008 char *tzc_body = zephyr_tzc_escape_msg(html_buf2);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2009 zsendstr = g_strdup_printf("((tzcfodder . send) (class . \"%s\") (auth . t) (recipients (\"%s\" . \"%s\")) (message . (\"%s\" \"%s\")) ) \n",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2010 zclass, instance, recipient, tzc_sig, tzc_body);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2011 /* fprintf(stderr,"zsendstr = %s\n",zsendstr); */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2012 write(zephyr->totzc[ZEPHYR_FD_WRITE],zsendstr,strlen(zsendstr));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2013 g_free(zsendstr);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2014 } else if (use_zeph02(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2015 ZNotice_t notice;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2016 char *buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2017 bzero((char *)&notice, sizeof(notice));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2018
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2019 notice.z_kind = ACKED;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2020 notice.z_port = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2021 notice.z_opcode = "";
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2022 notice.z_class = zclass;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2023 notice.z_class_inst = instance;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2024 notice.z_recipient = recipient;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2025 notice.z_sender = 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2026 notice.z_default_format = "Class $class, Instance $instance:\n" "To: @bold($recipient) at $time $date\n" "From: @bold($1) <$sender>\n\n$2";
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2027 notice.z_message_len = strlen(html_buf2) + strlen(sig) + 2;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2028 notice.z_message = buf;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2029 notice.z_opcode = g_strdup(opcode);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2030 gaim_debug_info("zephyr","About to send notice");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2031 if (! ZSendNotice(&notice, ZAUTH) == ZERR_NONE) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2032 /* XXX handle errors here */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2033 return 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2034 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2035 gaim_debug_info("zephyr","notice sent");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2036 g_free(buf);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2037 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2038
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2039 g_free(html_buf2);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2040 g_free(html_buf);
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
2041
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2042 return 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2043 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2044
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2045 static const char *zephyr_normalize(const GaimAccount * account, const char *orig)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2046 {
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2047 /* returns the string you gave it. Maybe this function shouldn't be here */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2048 char * buf = g_malloc0(80);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2049 /* gaim_debug_error("zephyr","entering zephyr_normalize\n"); */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2050
7126
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
2051 if (!g_ascii_strcasecmp(orig, "")) {
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
2052 buf[0] = '\0';
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
2053 return buf;
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
2054 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2055 g_snprintf(buf, 80, "%s", orig);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2056 }
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2057 /* gaim_debug_error("zephyr","leaving zephyr_normalize\n"); */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2058
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2059 return buf;
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
2060 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
2061
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
2062
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2063 char *local_zephyr_normalize(zephyr_account *zephyr,const char *orig)
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
2064 {
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2065 /*
9912
f6a1054e2bdc [gaim-migrate @ 10804]
Luke Schierer <lschiere@pidgin.im>
parents: 9911
diff changeset
2066 Basically the inverse of zephyr_strip_local_realm
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2067 */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2068 char* buf;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2069
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
2070 if (!g_ascii_strcasecmp(orig, "")) {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2071 return g_strdup("");
7126
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
2072 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2073
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2074 if (strchr(orig,'@')) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2075 buf = g_strdup_printf("%s",orig);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2076 } else {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2077 buf = g_strdup_printf("%s@%s",orig,zephyr->realm);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2078 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2079 return buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2080 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2081
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
2082 static void zephyr_zloc(GaimConnection *gc, const char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2083 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2084 ZAsyncLocateData_t ald;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2085 zephyr_account *zephyr = gc->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2086 gchar* normalized_who = local_zephyr_normalize(zephyr,who);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2087
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2088 if (use_zeph02(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2089 if (ZRequestLocations(normalized_who, &ald, UNACKED, ZAUTH) == ZERR_NONE) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2090 zephyr->pending_zloc_names = g_list_append(zephyr->pending_zloc_names,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2091 g_strdup(normalized_who));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2092 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2093 /* XXX deal with errors somehow */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2094 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2095 } else if (use_tzc(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2096 char* zlocstr = g_strdup_printf("((tzcfodder . zlocate) \"%s\")\n",normalized_who);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2097 zephyr->pending_zloc_names = g_list_append(zephyr->pending_zloc_names, g_strdup(normalized_who));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2098 write(zephyr->totzc[ZEPHYR_FD_WRITE],zlocstr,strlen(zlocstr));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2099 g_free(zlocstr);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2100 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2101 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2102
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2103 static void zephyr_set_away(GaimConnection * gc, const char *state, const char *msg)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2104 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2105 zephyr_account *zephyr = gc->proto_data;
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
2106 if (gc->away) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2107 g_free(gc->away);
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
2108 gc->away = NULL;
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
2109 }
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
2110
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
2111 if (!g_ascii_strcasecmp(state, _("Hidden"))) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2112 /* XXX handle errors */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2113 if (use_zeph02(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2114 ZSetLocation(EXPOSE_OPSTAFF);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2115 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2116 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,EXPOSE_OPSTAFF);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2117 write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,strlen(zexpstr));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2118 g_free(zexpstr);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2119 }
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
2120 gc->away = g_strdup("");
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2121 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2122 else if (!g_ascii_strcasecmp(state, _("Online"))) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2123 /* XXX handle errors */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2124 if (use_zeph02(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2125 ZSetLocation(get_exposure_level());
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2126 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2127 else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2128 char *zexpstr = g_strdup_printf("((tzcfodder . set-location) (hostname . \"%s\") (exposure . \"%s\"))\n",zephyr->ourhost,zephyr->exposure);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2129 write(zephyr->totzc[ZEPHYR_FD_WRITE],zexpstr,strlen(zexpstr));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2130 g_free(zexpstr);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2131 }
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2132 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2133 else /* state is GAIM_AWAY_CUSTOM */ if (msg)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2134 gc->away = g_strdup(msg);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2135 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2136
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2137 static GList *zephyr_away_states(GaimConnection * gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2138 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2139 GList *m = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2140
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
2141 m = g_list_append(m, _("Online"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2142 m = g_list_append(m, GAIM_AWAY_CUSTOM);
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
2143 m = g_list_append(m, _("Hidden"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2144
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2145 return m;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2146 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2147
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2148 static GList *zephyr_chat_info(GaimConnection * gc)
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2149 {
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2150 GList *m = NULL;
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2151 struct proto_chat_entry *pce;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2152
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2153 pce = g_new0(struct proto_chat_entry, 1);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2154
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7475
diff changeset
2155 pce->label = _("_Class:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
2156 pce->identifier = "class";
3158
ea6f8d8d74e5 [gaim-migrate @ 3174]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
2157 m = g_list_append(m, pce);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2158
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2159 pce = g_new0(struct proto_chat_entry, 1);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2160
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7475
diff changeset
2161 pce->label = _("_Instance:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
2162 pce->identifier = "instance";
3158
ea6f8d8d74e5 [gaim-migrate @ 3174]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
2163 m = g_list_append(m, pce);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2164
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2165 pce = g_new0(struct proto_chat_entry, 1);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2166
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7475
diff changeset
2167 pce->label = _("_Recipient:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
2168 pce->identifier = "recipient";
3158
ea6f8d8d74e5 [gaim-migrate @ 3174]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
2169 m = g_list_append(m, pce);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2170
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2171 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2172 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2173
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2174 /* Called when the server notifies us a message couldn't get sent */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2175
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2176 static void zephyr_subscribe_failed(GaimConnection *gc,char * z_class, char *z_instance, char * z_recipient, char* z_galaxy)
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2177 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2178 gchar* subscribe_failed = g_strdup_printf(_("Attempt to subscribe to %s,%s,%s failed"), z_class, z_instance,z_recipient);
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
2179 gaim_notify_error(gc,"", subscribe_failed, NULL);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2180 g_free(subscribe_failed);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2181 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2182
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2183 static void zephyr_join_chat(GaimConnection * gc, GHashTable * data)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2184 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2185 /* ZSubscription_t sub; */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2186 zephyr_triple *zt1, *zt2;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2187 const char *classname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2188 const char *instname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2189 const char *recip;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2190 zephyr_account *zephyr=gc->proto_data;
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
2191 classname = g_hash_table_lookup(data, "class");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
2192 instname = g_hash_table_lookup(data, "instance");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
2193 recip = g_hash_table_lookup(data, "recipient");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
2194
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2195
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2196 if (!classname)
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
2197 return;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2198
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2199 if (!g_ascii_strcasecmp(classname,"%host%"))
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2200 classname = g_strdup(zephyr->ourhost);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2201 if (!g_ascii_strcasecmp(classname,"%canon%"))
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2202 classname = g_strdup(zephyr->ourhostcanon);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2203
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2204 if (!instname || !strlen(instname))
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2205 instname = "*";
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2206
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2207 if (!g_ascii_strcasecmp(instname,"%host%"))
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2208 instname = g_strdup(zephyr->ourhost);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2209 if (!g_ascii_strcasecmp(instname,"%canon%"))
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2210 instname = g_strdup(zephyr->ourhostcanon);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2211
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2212 if (!recip || (*recip == '*'))
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2213 recip = "";
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
2214 if (!g_ascii_strcasecmp(recip, "%me%"))
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2215 recip = zephyr->username;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2216
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
2217 zt1 = new_triple(gc->proto_data,classname, instname, recip);
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
2218 zt2 = find_sub_by_triple(gc->proto_data,zt1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2219 if (zt2) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2220 free_triple(zt1);
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2221 if (!zt2->open) {
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2222 if (!g_ascii_strcasecmp(instname,"*"))
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2223 instname = "PERSONAL";
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2224 serv_got_joined_chat(gc, zt2->id, zt2->name);
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2225 zephyr_chat_set_topic(gc,zt2->id,instname);
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2226 zt2->open = TRUE;
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2227 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2228 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2229 }
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2230
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2231 /* sub.zsub_class = zt1->class;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2232 sub.zsub_classinst = zt1->instance;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2233 sub.zsub_recipient = zt1->recipient; */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2234
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2235 if (zephyr_subscribe_to(zephyr,zt1->class,zt1->instance,zt1->recipient,NULL) != ZERR_NONE) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2236 /* XXX output better subscription information */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2237 zephyr_subscribe_failed(gc,zt1->class,zt1->instance,zt1->recipient,NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2238 free_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2239 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2240 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2241
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
2242 zephyr->subscrips = g_slist_append(zephyr->subscrips, zt1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2243 zt1->open = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2244 serv_got_joined_chat(gc, zt1->id, zt1->name);
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2245 if (!g_ascii_strcasecmp(instname,"*"))
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
2246 instname = "PERSONAL";
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2247 zephyr_chat_set_topic(gc,zt1->id,instname);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2248 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2249
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2250 static void zephyr_chat_leave(GaimConnection * gc, int id)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2251 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2252 zephyr_triple *zt;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2253 zephyr_account *zephyr = gc->proto_data;
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
2254 zt = find_sub_by_id(zephyr,id);
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2255
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2256 if (zt) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2257 zt->open = FALSE;
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
2258 zt->id = ++(zephyr->last_id);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2259 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2260 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2261
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2262 static GaimChat *zephyr_find_blist_chat(GaimAccount *account, const char *name)
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2263 {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2264 GaimBlistNode *gnode, *cnode;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2265
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2266 /* XXX needs to be %host%,%canon%, and %me% clean */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2267 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2268 for(cnode = gnode->child; cnode; cnode = cnode->next) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2269 GaimChat *chat = (GaimChat*)cnode;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2270 char *zclass, *inst, *recip;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2271 char** triple;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2272 if(!GAIM_BLIST_NODE_IS_CHAT(cnode))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2273 continue;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2274 if(chat->account !=account)
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2275 continue;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2276 if(!(zclass = g_hash_table_lookup(chat->components, "class")))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2277 continue;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2278 if(!(inst = g_hash_table_lookup(chat->components, "instance")))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2279 inst = g_strdup("");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2280 if(!(recip = g_hash_table_lookup(chat->components, "recipient")))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2281 recip = g_strdup("");
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2282 /* gaim_debug_info("zephyr","in zephyr_find_blist_chat name: %s\n",name?name:""); */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2283 triple = g_strsplit(name,",",3);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2284 if (!g_ascii_strcasecmp(triple[0],zclass) && !g_ascii_strcasecmp(triple[1],inst) && !g_ascii_strcasecmp(triple[2],recip))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2285 return chat;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2286
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2287 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2288 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2289 return NULL;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2290 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2291 static const char *zephyr_list_icon(GaimAccount * a, GaimBuddy * b)
5202
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
2292 {
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
2293 return "zephyr";
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
2294 }
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
2295
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2296 static int zephyr_send_typing(GaimConnection *gc, const char *who, int typing) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2297 gchar *recipient;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2298 zephyr_account *zephyr = gc->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2299 if (use_tzc(zephyr))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2300 return 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2301
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2302 if (!typing)
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2303 return 0;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2304 /* XXX We probably should care if this fails. Or maybe we don't want to */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2305 if (!who) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2306 gaim_debug_info("zephyr", "who is null\n");
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2307 recipient = local_zephyr_normalize(zephyr,"");
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2308 } else {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2309 /* Don't ping broadcast (chat) recipients */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2310 /* The strrchr case finds a realm-stripped broadcast subscription
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2311 e.g. comma is the last character in the string */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2312 if ((strrchr(who, ',') && ((strrchr(who, ',') == (who+strlen(who)-1)) || ((char *)(strrchr(who, ',')[1] == '@')))))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2313 return 0;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2314
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2315 recipient = local_zephyr_normalize(zephyr,who);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2316 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2317
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2318 gaim_debug_info("zephyr","about to send typing notification to %s\n",recipient);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2319 zephyr_send_message(zephyr,"MESSAGE","PERSONAL",recipient,"","","PING");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2320 gaim_debug_info("zephyr","sent typing notification\n");
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2321 return ZEPHYR_TYPING_SEND_TIMEOUT;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2322 }
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
2323
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2324
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2325
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2326 static void zephyr_chat_set_topic(GaimConnection * gc, int id, const char *topic)
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2327 {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2328 zephyr_triple *zt;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2329 GaimConversation *gconv;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2330 GaimConvChat *gcc;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2331 gchar *topic_utf8;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2332 zephyr_account* zephyr = gc->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2333 char *sender = (char *)zephyr->username;
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
2334
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
2335 zt = find_sub_by_id(gc->proto_data,id);
9911
4f1fcf5efaf9 [gaim-migrate @ 10803]
Luke Schierer <lschiere@pidgin.im>
parents: 9896
diff changeset
2336 /* find_sub_by_id can return NULL */
4f1fcf5efaf9 [gaim-migrate @ 10803]
Luke Schierer <lschiere@pidgin.im>
parents: 9896
diff changeset
2337 if (!zt)
4f1fcf5efaf9 [gaim-migrate @ 10803]
Luke Schierer <lschiere@pidgin.im>
parents: 9896
diff changeset
2338 return;
9610
a6362795bf2c [gaim-migrate @ 10453]
Luke Schierer <lschiere@pidgin.im>
parents: 9597
diff changeset
2339 gconv = gaim_find_conversation_with_account(zt->name, gc->account);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2340 gcc = gaim_conversation_get_chat_data(gconv);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2341
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2342 topic_utf8 = zephyr_recv_convert(gc,(gchar *)topic,strlen(topic));
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2343 gaim_conv_chat_set_topic(gcc,sender,topic_utf8);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2344 g_free(topic_utf8);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2345 return;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2346 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2347
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2348 /* commands */
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2349
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2350 static GaimCmdRet zephyr_gaim_cmd_msg(GaimConversation *conv,
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2351 const char *cmd, char **args, char **error, void *data)
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2352 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2353 char *recipient;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2354 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2355 if (!g_ascii_strcasecmp(args[0],"*"))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2356 return GAIM_CMD_RET_FAILED; /* "*" is not a valid argument */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2357 else
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2358 recipient = local_zephyr_normalize(zephyr,args[0]);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2359
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2360 if (strlen(recipient) < 1)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2361 return GAIM_CMD_RET_FAILED; /* a null recipient is a chat message, not an IM */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2362
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2363 if (zephyr_send_message(zephyr,"MESSAGE","PERSONAL",recipient,args[1],zephyr_get_signature(),""))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2364 return GAIM_CMD_RET_OK;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2365 else
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2366 return GAIM_CMD_RET_FAILED;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2367 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2368
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2369 static GaimCmdRet zephyr_gaim_cmd_zlocate(GaimConversation *conv,
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2370 const char *cmd, char **args, char **error, void *data)
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2371 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2372 zephyr_zloc(gaim_conversation_get_gc(conv),args[0]);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2373 return GAIM_CMD_RET_OK;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2374 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2375
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2376 static GaimCmdRet zephyr_gaim_cmd_instance(GaimConversation *conv,
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2377 const char *cmd, char **args, char **error, void *data)
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2378 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2379 /* Currently it sets the instance with leading spaces and
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2380 * all. This might not be the best thing to do, though having
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2381 * one word isn't ideal either. */
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2382
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2383 GaimConvChat *gcc = gaim_conversation_get_chat_data(conv);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2384 int id = gcc->id;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2385 const char* instance = args[0];
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2386 zephyr_chat_set_topic(gaim_conversation_get_gc(conv),id,instance);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2387 return GAIM_CMD_RET_OK;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2388 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2389
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2390 static GaimCmdRet zephyr_gaim_cmd_joinchat_cir(GaimConversation *conv,
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2391 const char *cmd, char **args, char **error, void *data)
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2392 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2393 /* Join a new zephyr chat */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2394 GHashTable *triple = g_hash_table_new(NULL,NULL);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2395 g_hash_table_insert(triple,"class",args[0]);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2396 g_hash_table_insert(triple,"instance",args[1]);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2397 g_hash_table_insert(triple,"recipient",args[2]);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2398 zephyr_join_chat(gaim_conversation_get_gc(conv),triple);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2399 return GAIM_CMD_RET_OK;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2400 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2401
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2402 static GaimCmdRet zephyr_gaim_cmd_zi(GaimConversation *conv,
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2403 const char *cmd, char **args, char **error, void *data)
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2404 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2405 /* args = instance, message */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2406 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2407 if ( zephyr_send_message(zephyr,"message",args[0],"",args[1],zephyr_get_signature(),""))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2408 return GAIM_CMD_RET_OK;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2409 else
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2410 return GAIM_CMD_RET_FAILED;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2411 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2412
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2413 static GaimCmdRet zephyr_gaim_cmd_zci(GaimConversation *conv,
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2414 const char *cmd, char **args, char **error, void *data)
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2415 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2416 /* args = class, instance, message */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2417 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2418 if ( zephyr_send_message(zephyr,args[0],args[1],"",args[2],zephyr_get_signature(),""))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2419 return GAIM_CMD_RET_OK;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2420 else
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2421 return GAIM_CMD_RET_FAILED;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2422 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2423
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2424 static GaimCmdRet zephyr_gaim_cmd_zcir(GaimConversation *conv,
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2425 const char *cmd, char **args, char **error, void *data)
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2426 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2427 /* args = class, instance, recipient, message */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2428 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2429 if ( zephyr_send_message(zephyr,args[0],args[1],args[2],args[3],zephyr_get_signature(),""))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2430 return GAIM_CMD_RET_OK;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2431 else
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2432 return GAIM_CMD_RET_FAILED;
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
2433 }
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
2434
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2435 static GaimCmdRet zephyr_gaim_cmd_zir(GaimConversation *conv,
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2436 const char *cmd, char **args, char **error, void *data)
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2437 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2438 /* args = instance, recipient, message */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2439 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2440 if ( zephyr_send_message(zephyr,"message",args[0],args[1],args[2],zephyr_get_signature(),""))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2441 return GAIM_CMD_RET_OK;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2442 else
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2443 return GAIM_CMD_RET_FAILED;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2444 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2445
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2446 static GaimCmdRet zephyr_gaim_cmd_zc(GaimConversation *conv,
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2447 const char *cmd, char **args, char **error, void *data)
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2448 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2449 /* args = class, message */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2450 zephyr_account *zephyr = gaim_conversation_get_gc(conv)->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2451 if ( zephyr_send_message(zephyr,args[0],"PERSONAL","",args[1],zephyr_get_signature(),""))
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2452 return GAIM_CMD_RET_OK;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2453 else
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2454 return GAIM_CMD_RET_FAILED;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2455 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2456
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9584
diff changeset
2457 static void zephyr_register_slash_commands()
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2458 {
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2459
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2460 gaim_cmd_register("msg","ws", GAIM_CMD_P_PRPL,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2461 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2462 "prpl-zephyr",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2463 zephyr_gaim_cmd_msg, _("msg &lt;nick&gt; &lt;message&gt;: Send a private message to a user"), NULL);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2464
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2465 gaim_cmd_register("zlocate","w", GAIM_CMD_P_PRPL,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2466 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2467 "prpl-zephyr",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2468 zephyr_gaim_cmd_zlocate, _("zlocate &lt;nick&gt;: Locate user"), NULL);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2469
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2470 gaim_cmd_register("zl","w", GAIM_CMD_P_PRPL,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2471 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2472 "prpl-zephyr",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2473 zephyr_gaim_cmd_zlocate, _("zl &lt;nick&gt;: Locate user"), NULL);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2474
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2475 gaim_cmd_register("instance","s", GAIM_CMD_P_PRPL,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2476 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2477 "prpl-zephyr",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2478 zephyr_gaim_cmd_instance, _("instance &lt;instance&gt;: Set the instance to be used on this class"), NULL);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2479
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2480 gaim_cmd_register("inst","s", GAIM_CMD_P_PRPL,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2481 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2482 "prpl-zephyr",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2483 zephyr_gaim_cmd_instance, _("inst &lt;instance&gt;: Set the instance to be used on this class"), NULL);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2484
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2485 gaim_cmd_register("sub", "www", GAIM_CMD_P_PRPL,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2486 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2487 "prpl-zephyr",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2488 zephyr_gaim_cmd_joinchat_cir,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2489 _("sub &lt;class&gt; &lt;instance&gt; &lt;recipient&gt;: Join a new chat"), NULL);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2490
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2491 gaim_cmd_register("zi","ws", GAIM_CMD_P_PRPL,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2492 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2493 "prpl-zephyr",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2494 zephyr_gaim_cmd_zi, _("zi &lt;instance&gt;: Send a message to &lt;message,<i>instance</i>,*&gt;"), NULL);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2495
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2496 gaim_cmd_register("zci","wws",GAIM_CMD_P_PRPL,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2497 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2498 "prpl-zephyr",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2499 zephyr_gaim_cmd_zci,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2500 _("zci &lt;class&gt; &lt;instance&gt;: Send a message to &lt;<i>class</i>,<i>instance</i>,*&gt;"), NULL);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2501
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2502 gaim_cmd_register("zcir","wwws",GAIM_CMD_P_PRPL,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2503 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2504 "prpl-zephyr",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2505 zephyr_gaim_cmd_zcir,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2506 _("zcir &lt;class&gt; &lt;instance&gt; &lt;recipient&gt;: Send a message to &lt;<i>class</i>,<i>instance</i>,<i>recipient</i>&gt;"), NULL);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2507
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2508 gaim_cmd_register("zir","wws",GAIM_CMD_P_PRPL,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2509 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2510 "prpl-zephyr",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2511 zephyr_gaim_cmd_zir,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2512 _("zir &lt;instance&gt; &lt;recipient&gt;: Send a message to &lt;MESSAGE,<i>instance</i>,<i>recipient</i>&gt;"), NULL);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2513
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2514 gaim_cmd_register("zc","ws", GAIM_CMD_P_PRPL,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2515 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2516 "prpl-zephyr",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2517 zephyr_gaim_cmd_zc, _("zc &lt;class&gt;: Send a message to &lt;<i>class</i>,PERSONAL,*&gt;"), NULL);
9597
d6f398e80b32 [gaim-migrate @ 10440]
Tim Ringenbach <marv@pidgin.im>
parents: 9584
diff changeset
2518
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2519 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2520
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2521
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2522 static void
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2523 zephyr_add_deny(GaimConnection *gc, const char *who)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2524 {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2525 gaim_privacy_deny_add(gc->account,who,1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2526 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2527
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2528 static void
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2529 zephyr_remove_deny(GaimConnection *gc, const char *who)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2530 {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2531 gaim_privacy_deny_remove(gc->account,who,1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2532 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2533
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2534 static void
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2535 zephyr_add_permit(GaimConnection *gc, const char *who)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2536 {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2537 gaim_privacy_permit_add(gc->account,who,1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2538 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2539
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2540 static void
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2541 zephyr_remove_permit(GaimConnection *gc, const char *who)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2542 {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2543 gaim_privacy_permit_remove(gc->account,who,1);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2544 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2545
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2546 static void
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2547 zephyr_set_permit_deny(GaimConnection *gc)
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2548 {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2549 /* This doesn't have to do anything, since really, we can just check account->perm_deny when deciding whether to di */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2550 return;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2551 }
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2552 static int zephyr_resubscribe(GaimConnection *gc)
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2553 {
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2554 /* Resubscribe to the in-memory list of subscriptions and also
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2555 unsubscriptions*/
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2556 zephyr_account *zephyr = gc->proto_data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2557 GSList *s = zephyr->subscrips;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2558 zephyr_triple *zt;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2559 while (s) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2560 zt = s->data;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2561 /* XXX We really should care if this fails */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2562 zephyr_subscribe_to(zephyr,zt->class,zt->instance,zt->recipient,NULL);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2563 s = s->next;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2564 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2565 /* XXX handle unsubscriptions */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2566 return 1;
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2567 }
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2568
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
2569
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2570 static void zephyr_action_resubscribe(GaimPluginAction *action)
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2571 {
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2572
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2573 GaimConnection *gc = (GaimConnection *) action->context;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2574 zephyr_resubscribe(gc);
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2575 }
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2576
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2577
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2578 static void zephyr_action_get_subs_from_server(GaimPluginAction *action)
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2579 {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2580 GaimConnection *gc = (GaimConnection *) action->context;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2581 zephyr_account *zephyr = gc->proto_data;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2582 gchar *title;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2583 int retval, nsubs, one,i;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2584 ZSubscription_t subs;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2585 if (use_zeph02(zephyr)) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2586 GString* subout = g_string_new("Subscription list<br>");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2587
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2588 title = g_strdup_printf("Server subscriptions for %s", zephyr->username);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2589
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2590 if (zephyr->port == 0) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2591 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving port");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2592 return;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2593 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2594 if ((retval = ZRetrieveSubscriptions(zephyr->port,&nsubs)) != ZERR_NONE) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2595 /* XXX better error handling */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2596 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving subscriptions from server");
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2597 return;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2598 }
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2599 for(i=0;i<nsubs;i++) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2600 one = 1;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2601 if ((retval = ZGetSubscriptions(&subs,&one)) != ZERR_NONE) {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2602 /* XXX better error handling */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2603 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving individual subscription");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2604 return;
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2605 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2606 g_string_append_printf(subout, "Class %s Instance %s Recipient %s<br>",
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2607 subs.zsub_class, subs.zsub_classinst,
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2608 subs.zsub_recipient);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2609 }
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2610 gaim_notify_formatted(gc, title, title, NULL, subout->str, NULL, NULL);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2611 } else {
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2612 /* XXX fix */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2613 gaim_notify_error(gc,"","tzc doesn't support this action",NULL);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2614 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2615 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2616
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2617
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2618 static GList *zephyr_actions(GaimPlugin *plugin, gpointer context)
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2619 {
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2620 GList *list = NULL;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2621 GaimPluginAction *act = NULL;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2622
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2623 act = gaim_plugin_action_new(_("Resubscribe"), zephyr_action_resubscribe);
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2624 list = g_list_append(list, act);
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2625
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2626 act = gaim_plugin_action_new(_("Retrieve subscriptions from server"), zephyr_action_get_subs_from_server);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2627 list = g_list_append(list,act);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2628
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2629 return list;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2630 }
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2631
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
2632 static GaimPlugin *my_protocol = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2633
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2634 static GaimPluginProtocolInfo prpl_info = {
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8713
diff changeset
2635 GAIM_PRPL_API_VERSION,
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2636 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD,
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2637 NULL, /* ??? user_splits */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2638 NULL, /* ??? protocol_options */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2639 NO_BUDDY_ICONS,
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2640 zephyr_list_icon,
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2641 NULL, /* ??? list_emblems */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2642 NULL, /* ??? status_text */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2643 NULL, /* ??? tooltip_text */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2644 zephyr_away_states, /* away_states */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2645 NULL, /* ??? blist_node_menu - probably all useful actions are already handled*/
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2646 zephyr_chat_info, /* chat_info */
9754
4a8bf81b82ae [gaim-migrate @ 10621]
Luke Schierer <lschiere@pidgin.im>
parents: 9741
diff changeset
2647 NULL, /* chat_info_defaults */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2648 zephyr_login, /* login */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2649 zephyr_close, /* close */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2650 zephyr_send_im, /* send_im */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2651 NULL, /* XXX set info (Location?) */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2652 zephyr_send_typing, /* send_typing */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2653 zephyr_zloc, /* get_info */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2654 zephyr_set_away, /* XXX set_away need to fix */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2655 NULL, /* ??? set idle */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
2656 NULL, /* change password */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2657 NULL, /* add_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2658 NULL, /* add_buddies */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2659 NULL, /* remove_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2660 NULL, /* remove_buddies */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2661 zephyr_add_permit, /* add_permit */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2662 zephyr_add_deny, /* add_deny */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2663 zephyr_remove_permit, /* remove_permit */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2664 zephyr_remove_deny, /* remove_deny */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2665 zephyr_set_permit_deny, /* set_permit_deny */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2666 NULL, /* warn -- not supported in zephyr */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2667 zephyr_join_chat, /* join_chat */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2668 NULL, /* reject_chat -- No chat invites*/
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2669 NULL, /* chat_invite -- No chat invites*/
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2670 zephyr_chat_leave, /* chat_leave */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2671 NULL, /* chat_whisper -- No "whispering"*/
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2672 zephyr_chat_send, /* chat_send */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2673 NULL, /* keepalive -- Not necessary*/
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2674 NULL, /* register_user -- Not supported*/
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2675 NULL, /* XXX get_cb_info */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2676 NULL, /* get_cb_away */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2677 NULL, /* alias_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2678 NULL, /* group_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2679 NULL, /* rename_group */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2680 NULL, /* buddy_free */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2681 NULL, /* convo_closed */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2682 zephyr_normalize, /* normalize */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2683 NULL, /* XXX set_buddy_icon */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2684 NULL, /* remove_group */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2685 NULL, /* XXX get_cb_real_name */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2686 zephyr_chat_set_topic, /* set_chat_topic */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2687 zephyr_find_blist_chat, /* find_blist_chat */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2688 NULL, /* roomlist_get_list */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2689 NULL, /* roomlist_cancel */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2690 NULL, /* roomlist_expand_category */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2691 NULL, /* can_receive_file */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
2692 NULL /* send_file */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
2693 };
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2694
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2695 static GaimPluginInfo info = {
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8713
diff changeset
2696 GAIM_PLUGIN_API_VERSION, /**< api_version */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2697 GAIM_PLUGIN_PROTOCOL, /**< type */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2698 NULL, /**< ui_requirement */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2699 0, /**< flags */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2700 NULL, /**< dependencies */
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2701 GAIM_PRIORITY_DEFAULT, /**< priority */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
2702
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2703 "prpl-zephyr", /**< id */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2704 "Zephyr", /**< name */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2705 VERSION, /**< version */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2706 /** summary */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
2707 N_("Zephyr Protocol Plugin"),
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2708 /** description */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
2709 N_("Zephyr Protocol Plugin"),
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2710 NULL, /**< author */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2711 GAIM_WEBSITE, /**< homepage */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
2712
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2713 NULL, /**< load */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2714 NULL, /**< unload */
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2715 NULL, /**< destroy */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
2716
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2717 NULL, /**< ui_info */
8993
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8954
diff changeset
2718 &prpl_info, /**< extra_info */
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8954
diff changeset
2719 NULL,
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
2720 zephyr_actions
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
2721 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
2722
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2723 static void init_plugin(GaimPlugin * plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
2724 {
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
2725 GaimAccountOption *option;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2726 char *tmp = get_exposure_level();
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2727
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2728 option = gaim_account_option_bool_new("Use tzc", "use_tzc", FALSE);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2729 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2730
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2731 option = gaim_account_option_string_new("tzc command", "tzc_command", "/usr/bin/tzc -e %s");
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2732 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2733
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2734 option = gaim_account_option_bool_new(_("Export to .anyone"), "write_anyone", FALSE);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2735 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
2736
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2737 option = gaim_account_option_bool_new(_("Export to .zephyr.subs"), "write_zsubs", FALSE);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2738 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
2739
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2740 option = gaim_account_option_string_new(_("Exposure"), "exposure_level", tmp ? tmp : EXPOSE_REALMVIS);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2741 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
2742
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2743 option = gaim_account_option_string_new(_("Encoding"), "encoding", ZEPHYR_FALLBACK_CHARSET);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
2744 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
2745
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
2746 my_protocol = plugin;
9896
a806e5150eca [gaim-migrate @ 10785]
Luke Schierer <lschiere@pidgin.im>
parents: 9846
diff changeset
2747 zephyr_register_slash_commands();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2748 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2749
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
2750 GAIM_INIT_PLUGIN(zephyr, init_plugin, info);