annotate src/protocols/zephyr/zephyr.c @ 12216:4d3119205a33

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