annotate src/protocols/zephyr/zephyr.c @ 9584:fe35f55ee984

[gaim-migrate @ 10427] " When joining a jabber conference many jabber servers send a recap of the last 20 or so messages. If you have sounds enabled, this will result in either 20 sounds in row, or worse if mixing is available, a horrible mix of 20 overlapping sounds. These recap messages can be identifed be the presence of the "jabber:x:delay". This patch identifies delayed messages, passes that information through flags from the prpl to the core, and then on to the gui. Detailed changes: Add GAIM_MESSAGE_DELAYED to GaimMessageFlags to indicate a delayed message. Change gtkconv.c to not play sounds when either GAIM_MESSAGE_DELAYED or GAIM_MESSAGE_SYSTEM are set. Add GaimConvChatFlags, parallel to GaimConvImFlags, to pass flags from protocols to core. Currently contains two flags: GAIM_CONV_CHAT_WHISPER GAIM_CONV_CHAT_DELAYED Change fourth arg of serv_got_chat_in() from "int whisper" to "GaimConvChatFlags chatflags". Change jabber prpl to set delayed flag when the "jabber:x:delay" element is present. Change toc protocol since it uses the whisper flag." --Nathan Fredrickson Date: 2004-07-24 00:49 Sender: marv_sfAccepting Donations Logged In: YES user_id=790708 I'm not sure I like naming the flags "DELAYED". I mean that's okay inside jabber since that's what the jabber protocol refers to it as, but for the the GAIM_*_DELAYED flags, I think they should be named something else. I thought about NOSOUND, but I decided that was wrong, because the flag should say what kind of message it is, not what to do with it, that's up to the UI to decide. What's up with not playing sounds on GAIM_MESSAGE_SYSTEM? This sounds unrelated to this. Are there times when we want to play sounds on system messages? Date: 2004-07-24 09:13 Sender: noif Logged In: YES user_id=365548 I purposely did not use a name that implied what the UI should do with the flag. The only characteristic that makes these messages unique is that they've been stored in the server for some period of time and are not current. I'm open to a better flag name than "DELAYED"... I thought about "RECAP", but that seemed less generalized than "DELAYED". As for not playing sounds on GAIM_MESSAGE_SYSTEM, that can be removed if it's controversial. I think I slipped that in since the setting of the topic was still playing a sound every time you joined a jabber conference. I think we can change the flag name ourselves if something else is better. committer: Tailor Script <tailor@pidgin.im>
author Luke Schierer <lschiere@pidgin.im>
date Sat, 24 Jul 2004 15:18:32 +0000
parents 8b2451878e26
children d6f398e80b32
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"
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
35 #include "cmds.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
36
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
37 #include "zephyr/zephyr.h"
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
38 #include "internal.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5717
diff changeset
39
8386
143d0b29ba82 [gaim-migrate @ 9114]
Mark Doliner <mark@kingant.net>
parents: 8354
diff changeset
40 #include <strings.h>
143d0b29ba82 [gaim-migrate @ 9114]
Mark Doliner <mark@kingant.net>
parents: 8354
diff changeset
41
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
42 #define ZEPHYR_FALLBACK_CHARSET "ISO-8859-1"
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
43
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
44 /* these are deliberately high, since most people don't send multiple "PING"s */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
45 #define ZEPHYR_TYPING_SEND_TIMEOUT 15
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
46 #define ZEPHYR_TYPING_RECV_TIMEOUT 10
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
47
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 extern Code_t ZGetLocations(ZLocations_t *, int *);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 extern Code_t ZSetLocation(char *);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50 extern Code_t ZUnsetLocation();
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
51 extern Code_t ZGetSubscriptions(ZSubscription_t *, int*);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 typedef struct _zframe zframe;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 typedef struct _zephyr_triple zephyr_triple;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
56 char ourhost[MAXHOSTNAMELEN];
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
57 char ourhostcanon[MAXHOSTNAMELEN];
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
58
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 /* struct I need for zephyr_to_html */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60 struct _zframe {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 /* true for everything but @color, since inside the parens of that one is
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
62 * the color. */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 gboolean has_closer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 /* </i>, </font>, </b>, etc. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 char *closing;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66 /* text including the opening html thingie. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 GString *text;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 struct _zframe *enclosing;
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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 struct _zephyr_triple {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 char *class;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 char *instance;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 char *recipient;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 char *name;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 gboolean open;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 int id;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 };
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 #define z_call(func) if (func != ZERR_NONE)\
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 #define z_call_r(func) if (func != ZERR_NONE)\
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 #define z_call_s(func, err) if (func != ZERR_NONE) {\
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
85 gaim_connection_error(zgc, err);\
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 return;\
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
89 char *local_zephyr_normalize(const char *);
7322
ab828b8c3f22 [gaim-migrate @ 7908]
Nathan Walp <nwalp@pidgin.im>
parents: 7262
diff changeset
90 static const char *zephyr_normalize(const GaimAccount *, const char *);
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
91 static const char *gaim_zephyr_get_realm();
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
92 static void zephyr_chat_set_topic(GaimConnection * gc, int id, const char *topic);
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
93
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
94 char *zephyr_strip_foreign_realm(const char* user){
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
95 /*
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
96 Takes in a username of the form username or username@realm
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
97 and returns:
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
98 username, if there is no realm, or the realm is the local realm
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
99 or:
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
100 username@realm if there is a realm and it is foreign
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
101 */
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
102 char *tmp = g_strdup(user);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
103 char *at = strchr(tmp,'@');
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
104 if (at && !g_ascii_strcasecmp(at+1,gaim_zephyr_get_realm())) {
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
105 /* We're passed in a username of the form user@users-realm */
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
106 char* tmp2;
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
107 *at = '\0';
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
108 tmp2 = g_strdup(tmp);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
109 g_free(tmp);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
110 return tmp2;
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
111 }
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
112 else {
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
113 /* We're passed in a username of the form user or user@foreign-realm */
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
114 return tmp;
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
115 }
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
116 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 /* 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
119 * wouldn't do this. but it is so i will. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 static guint32 nottimer = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 static guint32 loctimer = 0;
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
122 GaimConnection *zgc = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 static GList *pending_zloc_names = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 static GSList *subscrips = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 static int last_id = 0;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
126 unsigned short zephyr_port;
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
127 /* just for debugging */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 static void handle_unknown(ZNotice_t notice)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129 {
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
130 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_packet: %s\n", notice.z_packet);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
131 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_version: %s\n", notice.z_version);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
132 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_kind: %d\n", (int)(notice.z_kind));
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
133 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_class: %s\n", notice.z_class);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
134 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_class_inst: %s\n", notice.z_class_inst);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
135 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_opcode: %s\n", notice.z_opcode);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
136 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_sender: %s\n", notice.z_sender);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
137 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_recipient: %s\n", notice.z_recipient);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
138 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_message: %s\n", notice.z_message);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
139 gaim_debug(GAIM_DEBUG_MISC, "zephyr","z_message_len: %d\n", notice.z_message_len);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 }
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
141
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 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
144 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 zephyr_triple *zt;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
146
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147 zt = g_new0(zephyr_triple, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 zt->class = g_strdup(c);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 zt->instance = g_strdup(i);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 zt->recipient = g_strdup(r);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 zt->name = g_strdup_printf("%s,%s,%s", c, i, r);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152 zt->id = ++last_id;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 zt->open = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 return zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
157 static void free_triple(zephyr_triple * zt)
2086
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 g_free(zt->class);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 g_free(zt->instance);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 g_free(zt->recipient);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 g_free(zt->name);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 g_free(zt);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
166 static gchar *gaim_zephyr_get_sender()
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
167 {
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
168 /* will be useful once this plugin can use a backend other
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
169 than libzephyr */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
170 /* XXX add zephyr error reporting */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
171 gchar *sender;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
172 sender = ZGetSender();
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
173 if (!sender || !g_ascii_strcasecmp(sender,"")) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
174 sender = "";
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
175 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
176 return sender;
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
177 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
178
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
179 static const char *gaim_zephyr_get_realm()
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
180 {
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
181 /* will be useful once this plugin can use a backend other
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
182 than libzephyr */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
183 gchar *realm=NULL;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
184 /* XXX add zephyr error reporting */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
185 realm= ZGetRealm();
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
186 return realm;
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
187 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
188
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
189 /* returns true if zt1 is a subset of zt2. This function is used to
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
190 determine whether a zephyr sent to zt1 should be placed in the chat
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
191 with triple zt2
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
192
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
193 zt1 is a subset of zt2
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
194 iff. the classnames are identical ignoring case
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
195 AND. the instance names are identical (ignoring case), or zt2->instance is *.
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
196 AND. the recipient names are identical
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
197 */
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
198
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
199 static gboolean triple_subset(zephyr_triple * zt1, zephyr_triple * zt2)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 {
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
201 if (g_ascii_strcasecmp(zt2->class, zt1->class)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
204 if (g_ascii_strcasecmp(zt2->instance, zt1->instance) && g_ascii_strcasecmp(zt2->instance, "*")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206 }
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
207 if (g_ascii_strcasecmp(zt2->recipient, zt1->recipient)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
213 static zephyr_triple *find_sub_by_triple(zephyr_triple * zt)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 zephyr_triple *curr_t;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 GSList *curr = subscrips;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
217
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 while (curr) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 curr_t = curr->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 if (triple_subset(zt, curr_t))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221 return curr_t;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 curr = curr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227 static zephyr_triple *find_sub_by_id(int id)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229 zephyr_triple *zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230 GSList *curr = subscrips;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
231
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232 while (curr) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 zt = curr->data;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234 if (zt->id == id)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235 return zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236 curr = curr->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238 return NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
241 /*
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
242 Converts strings to utf-8 if necessary using user specified encoding
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
243 */
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
244
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
245 static gchar *zephyr_recv_convert(gchar *string, int len)
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
246 {
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
247 gchar *utf8;
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
248 GError *err = NULL;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
249
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
250 if (g_utf8_validate(string, len, NULL)) {
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
251 return g_strdup(string);
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
252 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
253 utf8 = g_convert(string, len, "UTF-8", gaim_account_get_string(zgc->account, "encoding", ZEPHYR_FALLBACK_CHARSET), NULL, NULL, &err);
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
254 if (err) {
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
255 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
256 utf8 = g_strdup(_("(There was an error converting this message. Check the 'Encoding' option in the Account Editor)"));
8954
c60f82d78dea [gaim-migrate @ 9727]
Luke Schierer <lschiere@pidgin.im>
parents: 8950
diff changeset
257 g_error_free(err);
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
258 }
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
259
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
260 return utf8;
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
261 }
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
262 }
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
263
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 /* utility macros that are useful for zephyr_to_html */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 #define IS_OPENER(c) ((c == '{') || (c == '[') || (c == '(') || (c == '<'))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 #define IS_CLOSER(c) ((c == '}') || (c == ']') || (c == ')') || (c == '>'))
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
269 /* 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
270 And converts it to zephyr formatting.
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
271 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
272 It ignores <font back=...>
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
273 It does
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
274 <font size = "1 or 2" -> @small
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
275 3 or 4 @medium()
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
276 5,6, or 7 @large()
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
277 <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
278 */
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
279
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
280 static char *html_to_zephyr(const char *message)
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
281 {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
282 int len, cnt, retcount;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
283 char *ret;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
284
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
285 len = strlen(message);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
286 if (!len)
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
287 return g_strdup("");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
288
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
289 ret = g_new0(char, len * 3);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
290
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
291 bzero(ret, len * 3);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
292 retcount = 0;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
293 cnt = 0;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
294 while (cnt <= len) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
295 if (message[cnt] == '<') {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
296 if (!g_ascii_strncasecmp(message + cnt + 1, "i>", 2)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
297 strncpy(ret + retcount, "@i(", 3);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
298 cnt += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
299 retcount += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
300 } else if (!g_ascii_strncasecmp(message + cnt + 1, "b>", 2)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
301 strncpy(ret + retcount, "@b(", 3);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
302 cnt += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
303 retcount += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
304 } else if (!g_ascii_strncasecmp(message + cnt + 1, "br>", 3)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
305 strncpy(ret + retcount, "\n", 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
306 cnt += 4;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
307 retcount += 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
308 } else if (!g_ascii_strncasecmp(message + cnt + 1, "a href=\"", 8)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
309 cnt += 9;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
310 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
311 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
312 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
313 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
314 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
315 cnt += 2;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
316 /* ignore descriptive string */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
317 while (g_ascii_strncasecmp(message + cnt, "</a>", 4) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
318 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
319 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
320 cnt += 4;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
321 } else if (!g_ascii_strncasecmp(message + cnt + 1, "font", 4)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
322 cnt += 5;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
323 while (!g_ascii_strncasecmp(message + cnt, " ", 1))
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
324 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
325 if (!g_ascii_strncasecmp(message + cnt, "color=\"", 7)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
326 cnt += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
327 strncpy(ret + retcount, "@color(", 7);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
328 retcount += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
329 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
330 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
331 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
332 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
333 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
334 ret[retcount] = ')';
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
335 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
336 cnt += 2;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
337 } else if (!g_ascii_strncasecmp(message + cnt, "face=\"", 6)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
338 cnt += 6;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
339 strncpy(ret + retcount, "@font(", 6);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
340 retcount += 6;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
341 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
342 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
343 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
344 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
345 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
346 ret[retcount] = ')';
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
347 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
348 cnt += 2;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
349 } else if (!g_ascii_strncasecmp(message + cnt, "size=\"", 6)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
350 cnt += 6;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
351 if ((message[cnt] == '1') || (message[cnt] == '2')) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
352 strncpy(ret + retcount, "@small(", 7);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
353 retcount += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
354 } else if ((message[cnt] == '3')
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
355 || (message[cnt] == '4')) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
356 strncpy(ret + retcount, "@medium(", 8);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
357 retcount += 8;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
358 } else if ((message[cnt] == '5')
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
359 || (message[cnt] == '6')
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
360 || (message[cnt] == '7')) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
361 strncpy(ret + retcount, "@large(", 7);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
362 retcount += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
363 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
364 cnt += 3;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
365 } else {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
366 /* Drop all unrecognized/misparsed font tags */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
367 while (g_ascii_strncasecmp(message + cnt, "\">", 2) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
368 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
369 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
370 cnt += 2;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
371 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
372 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/i>", 3)
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
373 || !g_ascii_strncasecmp(message + cnt + 1, "/b>", 3)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
374 cnt += 4;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
375 ret[retcount] = ')';
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
376 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
377 } else if (!g_ascii_strncasecmp(message + cnt + 1, "/font>", 6)) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
378 cnt += 7;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
379 strncpy(ret + retcount, "@font(fixed)", 12);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
380 retcount += 12;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
381 } else {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
382 /* Catch all for all unrecognized/misparsed <foo> tage */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
383 while (g_ascii_strncasecmp(message + cnt, ">", 1) != 0) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
384 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
385 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
386 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
387 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
388 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
389 } else {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
390 /* Duh */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
391 ret[retcount] = message[cnt];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
392 retcount++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
393 cnt++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
394 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
395 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
396 return ret;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
397 }
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
398
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
399 /* this parses zephyr formatting and converts it to html. For example, if
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
400 * you pass in "@{@color(blue)@i(hello)}" you should get out
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
401 * "<font color=blue><i>hello</i></font>". */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
402 static char *zephyr_to_html(char *message)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
403 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
404 int len, cnt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
405 zframe *frames, *curr;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
406 char *ret;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
407
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
408 frames = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
409 frames->text = g_string_new("");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
410 frames->enclosing = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
411 frames->closing = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
412 frames->has_closer = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
413
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
414 len = strlen(message);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
415 cnt = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
416 while (cnt <= len) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
417 if (message[cnt] == '@') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
418 zframe *new_f;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
419 char *buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
420 int end;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
421
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
422 for (end = 1; (cnt + end) <= len && !IS_OPENER(message[cnt + end])
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
423 && !IS_CLOSER(message[cnt + end]); end++);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
424 buf = g_new0(char, end);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
425
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
426 if (end) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
427 g_snprintf(buf, end, "%s", message + cnt + 1);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
428 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
429 if (!g_ascii_strcasecmp(buf, "italic") || !g_ascii_strcasecmp(buf, "i")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
430 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
431 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
432 new_f->text = g_string_new("<i>");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
433 new_f->closing = "</i>";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
434 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
435 frames = new_f;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
436 cnt += end + 1; /* cnt points to char after opener */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
437 } else if (!g_ascii_strcasecmp(buf, "small")) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
438 new_f = g_new(zframe, 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
439 new_f->enclosing = frames;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
440 new_f->text = g_string_new("<font size=\"1\">");
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
441 new_f->closing = "</font>";
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
442 frames = new_f;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
443 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
444 } else if (!g_ascii_strcasecmp(buf, "medium")) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
445 new_f = g_new(zframe, 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
446 new_f->enclosing = frames;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
447 new_f->text = g_string_new("<font size=\"3\">");
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
448 new_f->closing = "</font>";
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
449 frames = new_f;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
450 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
451 } else if (!g_ascii_strcasecmp(buf, "large")) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
452 new_f = g_new(zframe, 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
453 new_f->enclosing = frames;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
454 new_f->text = g_string_new("<font size=\"7\">");
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
455 new_f->closing = "</font>";
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
456 frames = new_f;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
457 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
458 } else if (!g_ascii_strcasecmp(buf, "bold")
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
459 || !g_ascii_strcasecmp(buf, "b")) {
2086
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("<b>");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
463 new_f->closing = "</b>";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
464 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
465 frames = new_f;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
466 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
467 } else if (!g_ascii_strcasecmp(buf, "font")) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
468 cnt += end + 1;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
469 new_f = g_new(zframe, 1);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
470 new_f->enclosing = frames;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
471 new_f->text = g_string_new("<font face=");
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
472 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) {
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
473 g_string_append_c(new_f->text, message[cnt]);
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
474 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
475 cnt++; /* point to char after closer */
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
476 g_string_append_c(new_f->text, '>');
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
477 new_f->closing = "</font>";
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
478 new_f->has_closer = FALSE;
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
479 frames = new_f;
8568
88988327a4e0 [gaim-migrate @ 9316]
Mark Doliner <mark@kingant.net>
parents: 8562
diff changeset
480 } else if (!g_ascii_strcasecmp(buf, "color")) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
481 cnt += end + 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
482 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
483 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
484 new_f->text = g_string_new("<font color=");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
485 for (; (cnt <= len) && !IS_CLOSER(message[cnt]); cnt++) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
486 g_string_append_c(new_f->text, message[cnt]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
487 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
488 cnt++; /* point to char after closer */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
489 g_string_append_c(new_f->text, '>');
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
490 new_f->closing = "</font>";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
491 new_f->has_closer = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
492 frames = new_f;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
493 } else if (!g_ascii_strcasecmp(buf, "")) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
494 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
495 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
496 new_f->text = g_string_new("");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
497 new_f->closing = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
498 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
499 frames = new_f;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
500 cnt += end + 1; /* cnt points to char after opener */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
501 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
502 if ((cnt + end) > len) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
503 g_string_append_c(frames->text, '@');
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
504 cnt++;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
505 } else if (IS_CLOSER(message[cnt + end])) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
506 /* We have @chars..closer . This is
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
507 merely a sequence of chars that isn't a formatting tag
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
508 */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
509 int tmp = cnt;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
510
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
511 while (tmp <= cnt + end) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
512 g_string_append_c(frames->text, message[tmp]);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
513 tmp++;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
514 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
515 cnt += end + 1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
516 } else {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
517 /* unrecognized thingie. act like it's not there, but we
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
518 * still need to take care of the corresponding closer,
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
519 * make a frame that does nothing. */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
520 new_f = g_new(zframe, 1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
521 new_f->enclosing = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
522 new_f->text = g_string_new("");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
523 new_f->closing = "";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
524 new_f->has_closer = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
525 frames = new_f;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
526 cnt += end + 1; /* cnt points to char after opener */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
527 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
528 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
529 } else if (IS_CLOSER(message[cnt])) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
530 zframe *popped;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
531 gboolean last_had_closer;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
532
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
533 if (frames->enclosing) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
534 do {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
535 popped = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
536 frames = frames->enclosing;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
537 g_string_append(frames->text, popped->text->str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
538 g_string_append(frames->text, popped->closing);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
539 g_string_free(popped->text, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
540 last_had_closer = popped->has_closer;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
541 g_free(popped);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
542 } while (frames && frames->enclosing && !last_had_closer);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
543 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
544 g_string_append_c(frames->text, message[cnt]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
545 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
546 cnt++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
547 } else if (message[cnt] == '\n') {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
548 g_string_append(frames->text, "<br>");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
549 cnt++;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
550 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
551 g_string_append_c(frames->text, message[cnt++]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
552 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
553 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
554 /* go through all the stuff that they didn't close */
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
555 while (frames->enclosing) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
556 curr = frames;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
557 g_string_append(frames->enclosing->text, frames->text->str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
558 g_string_append(frames->enclosing->text, frames->closing);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
559 g_string_free(frames->text, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
560 frames = frames->enclosing;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
561 g_free(curr);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
562 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
563 ret = frames->text->str;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
564 g_string_free(frames->text, FALSE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
565 g_free(frames);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
566 return ret;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
567 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
568
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
569 static gboolean pending_zloc(char *who)
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 GList *curr;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
572
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
573 for (curr = pending_zloc_names; curr != NULL; curr = curr->next) {
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
574 char* normalized_who = local_zephyr_normalize(who);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
575 if (!g_ascii_strcasecmp(normalized_who, (char *)curr->data)) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
576 g_free((char *)curr->data);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
577 pending_zloc_names = g_list_remove(pending_zloc_names, curr->data);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
578 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
579 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
580 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
581 return FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
582 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
583
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
584 /* Called when the server notifies us a message couldn't get sent */
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
585
8559
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
586 static void message_failed(ZNotice_t notice, struct sockaddr_in from)
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
587 {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
588 if (g_ascii_strcasecmp(notice.z_class, "message")) {
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
589 gchar* chat_failed = g_strdup_printf(_("Unable send to chat %s,%s,%s"),notice.z_class,notice.z_class_inst,notice.z_recipient);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
590 gaim_notify_error(zgc,"",chat_failed,NULL);
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
591 g_free(chat_failed);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
592 } else {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
593 gaim_notify_error(zgc, notice.z_recipient, _("User is offline"), NULL);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
594 }
8559
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
595 }
1c20aa5bd389 [gaim-migrate @ 9303]
Luke Schierer <lschiere@pidgin.im>
parents: 8451
diff changeset
596
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
597 static void handle_message(ZNotice_t notice, struct sockaddr_in from)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
598 {
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
599 if (!g_ascii_strcasecmp(notice.z_class, LOGIN_CLASS)) {
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
600 /* 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
601 } else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) {
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
602 if (!g_ascii_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
603 int nlocs;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
604 char *user;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
605 GaimBuddy *b;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
606
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
607 /* XXX add real error reporting */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
608 if (ZParseLocations(&notice, NULL, &nlocs, &user) != ZERR_NONE)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
609 return;
8435
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
610
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
611 if ((b = gaim_find_buddy(zgc->account, user)) == NULL) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
612 char *e = strchr(user, '@');
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
613
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
614 if (e && !g_ascii_strcasecmp(e + 1, gaim_zephyr_get_realm())) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
615 *e = '\0';
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
616 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4682
diff changeset
617 b = gaim_find_buddy(zgc->account, user);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
618 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
619 if ((b && pending_zloc(b->name)) || pending_zloc(user)) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
620 ZLocations_t locs;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
621 int one = 1;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
622 GString *str = g_string_new("");
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
623
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
624 g_string_append_printf(str, _("<b>User:</b> %s<br>"), b ? b->name : user);
8435
6bd8bc8f07bb [gaim-migrate @ 9165]
Luke Schierer <lschiere@pidgin.im>
parents: 8386
diff changeset
625 if (b && b->alias)
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
626 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
627 if (!nlocs) {
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
628 g_string_append_printf(str, _("<br>Hidden or not logged-in"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
629 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
630 for (; nlocs > 0; nlocs--) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
631 /* XXX add real error reporting */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
632 ZGetLocations(&locs, &one);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
633 g_string_append_printf(str, _("<br>At %s since %s"), locs.host, locs.time);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
634 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
635 gaim_notify_formatted(zgc, NULL, _("Buddy Information"), NULL, str->str, NULL, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
636 g_string_free(str, TRUE);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
637 } else
4732
c15e0699acae [gaim-migrate @ 5047]
Nathan Walp <nwalp@pidgin.im>
parents: 4687
diff changeset
638 serv_got_update(zgc, b->name, nlocs, 0, 0, 0, 0);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
639
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
640 g_free(user);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
641 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
642 } else {
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
643 char *buf, *buf2, *buf3;
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
644 char *send_inst;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
645 GaimConversation *gconv1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
646 GaimConvChat *gcc;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
647 char *ptr = notice.z_message + strlen(notice.z_message) + 1;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
648 int len;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
649 char *sendertmp = g_strdup_printf("%s", gaim_zephyr_get_sender());
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
650 int signature_length = strlen(notice.z_message);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
651 int message_has_no_body = 0;
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
652 GaimConvImFlags flags = 0;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
653 gchar *tmpescape;
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
654
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
655 /* Need to deal with 0 length messages to handle typing notification (OPCODE) ping messages */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
656 /* One field zephyrs would have caused gaim to crash */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
657 if ( (notice.z_message_len == 0) || (signature_length >= notice.z_message_len - 1)) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
658 message_has_no_body = 1;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
659 len = 0;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
660 gaim_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
661 buf3 = g_strdup("");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
662
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
663 } else {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
664 len = notice.z_message_len - ( signature_length +1);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
665 gaim_debug_info("zephyr","message_size %d %d %d\n",len,notice.z_message_len,signature_length);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
666 buf = g_malloc(len + 1);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
667 g_snprintf(buf, len + 1, "%s", ptr);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
668 g_strchomp(buf);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
669 tmpescape = gaim_escape_html(buf);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
670 g_free(buf);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
671 buf2 = zephyr_to_html(tmpescape);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
672 buf3 = zephyr_recv_convert(buf2, strlen(buf2));
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
673 g_free(buf2);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
674 g_free(tmpescape);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
675 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
676
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
677 if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL")
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
678 && !g_ascii_strcasecmp(notice.z_recipient,gaim_zephyr_get_sender())) {
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
679 gchar* stripped_sender;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
680 if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:"))
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
681 flags |= GAIM_CONV_IM_AUTO_RESP;
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
682 stripped_sender = zephyr_strip_foreign_realm(notice.z_sender);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
683
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
684 if (!g_ascii_strcasecmp(notice.z_opcode,"PING"))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
685 serv_got_typing(zgc,stripped_sender,ZEPHYR_TYPING_RECV_TIMEOUT, GAIM_TYPING);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
686 else
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
687 serv_got_im(zgc, stripped_sender, buf3, flags, time(NULL));
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
688
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
689 g_free(stripped_sender);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
690 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
691 zephyr_triple *zt1, *zt2;
9437
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
692 gchar *send_inst_utf8;
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
693
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
694 zt1 = new_triple(notice.z_class, notice.z_class_inst, notice.z_recipient);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
695 zt2 = find_sub_by_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
696 if (!zt2) {
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
697 /* This is a server supplied subscription */
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
698 subscrips = g_slist_append(subscrips, zt1);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
699 zt2 = find_sub_by_triple(zt1);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
700 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
701
9437
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
702 if (!zt2->open) {
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
703 zt2->open = TRUE;
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
704 serv_got_joined_chat(zgc, zt2->id, zt2->name);
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
705 zephyr_chat_set_topic(zgc,zt2->id,notice.z_class_inst);
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
706 }
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
707 g_free(sendertmp); /* fix memory leak? */
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
708 /* If the person is in the default Realm, then strip the
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
709 Realm from the sender field */
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
710 sendertmp = zephyr_strip_foreign_realm(notice.z_sender);
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
711 send_inst = g_strdup_printf("%s %s",sendertmp,notice.z_class_inst);
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
712 send_inst_utf8 = zephyr_recv_convert(send_inst, strlen(send_inst));
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
713 if (!send_inst_utf8) {
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
714 gaim_debug(GAIM_DEBUG_ERROR, "zephyr","send_inst %s became null\n", send_inst);
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
715 send_inst_utf8 = "malformed instance";
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
716 }
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
717
9584
fe35f55ee984 [gaim-migrate @ 10427]
Luke Schierer <lschiere@pidgin.im>
parents: 9554
diff changeset
718 serv_got_chat_in(zgc, zt2->id, send_inst_utf8, 0, buf3, time(NULL));
9437
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
719 g_free(send_inst);
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
720 gconv1 = gaim_find_conversation_with_account(zt2->name, zgc->account);
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
721 gcc = gaim_conversation_get_chat_data(gconv1);
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
722
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9478
diff changeset
723 if (!gaim_conv_chat_find_user(gcc, sendertmp)) {
9437
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
724 /* force interpretation in network byte order */
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
725 unsigned char *addrs = (unsigned char *)&(notice.z_sender_addr.s_addr);
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
726 gchar* ipaddr = g_strdup_printf("%hhd.%hhd.%hhd.%hhd", (unsigned char)addrs[0],
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
727 (unsigned char)addrs[1], (unsigned char)addrs[2],
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
728 (unsigned char) addrs[3]);
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
729
9554
8b2451878e26 [gaim-migrate @ 10387]
Luke Schierer <lschiere@pidgin.im>
parents: 9478
diff changeset
730 gaim_conv_chat_add_user(gcc, sendertmp, ipaddr, GAIM_CBFLAGS_NONE);
9437
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
731 g_free(ipaddr); /* fix memory leak? */
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
732
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
733 }
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
734 g_free(sendertmp);
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
735 g_free(send_inst_utf8);
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
736
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
737 free_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
738 }
8560
832fd9b754d0 [gaim-migrate @ 9304]
Luke Schierer <lschiere@pidgin.im>
parents: 8559
diff changeset
739 g_free(buf3);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
740
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
741 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
742 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
743
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
744 static gint check_notify(gpointer data)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
745 {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
746 /* XXX add real error reporting */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
747
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
748 while (ZPending()) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
749 ZNotice_t notice;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
750 struct sockaddr_in from;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
751 /* XXX add real error reporting */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
752
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
753 z_call_r(ZReceiveNotice(&notice, &from));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
754
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
755 switch (notice.z_kind) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
756 case UNSAFE:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
757 case UNACKED:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
758 case ACKED:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
759 handle_message(notice, from);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
760 break;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
761 case SERVACK:
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
762 if (!(g_ascii_strcasecmp(notice.z_message, ZSRVACK_NOTSENT))) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
763 message_failed(notice, from);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
764 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
765 break;
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
766 case CLIENTACK:
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
767 gaim_debug_error("zephyr", "Client ack received\n");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
768 default:
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
769 /* we'll just ignore things for now */
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
770 handle_unknown(notice);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
771 gaim_debug_error("zephyr", "Unhandled notice.\n");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
772 break;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
773 }
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
774 /* XXX add real error reporting */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
775 ZFreeNotice(&notice);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
776 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
777
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
778 return TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
779 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
780
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
781 static gint check_loc(gpointer data)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
782 {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
783 GaimBlistNode *gnode, *cnode, *bnode;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
784 ZAsyncLocateData_t ald;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
785
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
786 ald.user = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
787 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
788 ald.version = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
789
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
790 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
791 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
792 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
793 for (cnode = gnode->child; cnode; cnode = cnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
794 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
795 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
796 for (bnode = cnode->child; bnode; bnode = bnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
797 GaimBuddy *b = (GaimBuddy *) bnode;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
798
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
799 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
800 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
801 if (b->account->gc == zgc) {
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7126
diff changeset
802 const char *chk;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
803
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
804 chk = local_zephyr_normalize(b->name);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
805 /* XXX add real error reporting */
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
806 /* 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
807 ZRequestLocations(chk, &ald, UNACKED, ZAUTH);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
808 g_free(ald.user);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
809 g_free(ald.version);
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
810 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
811 }
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 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
814
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
815 return TRUE;
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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
818 static char *get_exposure_level()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
819 {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
820 /* XXX add real error reporting */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
821 char *exposure = ZGetVariable("exposure");
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 if (!exposure)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
824 return EXPOSE_REALMVIS;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
825 if (!g_ascii_strcasecmp(exposure, EXPOSE_NONE))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
826 return EXPOSE_NONE;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
827 if (!g_ascii_strcasecmp(exposure, EXPOSE_OPSTAFF))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
828 return EXPOSE_OPSTAFF;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
829 if (!g_ascii_strcasecmp(exposure, EXPOSE_REALMANN))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
830 return EXPOSE_REALMANN;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
831 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETVIS))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
832 return EXPOSE_NETVIS;
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
833 if (!g_ascii_strcasecmp(exposure, EXPOSE_NETANN))
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
834 return EXPOSE_NETANN;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
835 return EXPOSE_REALMVIS;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
836 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
837
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
838 static void strip_comments(char *str)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
839 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
840 char *tmp = strchr(str, '#');
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
841
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
842 if (tmp)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
843 *tmp = '\0';
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
844 g_strchug(str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
845 g_strchomp(str);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
846 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
847
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
848 static void zephyr_inithosts()
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
849 {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
850 /* XXX This code may not be Win32 clean */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
851 struct hostent *hent;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
852
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
853 if (gethostname(ourhost, sizeof(ourhost)-1) == -1) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
854 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "unable to retrieve hostname, %%host%% and %%canon%% will be wrong in subscriptions and have been set to unknown\n");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
855 g_stpcpy(ourhost,"unknown");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
856 g_stpcpy(ourhostcanon,"unknown");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
857 return;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
858 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
859
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
860 if (!(hent = gethostbyname(ourhost))) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
861 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "unable to resolve hostname, %%canon%% will be wrong in subscriptions.and has been set to the value of %%host%%, %s\n",ourhost);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
862 g_stpcpy(ourhostcanon,ourhost);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
863 return;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
864 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
865 g_stpcpy(ourhostcanon,hent->h_name);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
866 return;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
867 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
868
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
869 static void process_zsubs()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
870 {
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
871 /* Loads zephyr chats "(subscriptions) from ~/.zephyr.subs, and
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
872 registers (subscribes to) them on the server */
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
873
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
874 /* XXX deal with unsubscriptions */
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
875 /* XXX deal with punts */
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
876
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
877 FILE *f;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
878 gchar *fname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
879 gchar buff[BUFSIZ];
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
880
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
881 zephyr_inithosts();
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
882 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
883 f = fopen(fname, "r");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
884 if (f) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
885 char **triple;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
886 ZSubscription_t sub;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
887 char *recip;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
888 char *z_class;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
889 char *z_instance;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
890
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
891 while (fgets(buff, BUFSIZ, f)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
892 strip_comments(buff);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
893 if (buff[0]) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
894 triple = g_strsplit(buff, ",", 3);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
895 if (triple[0] && triple[1]) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
896 char *tmp = g_strdup_printf("%s", gaim_zephyr_get_sender());
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
897 char *atptr;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
898
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
899 sub.zsub_class = triple[0];
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
900 sub.zsub_classinst = triple[1];
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
901 if (triple[2] == NULL) {
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
902 recip = g_malloc0(1);
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
903 } else if (!g_ascii_strcasecmp(triple[2], "%me%")) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
904 recip = g_strdup_printf("%s", gaim_zephyr_get_sender());
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
905 } else if (!g_ascii_strcasecmp(triple[2], "*")) {
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
906 /* wildcard
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
907 * form of class,instance,* */
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
908 recip = g_malloc0(1);
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
909 } else if (!g_ascii_strcasecmp(triple[2], tmp)) {
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
910 /* form of class,instance,aatharuv@ATHENA.MIT.EDU */
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
911 recip = g_strdup(triple[2]);
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
912 } else if ((atptr = strchr(triple[2], '@')) != NULL) {
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
913 /* form of class,instance,*@ANDREW.CMU.EDU
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
914 * class,instance,@ANDREW.CMU.EDU
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
915 * If realm is local realm, blank recipient, else
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
916 * @REALM-NAME
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
917 */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
918 char *realmat = g_strdup_printf("@%s",
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
919 gaim_zephyr_get_realm());
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
920
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
921 if (!g_ascii_strcasecmp(atptr, realmat))
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
922 recip = g_malloc0(1);
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
923 else
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
924 recip = g_strdup(atptr);
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
925 g_free(realmat);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
926 } else {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
927 recip = g_strdup(triple[2]);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
928 }
2804
1648c703ddc2 [gaim-migrate @ 2817]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2791
diff changeset
929 g_free(tmp);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
930 sub.zsub_recipient = recip;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
931
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
932 if (!g_ascii_strcasecmp(triple[0],"%host%")) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
933 z_class = g_strdup(ourhost);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
934 } else if (!g_ascii_strcasecmp(triple[0],"%canon%")) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
935 z_class = g_strdup(ourhostcanon);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
936 } else {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
937 z_class = g_strdup(triple[0]);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
938 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
939 sub.zsub_class = z_class;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
940
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
941 if (!g_ascii_strcasecmp(triple[1],"%host%")) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
942 z_instance = g_strdup(ourhost);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
943 } else if (!g_ascii_strcasecmp(triple[1],"%canon%")) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
944 z_instance = g_strdup(ourhostcanon);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
945 } else {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
946 z_instance = g_strdup(triple[1]);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
947 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
948 sub.zsub_classinst = z_instance;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
949
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
950 /* There should be some sort of error report listing classes that couldn't be subbed to.
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
951 Not important right now though */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
952
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
953 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
954
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
955 gaim_debug(GAIM_DEBUG_ERROR, "zephyr", "Couldn't subscribe to %s, %s, %s\n", sub.zsub_class, sub.zsub_classinst, sub.zsub_recipient);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
956 }
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
957
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
958 subscrips = g_slist_append(subscrips, new_triple(sub.zsub_class,sub.zsub_classinst,sub.zsub_recipient));
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
959 /* g_hash_table_destroy(sub_hash_table); */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
960 g_free(z_instance);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
961 g_free(z_class);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
962 g_free(recip);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
963 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
964 g_strfreev(triple);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
965 }
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
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
970 static void process_anyone()
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 FILE *fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
973 gchar buff[BUFSIZ], *filename;
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
974 GaimGroup *g;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
975 GaimBuddy *b;
4775
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
976
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
977 if (!(g = gaim_find_group(_("Anyone")))) {
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
978 g = gaim_group_new(_("Anyone"));
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
979 gaim_blist_add_group(g, NULL);
92ae181271e9 [gaim-migrate @ 5095]
Mark Doliner <mark@kingant.net>
parents: 4770
diff changeset
980 }
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
981
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
982 filename = g_strconcat(gaim_home_dir(), "/.anyone", NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
983 if ((fd = fopen(filename, "r")) != NULL) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
984 while (fgets(buff, BUFSIZ, fd)) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
985 strip_comments(buff);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents: 4682
diff changeset
986 if (buff[0]) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
987 if (!(b = gaim_find_buddy(zgc->account, buff))) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
988 b = gaim_buddy_new(zgc->account, buff, NULL);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
989 gaim_blist_add_buddy(b, NULL, g, NULL);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
990 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
991 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
992 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
993 fclose(fd);
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_free(filename);
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
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
998 static void zephyr_login(GaimAccount * account)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
999 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1000 ZSubscription_t sub;
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1001
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1002 /* This needs to fixed to deal with multiple accounts somehow */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1003 if (zgc) {
5436
ad445074d239 [gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents: 5234
diff changeset
1004 gaim_notify_error(account->gc, NULL,
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1005 _("Already logged in with Zephyr"), _("Because Zephyr uses your system username, you " "are unable to have multiple accounts on it " "when logged in as the same user."));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1006 return;
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
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
1009 zgc = gaim_account_get_connection(account);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1010 zgc->flags |= GAIM_CONNECTION_HTML | GAIM_CONNECTION_NO_BGCOLOR | GAIM_CONNECTION_NO_URLDESC;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1011 gaim_connection_update_progress(zgc, _("Connecting"), 0, 8);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1012
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1013 /* XXX z_call_s should actually try to report the com_err determined error */
8645
47f647dd2ac3 [gaim-migrate @ 9397]
Mark Doliner <mark@kingant.net>
parents: 8644
diff changeset
1014
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1015 z_call_s(ZInitialize(), "Couldn't initialize zephyr");
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1016 z_call_s(ZOpenPort(&zephyr_port), "Couldn't open port");
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1017 z_call_s(ZSetLocation((char *)
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1018 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
1019
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1020 sub.zsub_class = "MESSAGE";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1021 sub.zsub_classinst = "PERSONAL";
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1022 sub.zsub_recipient = (char *)gaim_zephyr_get_sender();
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1023
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1024 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1025 /* XXX don't translate this yet. It could be written better */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1026 /* XXX error messages could be handled with more detail */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1027 gaim_notify_error(account->gc, NULL,
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1028 "Unable to subscribe to messages", "Unable to subscribe to initial messages");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1029 return;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1030 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1031
5606
328dde25685a [gaim-migrate @ 6010]
Nathan Walp <nwalp@pidgin.im>
parents: 5436
diff changeset
1032 gaim_connection_set_state(zgc, GAIM_CONNECTED);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1033 serv_finish_login(zgc);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1034
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1035 process_anyone();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1036 process_zsubs();
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1037
8273
f24172f53650 [gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents: 8212
diff changeset
1038 nottimer = gaim_timeout_add(100, check_notify, NULL);
f24172f53650 [gaim-migrate @ 8997]
Christian Hammond <chipx86@chipx86.com>
parents: 8212
diff changeset
1039 loctimer = gaim_timeout_add(20000, check_loc, NULL);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1040 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1041
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1042 static void write_zsubs()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1043 {
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1044 /* Exports subscription (chat) list back to
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1045 * .zephyr.subs
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1046 * XXX deal with %host%, %canon%, unsubscriptions, and negative subscriptions (punts?)
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1047 */
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1048
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1049 GSList *s = subscrips;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1050 zephyr_triple *zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1051 FILE *fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1052 char *fname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1053
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1054 char **triple;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1055
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
1056 fname = g_strdup_printf("%s/.zephyr.subs", gaim_home_dir());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1057 fd = fopen(fname, "w");
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1058
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1059 if (!fd) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1060 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1061 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1062 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1063
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1064 while (s) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1065 char *zclass, *zinst, *zrecip;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1066 zt = s->data;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1067 triple = g_strsplit(zt->name, ",", 3);
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1068
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1069 /* deal with classes */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1070 if (!g_ascii_strcasecmp(triple[0],ourhost)) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1071 zclass = g_strdup("%host%");;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1072 } else if (!g_ascii_strcasecmp(triple[0],ourhostcanon)) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1073 zclass = g_strdup("%canon%");;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1074 } else {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1075 zclass = g_strdup(triple[0]);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1076 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1077
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1078 /* deal with instances */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1079
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1080 if (!g_ascii_strcasecmp(triple[1],ourhost)) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1081 zinst = g_strdup("%host%");;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1082 } else if (!g_ascii_strcasecmp(triple[1],ourhostcanon)) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1083 zinst = g_strdup("%canon%");;
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1084 } else {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1085 zinst = g_strdup(triple[1]);
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1086 }
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1087
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1088 /* deal with recipients */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1089 if (triple[2] == NULL) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1090 zrecip = g_strdup("*");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1091 } else if (!g_ascii_strcasecmp(triple[2],"")){
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1092 zrecip = g_strdup("*");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1093 } else if (!g_ascii_strcasecmp(triple[2], gaim_zephyr_get_sender())) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1094 zrecip = g_strdup("%me%");
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1095 } else {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1096 zrecip = g_strdup(triple[2]);
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1097 }
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1098
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1099 fprintf(fd, "%s,%s,%s\n",zclass,zinst,zrecip);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1100
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1101 g_free(zclass);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1102 g_free(zinst);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1103 g_free(zrecip);
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1104 g_free(triple);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1105 s = s->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1106 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1107 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1108 fclose(fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1109 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1110
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1111 static void write_anyone()
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1112 {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1113 GaimBlistNode *gnode, *cnode, *bnode;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1114 GaimBuddy *b;
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1115 char *ptr, *fname, *ptr2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1116 FILE *fd;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1117
3630
9682c0e022c6 [gaim-migrate @ 3753]
Rob Flynn <gaim@robflynn.com>
parents: 3572
diff changeset
1118 fname = g_strdup_printf("%s/.anyone", gaim_home_dir());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1119 fd = fopen(fname, "w");
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1120 if (!fd) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1121 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1122 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1123 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1124
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1125 for (gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1126 if (!GAIM_BLIST_NODE_IS_GROUP(gnode))
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1127 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1128 for (cnode = gnode->child; cnode; cnode = cnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1129 if (!GAIM_BLIST_NODE_IS_CONTACT(cnode))
4785
1e28e7d802a1 [gaim-migrate @ 5105]
Nathan Walp <nwalp@pidgin.im>
parents: 4775
diff changeset
1130 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1131 for (bnode = cnode->child; bnode; bnode = bnode->next) {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1132 if (!GAIM_BLIST_NODE_IS_BUDDY(bnode))
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1133 continue;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1134 b = (GaimBuddy *) bnode;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1135 if (b->account == zgc->account) {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1136 if ((ptr = strchr(b->name, '@')) != NULL) {
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1137 ptr2 = ptr + 1;
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1138 /* We should only strip the realm name if the principal
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1139 is in the user's realm
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1140 */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1141 if (!g_ascii_strcasecmp(ptr2, gaim_zephyr_get_realm())) {
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1142 *ptr = '\0';
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1143 }
4349
0c68d402f59f [gaim-migrate @ 4614]
Nathan Walp <nwalp@pidgin.im>
parents: 4227
diff changeset
1144 }
6695
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1145 fprintf(fd, "%s\n", b->name);
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1146 if (ptr)
0c5637b5462e [gaim-migrate @ 7221]
Nathan Walp <nwalp@pidgin.im>
parents: 6679
diff changeset
1147 *ptr = '@';
3277
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1148 }
ec20536eaeb0 [gaim-migrate @ 3295]
Sean Egan <seanegan@gmail.com>
parents: 3158
diff changeset
1149 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1150 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1151 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1152
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1153 fclose(fd);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1154 g_free(fname);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1155 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1156
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1157 static void zephyr_close(GaimConnection * gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1158 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1159 GList *l;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1160 GSList *s;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1161
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1162 l = pending_zloc_names;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1163 while (l) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1164 g_free((char *)l->data);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1165 l = l->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1166 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1167 g_list_free(pending_zloc_names);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1168
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1169 if (gaim_account_get_bool(zgc->account, "write_anyone", FALSE))
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1170 write_anyone();
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1171
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1172 if (gaim_account_get_bool(zgc->account, "write_zsubs", FALSE))
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1173 write_zsubs();
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1174
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1175 s = subscrips;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1176 while (s) {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1177 free_triple((zephyr_triple *) s->data);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1178 s = s->next;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1179 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1180 g_slist_free(subscrips);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1181
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1182 if (nottimer)
8287
ef881489396e [gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents: 8273
diff changeset
1183 gaim_timeout_remove(nottimer);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1184 nottimer = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1185 if (loctimer)
8287
ef881489396e [gaim-migrate @ 9011]
Christian Hammond <chipx86@chipx86.com>
parents: 8273
diff changeset
1186 gaim_timeout_remove(loctimer);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1187 loctimer = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1188 zgc = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1189 z_call(ZCancelSubscriptions(0));
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1190 z_call(ZUnsetLocation());
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1191 z_call(ZClosePort());
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1192 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1193
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1194 static int zephyr_send_message(char* zclass, char* instance, char* recipient, const char *im,
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1195 const char *sig, char *opcode) ;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1196
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1197 const char * zephyr_get_signature()
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1198 {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1199 /* XXX add zephyr error reporting */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1200 const char * sig =ZGetVariable("zwrite-signature");
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1201 if (!sig) {
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1202 sig = g_get_real_name();
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1203 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1204 return sig;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1205 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1206
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1207 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
1208 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1209 zephyr_triple *zt;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1210 const char *sig;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1211 GaimConversation *gconv1;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1212 GaimConvChat *gcc;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1213 char *inst;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1214 char *recipient;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1215
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1216 zt = find_sub_by_id(id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1217 if (!zt)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1218 /* this should never happen. */
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
1219 return -EINVAL;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1220
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1221 sig = zephyr_get_signature();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1222
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1223 gconv1 = gaim_find_conversation_with_account(zt->name, zgc->account);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1224 gcc = gaim_conversation_get_chat_data(gconv1);
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1225
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1226 if (!(inst = (char *)gaim_conv_chat_get_topic(gcc)))
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1227 inst = g_strdup("PERSONAL");
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1228
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1229 if (!g_ascii_strcasecmp(zt->recipient, "*"))
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1230 recipient = local_zephyr_normalize("");
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1231 else
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1232 recipient = local_zephyr_normalize(zt->recipient);
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1233
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1234 zephyr_send_message(zt->class,inst,recipient,im,sig,"");
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1235 /* g_free(inst); */
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1236 /* g_free(recipient); */
2167
edf8c5a70e5b [gaim-migrate @ 2177]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2162
diff changeset
1237 return 0;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1238 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1239
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1240
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1241 static int zephyr_send_im(GaimConnection * gc, const char *who, const char *im, GaimConvImFlags flags)
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1242 {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1243 const char *sig;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1244
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7084
diff changeset
1245 if (flags & GAIM_CONV_IM_AUTO_RESP)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1246 sig = "Automated reply:";
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1247 else {
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1248 sig = zephyr_get_signature();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1249 }
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1250 zephyr_send_message("MESSAGE","PERSONAL",local_zephyr_normalize(who),im,sig,"");
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1251
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1252 return 1;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1253 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1254
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1255 static int zephyr_send_message(char* zclass, char* instance, char* recipient, const char *im,
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1256 const char *sig, char *opcode)
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1257 {
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1258 char *html_buf;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1259 char *html_buf2;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1260 char *buf;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1261 ZNotice_t notice;
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1262
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1263 html_buf = html_to_zephyr(im);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1264 html_buf2 = gaim_unescape_html(html_buf);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1265
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1266 buf = g_strdup_printf("%s%c%s", sig, '\0', html_buf2);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1267 bzero((char *)&notice, sizeof(notice));
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1268
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1269 notice.z_kind = ACKED;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1270 notice.z_port = 0;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1271 notice.z_opcode = "";
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1272 notice.z_class = zclass;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1273 notice.z_class_inst = instance;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1274 notice.z_recipient = recipient;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1275 notice.z_sender = 0;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1276 notice.z_default_format = "Class $class, Instance $instance:\n" "To: @bold($recipient) at $time $date\n" "From: @bold($1) <$sender>\n\n$2";
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1277 notice.z_message_len = strlen(html_buf2) + strlen(sig) + 2;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1278 notice.z_message = buf;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1279 notice.z_opcode = g_strdup(opcode);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1280 gaim_debug_info("zephyr","About to send notice");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1281 if (! ZSendNotice(&notice, ZAUTH) == ZERR_NONE) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1282 /* XXX handle errors here */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1283 return 0;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1284 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1285 gaim_debug_info("zephyr","notice sent");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1286 g_free(buf);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1287
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1288 g_free(html_buf2);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1289 g_free(html_buf);
8451
6b7b5b10cd8a [gaim-migrate @ 9181]
Luke Schierer <lschiere@pidgin.im>
parents: 8449
diff changeset
1290
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1291 return 1;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1292 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1293
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1294 static const char *zephyr_normalize(const GaimAccount * account, const char *orig)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1295 {
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1296 /* returns the string you gave it. Maybe this function shouldn't be here */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1297 static char buf[80];
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1298
7126
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1299 if (!g_ascii_strcasecmp(orig, "")) {
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1300 buf[0] = '\0';
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1301 return buf;
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1302 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1303 g_snprintf(buf, 80, "%s", orig);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1304 }
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1305 return buf;
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1306 }
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1307
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1308
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1309 char *local_zephyr_normalize(const char *orig)
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1310 {
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1311 /*
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1312 Basically the inverse of zephyr_strip_foreign_realm
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1313 */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1314 static char buf[80];
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1315
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1316 if (!g_ascii_strcasecmp(orig, "")) {
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1317 buf[0] = '\0';
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1318 return buf;
7126
eda3de6dacbb [gaim-migrate @ 7693]
Luke Schierer <lschiere@pidgin.im>
parents: 7118
diff changeset
1319 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1320
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1321 if (strchr(orig, '@')) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1322 g_snprintf(buf, 80, "%s", orig);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1323 } else {
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1324 g_snprintf(buf, 80, "%s@%s", orig, gaim_zephyr_get_realm());
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1325 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1326 return buf;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1327 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1328
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1329 static void zephyr_zloc(GaimConnection *gc, const char *who)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1330 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1331 ZAsyncLocateData_t ald;
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1332 gchar* normalized_who = local_zephyr_normalize(who);
7261
1930e3d00ecd [gaim-migrate @ 7838]
Nathan Walp <nwalp@pidgin.im>
parents: 7126
diff changeset
1333
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1334 if (ZRequestLocations(normalized_who, &ald, UNACKED, ZAUTH) == ZERR_NONE) {
9030
7ab20f829190 [gaim-migrate @ 9806]
Mark Doliner <mark@kingant.net>
parents: 9015
diff changeset
1335 pending_zloc_names = g_list_append(pending_zloc_names,
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1336 g_strdup(normalized_who));
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1337 } else {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1338 /* XXX deal with errors somehow */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1339 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1340 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1341
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1342 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
1343 {
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1344 if (gc->away) {
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1345 g_free(gc->away);
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1346 gc->away = NULL;
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1347 }
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1348
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
1349 if (!g_ascii_strcasecmp(state, _("Hidden"))) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1350 /* XXX handle errors */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1351 ZSetLocation(EXPOSE_OPSTAFF);
4111
ee884f1d7ae3 [gaim-migrate @ 4326]
Christian Hammond <chipx86@chipx86.com>
parents: 3867
diff changeset
1352 gc->away = g_strdup("");
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1353 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1354 else if (!g_ascii_strcasecmp(state, _("Online"))) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1355 /* XXX handle errors */
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1356 ZSetLocation(get_exposure_level());
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1357 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1358 else /* state is GAIM_AWAY_CUSTOM */ if (msg)
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1359 gc->away = g_strdup(msg);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1360 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1361
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1362 static GList *zephyr_away_states(GaimConnection * gc)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1363 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1364 GList *m = NULL;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1365
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
1366 m = g_list_append(m, _("Online"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1367 m = g_list_append(m, GAIM_AWAY_CUSTOM);
5132
494b6b6a6ffa [gaim-migrate @ 5495]
Mark Doliner <mark@kingant.net>
parents: 4793
diff changeset
1368 m = g_list_append(m, _("Hidden"));
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1369
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1370 return m;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1371 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1372
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1373 static GList *zephyr_chat_info(GaimConnection * gc)
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1374 {
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1375 GList *m = NULL;
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1376 struct proto_chat_entry *pce;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1377
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1378 pce = g_new0(struct proto_chat_entry, 1);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1379
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7475
diff changeset
1380 pce->label = _("_Class:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1381 pce->identifier = "class";
3158
ea6f8d8d74e5 [gaim-migrate @ 3174]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
1382 m = g_list_append(m, pce);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1383
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1384 pce = g_new0(struct proto_chat_entry, 1);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1385
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7475
diff changeset
1386 pce->label = _("_Instance:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1387 pce->identifier = "instance";
3158
ea6f8d8d74e5 [gaim-migrate @ 3174]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
1388 m = g_list_append(m, pce);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1389
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1390 pce = g_new0(struct proto_chat_entry, 1);
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1391
7841
0555e59dfba9 [gaim-migrate @ 8494]
Mark Doliner <mark@kingant.net>
parents: 7475
diff changeset
1392 pce->label = _("_Recipient:");
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1393 pce->identifier = "recipient";
3158
ea6f8d8d74e5 [gaim-migrate @ 3174]
Sean Egan <seanegan@gmail.com>
parents: 3033
diff changeset
1394 m = g_list_append(m, pce);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1395
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1396 return m;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1397 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1398
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1399 /* Called when the server notifies us a message couldn't get sent */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1400
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1401 static void zephyr_subscribe_failed(ZSubscription_t *sub)
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1402 {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1403 gchar* subscribe_failed = g_strdup_printf(_("Attempt to subscribe to %s,%s,%s failed"), sub->zsub_class, sub->zsub_classinst,sub->zsub_recipient);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1404 gaim_notify_error(zgc,"", subscribe_failed, NULL);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1405 g_free(subscribe_failed);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1406 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1407
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1408 static void zephyr_join_chat(GaimConnection * gc, GHashTable * data)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1409 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1410 ZSubscription_t sub;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1411 zephyr_triple *zt1, *zt2;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1412 const char *classname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1413 const char *instname;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1414 const char *recip;
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1415
5234
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1416 classname = g_hash_table_lookup(data, "class");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1417 instname = g_hash_table_lookup(data, "instance");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1418 recip = g_hash_table_lookup(data, "recipient");
890b29f00b68 [gaim-migrate @ 5604]
Nathan Walp <nwalp@pidgin.im>
parents: 5205
diff changeset
1419
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1420
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1421 if (!classname)
2205
cff4fbe01c7b [gaim-migrate @ 2215]
Eric Warmenhoven <eric@warmenhoven.org>
parents: 2170
diff changeset
1422 return;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1423
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1424 if (!g_ascii_strcasecmp(classname,"%host%"))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1425 classname = g_strdup(ourhost);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1426 if (!g_ascii_strcasecmp(classname,"%canon%"))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1427 classname = g_strdup(ourhostcanon);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1428
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1429 if (!instname || !strlen(instname))
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1430 instname = "*";
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1431
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1432 if (!g_ascii_strcasecmp(instname,"%host%"))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1433 instname = g_strdup(ourhost);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1434 if (!g_ascii_strcasecmp(instname,"%canon%"))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1435 instname = g_strdup(ourhostcanon);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1436
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1437 if (!recip || (*recip == '*'))
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1438 recip = "";
4793
677d3cb193a1 [gaim-migrate @ 5113]
Nathan Walp <nwalp@pidgin.im>
parents: 4785
diff changeset
1439 if (!g_ascii_strcasecmp(recip, "%me%"))
8354
43dec50d8d51 [gaim-migrate @ 9078]
Luke Schierer <lschiere@pidgin.im>
parents: 8287
diff changeset
1440 recip = gaim_zephyr_get_sender();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1441
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1442 zt1 = new_triple(classname, instname, recip);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1443 zt2 = find_sub_by_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1444 if (zt2) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1445 free_triple(zt1);
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1446 if (!zt2->open) {
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1447 if (!g_ascii_strcasecmp(instname,"*"))
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1448 instname = "PERSONAL";
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1449 serv_got_joined_chat(gc, zt2->id, zt2->name);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1450 zephyr_chat_set_topic(zgc,zt2->id,instname);
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1451 zt2->open = TRUE;
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1452 }
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1453 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1454 }
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1455
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1456 sub.zsub_class = zt1->class;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1457 sub.zsub_classinst = zt1->instance;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1458 sub.zsub_recipient = zt1->recipient;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1459
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1460 if (ZSubscribeTo(&sub, 1, 0) != ZERR_NONE) {
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1461 /* XXX output better subscription information */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1462 zephyr_subscribe_failed(&sub);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1463 free_triple(zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1464 return;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1465 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1466
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1467 subscrips = g_slist_append(subscrips, zt1);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1468 zt1->open = TRUE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1469 serv_got_joined_chat(gc, zt1->id, zt1->name);
9328
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1470 if (!g_ascii_strcasecmp(instname,"*"))
33e6b2b92cfe [gaim-migrate @ 10136]
Luke Schierer <lschiere@pidgin.im>
parents: 9308
diff changeset
1471 instname = "PERSONAL";
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1472 zephyr_chat_set_topic(zgc,zt1->id,instname);
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1473 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1474
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1475 static void zephyr_chat_leave(GaimConnection * gc, int id)
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1476 {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1477 zephyr_triple *zt;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1478
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1479 zt = find_sub_by_id(id);
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1480 if (zt) {
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1481 zt->open = FALSE;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1482 zt->id = ++last_id;
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1483 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1484 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1485
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1486 static GaimChat *zephyr_find_blist_chat(GaimAccount *account, const char *name)
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1487 {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1488 GaimBlistNode *gnode, *cnode;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1489
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1490 /* XXX needs to be %host%,%canon%, and %me% clean */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1491 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1492 for(cnode = gnode->child; cnode; cnode = cnode->next) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1493 GaimChat *chat = (GaimChat*)cnode;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1494 char *zclass, *inst, *recip;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1495 char** triple;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1496 if(!GAIM_BLIST_NODE_IS_CHAT(cnode))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1497 continue;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1498 if(chat->account !=account)
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1499 continue;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1500 if(!(zclass = g_hash_table_lookup(chat->components, "class")))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1501 continue;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1502 if(!(inst = g_hash_table_lookup(chat->components, "instance")))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1503 inst = g_strdup("");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1504 if(!(recip = g_hash_table_lookup(chat->components, "recipient")))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1505 recip = g_strdup("");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1506 triple = g_strsplit(name,",",3);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1507 if (!g_ascii_strcasecmp(triple[0],zclass) && !g_ascii_strcasecmp(triple[1],inst) && !g_ascii_strcasecmp(triple[2],recip))
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1508 return chat;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1509
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1510 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1511 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1512 return NULL;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1513 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1514 static const char *zephyr_list_icon(GaimAccount * a, GaimBuddy * b)
5202
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
1515 {
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
1516 return "zephyr";
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
1517 }
ccb0ab32ba01 [gaim-migrate @ 5568]
Mark Doliner <mark@kingant.net>
parents: 5136
diff changeset
1518
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1519 static int zephyr_send_typing(GaimConnection *gc, const char *who, int typing) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1520 gchar *recipient;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1521 if (!typing)
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1522 return 0;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1523 /* XXX We probably should care if this fails. Or maybe we don't want to */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1524 if (!who) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1525 gaim_debug_info("zephyr", "who is null\n");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1526 recipient = local_zephyr_normalize("");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1527 } else {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1528 recipient = local_zephyr_normalize(who);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1529 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1530
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1531 gaim_debug_info("zephyr","about to send typing notification to %s",recipient);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1532 zephyr_send_message("MESSAGE","PERSONAL",recipient,"","","PING");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1533 gaim_debug_info("zephyr","sent typing notification");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1534 return ZEPHYR_TYPING_SEND_TIMEOUT;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1535 }
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1536
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1537
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1538
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1539 static void zephyr_chat_set_topic(GaimConnection * gc, int id, const char *topic)
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1540 {
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1541 zephyr_triple *zt;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1542 GaimConversation *gconv;
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1543 GaimConvChat *gcc;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1544 gchar *topic_utf8;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1545 char *sender = (char *)gaim_zephyr_get_sender();
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1546
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1547 zt = find_sub_by_id(id);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1548 gconv = gaim_find_conversation_with_account(zt->name, zgc->account);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1549 gcc = gaim_conversation_get_chat_data(gconv);
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1550
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1551 topic_utf8 = zephyr_recv_convert((gchar *)topic,strlen(topic));
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1552 gaim_conv_chat_set_topic(gcc,sender,topic_utf8);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1553 g_free(topic_utf8);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1554 return;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1555 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1556
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1557 /* commands */
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1558
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1559 static GaimCmdRet zephyr_gaim_cmd_msg(GaimConversation *conv,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1560 const char *cmd, char **args, char **error)
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1561 {
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1562 char *recipient;
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1563
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1564 if (!g_ascii_strcasecmp(args[0],"*"))
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1565 return GAIM_CMD_RET_FAILED; /* "*" is not a valid argument */
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1566 else
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1567 recipient = local_zephyr_normalize(args[0]);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1568
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1569 if (strlen(recipient) < 1)
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1570 return GAIM_CMD_RET_FAILED; /* a null recipient is a chat message, not an IM */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1571
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1572 if (zephyr_send_message("MESSAGE","PERSONAL",recipient,args[1],zephyr_get_signature(),""))
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1573 return GAIM_CMD_RET_OK;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1574 else
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1575 return GAIM_CMD_RET_FAILED;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1576 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1577
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1578 static GaimCmdRet zephyr_gaim_cmd_zlocate(GaimConversation *conv,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1579 const char *cmd, char **args, char **error)
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1580 {
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1581 zephyr_zloc(zgc,args[0]);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1582 return GAIM_CMD_RET_OK;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1583 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1584
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1585 static GaimCmdRet zephyr_gaim_cmd_instance(GaimConversation *conv,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1586 const char *cmd, char **args, char **error)
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1587 {
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1588 /* Currently it sets the instance with leading spaces and
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1589 * all. This might not be the best thing to do, though having
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1590 * one word isn't ideal either. */
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1591
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1592 GaimConvChat *gc = gaim_conversation_get_chat_data(conv);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1593 int id = gc->id;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1594 const char* instance = args[0];
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1595 zephyr_chat_set_topic(zgc,id,instance);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1596 return GAIM_CMD_RET_OK;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1597 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1598
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1599 static GaimCmdRet zephyr_gaim_cmd_joinchat_cir(GaimConversation *conv,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1600 const char *cmd, char **args, char **error)
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1601 {
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1602 /* Join a new zephyr chat */
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1603 GHashTable *triple = g_hash_table_new(NULL,NULL);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1604 g_hash_table_insert(triple,"class",args[0]);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1605 g_hash_table_insert(triple,"instance",args[1]);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1606 g_hash_table_insert(triple,"recipient",args[2]);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1607 zephyr_join_chat(zgc,triple);
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1608 return GAIM_CMD_RET_OK;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1609 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1610
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1611 static GaimCmdRet zephyr_gaim_cmd_zi(GaimConversation *conv,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1612 const char *cmd, char **args, char **error)
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1613 {
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1614 /* args = instance, message */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1615 if ( zephyr_send_message("message",args[0],"",args[1],zephyr_get_signature(),""))
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1616 return GAIM_CMD_RET_OK;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1617 else
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1618 return GAIM_CMD_RET_FAILED;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1619 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1620
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1621 static GaimCmdRet zephyr_gaim_cmd_zci(GaimConversation *conv,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1622 const char *cmd, char **args, char **error)
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1623 {
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1624 /* args = class, instance, message */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1625 if ( zephyr_send_message(args[0],args[1],"",args[2],zephyr_get_signature(),""))
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1626 return GAIM_CMD_RET_OK;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1627 else
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1628 return GAIM_CMD_RET_FAILED;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1629 }
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1630
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1631 static GaimCmdRet zephyr_gaim_cmd_zcir(GaimConversation *conv,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1632 const char *cmd, char **args, char **error)
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1633 {
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1634 /* args = class, instance, recipient, message */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1635 if ( zephyr_send_message(args[0],args[1],args[2],args[3],zephyr_get_signature(),""))
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1636 return GAIM_CMD_RET_OK;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1637 else
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1638 return GAIM_CMD_RET_FAILED;
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1639 }
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1640
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1641 static GaimCmdRet zephyr_gaim_cmd_zir(GaimConversation *conv,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1642 const char *cmd, char **args, char **error)
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1643 {
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1644 /* args = instance, recipient, message */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1645 if ( zephyr_send_message("message",args[0],args[1],args[2],zephyr_get_signature(),""))
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1646 return GAIM_CMD_RET_OK;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1647 else
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1648 return GAIM_CMD_RET_FAILED;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1649 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1650
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1651 static GaimCmdRet zephyr_gaim_cmd_zc(GaimConversation *conv,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1652 const char *cmd, char **args, char **error)
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1653 {
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1654 /* args = class, message */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1655 if ( zephyr_send_message(args[0],"PERSONAL","",args[1],zephyr_get_signature(),""))
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1656 return GAIM_CMD_RET_OK;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1657 else
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1658 return GAIM_CMD_RET_FAILED;
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1659 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1660
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1661 static void zephyr_register_slash_commands()
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1662 {
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1663
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1664 gaim_cmd_register("msg","ws", GAIM_CMD_P_PRPL,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1665 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1666 "prpl-zephyr",
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1667 zephyr_gaim_cmd_msg, _("msg &lt;nick&gt; &lt;message&gt;: Send a private message to a user"));
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1668
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1669 gaim_cmd_register("zlocate","w", GAIM_CMD_P_PRPL,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1670 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1671 "prpl-zephyr",
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1672 zephyr_gaim_cmd_zlocate, _("zlocate &lt;nick&gt;: Locate user"));
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1673
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1674 gaim_cmd_register("zl","w", GAIM_CMD_P_PRPL,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1675 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1676 "prpl-zephyr",
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1677 zephyr_gaim_cmd_zlocate, _("zl &lt;nick&gt;: Locate user"));
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1678
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1679 gaim_cmd_register("instance","s", GAIM_CMD_P_PRPL,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1680 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1681 "prpl-zephyr",
9437
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
1682 zephyr_gaim_cmd_instance, _("instance &lt;instance&gt;: Set the instance to be used on this class"));
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1683
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1684 gaim_cmd_register("inst","s", GAIM_CMD_P_PRPL,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1685 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1686 "prpl-zephyr",
9437
d9f8658b305d [gaim-migrate @ 10258]
Luke Schierer <lschiere@pidgin.im>
parents: 9434
diff changeset
1687 zephyr_gaim_cmd_instance, _("inst &lt;instance&gt;: Set the instance to be used on this class"));
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1688
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1689 gaim_cmd_register("sub", "www", GAIM_CMD_P_PRPL,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1690 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1691 "prpl-zephyr",
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1692 zephyr_gaim_cmd_joinchat_cir,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1693 _("sub &lt;class&gt; &lt;instance&gt; &lt;recipient&gt;: Join a new chat"));
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1694
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1695 gaim_cmd_register("zi","ws", GAIM_CMD_P_PRPL,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1696 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1697 "prpl-zephyr",
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1698 zephyr_gaim_cmd_zi, _("zi &lt;instance&gt;: Send a message to &lt;message,<i>instance</i>,*&gt;"));
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1699
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1700 gaim_cmd_register("zci","wws",GAIM_CMD_P_PRPL,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1701 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1702 "prpl-zephyr",
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1703 zephyr_gaim_cmd_zci,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1704 _("zci &lt;class&gt; &lt;instance&gt;: Send a message to &lt;<i>class</i>,<i>instance</i>,*&gt;"));
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1705
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1706 gaim_cmd_register("zcir","wwws",GAIM_CMD_P_PRPL,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1707 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1708 "prpl-zephyr",
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1709 zephyr_gaim_cmd_zcir,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1710 _("zcir &lt;class&gt; &lt;instance&gt; &lt;recipient&gt;: Send a message to &lt;<i>class</i>,<i>instance</i>,<i>recipient</i>&gt;"));
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1711
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1712 gaim_cmd_register("zir","wws",GAIM_CMD_P_PRPL,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1713 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1714 "prpl-zephyr",
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1715 zephyr_gaim_cmd_zir,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1716 _("zir &lt;instance&gt; &lt;recipient&gt;: Send a message to &lt;MESSAGE,<i>instance</i>,<i>recipient</i>&gt;"));
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1717
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1718 gaim_cmd_register("zc","ws", GAIM_CMD_P_PRPL,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1719 GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_PRPL_ONLY,
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1720 "prpl-zephyr",
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1721 zephyr_gaim_cmd_zc, _("zc &lt;class&gt;: Send a message to &lt;<i>class</i>,PERSONAL,*&gt;"));
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1722
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1723 }
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1724
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1725
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1726 static int zephyr_resubscribe(GaimConnection *gc)
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1727 {
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1728 /* Resubscribe to the in-memory list of subscriptions and also
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1729 unsubscriptions*/
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1730
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1731 GSList *s = subscrips;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1732 zephyr_triple *zt;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1733 ZSubscription_t zst;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1734 while (s) {
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1735 zt = s->data;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1736 zst.zsub_class = zt->class;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1737 zst.zsub_classinst = zt->instance;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1738 zst.zsub_recipient = zt->recipient;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1739 /* XXX We really should care if this fails */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1740 ZSubscribeTo(&zst, 1, 0);
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1741 s = s->next;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1742 }
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1743 /* XXX handle unsubscriptions */
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1744 return 1;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1745 }
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1746
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1747
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1748 static void zephyr_action_resubscribe(GaimPluginAction *action)
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1749 {
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1750
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1751 GaimConnection *gc = (GaimConnection *) action->context;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1752 zephyr_resubscribe(gc);
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1753 }
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1754
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1755
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1756 static void zephyr_action_get_subs_from_server(GaimPluginAction *action)
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1757 {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1758 GaimConnection *gc = (GaimConnection *) action->context;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1759 gchar *title;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1760 int retval, nsubs, one,i;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1761 ZSubscription_t subs;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1762 GString* subout = g_string_new("Subscription list<br>");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1763
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1764 title = g_strdup_printf("Server subscriptions for %s", gaim_zephyr_get_sender());
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1765
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1766 if (zephyr_port == 0) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1767 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving port");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1768 return;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1769 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1770 if ((retval = ZRetrieveSubscriptions(zephyr_port,&nsubs)) != ZERR_NONE) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1771 /* XXX better error handling */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1772 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving subscriptions from server");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1773 return;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1774 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1775 g_string_append_printf(subout,"Subscription list <br>");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1776 for(i=0;i<nsubs;i++) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1777 one = 1;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1778 if ((retval = ZGetSubscriptions(&subs,&one)) != ZERR_NONE) {
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1779 /* XXX better error handling */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1780 gaim_debug(GAIM_DEBUG_ERROR,"zephyr", "error while retrieving individual subscription");
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1781 return;
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1782 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1783 g_string_append_printf(subout, "Class %s Instance %s Recipient %s<br>",
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1784 subs.zsub_class, subs.zsub_classinst,
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1785 subs.zsub_recipient);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1786 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1787 gaim_notify_formatted(gc, title, title, NULL, subout->str, NULL, NULL);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1788 }
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1789
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1790
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1791 static GList *zephyr_actions(GaimPlugin *plugin, gpointer context)
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1792 {
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1793 GList *list = NULL;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1794 GaimPluginAction *act = NULL;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1795
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1796 act = gaim_plugin_action_new(_("Resubscribe"), zephyr_action_resubscribe);
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1797 list = g_list_append(list, act);
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1798
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1799 act = gaim_plugin_action_new(_("Retrieve subscriptions from server"), zephyr_action_get_subs_from_server);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1800 list = g_list_append(list,act);
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1801
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1802 return list;
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1803 }
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1804
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1805 static GaimPlugin *my_protocol = NULL;
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1806
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1807 static GaimPluginProtocolInfo prpl_info = {
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8713
diff changeset
1808 GAIM_PRPL_API_VERSION,
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1809 OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD,
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1810 NULL, /* ??? user_splits */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1811 NULL, /* ??? protocol_options */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1812 NO_BUDDY_ICONS,
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1813 zephyr_list_icon,
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1814 NULL, /* ??? list_emblems */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1815 NULL, /* ??? status_text */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1816 NULL, /* ??? tooltip_text */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1817 zephyr_away_states, /* away_states */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1818 NULL, /* ??? blist_node_menu - probably all useful actions are already handled*/
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1819 zephyr_chat_info, /* chat_info */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1820 zephyr_login, /* login */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1821 zephyr_close, /* close */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1822 zephyr_send_im, /* send_im */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1823 NULL, /* XXX set info (Location?) */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1824 zephyr_send_typing, /* send_typing */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1825 zephyr_zloc, /* get_info */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1826 zephyr_set_away, /* XXX set_away need to fix */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1827 NULL, /* ??? set idle */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1828 NULL, /* change password */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1829 NULL, /* add_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1830 NULL, /* add_buddies */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1831 NULL, /* remove_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1832 NULL, /* remove_buddies */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1833 NULL, /* add_permit -- not useful, since anyone can zephyr you by default*/
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1834 NULL, /* XXX add deny -- maybe put an auto "I'm ignoring your zephyrs*/
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1835 NULL, /* remove_permit -- not useful, see add permit */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1836 NULL, /* XXX remove deny -- remove above deny, */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1837 NULL, /* ??? set permit deny */
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1838 NULL, /* --- warn */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1839 zephyr_join_chat, /* join_chat */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1840 NULL, /* reject_chat */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1841 NULL, /* chat_invite */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1842 zephyr_chat_leave, /* chat_leave */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1843 NULL, /* chat_whisper */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1844 zephyr_chat_send, /* chat_send */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1845 NULL, /* keepalive */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1846 NULL, /* register_user */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1847 NULL, /* XXX get_cb_info get chat buddy info */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1848 NULL, /* get_cb_away */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1849 NULL, /* alias_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1850 NULL, /* group_buddy */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1851 NULL, /* rename_group */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1852 NULL, /* ??? buddy_free */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1853 NULL, /* convo_closed */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1854 zephyr_normalize, /* normalize */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1855 NULL, /* XXX set_buddy_icon */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1856 NULL, /* remove_group */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1857 NULL, /* XXX get_cb_real_name */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1858 zephyr_chat_set_topic, /* set_chat_topic */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1859 zephyr_find_blist_chat, /* find_blist_chat */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1860 NULL, /* roomlist_get_list */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1861 NULL, /* roomlist_cancel */
9478
0efa260e384f [gaim-migrate @ 10303]
Luke Schierer <lschiere@pidgin.im>
parents: 9475
diff changeset
1862 NULL, /* roomlist_expand_category */
9475
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1863 NULL, /* can_receive_file */
7a65fdba750f [gaim-migrate @ 10300]
Luke Schierer <lschiere@pidgin.im>
parents: 9473
diff changeset
1864 NULL /* send_file */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1865 };
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1866
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1867 static GaimPluginInfo info = {
8749
d7b8eb1f0a18 [gaim-migrate @ 9504]
Christian Hammond <chipx86@chipx86.com>
parents: 8713
diff changeset
1868 GAIM_PLUGIN_API_VERSION, /**< api_version */
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1869 GAIM_PLUGIN_PROTOCOL, /**< type */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1870 NULL, /**< ui_requirement */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1871 0, /**< flags */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1872 NULL, /**< dependencies */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1873 GAIM_PRIORITY_DEFAULT, /**< priority */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1874
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1875 "prpl-zephyr", /**< id */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1876 "Zephyr", /**< name */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1877 VERSION, /**< version */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1878 /** summary */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1879 N_("Zephyr Protocol Plugin"),
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1880 /** description */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1881 N_("Zephyr Protocol Plugin"),
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1882 NULL, /**< author */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1883 GAIM_WEBSITE, /**< homepage */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1884
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1885 NULL, /**< load */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1886 NULL, /**< unload */
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1887 NULL, /**< destroy */
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1888
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1889 NULL, /**< ui_info */
8993
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8954
diff changeset
1890 &prpl_info, /**< extra_info */
294ae6548d4e [gaim-migrate @ 9768]
Luke Schierer <lschiere@pidgin.im>
parents: 8954
diff changeset
1891 NULL,
9427
66b3f54527e6 [gaim-migrate @ 10245]
Luke Schierer <lschiere@pidgin.im>
parents: 9426
diff changeset
1892 zephyr_actions
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1893 };
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1894
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1895 static void init_plugin(GaimPlugin * plugin)
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1896 {
8212
ad164c1ca79d [gaim-migrate @ 8935]
Luke Schierer <lschiere@pidgin.im>
parents: 8170
diff changeset
1897 GaimAccountOption *option;
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1898 char *tmp = get_exposure_level();
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1899
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1900 option = gaim_account_option_bool_new(_("Export to .anyone"), "write_anyone", FALSE);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1901 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
1902
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1903 option = gaim_account_option_bool_new(_("Export to .zephyr.subs"), "write_zsubs", FALSE);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1904 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
1905
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1906 option = gaim_account_option_string_new(_("Exposure"), "exposure_level", tmp ? tmp : EXPOSE_REALMVIS);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1907 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
1908
8644
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1909 option = gaim_account_option_string_new(_("Encoding"), "encoding", ZEPHYR_FALLBACK_CHARSET);
bdc92fcf1277 [gaim-migrate @ 9396]
Mark Doliner <mark@kingant.net>
parents: 8641
diff changeset
1910 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
1911
5205
fefad67de2c7 [gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents: 5202
diff changeset
1912 my_protocol = plugin;
9434
c5cf752acc4a [gaim-migrate @ 10254]
Luke Schierer <lschiere@pidgin.im>
parents: 9427
diff changeset
1913 zephyr_register_slash_commands();
2086
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1914 }
424a40f12a6c [gaim-migrate @ 2096]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1915
5920
7d385de2f9cd [gaim-migrate @ 6360]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1916 GAIM_INIT_PLUGIN(zephyr, init_plugin, info);