annotate src/protocols/zephyr/zephyr.c @ 8586:5af95c2b1179

[gaim-migrate @ 9336] Another patch from Pekka Riikonen, this one implementing a prpl-specific blist chat menu similar to the prpl-specific blist buddy menu. I also took the liberty of filling out the prpl callback structures with NULL entries for those which were short -- not that it matters, but it soothes my sense of aesthetics. committer: Tailor Script <tailor@pidgin.im>
author Ethan Blanton <elb@pidgin.im>
date Mon, 05 Apr 2004 20:42:13 +0000
parents 88988327a4e0
children f6203301aa19
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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 * the color. */
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;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 zt = g_new0(zephyr_triple, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 zt->class = g_strdup(c);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 zt->instance = g_strdup(i);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 zt->recipient = g_strdup(r);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 zt->name = g_strdup_printf("%s,%s,%s", c, i, r);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 zt->id = ++last_id;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 zt->open = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 return zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 }
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 static void free_triple(zephyr_triple *zt)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122 g_free(zt->class);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 g_free(zt->instance);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 g_free(zt->recipient);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 g_free(zt->name);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 g_free(zt);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
129 static const char* gaim_zephyr_get_sender() {
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
130 /* will be useful once this plugin can use a backend other
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
131 than libzephyr */
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
132 return ZGetSender();
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
133 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
134
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
135 static const char* gaim_zephyr_get_realm() {
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
136 /* will be useful once this plugin can use a backend other
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
137 than libzephyr */
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
138 return ZGetRealm();
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
139 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
140
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141 /* 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
142 * wildcards in each field of zt1. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 static gboolean triple_subset(zephyr_triple *zt1, zephyr_triple *zt2)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144 {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
145 if (g_ascii_strcasecmp(zt2->class, zt1->class) &&
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
146 g_ascii_strcasecmp(zt2->class, "*")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 }
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
149 if (g_ascii_strcasecmp(zt2->instance, zt1->instance) &&
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
150 g_ascii_strcasecmp(zt2->instance, "*")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 }
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
153 if (g_ascii_strcasecmp(zt2->recipient, zt1->recipient) &&
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
154 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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 static zephyr_triple *find_sub_by_triple(zephyr_triple *zt)
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;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 while (curr) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 curr_t = curr->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 if (triple_subset(zt, curr_t))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 return curr_t;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 curr = curr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 }
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 static zephyr_triple *find_sub_by_id(int id)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175 zephyr_triple *zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 GSList *curr = subscrips;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 while (curr) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178 zt = curr->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 if (zt->id == id)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 return zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 curr = curr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 return NULL;
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
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
186 static gchar *zephyr_recv_convert(char *string, int len)
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
187 {
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
188 gchar *utf8;
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
189 GError *err = NULL;
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
190 if (g_utf8_validate(string,len,NULL)) {
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
191 return g_strdup(string);
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
192 } else {
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
193 utf8 = g_convert(string, len, "UTF-8",
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
194 gaim_account_get_string(zgc->account, "encoding", ZEPHYR_FALLBACK_CHARSET),
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
195 NULL, NULL, &err);
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
196 if (err) {
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
197 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
198 utf8 = g_strdup(_("(There was an error converting this message. Check the 'Encoding' option in the Account Editor)"));
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
199 }
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
200
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
201 return utf8;
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
202 }
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
203 }
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
204
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 /* utility macros that are useful for zephyr_to_html */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<'))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 #define IS_CLOSER(c) ((c == '}') || (c == ']') || (c == ')') || (c == '>'))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
210 /* 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
211 And converts it to zephyr formatting.
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
212 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
213 It ignores <font back=...>
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
214 It does
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
215 <font size = "1 or 2" -> @small
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
216 3 or 4 @medium()
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
217 5,6, or 7 @large()
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
218 <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
219 */
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
220
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
221 static char *html_to_zephyr(const char *message)
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 int len,cnt,retcount;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
224 char *ret;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
225 len = strlen(message);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
226 ret = g_new0(char,len*3);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
227 bzero(ret,len*3);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
228 retcount=0;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
229 cnt = 0;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
230 while (cnt <= len) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
231 if (message[cnt] == '<') {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
232 if (!g_ascii_strncasecmp(message+cnt+1,"i>",2)) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
233 strncpy(ret+retcount,"@i(",3);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
234 cnt+=3;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
235 retcount+=3;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
236 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
237 else if (!g_ascii_strncasecmp(message+cnt+1,"b>",2)) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
238 strncpy(ret+retcount,"@b(",3);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
239 cnt+=3;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
240 retcount+=3;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
241 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
242 else if (!g_ascii_strncasecmp(message+cnt+1,"br>",3)) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
243 strncpy(ret+retcount,"\n",1);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
244 cnt+=4;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
245 retcount+=1;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
246 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
247 else if (!g_ascii_strncasecmp(message+cnt+1,"a href=\"",8)) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
248 cnt+=9;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
249 while(g_ascii_strncasecmp(message+cnt,"\">",2) !=0) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
250 ret[retcount]=message[cnt];
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
251 retcount++; cnt++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
252 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
253 cnt+=2;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
254 /* ignore descriptive string */
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
255 while(g_ascii_strncasecmp(message+cnt,"</a>",4) !=0) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
256 cnt++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
257 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
258 cnt+=4;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
259 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
260 else if (!g_ascii_strncasecmp(message+cnt+1, "font",4)) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
261 cnt+=5;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
262 while(!g_ascii_strncasecmp(message+cnt," ",1)) cnt++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
263 if (!g_ascii_strncasecmp(message+cnt,"color=\"",7)) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
264 cnt+=7;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
265 strncpy(ret+retcount,"@color(",7);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
266 retcount+=7;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
267 while(g_ascii_strncasecmp(message+cnt,"\">",2) !=0) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
268 ret[retcount] = message[cnt];
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
269 retcount++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
270 cnt++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
271 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
272 ret[retcount]=')';
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
273 retcount++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
274 cnt+=2;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
275 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
276 else if (!g_ascii_strncasecmp(message+cnt,"face=\"",6)) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
277 cnt+=6;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
278 strncpy(ret+retcount,"@font(",6);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
279 retcount+=6;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
280 while(g_ascii_strncasecmp(message+cnt,"\">",2) !=0) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
281 ret[retcount] = message[cnt];
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
282 retcount++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
283 cnt++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
284 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
285 ret[retcount]=')';
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
286 retcount++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
287 cnt+=2;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
288 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
289 else if (!g_ascii_strncasecmp(message+cnt,"size=\"",6)) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
290 cnt+=6;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
291 if ( (message[cnt] == '1')|| (message[cnt] == '2')) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
292 strncpy(ret+retcount,"@small(",7);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
293 retcount+=7;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
294 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
295 else if ( (message[cnt] == '3')|| (message[cnt] == '4')) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
296 strncpy(ret+retcount,"@medium(",8);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
297 retcount+=8;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
298 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
299 else if ( (message[cnt] == '5')|| (message[cnt] == '6') || (message[cnt] == '7')) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
300 strncpy(ret+retcount,"@large(",7);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
301 retcount+=7;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
302 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
303 cnt+=3;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
304 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
305 else {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
306 /* Drop all unrecognized/misparsed font tags */
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
307 while(g_ascii_strncasecmp(message+cnt,"\">",2) !=0) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
308 cnt++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
309 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
310 cnt+=2;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
311 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
312 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
313 else if (!g_ascii_strncasecmp(message+cnt+1,"/i>",3) || !g_ascii_strncasecmp(message+cnt+1,"/b>",3)) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
314 cnt+=4;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
315 ret[retcount]=')';
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
316 retcount++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
317 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
318 else if (!g_ascii_strncasecmp(message+cnt+1,"/font>",6)) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
319 cnt+=7;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
320 strncpy(ret+retcount,"@font(fixed)",12);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
321 retcount+=12;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
322 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
323 else {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
324 /* Catch all for all unrecognized/misparsed <foo> tage */
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
325 while(g_ascii_strncasecmp(message+cnt,">",1) != 0) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
326 ret[retcount]=message[cnt];
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
327 retcount++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
328 cnt++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
329 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
330 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
331 } else {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
332 /* Duh */
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
333 ret[retcount]=message[cnt];
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
334 retcount++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
335 cnt++;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
336 }
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 return ret;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
339 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
340
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
341 /* this parses zephyr formatting and converts it to html. For example, if
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
342 * you pass in "@{@color(blue)@i(hello)}" you should get out
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
343 * "<font color=blue><i>hello</i></font>". */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
344 static char *zephyr_to_html(char *message)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
345 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
346 int len, cnt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
347 zframe *frames, *curr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
348 char *ret;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
349
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
350 frames = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
351 frames->text = g_string_new("");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
352 frames->enclosing = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
353 frames->closing = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
354 frames->has_closer = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
355
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
356 len = strlen(message);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
357 cnt = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
358 while (cnt <= len) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
359 if (message[cnt] == '@') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
360 zframe *new_f;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
361 char *buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
362 int end;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
363 for (end=1; (cnt+end) <= len &&
7070
b794695d7c72 [gaim-migrate @ 7635]
Luke Schierer <lschiere@pidgin.im>
parents: 7062
diff changeset
364 !IS_OPENER(message[cnt+end]) && !IS_CLOSER(message[cnt+end]); end++);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
365 buf = g_new0(char, end);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
366 if (end) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
367 g_snprintf(buf, end, "%s", message+cnt+1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
368 }
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
369 if (!g_ascii_strcasecmp(buf, "italic") ||
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
370 !g_ascii_strcasecmp(buf, "i")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
371 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
372 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
373 new_f->text = g_string_new("<i>");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
374 new_f->closing = "</i>";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
375 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
376 frames = new_f;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
377 cnt += end+1; /* cnt points to char after opener */
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
378 } else if (!g_ascii_strcasecmp(buf,"small")) {
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
379 new_f = g_new(zframe,1);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
380 new_f->enclosing = frames;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
381 new_f->text = g_string_new("<font size=\"1\">");
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
382 new_f->closing ="</font>";
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
383 frames = new_f;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
384 cnt+= end+1;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
385 } else if (!g_ascii_strcasecmp(buf,"medium")) {
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
386 new_f = g_new(zframe,1);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
387 new_f->enclosing = frames;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
388 new_f->text = g_string_new("<font size=\"3\">");
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
389 new_f->closing ="</font>";
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
390 frames = new_f;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
391 cnt+= end+1;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
392 } else if (!g_ascii_strcasecmp(buf,"large")) {
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
393 new_f = g_new(zframe,1);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
394 new_f->enclosing = frames;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
395 new_f->text = g_string_new("<font size=\"7\">");
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
396 new_f->closing ="</font>";
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
397 frames = new_f;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
398 cnt+= end+1;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
399 } else if (!g_ascii_strcasecmp(buf, "bold")
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
400 || !g_ascii_strcasecmp(buf, "b")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 new_f->text = g_string_new("<b>");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 new_f->closing = "</b>";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406 frames = new_f;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407 cnt += end+1;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
408 } else if (!g_ascii_strcasecmp(buf, "font")) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
409 cnt += end+1;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
410 new_f = g_new(zframe, 1);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
411 new_f->enclosing = frames;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
412 new_f->text = g_string_new("<font face=");
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
413 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
414 g_string_append_c(new_f->text, message[cnt]);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
415 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
416 cnt++; /* point to char after closer */
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
417 g_string_append_c(new_f->text, '>');
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
418 new_f->closing = "</font>";
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
419 new_f->has_closer = FALSE;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
420 frames = new_f;
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
421 } else if (!g_ascii_strcasecmp(buf, "color")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
422 cnt += end+1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
423 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
425 new_f->text = g_string_new("<font color=");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
427 g_string_append_c(new_f->text, message[cnt]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
429 cnt++; /* point to char after closer */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430 g_string_append_c(new_f->text, '>');
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 new_f->closing = "</font>";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 new_f->has_closer = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433 frames = new_f;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
434 } else if (!g_ascii_strcasecmp(buf, "")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
436 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
437 new_f->text = g_string_new("");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
438 new_f->closing = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
439 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
440 frames = new_f;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
441 cnt += end+1; /* cnt points to char after opener */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
442 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
443 if ((cnt+end) > len) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
444 g_string_append_c(frames->text, '@');
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
445 cnt++;
7070
b794695d7c72 [gaim-migrate @ 7635]
Luke Schierer <lschiere@pidgin.im>
parents: 7062
diff changeset
446 } else if (IS_CLOSER(message[cnt+end])) {
b794695d7c72 [gaim-migrate @ 7635]
Luke Schierer <lschiere@pidgin.im>
parents: 7062
diff changeset
447 /* We have @chars..closer . This is
b794695d7c72 [gaim-migrate @ 7635]
Luke Schierer <lschiere@pidgin.im>
parents: 7062
diff changeset
448 merely a sequence of chars that isn't a formatting tag
b794695d7c72 [gaim-migrate @ 7635]
Luke Schierer <lschiere@pidgin.im>
parents: 7062
diff changeset
449 */
b794695d7c72 [gaim-migrate @ 7635]
Luke Schierer <lschiere@pidgin.im>
parents: 7062
diff changeset
450 int tmp=cnt;
b794695d7c72 [gaim-migrate @ 7635]
Luke Schierer <lschiere@pidgin.im>
parents: 7062
diff changeset
451 while (tmp<=cnt+end) {
b794695d7c72 [gaim-migrate @ 7635]
Luke Schierer <lschiere@pidgin.im>
parents: 7062
diff changeset
452 g_string_append_c(frames->text,message[tmp]);
b794695d7c72 [gaim-migrate @ 7635]
Luke Schierer <lschiere@pidgin.im>
parents: 7062
diff changeset
453 tmp++;
b794695d7c72 [gaim-migrate @ 7635]
Luke Schierer <lschiere@pidgin.im>
parents: 7062
diff changeset
454 }
b794695d7c72 [gaim-migrate @ 7635]
Luke Schierer <lschiere@pidgin.im>
parents: 7062
diff changeset
455 cnt+=end+1;
b794695d7c72 [gaim-migrate @ 7635]
Luke Schierer <lschiere@pidgin.im>
parents: 7062
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;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
466 cnt += end+1; /* cnt points to char after opener */
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;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
472 if (frames->enclosing) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
473 do {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
474 popped = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
475 frames = frames->enclosing;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
476 g_string_append(frames->text, popped->text->str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
477 g_string_append(frames->text, popped->closing);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
478 g_string_free(popped->text, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
479 last_had_closer = popped->has_closer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
480 g_free(popped);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
481 } while (frames && frames->enclosing && !last_had_closer);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
482 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
483 g_string_append_c(frames->text, message[cnt]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
484 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
485 cnt++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 } else if (message[cnt] == '\n') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487 g_string_append(frames->text, "<br>");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
488 cnt++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
489 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
490 g_string_append_c(frames->text, message[cnt++]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
491 }
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 /* go through all the stuff that they didn't close */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494 while (frames->enclosing) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
495 curr = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
496 g_string_append(frames->enclosing->text, frames->text->str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497 g_string_append(frames->enclosing->text, frames->closing);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498 g_string_free(frames->text, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499 frames = frames->enclosing;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
500 g_free(curr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
502 ret = frames->text->str;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
503 g_string_free(frames->text, FALSE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 g_free(frames);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
505 return ret;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
506 }
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 static gboolean pending_zloc(char *who)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
509 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
510 GList *curr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
511 for (curr = pending_zloc_names; curr != NULL; curr = curr->next) {
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
512 if (!g_ascii_strcasecmp(local_zephyr_normalize(who), (char*)curr->data)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
513 g_free((char*)curr->data);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
514 pending_zloc_names = g_list_remove(pending_zloc_names, curr->data);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
515 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
516 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
517 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518 return FALSE;
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
8559
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
521 static void message_failed(ZNotice_t notice, struct sockaddr_in from)
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
522 {
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
523 if (g_ascii_strcasecmp(notice.z_class,"message")) {
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
524 /* message to chat failed ignore for now */
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
525 } else {
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
526 gaim_notify_error(zgc,notice.z_recipient,_("User is offline"),NULL);
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
527 }
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
528 }
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
529
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
530 static void handle_message(ZNotice_t notice, struct sockaddr_in from)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
531 {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
532 if (!g_ascii_strcasecmp(notice.z_class, LOGIN_CLASS)) {
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
533 /* 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
534 } else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) {
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
535 if (!g_ascii_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
536 int nlocs;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
537 char *user;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
538 GaimBuddy *b;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
539
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
540 if (ZParseLocations(&notice, NULL, &nlocs, &user) != ZERR_NONE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
541 return;
8435
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
542
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
543 if ((b = gaim_find_buddy(zgc->account, user)) == NULL) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
544 char *e = strchr(user, '@');
8435
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
545 if(e && !g_ascii_strcasecmp(e+1,gaim_zephyr_get_realm()) ) {
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
546 *e = '\0';
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
547 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4682
diff changeset
548 b = gaim_find_buddy(zgc->account, user);
8435
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
549 }
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
550 if ((b && pending_zloc(b->name)) || pending_zloc(user) ) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
551 ZLocations_t locs;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
552 int one = 1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
553 GString *str = g_string_new("");
8435
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
554 g_string_append_printf(str, _("<b>User:</b> %s<br>"), b?b->name:user);
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
555 if (b && b->alias)
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
556 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
557 if (!nlocs) {
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
558 g_string_append_printf(str, _("<br>Hidden or not logged-in"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
559 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
560 for (; nlocs > 0; nlocs--) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
561 ZGetLocations(&locs, &one);
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
562 g_string_append_printf(str, _("<br>At %s since %s"), locs.host,
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
563 locs.time);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
564 }
7062
86ed8b2aa665 [gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
565 gaim_notify_formatted(zgc, NULL, _("Buddy Information"),
86ed8b2aa665 [gaim-migrate @ 7626]
Christian Hammond <chipx86@chipx86.com>
parents: 6982
diff changeset
566 NULL, str->str, NULL, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
567 g_string_free(str, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
568 } else
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
569 serv_got_update(zgc, b->name, nlocs, 0, 0, 0, 0);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
570
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
571 free(user);
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 } else {
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
574 char *buf, *buf2, *buf3;
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
575 char *send_inst;
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
576 char *realmptr;
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
577 GaimConversation *gconv1;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
578 GaimConvChat *gcc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
579 char *ptr = notice.z_message + strlen(notice.z_message) + 1;
7475
08ce2a94d9c7 [gaim-migrate @ 8088]
Mark Doliner <mark@kingant.net>
parents: 7322
diff changeset
580 int len = notice.z_message_len - ((int)ptr - (int)notice.z_message);
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
581 char *sendertmp = g_strdup_printf("%s",gaim_zephyr_get_sender());
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
582 GaimConvImFlags flags = 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
583 if (len > 0) {
8449
4ae3eb203615 [gaim-migrate @ 9179]
Luke Schierer <lschiere@pidgin.im>
parents: 8435
diff changeset
584 gchar* tmpescape;
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
585 buf = g_malloc(len + 1);
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
586 g_snprintf(buf, len + 1, "%s", ptr);
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
587 g_strchomp(buf);
8449
4ae3eb203615 [gaim-migrate @ 9179]
Luke Schierer <lschiere@pidgin.im>
parents: 8435
diff changeset
588 tmpescape = gaim_escape_html(buf);
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
589 buf2 = zephyr_to_html(tmpescape);
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
590 buf3 = zephyr_recv_convert(buf2,strlen(buf2));
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
591 g_free(buf2);
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
592 g_free(buf);
8449
4ae3eb203615 [gaim-migrate @ 9179]
Luke Schierer <lschiere@pidgin.im>
parents: 8435
diff changeset
593 g_free(tmpescape);
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
594
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
595 if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") &&
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
596 !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL")) {
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
597 if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:"))
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
598 flags |= GAIM_CONV_IM_AUTO_RESP;
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
599 serv_got_im(zgc, notice.z_sender, buf3, flags, time(NULL));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
600 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
601 zephyr_triple *zt1, *zt2;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
602 zt1 = new_triple(notice.z_class, notice.z_class_inst,
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4682
diff changeset
603 notice.z_recipient);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
604 zt2 = find_sub_by_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
605 if (!zt2) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
606 /* we shouldn't be subscribed to this message. ignore. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
607 } else {
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
608 GList *gltmp;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
609 int found=0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
610 if (!zt2->open) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
611 zt2->open = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
612 serv_got_joined_chat(zgc, zt2->id, zt2->name);
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
613 gconv1 = gaim_find_conversation_with_account(zt2->name,zgc->account);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
614 gcc = gaim_conversation_get_chat_data(gconv1);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
615 gaim_conv_chat_set_topic(gcc,sendertmp,notice.z_class_inst);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
616
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
617 }
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
618 /* If the person is in the default Realm, then strip the
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
619 Realm from the sender field */
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
620 sendertmp = g_strdup_printf("%s",notice.z_sender);
4682
a4498ce61bf6 [gaim-migrate @ 4993]
Nathan Walp <nwalp@pidgin.im>
parents: 4588
diff changeset
621 if ((realmptr = strchr(sendertmp,'@')) != NULL) {
4588
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
622 realmptr++;
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
623 if (!g_ascii_strcasecmp(realmptr,gaim_zephyr_get_realm())) {
4588
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
624 realmptr--;
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
625 sprintf(realmptr,"%c",'\0');
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
626 send_inst = g_strdup_printf("%s %s",sendertmp,
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
627 notice.z_class_inst);
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
628 } else {
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
629 send_inst = g_strdup_printf("%s %s",notice.z_sender,
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
630 notice.z_class_inst);
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
631 }
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
632 } else {
4588
2778ebd04b63 [gaim-migrate @ 4872]
Luke Schierer <lschiere@pidgin.im>
parents: 4491
diff changeset
633 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
634 }
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
635 serv_got_chat_in(zgc, zt2->id, send_inst, FALSE,
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
636 buf3, time(NULL));
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
637
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
638 gconv1 = gaim_find_conversation_with_account(zt2->name,zgc->account);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
639 gcc = gaim_conversation_get_chat_data(gconv1);
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
640 /* 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
641 for(gltmp = gaim_conv_chat_get_users(gcc);gltmp;gltmp=gltmp->next) {
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
642 if (!g_ascii_strcasecmp(gltmp->data,sendertmp) )
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
643 found = 1;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
644 }
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
645 if (!found) {
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
646 /* force interpretation in network byte order */
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
647 unsigned char* addrs = (unsigned char *)&(notice.z_sender_addr.s_addr);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
648 gaim_conv_chat_add_user(gcc,sendertmp,g_strdup_printf("%hhd.%hhd.%hhd.%hhd",
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
649 (unsigned char)addrs[0],
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
650 (unsigned char)addrs[1],
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
651 (unsigned char)addrs[2],
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
652 (unsigned char)addrs[3]));
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
653
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
654 }
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
655 g_free(sendertmp);
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
656 g_free(send_inst);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
657 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
658 free_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
659 }
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
660 g_free(buf3);
2086
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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
665 static gint check_notify(gpointer data)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
666 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
667 while (ZPending()) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
668 ZNotice_t notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
669 struct sockaddr_in from;
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;
8559
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
678 case SERVACK:
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
679 if(!(g_ascii_strcasecmp(notice.z_message,ZSRVACK_NOTSENT))){
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
680 message_failed(notice,from);
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
681 }
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
682 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
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
704 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
705 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
706 continue;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
707 for(cnode = gnode->child; cnode; cnode = cnode->next) {
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
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;
6935
d957f443c595 [gaim-migrate @ 7482]
Mark Doliner <mark@kingant.net>
parents: 6904
diff changeset
710 for(bnode = cnode->child; bnode; bnode = bnode->next) {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
711 GaimBuddy *b = (GaimBuddy *)bnode;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
712 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
713 continue;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
714 if(b->account->gc == zgc) {
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7126
diff changeset
715 const char *chk;
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
716 chk = local_zephyr_normalize(b->name);
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
717 /* 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
718 ZRequestLocations(chk, &ald, UNACKED, ZAUTH);
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
719 free(ald.user);
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
720 free(ald.version);
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
721 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
722 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
723 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
724 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
725
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
726 return TRUE;
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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
729 static char *get_exposure_level()
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 char *exposure = ZGetVariable("exposure");
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 if (!exposure)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
734 return EXPOSE_REALMVIS;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
735 if (!g_ascii_strcasecmp(exposure, EXPOSE_NONE))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
736 return EXPOSE_NONE;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
737 if (!g_ascii_strcasecmp(exposure, EXPOSE_OPSTAFF))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
738 return EXPOSE_OPSTAFF;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
739 if (!g_ascii_strcasecmp(exposure, EXPOSE_REALMANN))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
740 return EXPOSE_REALMANN;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
741 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETVIS))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
742 return EXPOSE_NETVIS;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
743 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETANN))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
744 return EXPOSE_NETANN;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
745 return EXPOSE_REALMVIS;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
746 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
747
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
748 static void strip_comments(char *str)
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 char *tmp = strchr(str, '#');
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
751 if (tmp)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
752 *tmp = '\0';
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
753 g_strchug(str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
754 g_strchomp(str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
755 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
756
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
757 static void process_zsubs()
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 FILE *f;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
760 gchar *fname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
761 gchar buff[BUFSIZ];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
762
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
763 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
764 f = fopen(fname, "r");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
765 if (f) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
766 char **triple;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
767 ZSubscription_t sub;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
768 char *recip;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
769 while (fgets(buff, BUFSIZ, f)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
770 strip_comments(buff);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
771 if (buff[0]) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
772 triple = g_strsplit(buff, ",", 3);
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
773 if (triple[0] && triple[1] ) {
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
774 char *tmp = g_strdup_printf("%s",gaim_zephyr_get_sender());
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
775 char *atptr;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
776 sub.zsub_class = triple[0];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
777 sub.zsub_classinst = triple[1];
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
778 if(triple[2] == NULL) {
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
779 recip = g_malloc0(1);
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
780 } else if (!g_ascii_strcasecmp(triple[2], "%me%")) {
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
781 recip = g_strdup_printf("%s",gaim_zephyr_get_sender());
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
782 } else if (!g_ascii_strcasecmp(triple[2], "*")) {
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
783 /* wildcard
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
784 * form of class,instance,* */
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
785 recip = g_malloc0(1);
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
786 } else if (!g_ascii_strcasecmp(triple[2], tmp)) {
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
787 /* form of class,instance,aatharuv@ATHENA.MIT.EDU */
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
788 recip = g_strdup(triple[2]);
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
789 } else if ((atptr = strchr(triple[2], '@')) != NULL) {
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
790 /* form of class,instance,*@ANDREW.CMU.EDU
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
791 * class,instance,@ANDREW.CMU.EDU
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
792 * If realm is local realm, blank recipient, else
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
793 * @REALM-NAME
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
794 */
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
795 char *realmat = g_strdup_printf("@%s", gaim_zephyr_get_realm());
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
796 if (!g_ascii_strcasecmp(atptr, realmat))
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
797 recip = g_malloc0(1);
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
798 else
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
799 recip = g_strdup(atptr);
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
800 g_free(realmat);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
801 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
802 recip = g_strdup(triple[2]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
803 }
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
804 g_free(tmp);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
805 sub.zsub_recipient = recip;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
806 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) {
6484
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
807 gaim_debug(GAIM_DEBUG_ERROR, "zephyr",
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
808 "Couldn't subscribe to %s, %s, %s\n",
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
809 sub.zsub_class,
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
810 sub.zsub_classinst,
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
811 sub.zsub_recipient);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
812 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
813 subscrips = g_slist_append(subscrips,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
814 new_triple(triple[0], triple[1], recip));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
815 g_free(recip);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
816 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
817 g_strfreev(triple);
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 }
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 static void process_anyone()
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 FILE *fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
826 gchar buff[BUFSIZ], *filename;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
827 GaimGroup *g;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
828 GaimBuddy *b;
4775
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
829
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
830 if (!(g = gaim_find_group(_("Anyone")))) {
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
831 g = gaim_group_new(_("Anyone"));
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
832 gaim_blist_add_group(g, NULL);
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
833 }
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
834
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
835 filename = g_strconcat(gaim_home_dir(), "/.anyone", NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
836 if ((fd = fopen(filename, "r")) != NULL) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
837 while (fgets(buff, BUFSIZ, fd)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
838 strip_comments(buff);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4682
diff changeset
839 if (buff[0]) {
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
840 if(! (b=gaim_find_buddy(zgc->account,buff))) {
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
841 b = gaim_buddy_new(zgc->account, buff, NULL);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
842 gaim_blist_add_buddy(b, NULL, g, NULL);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
843 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4682
diff changeset
844 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
845 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
846 fclose(fd);
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 g_free(filename);
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
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
851 static void zephyr_login(GaimAccount *account)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
852 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
853 ZSubscription_t sub;
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 if (zgc) {
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5234
diff changeset
856 gaim_notify_error(account->gc, NULL,
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5234
diff changeset
857 _("Already logged in with Zephyr"),
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5234
diff changeset
858 _("Because Zephyr uses your system username, you "
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5234
diff changeset
859 "are unable to have multiple accounts on it "
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5234
diff changeset
860 "when logged in as the same user."));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
861 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
862 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
863
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
864 zgc = gaim_account_get_connection(account);
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
865 zgc->flags |= GAIM_CONNECTION_HTML;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
866 z_call_s(ZInitialize(), "Couldn't initialize zephyr");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
867 z_call_s(ZOpenPort(NULL), "Couldn't open port");
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
868 z_call_s(ZSetLocation((char *)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
869
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
870 sub.zsub_class = "MESSAGE";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
871 sub.zsub_classinst = "PERSONAL";
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
872 sub.zsub_recipient = (char *)gaim_zephyr_get_sender();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
873
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
874 /* we don't care if this fails. i'm lying right now. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
875 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) {
6484
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
876 gaim_debug(GAIM_DEBUG_ERROR, "zephyr",
5ced8e111473 [gaim-migrate @ 6998]
Christian Hammond <chipx86@chipx86.com>
parents: 6371
diff changeset
877 "Couldn't subscribe to messages!\n");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
878 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
879
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
880 gaim_connection_set_state(zgc, GAIM_CONNECTED);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
881 serv_finish_login(zgc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
882
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
883 process_anyone();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
884 process_zsubs();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
885
8273
f24172f53650 [gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents: 8212
diff changeset
886 nottimer = gaim_timeout_add(100, check_notify, NULL);
f24172f53650 [gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents: 8212
diff changeset
887 loctimer = gaim_timeout_add(20000, check_loc, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
888 }
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 static void write_zsubs()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
891 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
892 GSList *s = subscrips;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
893 zephyr_triple *zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
894 FILE *fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
895 char *fname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
896
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
897 char** triple;
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
898 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
899 fd = fopen(fname, "w");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
900
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
901 if (!fd) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
902 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
903 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
904 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
905
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
906 while (s) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
907 zt = s->data;
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
908 triple = g_strsplit(zt->name,",",3);
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
909 if (triple[2] != NULL) {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
910 if (!g_ascii_strcasecmp(triple[2], "")) {
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
911 fprintf(fd, "%s,%s,*\n", triple[0], triple[1]);
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
912 } else if (!g_ascii_strcasecmp(triple[2], gaim_zephyr_get_sender())) {
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
913 fprintf(fd, "%s,%s,%%me%%\n",triple[0],triple[1]);
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
914 } else {
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
915 fprintf(fd, "%s\n", zt->name);
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
916 }
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
917 } else {
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
918 fprintf(fd, "%s,%s,*\n",triple[0], triple[1]);
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
919 }
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
920 g_free(triple);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
921 s = s->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
922 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
923 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
924 fclose(fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
925 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
926
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
927 static void write_anyone()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
928 {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
929 GaimBlistNode *gnode, *cnode, *bnode;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
930 GaimBuddy *b;
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
931 char *ptr, *fname, *ptr2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
932 FILE *fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
933
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
934 fname = g_strdup_printf("%s/.anyone", gaim_home_dir());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
935 fd = fopen(fname, "w");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
936 if (!fd) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
937 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
938 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
939 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
940
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
941 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
942 if(!GAIM_BLIST_NODE_IS_GROUP(gnode))
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
943 continue;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
944 for(cnode = gnode->child; cnode; cnode = cnode->next) {
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
945 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode))
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
946 continue;
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
947 for(bnode = cnode->child; bnode; bnode = bnode->next) {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
948 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode))
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
949 continue;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
950 b = (GaimBuddy *)bnode;
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
951 if(b->account == zgc->account) {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
952 if ((ptr = strchr(b->name, '@')) != NULL) {
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
953 ptr2 = ptr + 1;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
954 /* We should only strip the realm name if the principal
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
955 is in the user's realm
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
956 */
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
957 if (!g_ascii_strcasecmp(ptr2,gaim_zephyr_get_realm())) {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
958 *ptr = '\0';
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
959 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
960 }
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
961 fprintf(fd, "%s\n", b->name);
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
962 if (ptr)
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
963 *ptr = '@';
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
964 }
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
965 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
966 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
967 }
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 fclose(fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
970 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
971 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
972
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
973 static void zephyr_close(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
974 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
975 GList *l;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
976 GSList *s;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
977 l = pending_zloc_names;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
978 while (l) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
979 g_free((char*)l->data);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
980 l = l->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
981 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
982 g_list_free(pending_zloc_names);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
983
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
984 if (gaim_account_get_bool(zgc->account,"write_anyone",FALSE))
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
985 write_anyone();
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
986
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
987 if (gaim_account_get_bool(zgc->account,"write_zsubs",FALSE))
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
988 write_zsubs();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
989
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
990 s = subscrips;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
991 while (s) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
992 free_triple((zephyr_triple*)s->data);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
993 s = s->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
994 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
995 g_slist_free(subscrips);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
996
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
997 if (nottimer)
8287
ef881489396e [gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents: 8273
diff changeset
998 gaim_timeout_remove(nottimer);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
999 nottimer = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1000 if (loctimer)
8287
ef881489396e [gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents: 8273
diff changeset
1001 gaim_timeout_remove(loctimer);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1002 loctimer = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1003 zgc = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1004 z_call(ZCancelSubscriptions(0));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1005 z_call(ZUnsetLocation());
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1006 z_call(ZClosePort());
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1007 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1008
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1009 static void zephyr_add_buddy(GaimConnection *gc, const char *buddy, GaimGroup *group) {
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1010 GaimBuddy *b;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1011 if(! (b=gaim_find_buddy(zgc->account,buddy))) {
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1012 b = gaim_buddy_new(zgc->account, buddy, NULL);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1013 gaim_blist_add_buddy(b, NULL, group, NULL);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1014 }
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1015 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1016
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1017 static void zephyr_add_buddies(GaimConnection *gc, GList* buddies) {
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1018 GaimGroup *group;
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1019 if (!(group = gaim_find_group(_("Anyone")))) {
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1020 group = gaim_group_new(_("Anyone"));
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1021 gaim_blist_add_group(group, NULL);
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1022 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1023 while (buddies) {
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1024 zephyr_add_buddy(gc, buddies->data, group);
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1025 buddies = buddies->next;
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1026 }
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1027 }
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1028
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1029 static void zephyr_remove_buddy(GaimConnection *gc, const char *buddy, const char *group) {
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1030 GaimBuddy *b;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1031 fprintf(stderr,"In zephyr_remove_buddy\n");
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1032 if ((b=gaim_find_buddy(zgc->account,buddy)))
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1033 gaim_blist_remove_buddy(b);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1034 else
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1035 fprintf(stderr,"attempt to remove non-existent buddy %s\n",buddy);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1036 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1037
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1038 static void zephyr_remove_buddies(GaimConnection *gc, GList *buddies, const char *group) {
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1039 GaimBuddy *b;
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1040 while(buddies) {
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1041 if ((b=gaim_find_buddy(zgc->account,buddies->data))) {
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1042 gaim_blist_remove_buddy(b);
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1043 } else {
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1044 fprintf(stderr,"attempt to remove non-existent buddy %s\n",(char *)buddies->data);
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1045 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1046 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1047 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1048
6059
d8cd876e613e [gaim-migrate @ 6509]
Mark Doliner <mark@kingant.net>
parents: 5920
diff changeset
1049 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
1050 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1051 ZNotice_t notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1052 zephyr_triple *zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1053 char *buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1054 const char *sig;
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1055 GaimConversation * gconv1;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1056 GaimConvChat* gcc;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1057 char * inst;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1058 char * html_buf;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1059 char * html_buf2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1060
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1061 zt = find_sub_by_id(id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1062 if (!zt)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1063 /* this should never happen. */
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
1064 return -EINVAL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1065
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1066 sig = ZGetVariable("zwrite-signature");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1067 if (!sig) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1068 sig = g_get_real_name();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1069 }
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1070
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1071 html_buf = html_to_zephyr(im);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1072 html_buf2 = gaim_unescape_html(html_buf);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1073
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1074 buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1075
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1076 gconv1 = gaim_find_conversation_with_account(zt->name,zgc->account);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1077 gcc = gaim_conversation_get_chat_data(gconv1);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1078
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1079 if(!(inst = (char *)gaim_conv_chat_get_topic(gcc)))
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1080 inst = (char *)notice.z_class_inst;
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1081
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1082 bzero((char *)&notice, sizeof(notice));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1083 notice.z_kind = ACKED;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1084 notice.z_port = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1085 notice.z_opcode = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1086 notice.z_class = zt->class;
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1087 notice.z_class_inst = inst;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1088 if (!g_ascii_strcasecmp(zt->recipient, "*"))
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1089 notice.z_recipient = local_zephyr_normalize("");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1090 else
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1091 notice.z_recipient = local_zephyr_normalize(zt->recipient);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1092 notice.z_sender = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1093 notice.z_default_format =
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1094 "Class $class, Instance $instance:\n"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1095 "To: @bold($recipient) at $time $date\n"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1096 "From: @bold($1) <$sender>\n\n$2";
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1097 notice.z_message_len = strlen(html_buf2) + strlen(sig) + 2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1098 notice.z_message = buf;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1099 g_free(html_buf);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1100 g_free(html_buf2);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1101
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1102 ZSendNotice(&notice, ZAUTH);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1103 g_free(buf);
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
1104 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1105 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1106
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
1107 static int zephyr_send_im(GaimConnection *gc, const char *who, const char *im, GaimConvImFlags flags) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1108 ZNotice_t notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1109 char *buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1110 const char *sig;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1111 char *html_buf;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1112 char *html_buf2;
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
1113 if (flags & GAIM_CONV_IM_AUTO_RESP)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1114 sig = "Automated reply:";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1115 else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1116 sig = ZGetVariable("zwrite-signature");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1117 if (!sig) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1118 sig = g_get_real_name();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1119 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1120 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1121
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1122 html_buf = html_to_zephyr(im);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1123 html_buf2 = gaim_unescape_html(html_buf);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1124
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1125 buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1126 bzero((char *)&notice, sizeof(notice));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1127 notice.z_kind = ACKED;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1128 notice.z_port = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1129 notice.z_opcode = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1130 notice.z_class = "MESSAGE";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1131 notice.z_class_inst = "PERSONAL";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1132 notice.z_sender = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1133 notice.z_recipient = who;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1134 notice.z_default_format =
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1135 "Class $class, Instance $instance:\n"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1136 "To: @bold($recipient) at $time $date\n"
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1137 "From: @bold($1) <$sender>\n\n$2";
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1138 notice.z_message_len = strlen(html_buf2) + strlen(sig) + 2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1139 notice.z_message = buf;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1140 g_free(html_buf2);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1141 g_free(html_buf);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1142
6904
7c3a11c69be9 [gaim-migrate @ 7451]
Mark Doliner <mark@kingant.net>
parents: 6787
diff changeset
1143 ZSendNotice(&notice, ZAUTH);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1144 g_free(buf);
2303
f5bf315e6104 [gaim-migrate @ 2313]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2231
diff changeset
1145 return 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1146 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1147
7322
ab828b8c3f22 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7262
diff changeset
1148 static const char *zephyr_normalize(const GaimAccount *account,const char *orig)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1149 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1150 static char buf[80];
7126
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1151 if (!g_ascii_strcasecmp(orig, "")) {
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1152 buf[0] = '\0';
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1153 return buf;
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1154 } else {
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1155 g_snprintf(buf,80,"%s",orig);
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1156 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1157 return buf;
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1158 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1159
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1160
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1161 static const char *local_zephyr_normalize(const char *orig)
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1162 {
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1163 static char buf[80];
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1164 if (!g_ascii_strcasecmp(orig, "")) {
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1165 buf[0] = '\0';
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1166 return buf;
7126
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1167 }
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1168
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1169 if (strchr(orig, '@')) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1170 g_snprintf(buf, 80, "%s", orig);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1171 } else {
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1172 g_snprintf(buf,80,"%s@%s",orig,gaim_zephyr_get_realm());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1173 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1174 return buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1175 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1176
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
1177 static void zephyr_zloc(GaimConnection *gc, const char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1178 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1179 ZAsyncLocateData_t ald;
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7126
diff changeset
1180
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1181 if (ZRequestLocations(local_zephyr_normalize(who), &ald, UNACKED, ZAUTH)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1182 != ZERR_NONE) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1183 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1184 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1185 pending_zloc_names = g_list_append(pending_zloc_names,
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1186 g_strdup(local_zephyr_normalize(who)));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1187 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1188
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
1189 static GList *zephyr_buddy_menu(GaimConnection *gc, const char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1190 {
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1191 GList *m = NULL;
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1192 struct proto_buddy_menu *pbm;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1193
2170
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1194 pbm = g_new0(struct proto_buddy_menu, 1);
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1195 pbm->label = _("ZLocate");
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1196 pbm->callback = zephyr_zloc;
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1197 pbm->gc = gc;
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1198 m = g_list_append(m, pbm);
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1199
c24595d3c364 [gaim-migrate @ 2180]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2167
diff changeset
1200 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1201 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1202
6059
d8cd876e613e [gaim-migrate @ 6509]
Mark Doliner <mark@kingant.net>
parents: 5920
diff changeset
1203 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
1204 {
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1205 if (gc->away) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1206 g_free(gc->away);
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1207 gc->away = NULL;
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1208 }
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1209
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
1210 if (!g_ascii_strcasecmp(state, _("Hidden"))) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1211 ZSetLocation(EXPOSE_OPSTAFF);
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1212 gc->away = g_strdup("");
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
1213 } else if (!g_ascii_strcasecmp(state, _("Online")))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1214 ZSetLocation(get_exposure_level());
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1215 else /* state is GAIM_AWAY_CUSTOM */ if (msg)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1216 gc->away = g_strdup(msg);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1217 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1218
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
1219 static GList *zephyr_away_states(GaimConnection *gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1220 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1221 GList *m = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1222
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
1223 m = g_list_append(m, _("Online"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1224 m = g_list_append(m, GAIM_AWAY_CUSTOM);
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
1225 m = g_list_append(m, _("Hidden"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1226
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1227 return m;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1228 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1229
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
1230 static GList *zephyr_chat_info(GaimConnection *gc) {
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1231 GList *m = NULL;
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1232 struct proto_chat_entry *pce;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1233
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1234 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7475
diff changeset
1235 pce->label = _("_Class:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1236 pce->identifier = "class";
3158
ea6f8d8d74e5 [gaim-migrate @ 3174]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
1237 m = g_list_append(m, pce);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1238
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1239 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7475
diff changeset
1240 pce->label = _("_Instance:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1241 pce->identifier = "instance";
3158
ea6f8d8d74e5 [gaim-migrate @ 3174]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
1242 m = g_list_append(m, pce);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1243
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1244 pce = g_new0(struct proto_chat_entry, 1);
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7475
diff changeset
1245 pce->label = _("_Recipient:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1246 pce->identifier = "recipient";
3158
ea6f8d8d74e5 [gaim-migrate @ 3174]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
1247 m = g_list_append(m, pce);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1248
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1249 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1250 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1251
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
1252 static void zephyr_join_chat(GaimConnection *gc, GHashTable *data)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1253 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1254 ZSubscription_t sub;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1255 zephyr_triple *zt1, *zt2;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1256 const char *classname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1257 const char *instname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1258 const char *recip;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1259
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1260 classname = g_hash_table_lookup(data, "class");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1261 instname = g_hash_table_lookup(data, "instance");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1262 recip = g_hash_table_lookup(data, "recipient");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1263
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1264 if (!classname || !instname || !recip)
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1265 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1266
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1267 if (!g_ascii_strcasecmp(recip, "%me%"))
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1268 recip = gaim_zephyr_get_sender();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1269
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1270 zt1 = new_triple(classname, instname, recip);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1271 zt2 = find_sub_by_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1272 if (zt2) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1273 free_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1274 if (!zt2->open)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1275 serv_got_joined_chat(gc, zt2->id, zt2->name);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1276 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1277 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1278
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1279 sub.zsub_class = zt1->class;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1280 sub.zsub_classinst = zt1->instance;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1281 sub.zsub_recipient = zt1->recipient;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1282
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1283 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1284 free_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1285 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1286 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1287
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1288 subscrips = g_slist_append(subscrips, zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1289 zt1->open = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1290 serv_got_joined_chat(gc, zt1->id, zt1->name);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1291 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1292
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
1293 static void zephyr_chat_leave(GaimConnection *gc, int id)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1294 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1295 zephyr_triple *zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1296 zt = find_sub_by_id(id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1297 if (zt) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1298 zt->open = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1299 zt->id = ++last_id;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1300 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1301 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1302
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1303 static const char *zephyr_list_icon(GaimAccount *a, GaimBuddy *b)
5202
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
1304 {
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
1305 return "zephyr";
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
1306 }
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
1307
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1308
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1309 static void zephyr_chat_set_topic(GaimConnection *gc, int id, const char *topic) {
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1310 zephyr_triple *zt;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1311 GaimConversation *gconv;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1312 GaimConvChat* gcc;
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1313 char* sender = (char *)gaim_zephyr_get_sender();
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1314
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1315 zt = find_sub_by_id(id);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1316 gconv = gaim_find_conversation_with_account(zt->name,zgc->account);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1317 gcc = gaim_conversation_get_chat_data(gconv);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1318 gaim_conv_chat_set_topic(gcc,sender,topic);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1319
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1320 }
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1321
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1322 static GaimPlugin *my_protocol = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1323
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1324 static GaimPluginProtocolInfo prpl_info =
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1325 {
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1326 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD,
5205
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,
8170
9d1a984681fe [gaim-migrate @ 8883]
Nathan Walp <nwalp@pidgin.im>
parents: 7956
diff changeset
1329 NULL,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1330 zephyr_list_icon,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1331 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1332 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1333 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1334 zephyr_away_states,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1335 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1336 zephyr_buddy_menu,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1337 zephyr_chat_info,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1338 zephyr_login,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1339 zephyr_close,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1340 zephyr_send_im,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1341 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1342 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1343 zephyr_zloc,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1344 zephyr_set_away,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1345 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1346 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1347 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1348 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1349 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1350 zephyr_add_buddy,
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1351 zephyr_add_buddies,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1352 zephyr_remove_buddy,
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1353 zephyr_remove_buddies,
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1354 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1355 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1356 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1357 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1358 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1359 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1360 zephyr_join_chat,
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
1361 NULL, /* reject chat invite */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1362 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1363 zephyr_chat_leave,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1364 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1365 zephyr_chat_send,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1366 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1367 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1368 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1369 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1370 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1371 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1372 NULL,
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1373 NULL,
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
1374 NULL,
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1375 zephyr_normalize,
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
1376 NULL,
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
1377 NULL,
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
1378 NULL,
8586
5af95c2b1179 [gaim-migrate @ 9336]
Ethan Blanton <elb@pidgin.im>
parents: 8568
diff changeset
1379 zephyr_chat_set_topic,
5af95c2b1179 [gaim-migrate @ 9336]
Ethan Blanton <elb@pidgin.im>
parents: 8568
diff changeset
1380 NULL,
5af95c2b1179 [gaim-migrate @ 9336]
Ethan Blanton <elb@pidgin.im>
parents: 8568
diff changeset
1381 NULL,
5af95c2b1179 [gaim-migrate @ 9336]
Ethan Blanton <elb@pidgin.im>
parents: 8568
diff changeset
1382 NULL,
5af95c2b1179 [gaim-migrate @ 9336]
Ethan Blanton <elb@pidgin.im>
parents: 8568
diff changeset
1383 NULL,
5af95c2b1179 [gaim-migrate @ 9336]
Ethan Blanton <elb@pidgin.im>
parents: 8568
diff changeset
1384 NULL
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1385 };
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1386
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1387 static GaimPluginInfo info =
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1388 {
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1389 2, /**< api_version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1390 GAIM_PLUGIN_PROTOCOL, /**< type */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1391 NULL, /**< ui_requirement */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1392 0, /**< flags */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1393 NULL, /**< dependencies */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1394 GAIM_PRIORITY_DEFAULT, /**< priority */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1395
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1396 "prpl-zephyr", /**< id */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1397 "Zephyr", /**< name */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1398 VERSION, /**< version */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1399 /** summary */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1400 N_("Zephyr Protocol Plugin"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1401 /** description */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1402 N_("Zephyr Protocol Plugin"),
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1403 NULL, /**< author */
6371
8f94cce8faa5 [gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents: 6059
diff changeset
1404 GAIM_WEBSITE, /**< homepage */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1405
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1406 NULL, /**< load */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1407 NULL, /**< unload */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1408 NULL, /**< destroy */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1409
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1410 NULL, /**< ui_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1411 &prpl_info /**< extra_info */
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1412 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1413
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1414 static void
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1415 init_plugin(GaimPlugin *plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1416 {
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1417 GaimAccountOption *option;
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1418 char* tmp = get_exposure_level();
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1419 option = gaim_account_option_bool_new(_("Export to .anyone"),"write_anyone",FALSE);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1420 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,option);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1421
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1422 option = gaim_account_option_bool_new(_("Export to .zephyr.subs"),"write_zsubs",FALSE);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1423 prpl_info.protocol_options = g_list_append(prpl_info.protocol_options,option);
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1424
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
1425 option = gaim_account_option_string_new(_("Exposure"),"exposure_level",tmp?tmp:EXPOSE_REALMVIS);
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
1426 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
1427
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
1428 option = gaim_account_option_string_new(_("Encoding"),"encoding",ZEPHYR_FALLBACK_CHARSET);
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
1429 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
1430
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1431 my_protocol = plugin;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1432 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1433
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1434 GAIM_INIT_PLUGIN(zephyr, init_plugin, info);