annotate src/protocols/zephyr/zephyr.c @ 9030:7ab20f829190

[gaim-migrate @ 9806] Siege updated the code for creating right-click menu's for buddies, chats, groups, etc. It uses more stuff from the blist API and less stuff from multi.h. It also combines the code for right-click menus for chats, buddies, etc. (all types of blist nodes). So PRPLs and plugins can easily add right-click menu options to anything in the buddy list in a clean way. committer: Tailor Script <tailor@pidgin.im>
author Mark Doliner <mark@kingant.net>
date Sun, 23 May 2004 17:27:45 +0000
parents 67421e0dc497
children b3bda982996b
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 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * 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
12 * the Free Software Foundation; either version 2 of the License, or
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * (at your option) any later version.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * GNU General Public License for more details.
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 *
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
25 /* XXX eww */
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
26 #include "src/internal.h"
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
28 #include "accountopt.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
29 #include "debug.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
30 #include "multi.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
31 #include "notify.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
32 #include "prpl.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
33 #include "server.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
34 #include "util.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
35
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
36 #include "zephyr/zephyr.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
37
8386
143d0b29ba82 [gaim-migrate @ 9114]
Mark Doliner <mark@kingant.net>
parents: 8354
diff changeset
38 #include <strings.h>
143d0b29ba82 [gaim-migrate @ 9114]
Mark Doliner <mark@kingant.net>
parents: 8354
diff changeset
39
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
40 #define ZEPHYR_FALLBACK_CHARSET "ISO-8859-1"
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
41
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 extern Code_t ZGetLocations(ZLocations_t *, int *);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 extern Code_t ZSetLocation(char *);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 extern Code_t ZUnsetLocation();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 typedef struct _zframe zframe;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 typedef struct _zephyr_triple zephyr_triple;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 /* struct I need for zephyr_to_html */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 struct _zframe {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 /* 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
52 * the color. */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 gboolean has_closer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 /* </i>, </font>, </b>, etc. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 char *closing;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 /* text including the opening html thingie. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 GString *text;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 struct _zframe *enclosing;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 struct _zephyr_triple {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 char *class;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 char *instance;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 char *recipient;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 char *name;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 gboolean open;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 int id;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 #define z_call(func) if (func != ZERR_NONE)\
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 #define z_call_r(func) if (func != ZERR_NONE)\
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 #define z_call_s(func, err) if (func != ZERR_NONE) {\
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
75 gaim_connection_error(zgc, err);\
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 return;\
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
79 static const char *local_zephyr_normalize(const char *);
7322
ab828b8c3f22 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7262
diff changeset
80 static const char *zephyr_normalize(const GaimAccount *, const char *);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 /* 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
83 * wouldn't do this. but it is so i will. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 static guint32 nottimer = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 static guint32 loctimer = 0;
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
86 GaimConnection *zgc = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 static GList *pending_zloc_names = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 static GSList *subscrips = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 static int last_id = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 /* just for debugging
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 static void handle_unknown(ZNotice_t notice)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93 {
6484
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
94 gaim_debug(GAIM_DEBUG_MISC, "z_packet: %s\n", notice.z_packet);
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
95 gaim_debug(GAIM_DEBUG_MISC, "z_version: %s\n", notice.z_version);
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
96 gaim_debug(GAIM_DEBUG_MISC, "z_kind: %d\n", notice.z_kind);
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
97 gaim_debug(GAIM_DEBUG_MISC, "z_class: %s\n", notice.z_class);
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
98 gaim_debug(GAIM_DEBUG_MISC, "z_class_inst: %s\n", notice.z_class_inst);
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
99 gaim_debug(GAIM_DEBUG_MISC, "z_opcode: %s\n", notice.z_opcode);
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
100 gaim_debug(GAIM_DEBUG_MISC, "z_sender: %s\n", notice.z_sender);
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
101 gaim_debug(GAIM_DEBUG_MISC, "z_recipient: %s\n", notice.z_recipient);
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
102 gaim_debug(GAIM_DEBUG_MISC, "z_message: %s\n", notice.z_message);
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
103 gaim_debug(GAIM_DEBUG_MISC, "z_message_len: %d\n", notice.z_message_len);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 static zephyr_triple *new_triple(const char *c, const char *i, const char *r)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 zephyr_triple *zt;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
110
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 zt = g_new0(zephyr_triple, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 zt->class = g_strdup(c);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 zt->instance = g_strdup(i);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 zt->recipient = g_strdup(r);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 zt->name = g_strdup_printf("%s,%s,%s", c, i, r);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 zt->id = ++last_id;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 zt->open = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 return zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
121 static void free_triple(zephyr_triple * zt)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 g_free(zt->class);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 g_free(zt->instance);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 g_free(zt->recipient);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 g_free(zt->name);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 g_free(zt);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
130 static const char *gaim_zephyr_get_sender()
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
131 {
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
132 /* will be useful once this plugin can use a backend other
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
133 than libzephyr */
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
134 return ZGetSender();
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
135 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
136
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
137 static const char *gaim_zephyr_get_realm()
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
138 {
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
139 /* will be useful once this plugin can use a backend other
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
140 than libzephyr */
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
141 return ZGetRealm();
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
142 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
143
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 /* returns true if zt1 is a subset of zt2, i.e. zt2 has the same thing or
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 * wildcards in each field of zt1. */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
146 static gboolean triple_subset(zephyr_triple * zt1, zephyr_triple * zt2)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
148 if (g_ascii_strcasecmp(zt2->class, zt1->class) && g_ascii_strcasecmp(zt2->class, "*")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
151 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
152 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
154 if (g_ascii_strcasecmp(zt2->recipient, zt1->recipient) && g_ascii_strcasecmp(zt2->recipient, "*")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
160 static zephyr_triple *find_sub_by_triple(zephyr_triple * zt)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 zephyr_triple *curr_t;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 GSList *curr = subscrips;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
164
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 while (curr) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 curr_t = curr->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 if (triple_subset(zt, curr_t))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 return curr_t;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 curr = curr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 static zephyr_triple *find_sub_by_id(int id)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 zephyr_triple *zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 GSList *curr = subscrips;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
178
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 while (curr) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 zt = curr->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 if (zt->id == id)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 return zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 curr = curr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
188 static gchar *zephyr_recv_convert(char *string, int len)
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
189 {
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
190 gchar *utf8;
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
191 GError *err = NULL;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
192
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
193 if (g_utf8_validate(string, len, NULL)) {
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
194 return g_strdup(string);
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
195 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
196 utf8 = g_convert(string, len, "UTF-8", gaim_account_get_string(zgc->account, "encoding", ZEPHYR_FALLBACK_CHARSET), NULL, NULL, &err);
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
197 if (err) {
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
198 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "recv conversion error: %s\n", err->message);
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
199 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
200 g_error_free(err);
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
201 }
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
202
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
203 return utf8;
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
204 }
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
205 }
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
206
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 /* utility macros that are useful for zephyr_to_html */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<'))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 #define IS_CLOSER(c) ((c == '}') || (c == ']') || (c == ')') || (c == '>'))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
212 /* 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
213 And converts it to zephyr formatting.
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
214 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
215 It ignores <font back=...>
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
216 It does
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
217 <font size = "1 or 2" -> @small
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
218 3 or 4 @medium()
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
219 5,6, or 7 @large()
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
220 <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
221 */
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
222
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
223 static char *html_to_zephyr(const char *message)
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
224 {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
225 int len, cnt, retcount;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
226 char *ret;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
227
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
228 len = strlen(message);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
229 ret = g_new0(char, len * 3);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
230
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
231 bzero(ret, len * 3);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
232 retcount = 0;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
233 cnt = 0;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
234 while (cnt <= len) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
235 if (message[cnt] == '<') {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
236 if (!g_ascii_strncasecmp(message + cnt + 1, "i>", 2)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
237 strncpy(ret + retcount, "@i(", 3);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
238 cnt += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
239 retcount += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
240 } else if (!g_ascii_strncasecmp(message + cnt + 1, "b>", 2)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
241 strncpy(ret + retcount, "@b(", 3);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
242 cnt += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
243 retcount += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
244 } else if (!g_ascii_strncasecmp(message + cnt + 1, "br>", 3)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
245 strncpy(ret + retcount, "\n", 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
246 cnt += 4;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
247 retcount += 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
248 } else if (!g_ascii_strncasecmp(message + cnt + 1, "a href=\"", 8)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
249 cnt += 9;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
250 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
251 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
252 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
253 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
254 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
255 cnt += 2;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
256 /* ignore descriptive string */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
257 while (g_ascii_strncasecmp(message + cnt, "</a>", 4) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
258 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
259 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
260 cnt += 4;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
261 } else if (!g_ascii_strncasecmp(message + cnt + 1, "font", 4)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
262 cnt += 5;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
263 while (!g_ascii_strncasecmp(message + cnt, " ", 1))
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
264 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
265 if (!g_ascii_strncasecmp(message + cnt, "color=\"", 7)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
266 cnt += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
267 strncpy(ret + retcount, "@color(", 7);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
268 retcount += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
269 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
270 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
271 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
272 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
273 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
274 ret[retcount] = ')';
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
275 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
276 cnt += 2;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
277 } else if (!g_ascii_strncasecmp(message + cnt, "face=\"", 6)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
278 cnt += 6;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
279 strncpy(ret + retcount, "@font(", 6);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
280 retcount += 6;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
281 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
282 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
283 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
284 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
285 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
286 ret[retcount] = ')';
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
287 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
288 cnt += 2;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
289 } else if (!g_ascii_strncasecmp(message + cnt, "size=\"", 6)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
290 cnt += 6;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
291 if ((message[cnt] == '1') || (message[cnt] == '2')) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
292 strncpy(ret + retcount, "@small(", 7);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
293 retcount += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
294 } else if ((message[cnt] == '3')
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
295 || (message[cnt] == '4')) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
296 strncpy(ret + retcount, "@medium(", 8);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
297 retcount += 8;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
298 } else if ((message[cnt] == '5')
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
299 || (message[cnt] == '6')
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
300 || (message[cnt] == '7')) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
301 strncpy(ret + retcount, "@large(", 7);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
302 retcount += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
303 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
304 cnt += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
305 } else {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
306 /* Drop all unrecognized/misparsed font tags */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
307 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
308 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
309 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
310 cnt += 2;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
311 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
312 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/i>", 3)
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
313 || !g_ascii_strncasecmp(message + cnt + 1, "/b>", 3)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
314 cnt += 4;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
315 ret[retcount] = ')';
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
316 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
317 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/font>", 6)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
318 cnt += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
319 strncpy(ret + retcount, "@font(fixed)", 12);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
320 retcount += 12;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
321 } else {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
322 /* Catch all for all unrecognized/misparsed <foo> tage */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
323 while (g_ascii_strncasecmp(message + cnt, ">", 1) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
324 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
325 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
326 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
327 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
328 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
329 } else {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
330 /* Duh */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
331 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
332 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
333 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
334 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
335 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
336 return ret;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
337 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
338
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
339 /* this parses zephyr formatting and converts it to html. For example, if
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
340 * you pass in "@{@color(blue)@i(hello)}" you should get out
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 * "<font color=blue><i>hello</i></font>". */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 static char *zephyr_to_html(char *message)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 int len, cnt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 zframe *frames, *curr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 char *ret;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 frames = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349 frames->text = g_string_new("");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 frames->enclosing = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351 frames->closing = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352 frames->has_closer = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354 len = strlen(message);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355 cnt = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 while (cnt <= len) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357 if (message[cnt] == '@') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 zframe *new_f;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 char *buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 int end;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
361
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
362 for (end = 1; (cnt + end) <= len && !IS_OPENER(message[cnt + end])
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
363 && !IS_CLOSER(message[cnt + end]); end++);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
364 buf = g_new0(char, end);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
365
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 if (end) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
367 g_snprintf(buf, end, "%s", message + cnt + 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
369 if (!g_ascii_strcasecmp(buf, "italic") || !g_ascii_strcasecmp(buf, "i")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
370 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372 new_f->text = g_string_new("<i>");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373 new_f->closing = "</i>";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375 frames = new_f;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
376 cnt += end + 1; /* cnt points to char after opener */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
377 } else if (!g_ascii_strcasecmp(buf, "small")) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
378 new_f = g_new(zframe, 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
379 new_f->enclosing = frames;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
380 new_f->text = g_string_new("<font size=\"1\">");
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
381 new_f->closing = "</font>";
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
382 frames = new_f;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
383 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
384 } else if (!g_ascii_strcasecmp(buf, "medium")) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
385 new_f = g_new(zframe, 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
386 new_f->enclosing = frames;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
387 new_f->text = g_string_new("<font size=\"3\">");
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
388 new_f->closing = "</font>";
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
389 frames = new_f;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
390 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
391 } else if (!g_ascii_strcasecmp(buf, "large")) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
392 new_f = g_new(zframe, 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
393 new_f->enclosing = frames;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
394 new_f->text = g_string_new("<font size=\"7\">");
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
395 new_f->closing = "</font>";
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
396 frames = new_f;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
397 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
398 } else if (!g_ascii_strcasecmp(buf, "bold")
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
399 || !g_ascii_strcasecmp(buf, "b")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 new_f->text = g_string_new("<b>");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 new_f->closing = "</b>";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 frames = new_f;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
406 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
407 } else if (!g_ascii_strcasecmp(buf, "font")) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
408 cnt += end + 1;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
409 new_f = g_new(zframe, 1);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
410 new_f->enclosing = frames;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
411 new_f->text = g_string_new("<font face=");
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
412 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
413 g_string_append_c(new_f->text, message[cnt]);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
414 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
415 cnt++; /* point to char after closer */
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
416 g_string_append_c(new_f->text, '>');
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
417 new_f->closing = "</font>";
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
418 new_f->has_closer = FALSE;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
419 frames = new_f;
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
420 } else if (!g_ascii_strcasecmp(buf, "color")) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
421 cnt += end + 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
422 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
423 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 new_f->text = g_string_new("<font color=");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 g_string_append_c(new_f->text, message[cnt]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
428 cnt++; /* point to char after closer */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429 g_string_append_c(new_f->text, '>');
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430 new_f->closing = "</font>";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 new_f->has_closer = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 frames = new_f;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
433 } else if (!g_ascii_strcasecmp(buf, "")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 new_f->text = g_string_new("");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 new_f->closing = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 frames = new_f;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
440 cnt += end + 1; /* cnt points to char after opener */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
442 if ((cnt + end) > len) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 g_string_append_c(frames->text, '@');
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444 cnt++;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
445 } else if (IS_CLOSER(message[cnt + end])) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
446 /* We have @chars..closer . This is
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
447 merely a sequence of chars that isn't a formatting tag
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
448 */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
449 int tmp = cnt;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
450
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
451 while (tmp <= cnt + end) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
452 g_string_append_c(frames->text, message[tmp]);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
453 tmp++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
454 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
455 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
456 } else {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
457 /* unrecognized thingie. act like it's not there, but we
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
458 * still need to take care of the corresponding closer,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
459 * make a frame that does nothing. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
460 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
461 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
462 new_f->text = g_string_new("");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
463 new_f->closing = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 frames = new_f;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
466 cnt += end + 1; /* cnt points to char after opener */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
467 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
468 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
469 } else if (IS_CLOSER(message[cnt])) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
470 zframe *popped;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
471 gboolean last_had_closer;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
472
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
473 if (frames->enclosing) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 do {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475 popped = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
476 frames = frames->enclosing;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
477 g_string_append(frames->text, popped->text->str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
478 g_string_append(frames->text, popped->closing);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479 g_string_free(popped->text, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
480 last_had_closer = popped->has_closer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
481 g_free(popped);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
482 } while (frames && frames->enclosing && !last_had_closer);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
483 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
484 g_string_append_c(frames->text, message[cnt]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
485 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 cnt++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487 } else if (message[cnt] == '\n') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
488 g_string_append(frames->text, "<br>");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
489 cnt++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
490 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
491 g_string_append_c(frames->text, message[cnt++]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
492 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
493 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494 /* go through all the stuff that they didn't close */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
495 while (frames->enclosing) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
496 curr = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497 g_string_append(frames->enclosing->text, frames->text->str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498 g_string_append(frames->enclosing->text, frames->closing);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499 g_string_free(frames->text, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
500 frames = frames->enclosing;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501 g_free(curr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
502 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
503 ret = frames->text->str;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 g_string_free(frames->text, FALSE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
505 g_free(frames);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
506 return ret;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
507 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
508
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
509 static gboolean pending_zloc(char *who)
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 GList *curr;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
512
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
513 for (curr = pending_zloc_names; curr != NULL; curr = curr->next) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
514 if (!g_ascii_strcasecmp(local_zephyr_normalize(who), (char *)curr->data)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
515 g_free((char *)curr->data);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516 pending_zloc_names = g_list_remove(pending_zloc_names, curr->data);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
517 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
519 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
521 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
522
8559
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
523 static void message_failed(ZNotice_t notice, struct sockaddr_in from)
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
524 {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
525 if (g_ascii_strcasecmp(notice.z_class, "message")) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
526 /* message to chat failed ignore for now */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
527 } else {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
528 gaim_notify_error(zgc, notice.z_recipient, _("User is offline"), NULL);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
529 }
8559
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
530 }
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
531
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
532 static void handle_message(ZNotice_t notice, struct sockaddr_in from)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
533 {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
534 if (!g_ascii_strcasecmp(notice.z_class, LOGIN_CLASS)) {
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
535 /* 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
536 } else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) {
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
537 if (!g_ascii_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
538 int nlocs;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
539 char *user;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
540 GaimBuddy *b;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
541
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
542 if (ZParseLocations(&notice, NULL, &nlocs, &user) != ZERR_NONE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
543 return;
8435
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
544
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
545 if ((b = gaim_find_buddy(zgc->account, user)) == NULL) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
546 char *e = strchr(user, '@');
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
547
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
548 if (e && !g_ascii_strcasecmp(e + 1, gaim_zephyr_get_realm())) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
549 *e = '\0';
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
550 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4682
diff changeset
551 b = gaim_find_buddy(zgc->account, user);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
552 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
553 if ((b && pending_zloc(b->name)) || pending_zloc(user)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
554 ZLocations_t locs;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
555 int one = 1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
556 GString *str = g_string_new("");
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
557
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
558 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
559 if (b && b->alias)
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
560 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
561 if (!nlocs) {
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
562 g_string_append_printf(str, _("<br>Hidden or not logged-in"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
563 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
564 for (; nlocs > 0; nlocs--) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
565 ZGetLocations(&locs, &one);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
566 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
567 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
568 gaim_notify_formatted(zgc, NULL, _("Buddy Information"), NULL, str->str, NULL, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
569 g_string_free(str, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
570 } else
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
571 serv_got_update(zgc, b->name, nlocs, 0, 0, 0, 0);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
572
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
573 free(user);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
574 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
575 } else {
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
576 char *buf, *buf2, *buf3;
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
577 char *send_inst;
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
578 char *realmptr;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
579 GaimConversation *gconv1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
580 GaimConvChat *gcc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
581 char *ptr = notice.z_message + strlen(notice.z_message) + 1;
8876
f0f6af31c90a [gaim-migrate @ 9645]
Luke Schierer <lschiere@pidgin.im>
parents: 8749
diff changeset
582 int len = notice.z_message_len - (strlen(notice.z_message) +1);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
583 char *sendertmp = g_strdup_printf("%s", gaim_zephyr_get_sender());
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
584 GaimConvImFlags flags = 0;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
585
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
586 if (len > 0) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
587 gchar *tmpescape;
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
588
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
589 buf = g_malloc(len + 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
590 g_snprintf(buf, len + 1, "%s", ptr);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
591 g_strchomp(buf);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
592 tmpescape = gaim_escape_html(buf);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
593 buf2 = zephyr_to_html(tmpescape);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
594 buf3 = zephyr_recv_convert(buf2, strlen(buf2));
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
595 g_free(buf2);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
596 g_free(buf);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
597 g_free(tmpescape);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
598
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
599 if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL")) {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
600 if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:"))
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
601 flags |= GAIM_CONV_IM_AUTO_RESP;
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
602 serv_got_im(zgc, notice.z_sender, buf3, flags, time(NULL));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
603 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
604 zephyr_triple *zt1, *zt2;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
605
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
606 zt1 = new_triple(notice.z_class, notice.z_class_inst, notice.z_recipient);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607 zt2 = find_sub_by_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
608 if (!zt2) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
609 /* we shouldn't be subscribed to this message. ignore. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
610 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
611 GList *gltmp;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
612 int found = 0;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
613
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
614 if (!zt2->open) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
615 zt2->open = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
616 serv_got_joined_chat(zgc, zt2->id, zt2->name);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
617 gconv1 = gaim_find_conversation_with_account(zt2->name, zgc->account);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
618 gcc = gaim_conversation_get_chat_data(gconv1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
619 gaim_conv_chat_set_topic(gcc, sendertmp, notice.z_class_inst);
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
620
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
621 }
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
622 /* If the person is in the default Realm, then strip the
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
623 Realm from the sender field */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
624 sendertmp = g_strdup_printf("%s", notice.z_sender);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
625 if ((realmptr = strchr(sendertmp, '@')) != NULL) {
4588
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
626 realmptr++;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
627 if (!g_ascii_strcasecmp(realmptr, gaim_zephyr_get_realm())) {
4588
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
628 realmptr--;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
629 sprintf(realmptr, "%c", '\0');
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
630 send_inst = g_strdup_printf("%s %s", sendertmp, notice.z_class_inst);
4588
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
631 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
632 send_inst = g_strdup_printf("%s %s", notice.z_sender, notice.z_class_inst);
4588
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
633 }
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
634 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
635 send_inst = g_strdup_printf("%s %s", sendertmp, notice.z_class_inst);
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
636 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
637 serv_got_chat_in(zgc, zt2->id, send_inst, FALSE, buf3, time(NULL));
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
638
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
639 gconv1 = gaim_find_conversation_with_account(zt2->name, zgc->account);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
640 gcc = gaim_conversation_get_chat_data(gconv1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
641 /* gaim_conv_chat_set_topic(gcc,sendertmp,notice.z_class_inst); */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
642 for (gltmp = gaim_conv_chat_get_users(gcc); gltmp; gltmp = gltmp->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
643 if (!g_ascii_strcasecmp(gltmp->data, sendertmp))
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
644 found = 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
645 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
646 if (!found) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
647 /* force interpretation in network byte order */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
648 unsigned char *addrs = (unsigned char *)&(notice.z_sender_addr.s_addr);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
649
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
650 gaim_conv_chat_add_user(gcc, sendertmp, g_strdup_printf("%hhd.%hhd.%hhd.%hhd", (unsigned char)addrs[0], (unsigned char)addrs[1], (unsigned char)addrs[2], (unsigned char)
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
651 addrs[3]));
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
652
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
653 }
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
654 g_free(sendertmp);
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
655 g_free(send_inst);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
656 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 free_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658 }
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
659 g_free(buf3);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
660 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
661 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
662 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
663
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
664 static gint check_notify(gpointer data)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
665 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
666 while (ZPending()) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
667 ZNotice_t notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
668 struct sockaddr_in from;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
669
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
670 z_call_r(ZReceiveNotice(&notice, &from));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
671
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
672 switch (notice.z_kind) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
673 case UNSAFE:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
674 case UNACKED:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
675 case ACKED:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
676 handle_message(notice, from);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
677 break;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
678 case SERVACK:
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
679 if (!(g_ascii_strcasecmp(notice.z_message, ZSRVACK_NOTSENT))) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
680 message_failed(notice, from);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
681 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
682 break;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
683 default:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
684 /* we'll just ignore things for now */
6484
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
685 gaim_debug(GAIM_DEBUG_WARNING, "zephyr", "Unhandled notice.\n");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
686 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
687 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
688
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
689 ZFreeNotice(&notice);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
690 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
691
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
692 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
693 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
694
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
695 static gint check_loc(gpointer data)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
696 {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
697 GaimBlistNode *gnode, *cnode, *bnode;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
698 ZAsyncLocateData_t ald;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
699
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
700 ald.user = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
701 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
702 ald.version = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
703
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
704 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
705 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
706 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
707 for (cnode = gnode->child; cnode; cnode = cnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
708 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
709 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
710 for (bnode = cnode->child; bnode; bnode = bnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
711 GaimBuddy *b = (GaimBuddy *) bnode;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
712
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
713 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
714 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
715 if (b->account->gc == zgc) {
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7126
diff changeset
716 const char *chk;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
717
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
718 chk = local_zephyr_normalize(b->name);
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
719 /* doesn't matter if this fails or not; we'll just move on to the next one */
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
720 ZRequestLocations(chk, &ald, UNACKED, ZAUTH);
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
721 free(ald.user);
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
722 free(ald.version);
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
723 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
724 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
725 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
726 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
727
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
728 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
729 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
730
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
731 static char *get_exposure_level()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
732 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
733 char *exposure = ZGetVariable("exposure");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
734
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
735 if (!exposure)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
736 return EXPOSE_REALMVIS;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
737 if (!g_ascii_strcasecmp(exposure, EXPOSE_NONE))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
738 return EXPOSE_NONE;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
739 if (!g_ascii_strcasecmp(exposure, EXPOSE_OPSTAFF))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
740 return EXPOSE_OPSTAFF;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
741 if (!g_ascii_strcasecmp(exposure, EXPOSE_REALMANN))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
742 return EXPOSE_REALMANN;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
743 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETVIS))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
744 return EXPOSE_NETVIS;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
745 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETANN))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
746 return EXPOSE_NETANN;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
747 return EXPOSE_REALMVIS;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
748 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
749
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
750 static void strip_comments(char *str)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
751 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
752 char *tmp = strchr(str, '#');
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
753
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
754 if (tmp)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
755 *tmp = '\0';
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
756 g_strchug(str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
757 g_strchomp(str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
758 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
759
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
760 static void process_zsubs()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
761 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
762 FILE *f;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
763 gchar *fname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
764 gchar buff[BUFSIZ];
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
765
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
766 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
767 f = fopen(fname, "r");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
768 if (f) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
769 char **triple;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
770 ZSubscription_t sub;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
771 char *recip;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
772
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
773 while (fgets(buff, BUFSIZ, f)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
774 strip_comments(buff);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
775 if (buff[0]) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
776 triple = g_strsplit(buff, ",", 3);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
777 if (triple[0] && triple[1]) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
778 char *tmp = g_strdup_printf("%s", gaim_zephyr_get_sender());
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
779 char *atptr;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
780
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
781 sub.zsub_class = triple[0];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
782 sub.zsub_classinst = triple[1];
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
783 if (triple[2] == NULL) {
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
784 recip = g_malloc0(1);
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
785 } else if (!g_ascii_strcasecmp(triple[2], "%me%")) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
786 recip = g_strdup_printf("%s", gaim_zephyr_get_sender());
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
787 } else if (!g_ascii_strcasecmp(triple[2], "*")) {
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
788 /* wildcard
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
789 * form of class,instance,* */
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
790 recip = g_malloc0(1);
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
791 } else if (!g_ascii_strcasecmp(triple[2], tmp)) {
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
792 /* form of class,instance,aatharuv@ATHENA.MIT.EDU */
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
793 recip = g_strdup(triple[2]);
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
794 } else if ((atptr = strchr(triple[2], '@')) != NULL) {
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
795 /* form of class,instance,*@ANDREW.CMU.EDU
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
796 * class,instance,@ANDREW.CMU.EDU
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
797 * If realm is local realm, blank recipient, else
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
798 * @REALM-NAME
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
799 */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
800 char *realmat = g_strdup_printf("@%s",
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
801 gaim_zephyr_get_realm());
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
802
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
803 if (!g_ascii_strcasecmp(atptr, realmat))
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
804 recip = g_malloc0(1);
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
805 else
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
806 recip = g_strdup(atptr);
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
807 g_free(realmat);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
808 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
809 recip = g_strdup(triple[2]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
810 }
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
811 g_free(tmp);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
812 sub.zsub_recipient = recip;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
813 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
814 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Couldn't subscribe to %s, %s, %s\n", sub.zsub_class, sub.zsub_classinst, sub.zsub_recipient);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
815 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
816 subscrips = g_slist_append(subscrips, new_triple(triple[0], triple[1], recip));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
817 g_free(recip);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
818 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
819 g_strfreev(triple);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
820 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
821 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
822 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
823 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
824
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
825 static void process_anyone()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
826 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
827 FILE *fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
828 gchar buff[BUFSIZ], *filename;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
829 GaimGroup *g;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
830 GaimBuddy *b;
4775
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
831
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
832 if (!(g = gaim_find_group(_("Anyone")))) {
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
833 g = gaim_group_new(_("Anyone"));
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
834 gaim_blist_add_group(g, NULL);
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
835 }
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
836
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
837 filename = g_strconcat(gaim_home_dir(), "/.anyone", NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
838 if ((fd = fopen(filename, "r")) != NULL) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
839 while (fgets(buff, BUFSIZ, fd)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
840 strip_comments(buff);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4682
diff changeset
841 if (buff[0]) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
842 if (!(b = gaim_find_buddy(zgc->account, buff))) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
843 b = gaim_buddy_new(zgc->account, buff, NULL);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
844 gaim_blist_add_buddy(b, NULL, g, NULL);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
845 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
846 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
847 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
848 fclose(fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
849 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
850 g_free(filename);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
851 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
852
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
853 static void zephyr_login(GaimAccount * account)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
854 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
855 ZSubscription_t sub;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
856
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
857 if (zgc) {
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5234
diff changeset
858 gaim_notify_error(account->gc, NULL,
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
859 _("Already logged in with Zephyr"), _("Because Zephyr uses your system username, you " "are unable to have multiple accounts on it " "when logged in as the same user."));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
860 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
861 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
862
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
863 zgc = gaim_account_get_connection(account);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
864 zgc->flags |= GAIM_CONNECTION_HTML;
8645
47f647dd2ac3 [gaim-migrate @ 9397]
Mark Doliner <mark@kingant.net>
parents: 8644
diff changeset
865 gaim_connection_update_progress(zgc, _("Connecting"), 0, 2);
47f647dd2ac3 [gaim-migrate @ 9397]
Mark Doliner <mark@kingant.net>
parents: 8644
diff changeset
866
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
867 z_call_s(ZInitialize(), "Couldn't initialize zephyr");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
868 z_call_s(ZOpenPort(NULL), "Couldn't open port");
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
869 z_call_s(ZSetLocation((char *)
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
870 gaim_account_get_string(zgc->account, "exposure_level", EXPOSE_REALMVIS)), "Couldn't set location");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
871
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
872 sub.zsub_class = "MESSAGE";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
873 sub.zsub_classinst = "PERSONAL";
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
874 sub.zsub_recipient = (char *)gaim_zephyr_get_sender();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
875
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
876 /* we don't care if this fails. i'm lying right now. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
877 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
878 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Couldn't subscribe to messages!\n");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
879 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
880
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
881 gaim_connection_set_state(zgc, GAIM_CONNECTED);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
882 serv_finish_login(zgc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
883
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
884 process_anyone();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
885 process_zsubs();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
886
8273
f24172f53650 [gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents: 8212
diff changeset
887 nottimer = gaim_timeout_add(100, check_notify, NULL);
f24172f53650 [gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents: 8212
diff changeset
888 loctimer = gaim_timeout_add(20000, check_loc, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
889 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
890
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
891 static void write_zsubs()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
892 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
893 GSList *s = subscrips;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
894 zephyr_triple *zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
895 FILE *fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
896 char *fname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
897
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
898 char **triple;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
899
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
900 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
901 fd = fopen(fname, "w");
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
902
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
903 if (!fd) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
904 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
905 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
906 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
907
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
908 while (s) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
909 zt = s->data;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
910 triple = g_strsplit(zt->name, ",", 3);
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
911 if (triple[2] != NULL) {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
912 if (!g_ascii_strcasecmp(triple[2], "")) {
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
913 fprintf(fd, "%s,%s,*\n", triple[0], triple[1]);
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
914 } else if (!g_ascii_strcasecmp(triple[2], gaim_zephyr_get_sender())) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
915 fprintf(fd, "%s,%s,%%me%%\n", triple[0], triple[1]);
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
916 } else {
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
917 fprintf(fd, "%s\n", zt->name);
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
918 }
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
919 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
920 fprintf(fd, "%s,%s,*\n", triple[0], triple[1]);
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
921 }
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
922 g_free(triple);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
923 s = s->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
924 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
925 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
926 fclose(fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
927 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
928
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
929 static void write_anyone()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
930 {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
931 GaimBlistNode *gnode, *cnode, *bnode;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
932 GaimBuddy *b;
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
933 char *ptr, *fname, *ptr2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
934 FILE *fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
935
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
936 fname = g_strdup_printf("%s/.anyone", gaim_home_dir());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
937 fd = fopen(fname, "w");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
938 if (!fd) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
939 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
940 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
941 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
942
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
943 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
944 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
945 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
946 for (cnode = gnode->child; cnode; cnode = cnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
947 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
948 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
949 for (bnode = cnode->child; bnode; bnode = bnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
950 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
951 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
952 b = (GaimBuddy *) bnode;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
953 if (b->account == zgc->account) {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
954 if ((ptr = strchr(b->name, '@')) != NULL) {
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
955 ptr2 = ptr + 1;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
956 /* We should only strip the realm name if the principal
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
957 is in the user's realm
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
958 */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
959 if (!g_ascii_strcasecmp(ptr2, gaim_zephyr_get_realm())) {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
960 *ptr = '\0';
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
961 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
962 }
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
963 fprintf(fd, "%s\n", b->name);
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
964 if (ptr)
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
965 *ptr = '@';
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
966 }
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
967 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
968 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
969 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
970
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
971 fclose(fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
972 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
973 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
974
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
975 static void zephyr_close(GaimConnection * gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
976 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
977 GList *l;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
978 GSList *s;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
979
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
980 l = pending_zloc_names;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
981 while (l) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
982 g_free((char *)l->data);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
983 l = l->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
984 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
985 g_list_free(pending_zloc_names);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
986
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
987 if (gaim_account_get_bool(zgc->account, "write_anyone", FALSE))
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
988 write_anyone();
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
989
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
990 if (gaim_account_get_bool(zgc->account, "write_zsubs", FALSE))
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
991 write_zsubs();
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
992
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
993 s = subscrips;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
994 while (s) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
995 free_triple((zephyr_triple *) s->data);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
996 s = s->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
997 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
998 g_slist_free(subscrips);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
999
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1000 if (nottimer)
8287
ef881489396e [gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents: 8273
diff changeset
1001 gaim_timeout_remove(nottimer);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1002 nottimer = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1003 if (loctimer)
8287
ef881489396e [gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents: 8273
diff changeset
1004 gaim_timeout_remove(loctimer);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1005 loctimer = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1006 zgc = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1007 z_call(ZCancelSubscriptions(0));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1008 z_call(ZUnsetLocation());
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1009 z_call(ZClosePort());
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1010 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1011
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1012 static int zephyr_chat_send(GaimConnection * gc, int id, const char *im)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1013 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1014 ZNotice_t notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1015 zephyr_triple *zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1016 char *buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1017 const char *sig;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1018 GaimConversation *gconv1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1019 GaimConvChat *gcc;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1020 char *inst;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1021 char *html_buf;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1022 char *html_buf2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1023
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1024 zt = find_sub_by_id(id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1025 if (!zt)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1026 /* this should never happen. */
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
1027 return -EINVAL;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1028
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1029 sig = ZGetVariable("zwrite-signature");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1030 if (!sig) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1031 sig = g_get_real_name();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1032 }
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1033
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1034 html_buf = html_to_zephyr(im);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1035 html_buf2 = gaim_unescape_html(html_buf);
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1036
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1037 buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1038
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1039 gconv1 = gaim_find_conversation_with_account(zt->name, zgc->account);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1040 gcc = gaim_conversation_get_chat_data(gconv1);
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1041
8712
a4ff6e79c5fc [gaim-migrate @ 9466]
Ethan Blanton <elb@pidgin.im>
parents: 8645
diff changeset
1042 /* This patently does not make sense ... if inst is not set by
a4ff6e79c5fc [gaim-migrate @ 9466]
Ethan Blanton <elb@pidgin.im>
parents: 8645
diff changeset
1043 * gaim_conv_chat_get_topic, we set it to the uninitialized
a4ff6e79c5fc [gaim-migrate @ 9466]
Ethan Blanton <elb@pidgin.im>
parents: 8645
diff changeset
1044 * value of notice.z_class_inst, only to set notice.z_class_inst
a4ff6e79c5fc [gaim-migrate @ 9466]
Ethan Blanton <elb@pidgin.im>
parents: 8645
diff changeset
1045 * back to inst in a half a dozen lines. I'm just going to let
a4ff6e79c5fc [gaim-migrate @ 9466]
Ethan Blanton <elb@pidgin.im>
parents: 8645
diff changeset
1046 * it remain NULL instead.
a4ff6e79c5fc [gaim-migrate @ 9466]
Ethan Blanton <elb@pidgin.im>
parents: 8645
diff changeset
1047 *
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1048 if (!(inst = (char *)gaim_conv_chat_get_topic(gcc)))
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1049 inst = (char *)notice.z_class_inst;
8712
a4ff6e79c5fc [gaim-migrate @ 9466]
Ethan Blanton <elb@pidgin.im>
parents: 8645
diff changeset
1050 */
a4ff6e79c5fc [gaim-migrate @ 9466]
Ethan Blanton <elb@pidgin.im>
parents: 8645
diff changeset
1051 inst = (char *)gaim_conv_chat_get_topic(gcc);
a4ff6e79c5fc [gaim-migrate @ 9466]
Ethan Blanton <elb@pidgin.im>
parents: 8645
diff changeset
1052 /* There, now isn't that better? */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1053
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1054 bzero((char *)&notice, sizeof(notice));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1055 notice.z_kind = ACKED;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1056 notice.z_port = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1057 notice.z_opcode = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1058 notice.z_class = zt->class;
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1059 notice.z_class_inst = inst;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1060 if (!g_ascii_strcasecmp(zt->recipient, "*"))
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1061 notice.z_recipient = local_zephyr_normalize("");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1062 else
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1063 notice.z_recipient = local_zephyr_normalize(zt->recipient);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1064 notice.z_sender = 0;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1065 notice.z_default_format = "Class $class, Instance $instance:\n" "To: @bold($recipient) at $time $date\n" "From: @bold($1) <$sender>\n\n$2";
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1066 notice.z_message_len = strlen(html_buf2) + strlen(sig) + 2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1067 notice.z_message = buf;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1068 g_free(html_buf);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1069 g_free(html_buf2);
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1070
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1071 ZSendNotice(&notice, ZAUTH);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1072 g_free(buf);
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
1073 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1074 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1075
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1076 static int zephyr_send_im(GaimConnection * gc, const char *who, const char *im, GaimConvImFlags flags)
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1077 {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1078 ZNotice_t notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1079 char *buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1080 const char *sig;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1081 char *html_buf;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1082 char *html_buf2;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1083
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
1084 if (flags & GAIM_CONV_IM_AUTO_RESP)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1085 sig = "Automated reply:";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1086 else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1087 sig = ZGetVariable("zwrite-signature");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1088 if (!sig) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1089 sig = g_get_real_name();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1090 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1091 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1092
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1093 html_buf = html_to_zephyr(im);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1094 html_buf2 = gaim_unescape_html(html_buf);
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1095
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1096 buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1097 bzero((char *)&notice, sizeof(notice));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1098 notice.z_kind = ACKED;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1099 notice.z_port = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1100 notice.z_opcode = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1101 notice.z_class = "MESSAGE";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1102 notice.z_class_inst = "PERSONAL";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1103 notice.z_sender = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1104 notice.z_recipient = who;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1105 notice.z_default_format = "Class $class, Instance $instance:\n" "To: @bold($recipient) at $time $date\n" "From: @bold($1) <$sender>\n\n$2";
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1106 notice.z_message_len = strlen(html_buf2) + strlen(sig) + 2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1107 notice.z_message = buf;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1108 g_free(html_buf2);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1109 g_free(html_buf);
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1110
6904
7c3a11c69be9 [gaim-migrate @ 7451]
Mark Doliner <mark@kingant.net>
parents: 6787
diff changeset
1111 ZSendNotice(&notice, ZAUTH);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1112 g_free(buf);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
1113 return 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1114 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1115
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1116 static const char *zephyr_normalize(const GaimAccount * account, const char *orig)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1117 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1118 static char buf[80];
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1119
7126
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1120 if (!g_ascii_strcasecmp(orig, "")) {
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1121 buf[0] = '\0';
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1122 return buf;
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1123 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1124 g_snprintf(buf, 80, "%s", orig);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1125 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1126 return buf;
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1127 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1128
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1129
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1130 static const char *local_zephyr_normalize(const char *orig)
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1131 {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1132 static char buf[80];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1133
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1134 if (!g_ascii_strcasecmp(orig, "")) {
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1135 buf[0] = '\0';
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1136 return buf;
7126
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1137 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1138
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1139 if (strchr(orig, '@')) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1140 g_snprintf(buf, 80, "%s", orig);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1141 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1142 g_snprintf(buf, 80, "%s@%s", orig, gaim_zephyr_get_realm());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1143 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1144 return buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1145 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1146
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1147 static void zephyr_zloc(GaimConnection *gc, const char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1148 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1149 ZAsyncLocateData_t ald;
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7126
diff changeset
1150
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1151 if (ZRequestLocations(local_zephyr_normalize(who), &ald, UNACKED, ZAUTH) == ZERR_NONE) {
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1152 pending_zloc_names = g_list_append(pending_zloc_names,
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1153 g_strdup(local_zephyr_normalize(who)));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1154 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1155 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1156
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1157 static void zephyr_set_away(GaimConnection * gc, const char *state, const char *msg)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1158 {
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1159 if (gc->away) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1160 g_free(gc->away);
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1161 gc->away = NULL;
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1162 }
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1163
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
1164 if (!g_ascii_strcasecmp(state, _("Hidden"))) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1165 ZSetLocation(EXPOSE_OPSTAFF);
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1166 gc->away = g_strdup("");
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
1167 } else if (!g_ascii_strcasecmp(state, _("Online")))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1168 ZSetLocation(get_exposure_level());
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1169 else /* state is GAIM_AWAY_CUSTOM */ if (msg)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1170 gc->away = g_strdup(msg);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1171 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1172
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1173 static GList *zephyr_away_states(GaimConnection * gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1174 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1175 GList *m = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1176
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
1177 m = g_list_append(m, _("Online"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1178 m = g_list_append(m, GAIM_AWAY_CUSTOM);
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
1179 m = g_list_append(m, _("Hidden"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1180
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1181 return m;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1182 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1183
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1184 static GList *zephyr_chat_info(GaimConnection * gc)
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1185 {
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1186 GList *m = NULL;
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1187 struct proto_chat_entry *pce;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1188
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1189 pce = g_new0(struct proto_chat_entry, 1);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1190
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7475
diff changeset
1191 pce->label = _("_Class:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1192 pce->identifier = "class";
3158
ea6f8d8d74e5 [gaim-migrate @ 3174]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
1193 m = g_list_append(m, pce);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1194
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1195 pce = g_new0(struct proto_chat_entry, 1);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1196
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7475
diff changeset
1197 pce->label = _("_Instance:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1198 pce->identifier = "instance";
3158
ea6f8d8d74e5 [gaim-migrate @ 3174]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
1199 m = g_list_append(m, pce);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1200
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1201 pce = g_new0(struct proto_chat_entry, 1);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1202
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7475
diff changeset
1203 pce->label = _("_Recipient:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1204 pce->identifier = "recipient";
3158
ea6f8d8d74e5 [gaim-migrate @ 3174]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
1205 m = g_list_append(m, pce);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1206
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1207 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1208 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1209
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1210 static void zephyr_join_chat(GaimConnection * gc, GHashTable * data)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1211 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1212 ZSubscription_t sub;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1213 zephyr_triple *zt1, *zt2;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1214 const char *classname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1215 const char *instname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1216 const char *recip;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1217
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1218 classname = g_hash_table_lookup(data, "class");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1219 instname = g_hash_table_lookup(data, "instance");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1220 recip = g_hash_table_lookup(data, "recipient");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1221
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1222 if (!classname || !instname || !recip)
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1223 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1224
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1225 if (!g_ascii_strcasecmp(recip, "%me%"))
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1226 recip = gaim_zephyr_get_sender();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1227
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1228 zt1 = new_triple(classname, instname, recip);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1229 zt2 = find_sub_by_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1230 if (zt2) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1231 free_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1232 if (!zt2->open)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1233 serv_got_joined_chat(gc, zt2->id, zt2->name);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1234 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1235 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1236
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1237 sub.zsub_class = zt1->class;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1238 sub.zsub_classinst = zt1->instance;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1239 sub.zsub_recipient = zt1->recipient;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1240
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1241 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1242 free_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1243 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1244 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1245
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1246 subscrips = g_slist_append(subscrips, zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1247 zt1->open = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1248 serv_got_joined_chat(gc, zt1->id, zt1->name);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1249 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1250
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1251 static void zephyr_chat_leave(GaimConnection * gc, int id)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1252 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1253 zephyr_triple *zt;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1254
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1255 zt = find_sub_by_id(id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1256 if (zt) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1257 zt->open = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1258 zt->id = ++last_id;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1259 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1260 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1261
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1262 static const char *zephyr_list_icon(GaimAccount * a, GaimBuddy * b)
5202
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
1263 {
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
1264 return "zephyr";
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
1265 }
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
1266
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1267
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1268 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
1269 {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1270 zephyr_triple *zt;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1271 GaimConversation *gconv;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1272 GaimConvChat *gcc;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1273 char *sender = (char *)gaim_zephyr_get_sender();
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1274
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1275 zt = find_sub_by_id(id);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1276 gconv = gaim_find_conversation_with_account(zt->name, zgc->account);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1277 gcc = gaim_conversation_get_chat_data(gconv);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1278 gaim_conv_chat_set_topic(gcc, sender, topic);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1279
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1280 }
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1281
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1282 static GaimPlugin *my_protocol = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1283
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1284 static GaimPluginProtocolInfo prpl_info = {
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8713
diff changeset
1285 GAIM_PRPL_API_VERSION,
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1286 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1287 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1288 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1289 zephyr_list_icon,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1290 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1291 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1292 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1293 zephyr_away_states,
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1294 NULL,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1295 zephyr_chat_info,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1296 zephyr_login,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1297 zephyr_close,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1298 zephyr_send_im,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1299 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1300 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1301 zephyr_zloc,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1302 zephyr_set_away,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1303 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1304 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1305 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1306 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1307 NULL,
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1308 NULL,
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1309 NULL,
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1310 NULL,
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1311 NULL,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1312 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1313 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1314 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1315 zephyr_join_chat,
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1316 NULL, /* reject chat invite */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1317 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1318 zephyr_chat_leave,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1319 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1320 zephyr_chat_send,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1321 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1322 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1323 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1324 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1325 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1326 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1327 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1328 NULL,
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
1329 NULL,
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1330 zephyr_normalize,
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
1331 NULL,
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
1332 NULL,
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
1333 NULL,
8586
5af95c2b1179 [gaim-migrate @ 9336]
Ethan Blanton <elb@pidgin.im>
parents: 8568
diff changeset
1334 zephyr_chat_set_topic,
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1335 NULL,
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1336 NULL,
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1337 NULL,
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1338 NULL
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1339 };
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1340
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1341 static GaimPluginInfo info = {
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8713
diff changeset
1342 GAIM_PLUGIN_API_VERSION, /**< api_version */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1343 GAIM_PLUGIN_PROTOCOL, /**< type */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1344 NULL, /**< ui_requirement */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1345 0, /**< flags */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1346 NULL, /**< dependencies */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1347 GAIM_PRIORITY_DEFAULT, /**< priority */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1348
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1349 "prpl-zephyr", /**< id */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1350 "Zephyr", /**< name */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1351 VERSION, /**< version */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1352 /** summary */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1353 N_("Zephyr Protocol Plugin"),
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1354 /** description */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1355 N_("Zephyr Protocol Plugin"),
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1356 NULL, /**< author */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1357 GAIM_WEBSITE, /**< homepage */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1358
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1359 NULL, /**< load */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1360 NULL, /**< unload */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1361 NULL, /**< destroy */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1362
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1363 NULL, /**< ui_info */
8993
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8954
diff changeset
1364 &prpl_info, /**< extra_info */
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8954
diff changeset
1365 NULL,
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8954
diff changeset
1366 NULL
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1367 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1368
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1369 static void init_plugin(GaimPlugin * plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1370 {
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1371 GaimAccountOption *option;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1372 char *tmp = get_exposure_level();
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1373
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1374 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
1375 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
1376
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1377 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
1378 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
1379
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1380 option = gaim_account_option_string_new(_("Exposure"), "exposure_level", tmp ? tmp : EXPOSE_REALMVIS);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1381 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
1382
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1383 option = gaim_account_option_string_new(_("Encoding"), "encoding", ZEPHYR_FALLBACK_CHARSET);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1384 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
1385
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1386 my_protocol = plugin;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1387 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1388
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1389 GAIM_INIT_PLUGIN(zephyr, init_plugin, info);