annotate plugins/zephyr/zephyr.c @ 1718:20f070721b9f

[gaim-migrate @ 1728] fix for bad password signoff stuff. yeah. committer: Tailor Script <tailor@pidgin.im>
author Eric Warmenhoven <eric@warmenhoven.org>
date Sun, 15 Apr 2001 03:47:50 +0000
parents 1e0fa7e130d0
children 5800449e7ecc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1700
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
2 /*
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
3 * gaim
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
4 *
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
5 * Copyright (C) 1998-2001, Mark Spencer <markster@marko.net>
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
6 * Some code borrowed from GtkZephyr, by
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
7 * Jag/Sean Dilda <agrajag@linuxpower.org>/<smdilda@unity.ncsu.edu>
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
8 * http://gtkzephyr.linuxpower.org/
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
9 *
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
13 * (at your option) any later version.
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
14 *
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
15 * This program is distributed in the hope that it will be useful,
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
18 * GNU General Public License for more details.
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
19 *
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
23 *
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
24 */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
25
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
26 #ifdef HAVE_CONFIG_H
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
27 #include "config.h"
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
28 #endif
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
29
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
30 #include <gtk/gtk.h>
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
31 #include <string.h>
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
32 #include "gaim.h"
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
33 #include "prpl.h"
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
34 #include "zephyr/zephyr.h"
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
35
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
36 char *name()
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
37 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
38 return "Zephyr";
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
39 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
40
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
41 char *description()
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
42 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
43 return "Allows gaim to use the Zephyr protocol";
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
44 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
45
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
46 static char *zephyr_name()
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
47 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
48 return "Zephyr";
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
49 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
50
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
51 #define z_call(func) if (func != ZERR_NONE)\
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
52 return;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
53 #define z_call_r(func) if (func != ZERR_NONE)\
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
54 return TRUE;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
55 #define z_call_s(func, err) if (func != ZERR_NONE) {\
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
56 hide_login_progress(zgc, err);\
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
57 signoff(zgc);\
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
58 return;\
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
59 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
60
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
61 /* this is so bad, and if Zephyr weren't so fucked up to begin with I
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
62 * wouldn't do this. but it is so i will. */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
63 static guint32 nottimer = 0;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
64 static guint32 loctimer = 0;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
65 struct gaim_connection *zgc = NULL;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
66
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
67 /* just for debugging
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
68 static void handle_unknown(ZNotice_t notice)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
69 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
70 g_print("z_packet: %s\n", notice.z_packet);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
71 g_print("z_version: %s\n", notice.z_version);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
72 g_print("z_kind: %d\n", notice.z_kind);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
73 g_print("z_class: %s\n", notice.z_class);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
74 g_print("z_class_inst: %s\n", notice.z_class_inst);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
75 g_print("z_opcode: %s\n", notice.z_opcode);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
76 g_print("z_sender: %s\n", notice.z_sender);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
77 g_print("z_recipient: %s\n", notice.z_recipient);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
78 g_print("z_message: %s\n", notice.z_message);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
79 g_print("z_message_len: %d\n", notice.z_message_len);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
80 g_print("\n");
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
81 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
82 */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
83
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
84 static void handle_message(ZNotice_t notice, struct sockaddr_in from)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
85 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
86 if (!g_strcasecmp(notice.z_class, LOGIN_CLASS)) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
87 /* well, we'll be updating in 2 seconds anyway, might as well ignore this. */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
88 } else if (!g_strcasecmp(notice.z_class, LOCATE_CLASS)) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
89 if (!g_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
90 int nlocs;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
91 char *user;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
92 struct buddy *b;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
93
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
94 if (ZParseLocations(&notice, NULL, &nlocs, &user) != ZERR_NONE)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
95 return;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
96 if ((b = find_buddy(zgc, user)) == NULL) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
97 char *e = strchr(user, '@');
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
98 if (e) *e = '\0';
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
99 b = find_buddy(zgc, user);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
100 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
101 if (!b) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
102 free(user);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
103 return;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
104 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
105 serv_got_update(zgc, b->name, nlocs, 0, 0, 0, 0, 0);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
106
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
107 free(user);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
108 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
109 } else if (!g_strcasecmp(notice.z_class, "MESSAGE")) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
110 char buf[BUF_LONG];
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
111 char *ptr = notice.z_message + strlen(notice.z_message) + 1;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
112 int len = notice.z_message_len - (ptr - notice.z_message);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
113 if (len > 0) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
114 g_snprintf(buf, len + 1, "%s", ptr);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
115 g_strchomp(buf);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
116 serv_got_im(zgc, notice.z_sender, buf, 0);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
117 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
118 } else {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
119 /* yes. */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
120 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
121 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
122
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
123 static gint check_notify(gpointer data)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
124 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
125 while (ZPending()) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
126 ZNotice_t notice;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
127 struct sockaddr_in from;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
128 z_call_r(ZReceiveNotice(&notice, &from));
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
129
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
130 switch (notice.z_kind) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
131 case UNSAFE:
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
132 case UNACKED:
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
133 case ACKED:
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
134 handle_message(notice, from);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
135 break;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
136 default:
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
137 /* we'll just ignore things for now */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
138 debug_printf("ZEPHYR: Unhandled Notice\n");
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
139 break;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
140 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
141
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
142 ZFreeNotice(&notice);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
143 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
144
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
145 return TRUE;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
146 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
147
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
148 static gint check_loc(gpointer data)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
149 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
150 GSList *gr, *m;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
151 ZAsyncLocateData_t ald;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
152
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
153 ald.user = NULL;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
154 memset(&(ald.uid), 0, sizeof(ZUnique_Id_t));
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
155 ald.version = NULL;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
156
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
157 gr = zgc->groups;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
158 while (gr) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
159 struct group *g = gr->data;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
160 m = g->members;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
161 while (m) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
162 struct buddy *b = m->data;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
163 char *chk;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
164 if (!strchr(b->name, '@'))
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
165 chk = g_strdup_printf("%s@%s", b->name, ZGetRealm());
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
166 else
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
167 chk = g_strdup(b->name);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
168 /* doesn't matter if this fails or not; we'll just move on to the next one */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
169 ZRequestLocations(chk, &ald, UNACKED, ZAUTH);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
170 g_free(chk);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
171 m = m->next;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
172 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
173 gr = gr->next;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
174 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
175
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
176 return TRUE;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
177 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
178
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
179 static char *get_exposure_level()
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
180 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
181 char *exposure = ZGetVariable("exposure");
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
182
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
183 if (!exposure)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
184 return EXPOSE_REALMVIS;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
185 if (!g_strcasecmp(exposure, EXPOSE_NONE))
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
186 return EXPOSE_NONE;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
187 if (!g_strcasecmp(exposure, EXPOSE_OPSTAFF))
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
188 return EXPOSE_OPSTAFF;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
189 if (!g_strcasecmp(exposure, EXPOSE_REALMANN))
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
190 return EXPOSE_REALMANN;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
191 if (!g_strcasecmp(exposure, EXPOSE_NETVIS))
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
192 return EXPOSE_NETVIS;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
193 if (!g_strcasecmp(exposure, EXPOSE_NETANN))
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
194 return EXPOSE_NETANN;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
195 return EXPOSE_REALMVIS;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
196 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
197
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
198 static void strip_comments(char *str)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
199 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
200 char *tmp = strchr(str, '#');
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
201 if (tmp)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
202 *tmp = '\0';
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
203 g_strchug(str);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
204 g_strchomp(str);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
205 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
206
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
207 static void process_anyone()
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
208 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
209 FILE *fd;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
210 gchar buff[BUFSIZ], *filename;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
211
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
212 filename = g_strconcat(g_get_home_dir(), "/.anyone", NULL);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
213 if ((fd = fopen(filename, "r")) != NULL) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
214 while (fgets(buff, BUFSIZ, fd)) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
215 strip_comments(buff);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
216 if (buff[0])
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
217 add_buddy(zgc, "Anyone", buff, buff);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
218 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
219 fclose(fd);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
220 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
221 g_free(filename);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
222 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
223
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
224 static void zephyr_login(struct aim_user *user)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
225 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
226 ZSubscription_t sub;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
227
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
228 if (zgc) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
229 do_error_dialog("Already logged in with Zephyr", "Zephyr");
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
230 return;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
231 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
232
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
233 zgc = new_gaim_conn(user);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
234
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
235 z_call_s(ZInitialize(), "Couldn't initialize zephyr");
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
236 z_call_s(ZOpenPort(NULL), "Couldn't open port");
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
237 z_call_s(ZSetLocation(get_exposure_level()), "Couldn't set location");
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
238
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
239 sub.zsub_class = "MESSAGE";
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
240 sub.zsub_classinst = "PERSONAL";
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
241 sub.zsub_recipient = ZGetSender();
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
242
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
243 /* we don't care if this fails. i'm lying right now. */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
244 ZSubscribeTo(&sub, 1, 0);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
245
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
246 account_online(zgc);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
247 serv_finish_login(zgc);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
248
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
249 if (bud_list_cache_exists(zgc))
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
250 do_import(NULL, zgc);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
251 process_anyone();
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
252 /* should also process .zephyr.subs */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
253
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
254 nottimer = gtk_timeout_add(100, check_notify, NULL);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
255 loctimer = gtk_timeout_add(2000, check_loc, NULL);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
256 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
257
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
258 static void zephyr_close(struct gaim_connection *gc)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
259 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
260 /* should probably write .anyone, but eh. we all use gaim exclusively, right? :-P */
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
261 if (nottimer)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
262 gtk_timeout_remove(nottimer);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
263 nottimer = 0;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
264 if (loctimer)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
265 gtk_timeout_remove(loctimer);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
266 loctimer = 0;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
267 zgc = NULL;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
268 z_call(ZCancelSubscriptions(0));
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
269 z_call(ZUnsetLocation());
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
270 z_call(ZClosePort());
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
271 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
272
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
273 static void zephyr_add_buddy(struct gaim_connection *gc, char *buddy) { }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
274 static void zephyr_remove_buddy(struct gaim_connection *gc, char *buddy) { }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
275
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
276 static void zephyr_send_im(struct gaim_connection *gc, char *who, char *im, int away) {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
277 ZNotice_t notice;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
278
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
279 bzero((char *)&notice, sizeof(notice));
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
280 notice.z_kind = ACKED;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
281 notice.z_port = 0;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
282 notice.z_opcode = "";
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
283 notice.z_class = "MESSAGE";
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
284 notice.z_class_inst = "PERSONAL";
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
285 notice.z_sender = 0;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
286 notice.z_recipient = who;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
287 notice.z_default_format =
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
288 "Class $class, Instance $instance:\nTo: @bold($recipient) at $time $date\n$message";
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
289 notice.z_message_len = strlen(im) + 1;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
290 notice.z_message = im;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
291 ZSendNotice(&notice, ZAUTH);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
292 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
293
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
294 static struct prpl *my_protocol = NULL;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
295
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
296 void zephyr_init(struct prpl *ret)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
297 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
298 ret->protocol = PROTO_ZEPHYR;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
299 ret->name = zephyr_name;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
300 ret->login = zephyr_login;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
301 ret->close = zephyr_close;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
302 ret->add_buddy = zephyr_add_buddy;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
303 ret->remove_buddy = zephyr_remove_buddy;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
304 ret->send_im = zephyr_send_im;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
305
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
306 my_protocol = ret;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
307 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
308
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
309 char *gaim_plugin_init(GModule *handle)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
310 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
311 load_protocol(zephyr_init, sizeof(struct prpl));
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
312 return NULL;
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
313 }
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
314
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
315 void gaim_plugin_remove()
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
316 {
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
317 struct prpl *p = find_prpl(PROTO_ZEPHYR);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
318 if (p == my_protocol)
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
319 unload_protocol(p);
1e0fa7e130d0 [gaim-migrate @ 1710]
Eric Warmenhoven <eric@warmenhoven.org>
parents:
diff changeset
320 }