Sat, 06 Feb 2021 01:41:47 -0600
Use more get_paren_level
Deduplicate code.
Testing Done:
Compile.
Reviewed at https://reviews.imfreedom.org/r/480/
| 14520 | 1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
| 2086 | 2 | /* |
| 15884 | 3 | * purple |
| 2086 | 4 | * |
| 5 | * Copyright (C) 1998-2001, Mark Spencer <markster@marko.net> | |
| 6 | * Some code borrowed from GtkZephyr, by | |
|
7084
da83f7ead5c6
[gaim-migrate @ 7649]
Christian Hammond <chipx86@chipx86.com>
parents:
7070
diff
changeset
|
7 | * Jag/Sean Dilda <agrajag@linuxpower.org>/<smdilda@unity.ncsu.edu> |
|
da83f7ead5c6
[gaim-migrate @ 7649]
Christian Hammond <chipx86@chipx86.com>
parents:
7070
diff
changeset
|
8 | * http://gtkzephyr.linuxpower.org/ |
| 2086 | 9 | * |
| 9896 | 10 | * Some code borrowed from kzephyr, by |
| 11 | * Chris Colohan <colohan+@cs.cmu.edu> | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
12 | * |
| 2086 | 13 | * This program is free software; you can redistribute it and/or modify |
| 14 | * it under the terms of the GNU General Public License as published by | |
| 15 | * the Free Software Foundation; either version 2 of the License, or | |
| 16 | * (at your option) any later version. | |
| 17 | * | |
| 18 | * This program is distributed in the hope that it will be useful, | |
| 19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 9896 | 20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 2086 | 21 | * GNU General Public License for more details. |
| 22 | * | |
| 23 | * You should have received a copy of the GNU General Public License | |
| 24 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19832
diff
changeset
|
25 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 2086 | 26 | * |
| 9896 | 27 | |
| 28 | */ | |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
29 | |
|
40441
f23c7e772667
Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
30 | #include <glib/gi18n-lib.h> |
|
f23c7e772667
Make sure we're not including the gettext macros in header files and deal with the repercussions of that.
Gary Kramlich <grim@reaperworld.com>
parents:
40439
diff
changeset
|
31 | |
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
32 | #include <glib.h> |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
33 | #include <glib/gstdio.h> |
| 2086 | 34 | |
|
40358
e6fe6fc1f516
move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents:
40161
diff
changeset
|
35 | #include <purple.h> |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
36 | |
| 9478 | 37 | #include "internal.h" |
|
36600
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
38 | #include "zephyr.h" |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
39 | #include "zephyr_account.h" |
|
40681
675b8605dca2
Move zephyr<->html conversion to own module
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40672
diff
changeset
|
40 | #include "zephyr_html.h" |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
41 | #include "zephyr_tzc.h" |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
42 | #include "zephyr_zeph02.h" |
|
5872
754c63f29b77
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5717
diff
changeset
|
43 | |
| 8560 | 44 | #define ZEPHYR_FALLBACK_CHARSET "ISO-8859-1" |
| 45 | ||
|
40439
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
46 | #define BUF_LEN (2048) |
|
e9838d634d5e
Make sure that internal.h can only be included by libpurple and split out some pieces to purpleprivate.h
Gary Kramlich <grim@reaperworld.com>
parents:
40358
diff
changeset
|
47 | |
| 9478 | 48 | /* these are deliberately high, since most people don't send multiple "PING"s */ |
| 49 | #define ZEPHYR_TYPING_SEND_TIMEOUT 15 | |
| 50 | #define ZEPHYR_TYPING_RECV_TIMEOUT 10 | |
| 51 | ||
|
36600
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
52 | static PurpleProtocol *my_protocol = NULL; |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
53 | static GSList *cmds = NULL; |
|
36600
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
54 | |
|
40633
d884c4b6e202
Fix build with external libzephyr.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40622
diff
changeset
|
55 | #ifdef LIBZEPHYR_EXT |
|
d884c4b6e202
Fix build with external libzephyr.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40622
diff
changeset
|
56 | extern char __Zephyr_realm[]; |
|
d884c4b6e202
Fix build with external libzephyr.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40622
diff
changeset
|
57 | #endif |
|
d884c4b6e202
Fix build with external libzephyr.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40622
diff
changeset
|
58 | |
| 2086 | 59 | typedef struct _zephyr_triple zephyr_triple; |
| 60 | ||
|
40698
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
61 | typedef gboolean (*ZephyrLoginFunc)(zephyr_account *zephyr); |
| 9896 | 62 | |
| 2086 | 63 | struct _zephyr_triple { |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
64 | ZSubscription_t sub; |
| 2086 | 65 | char *name; |
| 66 | gboolean open; | |
| 67 | int id; | |
| 68 | }; | |
| 69 | ||
| 10867 | 70 | #ifdef WIN32 |
| 71 | extern const char *username; | |
| 72 | #endif | |
| 9896 | 73 | |
|
40715
206563c8b5c6
zephyr_tzc_escape_msg and zephyr_tzc_deescape_str refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40708
diff
changeset
|
74 | static void zephyr_chat_set_topic(PurpleConnection *gc, int id, const char *topic); |
|
40702
d036174d9e22
zephyr_subscribe_to refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40701
diff
changeset
|
75 | |
|
40662
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
76 | static char * |
|
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
77 | zephyr_strip_local_realm(const zephyr_account *zephyr, const char *user) |
|
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
78 | { |
| 9896 | 79 | /* |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
80 | Takes in a username of the form username or username@realm |
| 9896 | 81 | and returns: |
| 82 | username, if there is no realm, or the realm is the local realm | |
| 83 | or: | |
| 84 | username@realm if there is a realm and it is foreign | |
| 85 | */ | |
|
40635
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
86 | char *at = strchr(user, '@'); |
| 9896 | 87 | if (at && !g_ascii_strcasecmp(at+1,zephyr->realm)) { |
| 9328 | 88 | /* We're passed in a username of the form user@users-realm */ |
|
40635
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
89 | return g_strndup(user, at - user); |
| 9328 | 90 | } |
| 91 | else { | |
| 92 | /* We're passed in a username of the form user or user@foreign-realm */ | |
|
40635
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
93 | return g_strdup(user); |
| 9328 | 94 | } |
| 95 | } | |
| 2086 | 96 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
97 | static zephyr_triple * |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
98 | zephyr_triple_new(zephyr_account *zephyr, const ZSubscription_t *sub) |
| 2086 | 99 | { |
| 100 | zephyr_triple *zt; | |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
101 | |
| 2086 | 102 | zt = g_new0(zephyr_triple, 1); |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
103 | zt->sub.zsub_class = g_strdup(sub->zsub_class); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
104 | zt->sub.zsub_classinst = g_strdup(sub->zsub_classinst); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
105 | zt->sub.zsub_recipient = g_strdup(sub->zsub_recipient); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
106 | zt->name = g_strdup_printf("%s,%s,%s", sub->zsub_class, |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
107 | sub->zsub_classinst ? sub->zsub_classinst : "", |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
108 | sub->zsub_recipient ? sub->zsub_recipient : ""); |
| 9610 | 109 | zt->id = ++(zephyr->last_id); |
| 2086 | 110 | zt->open = FALSE; |
| 111 | return zt; | |
| 112 | } | |
| 113 | ||
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
114 | static void |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
115 | zephyr_triple_free(zephyr_triple *zt) |
| 2086 | 116 | { |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
117 | g_free(zt->sub.zsub_class); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
118 | g_free(zt->sub.zsub_classinst); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
119 | g_free(zt->sub.zsub_recipient); |
| 2086 | 120 | g_free(zt->name); |
| 121 | g_free(zt); | |
| 122 | } | |
| 123 | ||
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
124 | /* returns 0 if sub is a subset of zt.sub. This function is used to |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
125 | determine whether a zephyr sent to sub should be placed in the chat |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
126 | with triple zt.sub |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
127 | |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
128 | sub is a subset of zt.sub |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
129 | iff. the classnames are identical ignoring case |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
130 | AND. the instance names are identical (ignoring case), or zt.sub->instance is *. |
| 9328 | 131 | AND. the recipient names are identical |
| 132 | */ | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
133 | static gint |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
134 | zephyr_triple_subset(const zephyr_triple *zt, const ZSubscription_t *sub) |
| 2086 | 135 | { |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
136 | if (!sub->zsub_class) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
137 | purple_debug_error("zephyr", "sub1c doesn't exist\n"); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
138 | return 1; |
|
13454
10592212bb27
[gaim-migrate @ 15828]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
13297
diff
changeset
|
139 | } |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
140 | if (!sub->zsub_classinst) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
141 | purple_debug_error("zephyr", "sub1i doesn't exist\n"); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
142 | return 1; |
|
13454
10592212bb27
[gaim-migrate @ 15828]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
13297
diff
changeset
|
143 | } |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
144 | if (!sub->zsub_recipient) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
145 | purple_debug_error("zephyr", "sub1r doesn't exist\n"); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
146 | return 1; |
|
13454
10592212bb27
[gaim-migrate @ 15828]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
13297
diff
changeset
|
147 | } |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
148 | if (!zt->sub.zsub_class) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
149 | purple_debug_error("zephyr", "sub2c doesn't exist\n"); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
150 | return 1; |
|
13454
10592212bb27
[gaim-migrate @ 15828]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
13297
diff
changeset
|
151 | } |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
152 | if (!zt->sub.zsub_classinst) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
153 | purple_debug_error("zephyr", "sub2i doesn't exist\n"); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
154 | return 1; |
| 2086 | 155 | } |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
156 | if (!zt->sub.zsub_recipient) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
157 | purple_debug_error("zephyr", "sub2r doesn't exist\n"); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
158 | return 1; |
| 2086 | 159 | } |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
160 | |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
161 | if (g_ascii_strcasecmp(zt->sub.zsub_class, sub->zsub_class)) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
162 | return 1; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
163 | } |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
164 | if (g_ascii_strcasecmp(zt->sub.zsub_classinst, sub->zsub_classinst) && g_ascii_strcasecmp(zt->sub.zsub_classinst, "*")) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
165 | return 1; |
| 2086 | 166 | } |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
167 | if (g_ascii_strcasecmp(zt->sub.zsub_recipient, sub->zsub_recipient)) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
168 | return 1; |
| 2086 | 169 | } |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
170 | purple_debug_info("zephyr", "<%s,%s,%s> is in <%s,%s,%s>\n", |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
171 | sub->zsub_class, sub->zsub_classinst, sub->zsub_recipient, |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
172 | zt->sub.zsub_class, zt->sub.zsub_classinst, zt->sub.zsub_recipient); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
173 | return 0; |
| 2086 | 174 | } |
| 175 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
176 | /* |
| 9434 | 177 | Converts strings to utf-8 if necessary using user specified encoding |
| 9328 | 178 | */ |
| 179 | ||
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
180 | static gchar * |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
181 | convert_to_utf8(const gchar *string, const gchar *from_encoding) |
| 8560 | 182 | { |
| 183 | gchar *utf8; | |
| 184 | GError *err = NULL; | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
185 | |
| 24808 | 186 | if (g_utf8_validate(string, -1, NULL)) { |
|
8568
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8562
diff
changeset
|
187 | return g_strdup(string); |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
188 | } |
|
8568
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8562
diff
changeset
|
189 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
190 | utf8 = g_convert(string, -1, "UTF-8", from_encoding, NULL, NULL, &err); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
191 | if (err) { |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
192 | purple_debug_error("zephyr", "recv conversion error: %s\n", err->message); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
193 | utf8 = g_strdup(_("(There was an error converting this message. Check the 'Encoding' option in the Account Editor)")); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
194 | g_error_free(err); |
|
8568
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8562
diff
changeset
|
195 | } |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
196 | |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
197 | return utf8; |
| 8560 | 198 | } |
| 199 | ||
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
200 | gboolean |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
201 | pending_zloc(zephyr_account *zephyr, const char *who) |
| 2086 | 202 | { |
| 203 | GList *curr; | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
204 | char* normalized_who = zephyr_normalize_local_realm(zephyr, who); |
|
40043
90446617d967
Use GList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39970
diff
changeset
|
205 | |
|
90446617d967
Use GList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39970
diff
changeset
|
206 | curr = g_list_find_custom(zephyr->pending_zloc_names, normalized_who, (GCompareFunc)g_ascii_strcasecmp); |
| 40045 | 207 | g_free(normalized_who); |
|
40043
90446617d967
Use GList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39970
diff
changeset
|
208 | if (curr == NULL) |
|
90446617d967
Use GList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39970
diff
changeset
|
209 | return FALSE; |
|
90446617d967
Use GList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39970
diff
changeset
|
210 | |
|
90446617d967
Use GList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39970
diff
changeset
|
211 | g_free((char *)curr->data); |
|
90446617d967
Use GList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39970
diff
changeset
|
212 | zephyr->pending_zloc_names = g_list_delete_link(zephyr->pending_zloc_names, curr); |
|
90446617d967
Use GList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39970
diff
changeset
|
213 | return TRUE; |
| 2086 | 214 | } |
| 215 | ||
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
216 | PurpleBuddy * |
|
40672
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
217 | find_buddy(const zephyr_account *zephyr, const char *user) |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
218 | { |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
219 | PurpleBuddy *buddy = purple_blist_find_buddy(zephyr->account, user); |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
220 | |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
221 | if (buddy == NULL) { |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
222 | char *stripped_user = zephyr_strip_local_realm(zephyr, user); |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
223 | buddy = purple_blist_find_buddy(zephyr->account, stripped_user); |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
224 | g_free(stripped_user); |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
225 | } |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
226 | |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
227 | return buddy; |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
228 | } |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
229 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
230 | static void |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
231 | zephyr_triple_open(zephyr_triple *zt, PurpleConnection *gc, const char *instance) |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
232 | { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
233 | zt->open = TRUE; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
234 | purple_serv_got_joined_chat(gc, zt->id, zt->name); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
235 | zephyr_chat_set_topic(gc, zt->id, instance); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
236 | } |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
237 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
238 | void |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
239 | handle_message(PurpleConnection *gc, ZNotice_t *notice_p) |
| 2086 | 240 | { |
|
35993
bd0a2508b477
Fix some other coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35966
diff
changeset
|
241 | ZNotice_t notice; |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
242 | zephyr_account* zephyr = purple_connection_get_protocol_data(gc); |
| 9896 | 243 | |
|
35993
bd0a2508b477
Fix some other coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35966
diff
changeset
|
244 | memcpy(¬ice, notice_p, sizeof(notice)); /* TODO - use pointer? */ |
|
bd0a2508b477
Fix some other coverity warnings
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35966
diff
changeset
|
245 | |
| 4793 | 246 | if (!g_ascii_strcasecmp(notice.z_class, LOGIN_CLASS)) { |
| 3277 | 247 | /* well, we'll be updating in 20 seconds anyway, might as well ignore this. */ |
| 4793 | 248 | } else if (!g_ascii_strcasecmp(notice.z_class, LOCATE_CLASS)) { |
| 249 | if (!g_ascii_strcasecmp(notice.z_opcode, LOCATE_LOCATE)) { | |
| 2086 | 250 | int nlocs; |
| 251 | char *user; | |
| 15884 | 252 | PurpleBuddy *b; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23352
diff
changeset
|
253 | const char *bname; |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
254 | const gchar *name; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23352
diff
changeset
|
255 | |
| 9478 | 256 | /* XXX add real error reporting */ |
| 2086 | 257 | if (ZParseLocations(¬ice, NULL, &nlocs, &user) != ZERR_NONE) |
| 258 | return; | |
| 8435 | 259 | |
|
40672
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
260 | b = find_buddy(zephyr, user); |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23352
diff
changeset
|
261 | bname = b ? purple_buddy_get_name(b) : NULL; |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
262 | name = b ? bname : user; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23352
diff
changeset
|
263 | if ((b && pending_zloc(zephyr,bname)) || pending_zloc(zephyr,user)) { |
| 15884 | 264 | PurpleNotifyUserInfo *user_info = purple_notify_user_info_new(); |
|
24950
143f594f0cd0
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24945
diff
changeset
|
265 | const char *balias; |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
266 | |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
267 | /* TODO: Check whether it's correct to call add_pair_html, |
|
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
268 | or if we should be using add_pair_plaintext */ |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
269 | purple_notify_user_info_add_pair_html(user_info, _("User"), name); |
|
34717
b3e588adef5a
Global replace purple_buddy_get_local_buddy_alias() with purple_buddy_get_local_alias()
Ankit Vani <a@nevitus.org>
parents:
34699
diff
changeset
|
270 | balias = purple_buddy_get_local_alias(b); |
|
24950
143f594f0cd0
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24945
diff
changeset
|
271 | if (b && balias) |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
272 | purple_notify_user_info_add_pair_plaintext(user_info, _("Alias"), balias); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15185
diff
changeset
|
273 | |
| 2086 | 274 | if (!nlocs) { |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
275 | purple_notify_user_info_add_pair_plaintext(user_info, NULL, _("Hidden or not logged-in")); |
| 2086 | 276 | } |
| 277 | for (; nlocs > 0; nlocs--) { | |
| 9478 | 278 | /* XXX add real error reporting */ |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
279 | ZLocations_t locs; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
280 | int one = 1; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
281 | char *tmp; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
282 | |
| 2086 | 283 | ZGetLocations(&locs, &one); |
|
32188
cb9cad610bc6
I went through all our calls to purple_notify_user_info_add_pair() and
Mark Doliner <markdoliner@pidgin.im>
parents:
32157
diff
changeset
|
284 | /* TODO: Need to escape locs.host and locs.time? */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
285 | tmp = g_strdup_printf(_("<br>At %s since %s"), locs.host, locs.time); |
|
32191
a4668d9dc8d1
Rename purple_notify_user_info_add_pair to
Mark Doliner <markdoliner@pidgin.im>
parents:
32190
diff
changeset
|
286 | purple_notify_user_info_add_pair_html(user_info, _("Location"), tmp); |
|
15205
f642029b2f97
[gaim-migrate @ 17929]
Evan Schoenberg <evands@pidgin.im>
parents:
15185
diff
changeset
|
287 | g_free(tmp); |
| 2086 | 288 | } |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
289 | purple_notify_userinfo(gc, name, user_info, NULL, NULL); |
| 15884 | 290 | purple_notify_user_info_destroy(user_info); |
| 9986 | 291 | } else { |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
292 | purple_protocol_got_user_status(purple_connection_get_account(gc), name, (nlocs > 0) ? "available" : "offline", NULL); |
|
10038
3589c2eed81c
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
293 | } |
| 2086 | 294 | |
| 9434 | 295 | g_free(user); |
| 2086 | 296 | } |
| 297 | } else { | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
298 | char *buf; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
299 | int len; |
|
24807
699a4dc72c49
A Warmenhoved patch from rwbarton to avoid showing the default instance
Richard Laager <rlaager@pidgin.im>
parents:
24806
diff
changeset
|
300 | char *stripped_sender; |
| 9478 | 301 | int signature_length = strlen(notice.z_message); |
| 8560 | 302 | |
| 9478 | 303 | /* Need to deal with 0 length messages to handle typing notification (OPCODE) ping messages */ |
| 15884 | 304 | /* One field zephyrs would have caused purple to crash */ |
| 9478 | 305 | if ( (notice.z_message_len == 0) || (signature_length >= notice.z_message_len - 1)) { |
| 306 | len = 0; | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
307 | buf = g_strdup(""); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
308 | |
| 9478 | 309 | } else { |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
310 | char *tmpbuf; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
311 | char *ptr = (char *) notice.z_message + (strlen(notice.z_message) + 1); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
312 | gchar *tmpescape; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
313 | |
| 9478 | 314 | len = notice.z_message_len - ( signature_length +1); |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
315 | tmpbuf = g_malloc(len + 1); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
316 | g_snprintf(tmpbuf, len + 1, "%s", ptr); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
317 | g_strchomp(tmpbuf); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
318 | tmpescape = g_markup_escape_text(tmpbuf, -1); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
319 | g_free(tmpbuf); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
320 | tmpbuf = zephyr_to_html(tmpescape); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
321 | buf = convert_to_utf8(tmpbuf, zephyr->encoding); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
322 | g_free(tmpbuf); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
323 | g_free(tmpescape); |
| 9478 | 324 | } |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
325 | purple_debug_info("zephyr", "message_size %d %d %d", len, notice.z_message_len, signature_length); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
326 | |
|
24807
699a4dc72c49
A Warmenhoved patch from rwbarton to avoid showing the default instance
Richard Laager <rlaager@pidgin.im>
parents:
24806
diff
changeset
|
327 | stripped_sender = zephyr_strip_local_realm(zephyr,notice.z_sender); |
|
699a4dc72c49
A Warmenhoved patch from rwbarton to avoid showing the default instance
Richard Laager <rlaager@pidgin.im>
parents:
24806
diff
changeset
|
328 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
329 | if (!g_ascii_strcasecmp(notice.z_class, "MESSAGE") && !g_ascii_strcasecmp(notice.z_class_inst, "PERSONAL") |
| 9896 | 330 | && !g_ascii_strcasecmp(notice.z_recipient,zephyr->username)) { |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
331 | PurpleMessageFlags flags = 0; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
332 | |
| 9896 | 333 | if (!g_ascii_strcasecmp(notice.z_message, "Automated reply:")) |
| 15884 | 334 | flags |= PURPLE_MESSAGE_AUTO_RESP; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
335 | |
| 9478 | 336 | if (!g_ascii_strcasecmp(notice.z_opcode,"PING")) |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35005
diff
changeset
|
337 | purple_serv_got_typing(gc,stripped_sender,ZEPHYR_TYPING_RECV_TIMEOUT, PURPLE_IM_TYPING); |
|
22391
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
338 | else |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
339 | purple_serv_got_im(gc, stripped_sender, buf, flags, time(NULL)); |
| 9896 | 340 | |
| 341 | } else { | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
342 | ZSubscription_t sub = { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
343 | .zsub_class = notice.z_class, |
|
40737
611ae5d8a232
Fix some new warnings in zephyr.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40733
diff
changeset
|
344 | .zsub_classinst = (gchar *)notice.z_class_inst, |
|
611ae5d8a232
Fix some new warnings in zephyr.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40733
diff
changeset
|
345 | .zsub_recipient = (gchar *)notice.z_recipient |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
346 | }; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
347 | zephyr_triple *zt; |
| 9896 | 348 | gchar *send_inst_utf8; |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
349 | GSList *l = g_slist_find_custom(zephyr->subscrips, &sub, (GCompareFunc)zephyr_triple_subset); |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
350 | PurpleChatConversation *gcc; |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
351 | |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
352 | if (!l) { |
| 9896 | 353 | /* This is a server supplied subscription */ |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
354 | zt = zephyr_triple_new(zephyr, &sub); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
355 | zephyr->subscrips = g_slist_append(zephyr->subscrips, zt); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
356 | } else { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
357 | zt = l->data; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
358 | } |
|
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
359 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
360 | if (!zt->open) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
361 | zephyr_triple_open(zt, gc, notice.z_class_inst); |
| 9896 | 362 | } |
|
24807
699a4dc72c49
A Warmenhoved patch from rwbarton to avoid showing the default instance
Richard Laager <rlaager@pidgin.im>
parents:
24806
diff
changeset
|
363 | |
|
699a4dc72c49
A Warmenhoved patch from rwbarton to avoid showing the default instance
Richard Laager <rlaager@pidgin.im>
parents:
24806
diff
changeset
|
364 | if (!g_ascii_strcasecmp(notice.z_class_inst,"PERSONAL")) |
|
699a4dc72c49
A Warmenhoved patch from rwbarton to avoid showing the default instance
Richard Laager <rlaager@pidgin.im>
parents:
24806
diff
changeset
|
365 | send_inst_utf8 = g_strdup(stripped_sender); |
|
699a4dc72c49
A Warmenhoved patch from rwbarton to avoid showing the default instance
Richard Laager <rlaager@pidgin.im>
parents:
24806
diff
changeset
|
366 | else { |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
367 | char *send_inst = g_strdup_printf("[%s] %s", notice.z_class_inst, stripped_sender); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
368 | send_inst_utf8 = convert_to_utf8(send_inst, zephyr->encoding); |
|
24807
699a4dc72c49
A Warmenhoved patch from rwbarton to avoid showing the default instance
Richard Laager <rlaager@pidgin.im>
parents:
24806
diff
changeset
|
369 | g_free(send_inst); |
|
699a4dc72c49
A Warmenhoved patch from rwbarton to avoid showing the default instance
Richard Laager <rlaager@pidgin.im>
parents:
24806
diff
changeset
|
370 | if (!send_inst_utf8) { |
|
699a4dc72c49
A Warmenhoved patch from rwbarton to avoid showing the default instance
Richard Laager <rlaager@pidgin.im>
parents:
24806
diff
changeset
|
371 | purple_debug_error("zephyr","Failed to convert instance for sender %s.\n", stripped_sender); |
|
699a4dc72c49
A Warmenhoved patch from rwbarton to avoid showing the default instance
Richard Laager <rlaager@pidgin.im>
parents:
24806
diff
changeset
|
372 | send_inst_utf8 = g_strdup(stripped_sender); |
|
699a4dc72c49
A Warmenhoved patch from rwbarton to avoid showing the default instance
Richard Laager <rlaager@pidgin.im>
parents:
24806
diff
changeset
|
373 | } |
| 2086 | 374 | } |
| 9912 | 375 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
376 | gcc = purple_conversations_find_chat_with_account(zt->name, purple_connection_get_account(gc)); |
|
34653
88ae47a7d595
Updated protocols for the API changes
Ankit Vani <a@nevitus.org>
parents:
34643
diff
changeset
|
377 | if (!purple_chat_conversation_has_user(gcc, stripped_sender)) { |
|
40643
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40635
diff
changeset
|
378 | GInetAddress *inet_addr = NULL; |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40635
diff
changeset
|
379 | gchar *ipaddr = NULL; |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40635
diff
changeset
|
380 | |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40635
diff
changeset
|
381 | inet_addr = g_inet_address_new_from_bytes( |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40635
diff
changeset
|
382 | (const guint8 *)¬ice.z_sender_addr, |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40635
diff
changeset
|
383 | G_SOCKET_FAMILY_IPV4); |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40635
diff
changeset
|
384 | ipaddr = g_inet_address_to_string(inet_addr); |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40635
diff
changeset
|
385 | purple_chat_conversation_add_user(gcc, stripped_sender, ipaddr, |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40635
diff
changeset
|
386 | PURPLE_CHAT_USER_NONE, TRUE); |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40635
diff
changeset
|
387 | g_free(ipaddr); |
|
1c9bdf8d3e85
Convert zephyr to gio
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40635
diff
changeset
|
388 | g_object_unref(inet_addr); |
| 9896 | 389 | } |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
390 | purple_serv_got_chat_in(gc, zt->id, send_inst_utf8, |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
391 | PURPLE_MESSAGE_RECV, buf, time(NULL)); |
| 9896 | 392 | g_free(send_inst_utf8); |
| 393 | } | |
|
24807
699a4dc72c49
A Warmenhoved patch from rwbarton to avoid showing the default instance
Richard Laager <rlaager@pidgin.im>
parents:
24806
diff
changeset
|
394 | g_free(stripped_sender); |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
395 | g_free(buf); |
| 9896 | 396 | } |
| 397 | } | |
| 398 | ||
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
399 | static void |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
400 | check_loc_buddy(PurpleBuddy *buddy, zephyr_account *zephyr) |
|
40686
fa1a8ad13da4
Use GNode instead of parse_tree
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40681
diff
changeset
|
401 | { |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
402 | const char *bname = purple_buddy_get_name(buddy); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
403 | char *chk = zephyr_normalize_local_realm(zephyr, bname); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
404 | #ifdef WIN32 |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
405 | int numlocs; |
| 9896 | 406 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
407 | ZLocateUser(chk, &numlocs, ZAUTH); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
408 | for (int i = 0; i < numlocs; i++) { |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
409 | ZLocations_t locations; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
410 | int one = 1; |
| 9896 | 411 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
412 | ZGetLocations(&locations, &one); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
413 | serv_got_update(zgc, bname, 1, 0, 0, 0, 0); |
|
40646
a8d60f091a56
Use read_from_tzc in zephyr_login
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40643
diff
changeset
|
414 | } |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
415 | #else |
|
24950
143f594f0cd0
Alias foo. I think blist.h structs are now completely hidden.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24945
diff
changeset
|
416 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
417 | purple_debug_info("zephyr", "chk: %s, bname: %s", chk, bname); |
| 9478 | 418 | /* XXX add real error reporting */ |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
419 | /* doesn't matter if this fails or not; we'll just move on to the next one */ |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
420 | zephyr->request_locations(zephyr, chk); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
421 | #endif /* WIN32 */ |
| 2086 | 422 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
423 | g_free(chk); |
| 2086 | 424 | } |
| 425 | ||
|
40635
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
426 | static gboolean |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
427 | check_loc(gpointer data) |
|
40739
f391d9d9352d
Split zephyr_request_locations
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40737
diff
changeset
|
428 | { |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
429 | zephyr_account *zephyr = (zephyr_account *)data; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
430 | GSList *buddies = purple_blist_find_buddies(zephyr->account, NULL); |
| 10867 | 431 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
432 | g_slist_foreach(buddies, (GFunc)check_loc_buddy, zephyr); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
433 | g_slist_free(buddies); |
| 10867 | 434 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
435 | return G_SOURCE_CONTINUE; |
| 2086 | 436 | } |
| 437 | ||
|
39831
c7e0d1617aae
zephyr: Fix const-ness of variable loading.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
438 | static const gchar * |
|
c7e0d1617aae
zephyr: Fix const-ness of variable loading.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
439 | get_exposure_level(void) |
| 2086 | 440 | { |
| 9478 | 441 | /* XXX add real error reporting */ |
|
39831
c7e0d1617aae
zephyr: Fix const-ness of variable loading.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
442 | const gchar *exposure = ZGetVariable("exposure"); |
| 2086 | 443 | |
|
40635
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
444 | if (exposure) { |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
445 | if (!g_ascii_strcasecmp(exposure, EXPOSE_NONE)) { |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
446 | return EXPOSE_NONE; |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
447 | } |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
448 | if (!g_ascii_strcasecmp(exposure, EXPOSE_OPSTAFF)) { |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
449 | return EXPOSE_OPSTAFF; |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
450 | } |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
451 | if (!g_ascii_strcasecmp(exposure, EXPOSE_REALMANN)) { |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
452 | return EXPOSE_REALMANN; |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
453 | } |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
454 | if (!g_ascii_strcasecmp(exposure, EXPOSE_NETVIS)) { |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
455 | return EXPOSE_NETVIS; |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
456 | } |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
457 | if (!g_ascii_strcasecmp(exposure, EXPOSE_NETANN)) { |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
458 | return EXPOSE_NETANN; |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
459 | } |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
460 | } |
| 2086 | 461 | return EXPOSE_REALMVIS; |
| 462 | } | |
| 463 | ||
| 464 | static void strip_comments(char *str) | |
| 465 | { | |
| 466 | char *tmp = strchr(str, '#'); | |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
467 | |
| 2086 | 468 | if (tmp) |
| 469 | *tmp = '\0'; | |
| 470 | g_strchug(str); | |
| 471 | g_strchomp(str); | |
| 472 | } | |
| 473 | ||
| 9896 | 474 | static void zephyr_inithosts(zephyr_account *zephyr) |
| 9478 | 475 | { |
| 476 | /* XXX This code may not be Win32 clean */ | |
| 477 | struct hostent *hent; | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
478 | |
|
9802
5de715c25c22
[gaim-migrate @ 10670]
Mark Doliner <markdoliner@pidgin.im>
parents:
9797
diff
changeset
|
479 | if (gethostname(zephyr->ourhost, sizeof(zephyr->ourhost)) == -1) { |
| 15884 | 480 | purple_debug_error("zephyr", "unable to retrieve hostname, %%host%% and %%canon%% will be wrong in subscriptions and have been set to unknown\n"); |
|
9802
5de715c25c22
[gaim-migrate @ 10670]
Mark Doliner <markdoliner@pidgin.im>
parents:
9797
diff
changeset
|
481 | g_strlcpy(zephyr->ourhost, "unknown", sizeof(zephyr->ourhost)); |
|
9803
3bf25f940805
[gaim-migrate @ 10671]
Mark Doliner <markdoliner@pidgin.im>
parents:
9802
diff
changeset
|
482 | g_strlcpy(zephyr->ourhostcanon, "unknown", sizeof(zephyr->ourhostcanon)); |
| 9478 | 483 | return; |
| 484 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
485 | |
| 9610 | 486 | if (!(hent = gethostbyname(zephyr->ourhost))) { |
| 15884 | 487 | purple_debug_error("zephyr", "unable to resolve hostname, %%canon%% will be wrong in subscriptions.and has been set to the value of %%host%%, %s\n",zephyr->ourhost); |
|
9803
3bf25f940805
[gaim-migrate @ 10671]
Mark Doliner <markdoliner@pidgin.im>
parents:
9802
diff
changeset
|
488 | g_strlcpy(zephyr->ourhostcanon, zephyr->ourhost, sizeof(zephyr->ourhostcanon)); |
| 9478 | 489 | return; |
| 490 | } | |
|
9802
5de715c25c22
[gaim-migrate @ 10670]
Mark Doliner <markdoliner@pidgin.im>
parents:
9797
diff
changeset
|
491 | |
|
5de715c25c22
[gaim-migrate @ 10670]
Mark Doliner <markdoliner@pidgin.im>
parents:
9797
diff
changeset
|
492 | g_strlcpy(zephyr->ourhostcanon, hent->h_name, sizeof(zephyr->ourhostcanon)); |
| 9478 | 493 | } |
| 494 | ||
| 9610 | 495 | static void process_zsubs(zephyr_account *zephyr) |
| 2086 | 496 | { |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
497 | /* Loads zephyr chats "(subscriptions) from ~/.zephyr.subs, and |
|
9802
5de715c25c22
[gaim-migrate @ 10670]
Mark Doliner <markdoliner@pidgin.im>
parents:
9797
diff
changeset
|
498 | registers (subscribes to) them on the server */ |
| 9434 | 499 | |
|
9802
5de715c25c22
[gaim-migrate @ 10670]
Mark Doliner <markdoliner@pidgin.im>
parents:
9797
diff
changeset
|
500 | /* XXX deal with unsubscriptions */ |
|
5de715c25c22
[gaim-migrate @ 10670]
Mark Doliner <markdoliner@pidgin.im>
parents:
9797
diff
changeset
|
501 | /* XXX deal with punts */ |
| 9434 | 502 | |
| 2086 | 503 | FILE *f; |
| 504 | gchar *fname; | |
| 505 | gchar buff[BUFSIZ]; | |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
506 | |
| 15884 | 507 | fname = g_strdup_printf("%s/.zephyr.subs", purple_home_dir()); |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10401
diff
changeset
|
508 | f = g_fopen(fname, "r"); |
| 2086 | 509 | if (f) { |
| 510 | char **triple; | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
511 | ZSubscription_t sub; |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
512 | |
| 2086 | 513 | while (fgets(buff, BUFSIZ, f)) { |
| 514 | strip_comments(buff); | |
| 515 | if (buff[0]) { | |
| 516 | triple = g_strsplit(buff, ",", 3); | |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
517 | if (triple[0] && triple[1]) { |
|
40700
4c3ee00e6107
Replace g_strdup_printf("%s", string) with g_strdup(string)
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40698
diff
changeset
|
518 | char *tmp = g_strdup(zephyr->username); |
| 2804 | 519 | char *atptr; |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
520 | |
|
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
521 | if (triple[2] == NULL) { |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
522 | sub.zsub_recipient = g_malloc0(1); |
| 4793 | 523 | } else if (!g_ascii_strcasecmp(triple[2], "%me%")) { |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
524 | sub.zsub_recipient = g_strdup(zephyr->username); |
| 4793 | 525 | } else if (!g_ascii_strcasecmp(triple[2], "*")) { |
| 2804 | 526 | /* wildcard |
| 527 | * form of class,instance,* */ | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
528 | sub.zsub_recipient = g_malloc0(1); |
| 4793 | 529 | } else if (!g_ascii_strcasecmp(triple[2], tmp)) { |
| 2804 | 530 | /* form of class,instance,aatharuv@ATHENA.MIT.EDU */ |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
531 | sub.zsub_recipient = g_strdup(triple[2]); |
| 2804 | 532 | } else if ((atptr = strchr(triple[2], '@')) != NULL) { |
| 533 | /* form of class,instance,*@ANDREW.CMU.EDU | |
| 534 | * class,instance,@ANDREW.CMU.EDU | |
| 535 | * If realm is local realm, blank recipient, else | |
| 536 | * @REALM-NAME | |
| 537 | */ | |
| 9896 | 538 | char *realmat = g_strdup_printf("@%s",zephyr->realm); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
539 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
540 | if (!g_ascii_strcasecmp(atptr, realmat)) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
541 | sub.zsub_recipient = g_malloc0(1); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
542 | } else { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
543 | sub.zsub_recipient = g_strdup(atptr); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
544 | } |
| 2804 | 545 | g_free(realmat); |
| 2086 | 546 | } else { |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
547 | sub.zsub_recipient = g_strdup(triple[2]); |
| 2086 | 548 | } |
| 2804 | 549 | g_free(tmp); |
| 9478 | 550 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
551 | if (!g_ascii_strcasecmp(triple[0], "%host%")) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
552 | sub.zsub_class = g_strdup(zephyr->ourhost); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
553 | } else if (!g_ascii_strcasecmp(triple[0], "%canon%")) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
554 | sub.zsub_class = g_strdup(zephyr->ourhostcanon); |
| 9478 | 555 | } else { |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
556 | sub.zsub_class = g_strdup(triple[0]); |
| 9478 | 557 | } |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
558 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
559 | if (!g_ascii_strcasecmp(triple[1], "%host%")) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
560 | sub.zsub_classinst = g_strdup(zephyr->ourhost); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
561 | } else if (!g_ascii_strcasecmp(triple[1], "%canon%")) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
562 | sub.zsub_classinst = g_strdup(zephyr->ourhostcanon); |
| 9478 | 563 | } else { |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
564 | sub.zsub_classinst = g_strdup(triple[1]); |
| 9478 | 565 | } |
| 566 | ||
| 567 | /* There should be some sort of error report listing classes that couldn't be subbed to. | |
| 568 | Not important right now though */ | |
| 569 | ||
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
570 | if (!zephyr->subscribe_to(zephyr, &sub)) { |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
571 | purple_debug_error("zephyr", "Couldn't subscribe to %s, %s, %s\n", |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
572 | sub.zsub_class, sub.zsub_classinst, sub.zsub_recipient); |
| 2086 | 573 | } |
| 9478 | 574 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
575 | zephyr->subscrips = g_slist_append(zephyr->subscrips, zephyr_triple_new(zephyr, &sub)); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
576 | g_free(sub.zsub_class); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
577 | g_free(sub.zsub_classinst); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
578 | g_free(sub.zsub_recipient); |
| 2086 | 579 | } |
| 580 | g_strfreev(triple); | |
| 581 | } | |
| 582 | } | |
|
13454
10592212bb27
[gaim-migrate @ 15828]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
13297
diff
changeset
|
583 | fclose(f); |
| 2086 | 584 | } |
|
33694
dabb189b6ac9
zephyr.c: Fix multiple leaks
Niels Thykier <niels@thykier.net>
parents:
32698
diff
changeset
|
585 | g_free(fname); |
| 2086 | 586 | } |
| 587 | ||
|
40662
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
588 | static void |
|
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
589 | process_anyone(const zephyr_account *zephyr) |
| 2086 | 590 | { |
| 591 | FILE *fd; | |
| 592 | gchar buff[BUFSIZ], *filename; | |
| 15884 | 593 | PurpleGroup *g; |
| 594 | PurpleBuddy *b; | |
|
4775
239cb803fb1d
[gaim-migrate @ 5095]
Mark Doliner <markdoliner@pidgin.im>
parents:
4770
diff
changeset
|
595 | |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
596 | if (!(g = purple_blist_find_group(_("Anyone")))) { |
| 15884 | 597 | g = purple_group_new(_("Anyone")); |
| 598 | purple_blist_add_group(g, NULL); | |
|
4775
239cb803fb1d
[gaim-migrate @ 5095]
Mark Doliner <markdoliner@pidgin.im>
parents:
4770
diff
changeset
|
599 | } |
| 6695 | 600 | |
| 15884 | 601 | filename = g_strconcat(purple_home_dir(), "/.anyone", NULL); |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10401
diff
changeset
|
602 | if ((fd = g_fopen(filename, "r")) != NULL) { |
| 2086 | 603 | while (fgets(buff, BUFSIZ, fd)) { |
| 604 | strip_comments(buff); | |
|
40672
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
605 | if (*buff && !find_buddy(zephyr, buff)) { |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
606 | char *stripped_user = zephyr_strip_local_realm(zephyr, buff); |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
607 | purple_debug_info("zephyr", "stripped_user %s\n", stripped_user); |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
608 | b = purple_buddy_new(zephyr->account, stripped_user, NULL); |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
609 | purple_blist_add_buddy(b, NULL, g, NULL); |
|
9375289dfc32
Reduce some code duplication
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40662
diff
changeset
|
610 | g_free(stripped_user); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
611 | } |
| 2086 | 612 | } |
| 613 | fclose(fd); | |
| 614 | } | |
| 615 | g_free(filename); | |
| 616 | } | |
| 617 | ||
|
39831
c7e0d1617aae
zephyr: Fix const-ness of variable loading.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
618 | static gchar * |
|
40662
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
619 | get_zephyr_exposure(PurpleAccount *account) |
|
39831
c7e0d1617aae
zephyr: Fix const-ness of variable loading.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
620 | { |
|
40662
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
621 | const gchar *exposure; |
|
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
622 | gchar *exp2; |
|
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
623 | |
|
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
624 | exposure = purple_account_get_string(account, "exposure_level", EXPOSE_REALMVIS); |
|
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
625 | |
|
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
626 | /* Make sure that the exposure (visibility) is set to a sane value */ |
|
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
627 | exp2 = g_strstrip(g_ascii_strup(exposure, -1)); |
|
40635
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
628 | if (exp2) { |
|
40662
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
629 | if (purple_strequal(exp2, EXPOSE_NONE) || |
|
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
630 | purple_strequal(exp2, EXPOSE_OPSTAFF) || |
|
40635
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
631 | purple_strequal(exp2, EXPOSE_REALMANN) || |
|
40662
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
632 | purple_strequal(exp2, EXPOSE_NETVIS) || |
|
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
633 | purple_strequal(exp2, EXPOSE_NETANN)) { |
|
40635
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
634 | return exp2; |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
635 | } |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
636 | g_free(exp2); |
|
39831
c7e0d1617aae
zephyr: Fix const-ness of variable loading.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
637 | } |
|
c7e0d1617aae
zephyr: Fix const-ness of variable loading.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
638 | return g_strdup(EXPOSE_REALMVIS); |
|
10038
3589c2eed81c
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
639 | } |
|
3589c2eed81c
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
640 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
641 | gchar * |
|
40698
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
642 | get_zephyr_realm(PurpleAccount *account, const gchar *local_realm) |
|
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
643 | { |
|
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
644 | const char *realm = purple_account_get_string(account, "realm", ""); |
|
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
645 | if (!*realm) { |
|
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
646 | realm = local_realm; |
|
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
647 | } |
|
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
648 | g_strlcpy(__Zephyr_realm, realm, REALM_SZ - 1); |
|
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
649 | return g_strdup(realm); |
|
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
650 | } |
|
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
651 | |
| 15884 | 652 | static void zephyr_login(PurpleAccount * account) |
| 2086 | 653 | { |
| 15884 | 654 | PurpleConnection *gc; |
| 9896 | 655 | zephyr_account *zephyr; |
|
40698
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
656 | ZephyrLoginFunc login; |
|
40662
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
657 | GSourceFunc check_notify; |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
658 | ZSubscription_t sub; |
| 9427 | 659 | |
| 15884 | 660 | gc = purple_account_get_connection(account); |
|
10038
3589c2eed81c
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
661 | |
| 10867 | 662 | #ifdef WIN32 |
| 15884 | 663 | username = purple_account_get_username(account); |
| 10867 | 664 | #endif |
|
36055
33978dc8ef6f
Remove redundant OPT_PROTO_IM_IMAGE (use \!PURPLE_CONNECTION_FLAG_NO_IMAGES instead)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36031
diff
changeset
|
665 | purple_connection_set_flags(gc, PURPLE_CONNECTION_FLAG_AUTO_RESP | |
|
33978dc8ef6f
Remove redundant OPT_PROTO_IM_IMAGE (use \!PURPLE_CONNECTION_FLAG_NO_IMAGES instead)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36031
diff
changeset
|
666 | PURPLE_CONNECTION_FLAG_HTML | PURPLE_CONNECTION_FLAG_NO_BGCOLOR | |
|
33978dc8ef6f
Remove redundant OPT_PROTO_IM_IMAGE (use \!PURPLE_CONNECTION_FLAG_NO_IMAGES instead)
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36031
diff
changeset
|
667 | PURPLE_CONNECTION_FLAG_NO_URLDESC | PURPLE_CONNECTION_FLAG_NO_IMAGES); |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
668 | zephyr = g_new0(zephyr_account, 1); |
|
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
669 | purple_connection_set_protocol_data(gc, zephyr); |
|
10038
3589c2eed81c
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
670 | |
| 9896 | 671 | zephyr->account = account; |
|
40662
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
672 | zephyr->exposure = get_zephyr_exposure(account); |
|
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
673 | |
|
40698
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
674 | if (purple_account_get_bool(account, "use_tzc", FALSE)) { |
| 15884 | 675 | zephyr->connection_type = PURPLE_ZEPHYR_TZC; |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
676 | login = tzc_login; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
677 | check_notify = tzc_check_notify; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
678 | zephyr->subscribe_to = tzc_subscribe_to; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
679 | zephyr->request_locations = tzc_request_locations; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
680 | zephyr->send_message = tzc_send_message; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
681 | zephyr->set_location = tzc_set_location; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
682 | zephyr->get_subs_from_server = tzc_get_subs_from_server; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
683 | zephyr->close = tzc_close; |
| 9896 | 684 | } else { |
| 15884 | 685 | zephyr->connection_type = PURPLE_ZEPHYR_KRB4; |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
686 | login = zeph02_login; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
687 | check_notify = zeph02_check_notify; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
688 | zephyr->subscribe_to = zeph02_subscribe_to; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
689 | zephyr->request_locations = zeph02_request_locations; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
690 | zephyr->send_message = zeph02_send_message; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
691 | zephyr->set_location = zeph02_set_location; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
692 | zephyr->get_subs_from_server = zeph02_get_subs_from_server; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
693 | zephyr->close = zeph02_close; |
| 9896 | 694 | } |
| 695 | ||
|
40662
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
696 | zephyr->encoding = (char *)purple_account_get_string(account, "encoding", ZEPHYR_FALLBACK_CHARSET); |
| 15884 | 697 | purple_connection_update_progress(gc, _("Connecting"), 0, 8); |
| 9478 | 698 | |
|
40698
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
699 | if (!login(zephyr)) { |
| 9896 | 700 | return; |
| 701 | } | |
| 15884 | 702 | purple_debug_info("zephyr","does it get here\n"); |
| 703 | purple_debug_info("zephyr"," realm: %s username:%s\n", zephyr->realm, zephyr->username); | |
| 9896 | 704 | |
| 705 | /* For now */ | |
| 706 | zephyr->galaxy = NULL; | |
| 707 | zephyr->krbtkfile = NULL; | |
| 708 | zephyr_inithosts(zephyr); | |
| 709 | ||
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
710 | sub.zsub_class = "MESSAGE"; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
711 | sub.zsub_classinst = "PERSONAL"; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
712 | sub.zsub_recipient = zephyr->username; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
713 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
714 | if (!zephyr->subscribe_to(zephyr, &sub)) { |
| 9478 | 715 | /* XXX don't translate this yet. It could be written better */ |
| 716 | /* XXX error messages could be handled with more detail */ | |
|
40662
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
717 | purple_notify_error(gc, NULL, |
|
34449
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34312
diff
changeset
|
718 | "Unable to subscribe to messages", "Unable to subscribe to initial messages", |
|
bbcb198650b7
Notify API: extend purple_notify_message with PurpleRequestCommonParameters
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
34312
diff
changeset
|
719 | purple_request_cpar_from_connection(gc)); |
| 9478 | 720 | return; |
| 2086 | 721 | } |
| 722 | ||
|
34746
dc9c911dbd35
Started GObjectification of PurpleConnection.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
723 | purple_connection_set_state(gc, PURPLE_CONNECTION_CONNECTED); |
|
10038
3589c2eed81c
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
724 | |
|
40698
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
725 | if (purple_account_get_bool(account, "read_anyone", TRUE)) { |
|
40662
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
726 | process_anyone(zephyr); |
|
40698
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
727 | } |
|
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
728 | if (purple_account_get_bool(account, "read_zsubs", TRUE)) { |
|
10038
3589c2eed81c
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
729 | process_zsubs(zephyr); |
|
40698
d06e6660b39c
zephyr_login refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40697
diff
changeset
|
730 | } |
|
10038
3589c2eed81c
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
731 | |
|
40662
80764d18e588
zephyr_login cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40661
diff
changeset
|
732 | zephyr->nottimer = g_timeout_add(100, check_notify, gc); |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
733 | zephyr->loctimer = g_timeout_add_seconds(20, check_loc, zephyr); |
| 2086 | 734 | } |
| 735 | ||
| 9610 | 736 | static void write_zsubs(zephyr_account *zephyr) |
| 2086 | 737 | { |
| 9896 | 738 | /* Exports subscription (chat) list back to |
| 739 | * .zephyr.subs | |
| 740 | * XXX deal with %host%, %canon%, unsubscriptions, and negative subscriptions (punts?) | |
| 741 | */ | |
| 9434 | 742 | |
| 9610 | 743 | GSList *s = zephyr->subscrips; |
| 2086 | 744 | zephyr_triple *zt; |
| 745 | FILE *fd; | |
| 746 | char *fname; | |
| 747 | ||
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
748 | char **triple; |
|
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
749 | |
| 15884 | 750 | fname = g_strdup_printf("%s/.zephyr.subs", purple_home_dir()); |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10401
diff
changeset
|
751 | fd = g_fopen(fname, "w"); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
752 | |
| 2086 | 753 | if (!fd) { |
| 754 | g_free(fname); | |
| 755 | return; | |
| 756 | } | |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
757 | |
| 2086 | 758 | while (s) { |
| 9478 | 759 | char *zclass, *zinst, *zrecip; |
| 2086 | 760 | zt = s->data; |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
761 | triple = g_strsplit(zt->name, ",", 3); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
762 | |
| 9478 | 763 | /* deal with classes */ |
| 9610 | 764 | if (!g_ascii_strcasecmp(triple[0],zephyr->ourhost)) { |
|
9775
e3a3555b0621
[gaim-migrate @ 10643]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
765 | zclass = g_strdup("%host%"); |
| 9610 | 766 | } else if (!g_ascii_strcasecmp(triple[0],zephyr->ourhostcanon)) { |
|
9775
e3a3555b0621
[gaim-migrate @ 10643]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
767 | zclass = g_strdup("%canon%"); |
| 9478 | 768 | } else { |
| 769 | zclass = g_strdup(triple[0]); | |
| 770 | } | |
| 771 | ||
| 772 | /* deal with instances */ | |
| 773 | ||
| 9610 | 774 | if (!g_ascii_strcasecmp(triple[1],zephyr->ourhost)) { |
|
9775
e3a3555b0621
[gaim-migrate @ 10643]
Daniel Atallah <datallah@pidgin.im>
parents:
9754
diff
changeset
|
775 | zinst = g_strdup("%host%"); |
| 9610 | 776 | } else if (!g_ascii_strcasecmp(triple[1],zephyr->ourhostcanon)) { |
| 9896 | 777 | zinst = g_strdup("%canon%");; |
| 778 | } else { | |
| 9478 | 779 | zinst = g_strdup(triple[1]); |
| 9896 | 780 | } |
| 9478 | 781 | |
| 782 | /* deal with recipients */ | |
| 783 | if (triple[2] == NULL) { | |
| 784 | zrecip = g_strdup("*"); | |
| 785 | } else if (!g_ascii_strcasecmp(triple[2],"")){ | |
| 786 | zrecip = g_strdup("*"); | |
| 9896 | 787 | } else if (!g_ascii_strcasecmp(triple[2], zephyr->username)) { |
| 9478 | 788 | zrecip = g_strdup("%me%"); |
| 3277 | 789 | } else { |
| 9478 | 790 | zrecip = g_strdup(triple[2]); |
| 3277 | 791 | } |
| 9478 | 792 | |
| 793 | fprintf(fd, "%s,%s,%s\n",zclass,zinst,zrecip); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
794 | |
| 9478 | 795 | g_free(zclass); |
| 796 | g_free(zinst); | |
| 797 | g_free(zrecip); | |
|
40514
30d9cbf04922
Fix some leaks.
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40507
diff
changeset
|
798 | g_strfreev(triple); |
| 2086 | 799 | s = s->next; |
| 800 | } | |
| 801 | g_free(fname); | |
| 802 | fclose(fd); | |
| 803 | } | |
| 804 | ||
|
31352
7f6c8c77ead0
Use convenience variables.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
805 | static void write_anyone(zephyr_account *zephyr) |
| 2086 | 806 | { |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27198
diff
changeset
|
807 | GSList *buddies; |
| 9912 | 808 | char *fname; |
| 2086 | 809 | FILE *fd; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23352
diff
changeset
|
810 | PurpleAccount *account; |
| 15884 | 811 | fname = g_strdup_printf("%s/.anyone", purple_home_dir()); |
|
10589
4e10236e06d4
[gaim-migrate @ 11994]
Daniel Atallah <datallah@pidgin.im>
parents:
10401
diff
changeset
|
812 | fd = g_fopen(fname, "w"); |
| 2086 | 813 | if (!fd) { |
| 814 | g_free(fname); | |
| 815 | return; | |
| 816 | } | |
| 817 | ||
|
31352
7f6c8c77ead0
Use convenience variables.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
818 | account = zephyr->account; |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34717
diff
changeset
|
819 | for (buddies = purple_blist_find_buddies(account, NULL); buddies; |
|
27199
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27198
diff
changeset
|
820 | buddies = g_slist_delete_link(buddies, buddies)) { |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27198
diff
changeset
|
821 | PurpleBuddy *b = buddies->data; |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27198
diff
changeset
|
822 | gchar *stripped_user = zephyr_strip_local_realm(zephyr, purple_buddy_get_name(b)); |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27198
diff
changeset
|
823 | fprintf(fd, "%s\n", stripped_user); |
|
ab2af9d15cba
Use purple_find_buddies() instead of iterating the buddy list.
Paul Aurich <darkrain42@pidgin.im>
parents:
27198
diff
changeset
|
824 | g_free(stripped_user); |
| 2086 | 825 | } |
| 826 | ||
| 827 | fclose(fd); | |
| 828 | g_free(fname); | |
| 829 | } | |
| 830 | ||
| 15884 | 831 | static void zephyr_close(PurpleConnection * gc) |
| 2086 | 832 | { |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
833 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
834 | |
|
40043
90446617d967
Use GList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
39970
diff
changeset
|
835 | g_list_free_full(zephyr->pending_zloc_names, g_free); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
836 | |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32624
diff
changeset
|
837 | if (purple_account_get_bool(purple_connection_get_account(gc), "write_anyone", FALSE)) |
|
31352
7f6c8c77ead0
Use convenience variables.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
838 | write_anyone(zephyr); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
839 | |
|
32678
01f6312a4a7b
On the way to hiding the PurpleConnection struct.
Andrew Victor <andrew.victor@mxit.com>
parents:
32624
diff
changeset
|
840 | if (purple_account_get_bool(purple_connection_get_account(gc), "write_zsubs", FALSE)) |
|
31352
7f6c8c77ead0
Use convenience variables.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
31294
diff
changeset
|
841 | write_zsubs(zephyr); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
842 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
843 | g_slist_free_full(zephyr->subscrips, (GDestroyNotify)zephyr_triple_free); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
844 | |
| 9610 | 845 | if (zephyr->nottimer) |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
846 | g_source_remove(zephyr->nottimer); |
| 9610 | 847 | zephyr->nottimer = 0; |
| 848 | if (zephyr->loctimer) | |
|
38433
361c801c4536
Remove purple_timeout_* function usage
Mike Ruprecht <cmaiku@gmail.com>
parents:
37523
diff
changeset
|
849 | g_source_remove(zephyr->loctimer); |
| 9610 | 850 | zephyr->loctimer = 0; |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
851 | zephyr->close(zephyr); |
| 2086 | 852 | } |
| 853 | ||
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
854 | static gboolean |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
855 | zephyr_send_message(zephyr_account *zephyr, gchar *zclass, gchar *instance, |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
856 | gchar *recipient, const gchar *im, const gchar *sig, |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
857 | gchar *opcode) |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
858 | { |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
859 | /* (From the tzc source) |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
860 | * emacs sends something of the form: |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
861 | * ((class . "MESSAGE") |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
862 | * (auth . t) |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
863 | * (recipients ("PERSONAL" . "bovik") ("test" . "")) |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
864 | * (sender . "bovik") |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
865 | * (message . ("Harry Bovik" "my zgram")) |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
866 | * ) |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
867 | */ |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
868 | char *tmp_buf; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
869 | char *html_buf; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
870 | gboolean result; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
871 | |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
872 | tmp_buf = html_to_zephyr(im); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
873 | html_buf = purple_unescape_html(tmp_buf); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
874 | g_free(tmp_buf); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
875 | |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
876 | result = zephyr->send_message(zephyr, zclass, instance, recipient, html_buf, sig, opcode); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
877 | g_free(html_buf); |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
878 | return result; |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
879 | } |
| 9434 | 880 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
881 | static gint |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
882 | zephyr_triple_cmp_id(gconstpointer data, gconstpointer user_data) |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
883 | { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
884 | const zephyr_triple *zt = data; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
885 | int id = GPOINTER_TO_INT(user_data); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
886 | return zt->id - id; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
887 | } |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
888 | |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
20288
diff
changeset
|
889 | static const char * zephyr_get_signature(void) |
| 9434 | 890 | { |
| 9478 | 891 | /* XXX add zephyr error reporting */ |
| 892 | const char * sig =ZGetVariable("zwrite-signature"); | |
| 9896 | 893 | if (!sig) { |
| 894 | sig = g_get_real_name(); | |
| 895 | } | |
| 896 | return sig; | |
| 9434 | 897 | } |
| 898 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
899 | static int |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
900 | zephyr_chat_send(PurpleProtocolChat *protocol_chat, PurpleConnection *gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
901 | int id, PurpleMessage *msg) |
| 2086 | 902 | { |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
903 | GSList *l; |
| 2086 | 904 | zephyr_triple *zt; |
| 905 | const char *sig; | |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
906 | PurpleChatConversation *gcc; |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
907 | char *inst; |
| 9896 | 908 | char *recipient; |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
909 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
| 2086 | 910 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
911 | l = g_slist_find_custom(zephyr->subscrips, GINT_TO_POINTER(id), zephyr_triple_cmp_id); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
912 | if (!l) { |
| 2086 | 913 | /* this should never happen. */ |
|
2167
cbb558585911
[gaim-migrate @ 2177]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2162
diff
changeset
|
914 | return -EINVAL; |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
915 | } |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
916 | |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
917 | zt = l->data; |
| 9896 | 918 | sig = zephyr_get_signature(); |
| 2086 | 919 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
920 | gcc = purple_conversations_find_chat_with_account(zt->name, purple_connection_get_account(gc)); |
| 8212 | 921 | |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
922 | if (!(inst = (char *)purple_chat_conversation_get_topic(gcc))) |
| 9434 | 923 | inst = g_strdup("PERSONAL"); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
924 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
925 | if (!g_ascii_strcasecmp(zt->sub.zsub_recipient, "*")) { |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
926 | recipient = zephyr_normalize_local_realm(zephyr, ""); |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
927 | } else { |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
928 | recipient = zephyr_normalize_local_realm(zephyr, zt->sub.zsub_recipient); |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
929 | } |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
930 | zephyr_send_message(zephyr, zt->sub.zsub_class, inst, recipient, |
|
36077
b7328f4317c7
Switch purple_serv_chat_send to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36076
diff
changeset
|
931 | purple_message_get_contents(msg), sig, ""); |
|
2167
cbb558585911
[gaim-migrate @ 2177]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2162
diff
changeset
|
932 | return 0; |
| 2086 | 933 | } |
| 934 | ||
| 9434 | 935 | |
|
40507
77d7bc9e5151
Make PurpleProtocolIM a proper interface
Gary Kramlich <grim@reaperworld.com>
parents:
40462
diff
changeset
|
936 | static int zephyr_send_im(PurpleProtocolIM *im, PurpleConnection *gc, PurpleMessage *msg) |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
937 | { |
| 2086 | 938 | const char *sig; |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
939 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
940 | |
|
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
941 | if (purple_message_get_flags(msg) & PURPLE_MESSAGE_AUTO_RESP) { |
| 2086 | 942 | sig = "Automated reply:"; |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
943 | } else { |
| 9434 | 944 | sig = zephyr_get_signature(); |
| 2086 | 945 | } |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
946 | zephyr_send_message(zephyr, "MESSAGE", "PERSONAL", |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
947 | zephyr_normalize_local_realm(zephyr, purple_message_get_recipient(msg)), |
|
36076
a0e5b68ff4ef
Switch purple_serv_send_im to PurpleMessage
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
36055
diff
changeset
|
948 | purple_message_get_contents(msg), sig, ""); |
| 9434 | 949 | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
950 | return 1; |
| 9434 | 951 | } |
| 2086 | 952 | |
|
40715
206563c8b5c6
zephyr_tzc_escape_msg and zephyr_tzc_deescape_str refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40708
diff
changeset
|
953 | |
|
206563c8b5c6
zephyr_tzc_escape_msg and zephyr_tzc_deescape_str refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40708
diff
changeset
|
954 | /* Basically the inverse of zephyr_strip_local_realm */ |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
955 | char * |
|
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
956 | zephyr_normalize_local_realm(const zephyr_account *zephyr, const char *orig) |
| 8354 | 957 | { |
|
40700
4c3ee00e6107
Replace g_strdup_printf("%s", string) with g_strdup(string)
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40698
diff
changeset
|
958 | if (*orig == '\0' || strchr(orig, '@')) { |
|
4c3ee00e6107
Replace g_strdup_printf("%s", string) with g_strdup(string)
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40698
diff
changeset
|
959 | return g_strdup(orig); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
960 | } |
|
40635
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
961 | |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
962 | return g_strdup_printf("%s@%s", orig, zephyr->realm); |
| 2086 | 963 | } |
| 964 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40633
diff
changeset
|
965 | static const char * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40633
diff
changeset
|
966 | zephyr_normalize(PurpleProtocolClient *client, PurpleAccount *account, |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40633
diff
changeset
|
967 | const char *who) |
|
22391
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
968 | { |
|
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
969 | static char buf[BUF_LEN]; |
|
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
970 | PurpleConnection *gc; |
|
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
971 | char *tmp; |
|
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
972 | |
|
35853
700097e7206b
Zephyr: fix username validation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35692
diff
changeset
|
973 | if (account == NULL) { |
|
700097e7206b
Zephyr: fix username validation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35692
diff
changeset
|
974 | if (strlen(who) >= sizeof(buf)) |
|
700097e7206b
Zephyr: fix username validation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35692
diff
changeset
|
975 | return NULL; |
|
700097e7206b
Zephyr: fix username validation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35692
diff
changeset
|
976 | return who; |
|
700097e7206b
Zephyr: fix username validation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35692
diff
changeset
|
977 | } |
|
700097e7206b
Zephyr: fix username validation
Tomasz Wasilczyk <twasilczyk@pidgin.im>
parents:
35692
diff
changeset
|
978 | |
|
39833
cd90938cd6f7
Silence various discarded const warnings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39831
diff
changeset
|
979 | gc = purple_account_get_connection((PurpleAccount *)account); |
|
22543
a73c80f1b40d
Fix a crash in the zephyr normalize function that I added when gc is
Mark Doliner <markdoliner@pidgin.im>
parents:
22391
diff
changeset
|
980 | if (gc == NULL) |
|
a73c80f1b40d
Fix a crash in the zephyr normalize function that I added when gc is
Mark Doliner <markdoliner@pidgin.im>
parents:
22391
diff
changeset
|
981 | return NULL; |
|
a73c80f1b40d
Fix a crash in the zephyr normalize function that I added when gc is
Mark Doliner <markdoliner@pidgin.im>
parents:
22391
diff
changeset
|
982 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
983 | tmp = zephyr_normalize_local_realm(purple_connection_get_protocol_data(gc), who); |
|
22391
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
984 | |
|
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
985 | if (strlen(tmp) >= sizeof(buf)) { |
|
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
986 | g_free(tmp); |
|
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
987 | return NULL; |
|
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
988 | } |
|
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
989 | |
|
31954
e5631d5590cc
Replace numerous strcpy() invocations with strlcpy() in Zephyr.
Ethan Blanton <elb@pidgin.im>
parents:
31595
diff
changeset
|
990 | g_strlcpy(buf, tmp, sizeof(buf)); |
|
22391
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
991 | g_free(tmp); |
|
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
992 | |
|
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
993 | return buf; |
|
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
994 | } |
|
823ac1e9cfbb
Get rid of some privacy checking code from zephyr that is done in
Mark Doliner <markdoliner@pidgin.im>
parents:
22389
diff
changeset
|
995 | |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40703
diff
changeset
|
996 | static void |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40703
diff
changeset
|
997 | zephyr_zloc(PurpleProtocolServer *protocol_server, PurpleConnection *gc, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40703
diff
changeset
|
998 | const gchar *who) |
| 2086 | 999 | { |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1000 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
1001 | gchar *normalized_who = zephyr_normalize_local_realm(zephyr, who); |
|
22197
853f77cffbbd
Part of a large patch from o_sukhodolsky to fix some build warnings.
Richard Laager <rlaager@pidgin.im>
parents:
22104
diff
changeset
|
1002 | |
|
40739
f391d9d9352d
Split zephyr_request_locations
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40737
diff
changeset
|
1003 | if (zephyr->request_locations(zephyr, normalized_who)) { |
|
40635
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
1004 | zephyr->pending_zloc_names = g_list_append(zephyr->pending_zloc_names, normalized_who); |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
1005 | } else { |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
1006 | /* XXX deal with errors somehow */ |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
1007 | g_free(normalized_who); |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
1008 | } |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
1009 | } |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
1010 | |
|
1f8b5b68a806
Some zephyr cleanups
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40634
diff
changeset
|
1011 | static void |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40703
diff
changeset
|
1012 | zephyr_set_status(PurpleProtocolServer *protocol_server, |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40703
diff
changeset
|
1013 | PurpleAccount *account, PurpleStatus *status) |
|
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40703
diff
changeset
|
1014 | { |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1015 | PurpleConnection *gc = purple_account_get_connection(account); |
|
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1016 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
|
34855
9c289149eed4
Global replaces according to GObject status API
Ankit Vani <a@nevitus.org>
parents:
34811
diff
changeset
|
1017 | PurpleStatusPrimitive primitive = purple_status_type_get_primitive(purple_status_get_status_type(status)); |
| 9986 | 1018 | |
|
37426
6fd4989b77e4
The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents:
37163
diff
changeset
|
1019 | g_free(zephyr->away); |
|
6fd4989b77e4
The last of the NULL-checks before free()
Michael McConville <mmcco@mykolab.com>
parents:
37163
diff
changeset
|
1020 | zephyr->away = NULL; |
|
4111
93b27900416e
[gaim-migrate @ 4326]
Robert McQueen <robot101@debian.org>
parents:
3867
diff
changeset
|
1021 | |
| 15884 | 1022 | if (primitive == PURPLE_STATUS_AWAY) { |
| 1023 | zephyr->away = g_strdup(purple_status_get_attr_string(status,"message")); | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1024 | } |
| 15884 | 1025 | else if (primitive == PURPLE_STATUS_AVAILABLE) { |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
1026 | zephyr->set_location(zephyr, zephyr->exposure); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1027 | } |
| 15884 | 1028 | else if (primitive == PURPLE_STATUS_INVISIBLE) { |
| 9478 | 1029 | /* XXX handle errors */ |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
1030 | zephyr->set_location(zephyr, EXPOSE_OPSTAFF); |
| 9478 | 1031 | } |
| 2086 | 1032 | } |
| 1033 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1034 | static GList *zephyr_status_types(PurpleAccount *account) |
| 2086 | 1035 | { |
| 15884 | 1036 | PurpleStatusType *type; |
| 9986 | 1037 | GList *types = NULL; |
| 1038 | ||
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1039 | /* zephyr has several exposures |
| 9986 | 1040 | NONE (where you are hidden, and zephyrs to you are in practice silently dropped -- yes this is wrong) |
| 1041 | OPSTAFF "hidden" | |
| 1042 | REALM-VISIBLE visible to people in local realm | |
| 1043 | REALM-ANNOUNCED REALM-VISIBLE+ plus your logins/logouts are announced to <login,username,*> | |
| 1044 | NET-VISIBLE REALM-ANNOUNCED, plus visible to people in foreign realm | |
| 1045 | NET-ANNOUNCED NET-VISIBLE, plus logins/logouts are announced to <login,username,*> | |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1046 | |
| 9986 | 1047 | Online will set the user to the exposure they have in their options (defaulting to REALM-VISIBLE), |
| 1048 | Hidden, will set the user's exposure to OPSTAFF | |
| 2086 | 1049 | |
| 9986 | 1050 | Away won't change their exposure but will set an auto away message (for IMs only) |
| 1051 | */ | |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1052 | |
| 15884 | 1053 | type = purple_status_type_new(PURPLE_STATUS_AVAILABLE, NULL, NULL, TRUE); |
| 9986 | 1054 | types = g_list_append(types,type); |
| 2086 | 1055 | |
| 15884 | 1056 | type = purple_status_type_new(PURPLE_STATUS_INVISIBLE, NULL, NULL, TRUE); |
| 9986 | 1057 | types = g_list_append(types,type); |
| 1058 | ||
| 15884 | 1059 | type = purple_status_type_new_with_attrs( |
| 1060 | PURPLE_STATUS_AWAY, NULL, NULL, TRUE, TRUE, FALSE, | |
|
35005
bff56dfca65d
Renamed purple_g_value_* to purple_value_*
Ankit Vani <a@nevitus.org>
parents:
34955
diff
changeset
|
1061 | "message", _("Message"), purple_value_new(G_TYPE_STRING), |
|
12595
8108c22aa723
[gaim-migrate @ 14925]
Richard Laager <rlaager@pidgin.im>
parents:
12467
diff
changeset
|
1062 | NULL); |
| 9986 | 1063 | types = g_list_append(types, type); |
| 1064 | ||
| 15884 | 1065 | type = purple_status_type_new(PURPLE_STATUS_OFFLINE, NULL, NULL, TRUE); |
|
12658
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1066 | types = g_list_append(types,type); |
|
4aa7a873628d
[gaim-migrate @ 15001]
Mark Doliner <markdoliner@pidgin.im>
parents:
12645
diff
changeset
|
1067 | |
| 9986 | 1068 | return types; |
| 2086 | 1069 | } |
| 1070 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1071 | static GList * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1072 | zephyr_chat_info(PurpleProtocolChat *protocol_chat, PurpleConnection * gc) { |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
1073 | GList *m = NULL; |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
1074 | PurpleProtocolChatEntry *pce; |
|
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
1075 | |
|
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
1076 | pce = g_new0(PurpleProtocolChatEntry, 1); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
1077 | |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7475
diff
changeset
|
1078 | pce->label = _("_Class:"); |
| 5234 | 1079 | pce->identifier = "class"; |
| 3158 | 1080 | m = g_list_append(m, pce); |
| 2086 | 1081 | |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
1082 | pce = g_new0(PurpleProtocolChatEntry, 1); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
1083 | |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7475
diff
changeset
|
1084 | pce->label = _("_Instance:"); |
| 5234 | 1085 | pce->identifier = "instance"; |
| 3158 | 1086 | m = g_list_append(m, pce); |
| 2086 | 1087 | |
|
36555
fc17a4351e63
Replaced struct proto_chat_entry with PurpleProtocolChatEntry
Ankit Vani <a@nevitus.org>
parents:
36545
diff
changeset
|
1088 | pce = g_new0(PurpleProtocolChatEntry, 1); |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
1089 | |
|
7841
0000a4c68bf8
[gaim-migrate @ 8494]
Mark Doliner <markdoliner@pidgin.im>
parents:
7475
diff
changeset
|
1090 | pce->label = _("_Recipient:"); |
| 5234 | 1091 | pce->identifier = "recipient"; |
| 3158 | 1092 | m = g_list_append(m, pce); |
| 2086 | 1093 | |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
1094 | return m; |
| 2086 | 1095 | } |
| 1096 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1097 | static char * |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1098 | zephyr_get_chat_name(PurpleProtocolChat *protocol_chat, GHashTable *data) { |
| 9922 | 1099 | gchar* zclass = g_hash_table_lookup(data,"class"); |
| 1100 | gchar* inst = g_hash_table_lookup(data,"instance"); | |
| 1101 | gchar* recipient = g_hash_table_lookup(data, "recipient"); | |
| 1102 | if (!zclass) /* This should never happen */ | |
| 1103 | zclass = ""; | |
| 1104 | if (!inst) | |
| 1105 | inst = "*"; | |
| 1106 | if (!recipient) | |
| 1107 | recipient = ""; | |
| 1108 | return g_strdup_printf("%s,%s,%s",zclass,inst,recipient); | |
|
9917
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9912
diff
changeset
|
1109 | } |
|
2fbb3c9fab2b
[gaim-migrate @ 10809]
Daniel Atallah <datallah@pidgin.im>
parents:
9912
diff
changeset
|
1110 | |
| 9922 | 1111 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1112 | static void |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1113 | zephyr_triple_open_personal(zephyr_triple *zt, PurpleConnection *gc, char *instance) |
| 2086 | 1114 | { |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1115 | if (!g_ascii_strcasecmp(instance, "*")) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1116 | instance = "PERSONAL"; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1117 | } |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1118 | zephyr_triple_open(zt, gc, instance); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1119 | } |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1120 | |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1121 | static void |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1122 | zephyr_join_chat(PurpleConnection *gc, ZSubscription_t *sub) |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1123 | { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1124 | GSList *l; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1125 | zephyr_triple *zt; |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1126 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
|
40150
eda298799a8e
Add some NULL checks to silence scan-build.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40131
diff
changeset
|
1127 | |
|
eda298799a8e
Add some NULL checks to silence scan-build.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40131
diff
changeset
|
1128 | g_return_if_fail(zephyr != NULL); |
|
eda298799a8e
Add some NULL checks to silence scan-build.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
40131
diff
changeset
|
1129 | |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1130 | if (!sub->zsub_class) { |
|
2205
68c42ce8eba6
[gaim-migrate @ 2215]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2170
diff
changeset
|
1131 | return; |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1132 | } |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1133 | if (!g_ascii_strcasecmp(sub->zsub_class, "%host%")) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1134 | sub->zsub_class = zephyr->ourhost; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1135 | } else if (!g_ascii_strcasecmp(sub->zsub_class, "%canon%")) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1136 | sub->zsub_class = zephyr->ourhostcanon; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1137 | } |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1138 | |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1139 | if (!sub->zsub_classinst || *sub->zsub_classinst == '\0') { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1140 | sub->zsub_classinst = "*"; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1141 | } else if (!g_ascii_strcasecmp(sub->zsub_classinst, "%host%")) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1142 | sub->zsub_classinst = zephyr->ourhost; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1143 | } else if (!g_ascii_strcasecmp(sub->zsub_classinst, "%canon%")) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1144 | sub->zsub_classinst = zephyr->ourhostcanon; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1145 | } |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1146 | |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1147 | if (!sub->zsub_recipient || *sub->zsub_recipient == '*') { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1148 | sub->zsub_recipient = ""; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1149 | } else if (!g_ascii_strcasecmp(sub->zsub_recipient, "%me%")) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1150 | sub->zsub_recipient = zephyr->username; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1151 | } |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1152 | |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1153 | l = g_slist_find_custom(zephyr->subscrips, &sub, (GCompareFunc)zephyr_triple_subset); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1154 | if (l) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1155 | zt = l->data; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1156 | if (!zt->open) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1157 | zephyr_triple_open_personal(zt, gc, sub->zsub_classinst); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1158 | } |
| 2086 | 1159 | return; |
| 1160 | } | |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1161 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
1162 | if (!zephyr->subscribe_to(zephyr, sub)) { |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1163 | /* Called when the server notifies us a message couldn't get sent */ |
| 9478 | 1164 | /* XXX output better subscription information */ |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1165 | gchar *subscribe_failed = g_strdup_printf(_("Attempt to subscribe to %s,%s,%s failed"), |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1166 | sub->zsub_class, sub->zsub_classinst, sub->zsub_recipient); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1167 | purple_notify_error(gc,"", subscribe_failed, NULL, purple_request_cpar_from_connection(gc)); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1168 | g_free(subscribe_failed); |
| 2086 | 1169 | return; |
| 1170 | } | |
| 1171 | ||
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1172 | zt = zephyr_triple_new(zephyr, sub); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1173 | zephyr->subscrips = g_slist_append(zephyr->subscrips, zt); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1174 | zephyr_triple_open_personal(zt, gc, sub->zsub_classinst); |
| 2086 | 1175 | } |
| 1176 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1177 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1178 | zephyr_protocol_chat_join(PurpleProtocolChat *protocol_chat, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1179 | PurpleConnection *gc, GHashTable * data) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1180 | { |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1181 | ZSubscription_t sub = { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1182 | .zsub_class = g_hash_table_lookup(data, "class"), |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1183 | .zsub_classinst = g_hash_table_lookup(data, "instance"), |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1184 | .zsub_recipient = g_hash_table_lookup(data, "recipient") |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1185 | }; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1186 | zephyr_join_chat(gc, &sub); |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1187 | } |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1188 | |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1189 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1190 | zephyr_chat_leave(PurpleProtocolChat *protocol_chat, PurpleConnection * gc, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1191 | int id) |
| 2086 | 1192 | { |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1193 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1194 | GSList *l; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1195 | |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1196 | l = g_slist_find_custom(zephyr->subscrips, GINT_TO_POINTER(id), zephyr_triple_cmp_id); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1197 | if (l) { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1198 | zephyr_triple *zt = l->data; |
| 2086 | 1199 | zt->open = FALSE; |
| 9610 | 1200 | zt->id = ++(zephyr->last_id); |
| 2086 | 1201 | } |
| 1202 | } | |
| 1203 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40633
diff
changeset
|
1204 | static PurpleChat * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40633
diff
changeset
|
1205 | zephyr_find_blist_chat(PurpleProtocolClient *client, PurpleAccount *account, |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40633
diff
changeset
|
1206 | const char *name) |
| 9478 | 1207 | { |
| 15884 | 1208 | PurpleBlistNode *gnode, *cnode; |
| 9478 | 1209 | |
| 1210 | /* XXX needs to be %host%,%canon%, and %me% clean */ | |
|
39665
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39480
diff
changeset
|
1211 | for (gnode = purple_blist_get_default_root(); gnode; |
|
2172e3b8eeef
Rename some buddy list accessor functions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39480
diff
changeset
|
1212 | gnode = purple_blist_node_get_sibling_next(gnode)) { |
|
24945
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1213 | for(cnode = purple_blist_node_get_first_child(gnode); |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1214 | cnode; |
|
6678a8c83797
Some more struct hiding.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24398
diff
changeset
|
1215 | cnode = purple_blist_node_get_sibling_next(cnode)) { |
| 15884 | 1216 | PurpleChat *chat = (PurpleChat*)cnode; |
|
39918
1c8e11f9274f
Fix several memory leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
1217 | const gchar *zclass, *inst, *recip; |
| 9478 | 1218 | char** triple; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23352
diff
changeset
|
1219 | GHashTable *components; |
|
34696
6e0d13978666
Global replace to use GObject-style macros. See details.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
1220 | if(!PURPLE_IS_CHAT(cnode)) |
| 9478 | 1221 | continue; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23352
diff
changeset
|
1222 | if(purple_chat_get_account(chat) != account) |
| 9478 | 1223 | continue; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23352
diff
changeset
|
1224 | components = purple_chat_get_components(chat); |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23352
diff
changeset
|
1225 | if(!(zclass = g_hash_table_lookup(components, "class"))) |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23352
diff
changeset
|
1226 | continue; |
|
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23352
diff
changeset
|
1227 | if(!(inst = g_hash_table_lookup(components, "instance"))) |
|
39918
1c8e11f9274f
Fix several memory leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
1228 | inst = ""; |
|
24398
4865c2ee6ea8
Start hiding blist.h internals in prpls.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23352
diff
changeset
|
1229 | if(!(recip = g_hash_table_lookup(components, "recipient"))) |
|
39918
1c8e11f9274f
Fix several memory leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
1230 | recip = ""; |
| 15884 | 1231 | /* purple_debug_info("zephyr","in zephyr_find_blist_chat name: %s\n",name?name:""); */ |
| 9478 | 1232 | triple = g_strsplit(name,",",3); |
|
39918
1c8e11f9274f
Fix several memory leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
1233 | if (!g_ascii_strcasecmp(triple[0], zclass) && |
|
1c8e11f9274f
Fix several memory leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
1234 | !g_ascii_strcasecmp(triple[1], inst) && |
|
1c8e11f9274f
Fix several memory leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
1235 | !g_ascii_strcasecmp(triple[2], recip)) { |
|
1c8e11f9274f
Fix several memory leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
1236 | g_strfreev(triple); |
| 9478 | 1237 | return chat; |
|
39918
1c8e11f9274f
Fix several memory leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
1238 | } |
|
1c8e11f9274f
Fix several memory leaks.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39913
diff
changeset
|
1239 | g_strfreev(triple); |
| 9478 | 1240 | } |
| 1241 | } | |
| 1242 | return NULL; | |
| 1243 | } | |
| 15884 | 1244 | static const char *zephyr_list_icon(PurpleAccount * a, PurpleBuddy * b) |
|
5202
2c78987f497b
[gaim-migrate @ 5568]
Mark Doliner <markdoliner@pidgin.im>
parents:
5136
diff
changeset
|
1245 | { |
|
2c78987f497b
[gaim-migrate @ 5568]
Mark Doliner <markdoliner@pidgin.im>
parents:
5136
diff
changeset
|
1246 | return "zephyr"; |
|
2c78987f497b
[gaim-migrate @ 5568]
Mark Doliner <markdoliner@pidgin.im>
parents:
5136
diff
changeset
|
1247 | } |
|
2c78987f497b
[gaim-migrate @ 5568]
Mark Doliner <markdoliner@pidgin.im>
parents:
5136
diff
changeset
|
1248 | |
|
40732
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1249 | static unsigned int |
|
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1250 | zephyr_send_typing(G_GNUC_UNUSED PurpleProtocolIM *im, PurpleConnection *gc, const char *who, PurpleIMTypingState state) |
|
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1251 | { |
|
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1252 | zephyr_account *zephyr; |
| 9478 | 1253 | gchar *recipient; |
|
40732
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1254 | |
|
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1255 | if (state == PURPLE_IM_NOT_TYPING) { |
| 9896 | 1256 | return 0; |
|
40732
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1257 | } |
|
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1258 | |
|
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1259 | zephyr = purple_connection_get_protocol_data(gc); |
| 9478 | 1260 | /* XXX We probably should care if this fails. Or maybe we don't want to */ |
| 1261 | if (!who) { | |
| 15884 | 1262 | purple_debug_info("zephyr", "who is null\n"); |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
1263 | recipient = zephyr_normalize_local_realm(zephyr, ""); |
| 9478 | 1264 | } else { |
| 10111 | 1265 | char *comma = strrchr(who, ','); |
| 9896 | 1266 | /* Don't ping broadcast (chat) recipients */ |
| 1267 | /* The strrchr case finds a realm-stripped broadcast subscription | |
| 1268 | e.g. comma is the last character in the string */ | |
|
40732
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1269 | if (comma && ((*(comma+1) == '\0') || (*(comma+1) == '@'))) { |
| 9896 | 1270 | return 0; |
|
40732
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1271 | } |
|
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1272 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
1273 | recipient = zephyr_normalize_local_realm(zephyr, who); |
| 9478 | 1274 | } |
| 1275 | ||
|
40732
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1276 | purple_debug_info("zephyr", "about to send typing notification to %s", recipient); |
|
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1277 | zephyr_send_message(zephyr, "MESSAGE", "PERSONAL", recipient, "", "", "PING"); |
|
0ac1c00269b1
Send typing for tzc too.
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40715
diff
changeset
|
1278 | purple_debug_info("zephyr", "sent typing notification\n"); |
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13548
diff
changeset
|
1279 | |
|
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13548
diff
changeset
|
1280 | /* |
|
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13548
diff
changeset
|
1281 | * TODO: Is this correct? It means we will call |
|
35499
c4c5e0a670b1
Fix namespaces issues in libpurple.
Ankit Vani <a@nevitus.org>
parents:
35005
diff
changeset
|
1282 | * purple_serv_send_typing(gc, who, PURPLE_IM_TYPING) once every 15 seconds |
| 15884 | 1283 | * until the Purple user stops typing. |
|
13844
835b8f7b3d1d
[gaim-migrate @ 16295]
Mark Doliner <markdoliner@pidgin.im>
parents:
13548
diff
changeset
|
1284 | */ |
| 9478 | 1285 | return ZEPHYR_TYPING_SEND_TIMEOUT; |
| 1286 | } | |
| 8212 | 1287 | |
| 9434 | 1288 | |
| 1289 | ||
| 15884 | 1290 | static void zephyr_chat_set_topic(PurpleConnection * gc, int id, const char *topic) |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
1291 | { |
|
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
1292 | zephyr_triple *zt; |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
34578
diff
changeset
|
1293 | PurpleChatConversation *gcc; |
| 9896 | 1294 | gchar *topic_utf8; |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1295 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1296 | GSList *l; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1297 | |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1298 | l = g_slist_find_custom(zephyr->subscrips, GINT_TO_POINTER(id), zephyr_triple_cmp_id); |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1299 | if (!l) { |
| 9986 | 1300 | return; |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1301 | } |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1302 | zt = l->data; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1303 | |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1304 | gcc = purple_conversations_find_chat_with_account(zt->name, purple_connection_get_account(gc)); |
| 9434 | 1305 | |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
1306 | topic_utf8 = convert_to_utf8(topic, zephyr->encoding); |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1307 | purple_chat_conversation_set_topic(gcc, zephyr->username, topic_utf8); |
| 9896 | 1308 | g_free(topic_utf8); |
| 9434 | 1309 | } |
| 1310 | ||
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1311 | static void |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1312 | zephyr_protocol_chat_set_topic(PurpleProtocolChat *protocol_chat, |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1313 | PurpleConnection *gc, int id, const char *topic) |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1314 | { |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1315 | zephyr_chat_set_topic(gc, id, topic); |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1316 | } |
|
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1317 | |
| 9434 | 1318 | /* commands */ |
| 1319 | ||
| 15884 | 1320 | static PurpleCmdRet zephyr_purple_cmd_msg(PurpleConversation *conv, |
| 9896 | 1321 | const char *cmd, char **args, char **error, void *data) |
| 9434 | 1322 | { |
| 9896 | 1323 | char *recipient; |
|
33694
dabb189b6ac9
zephyr.c: Fix multiple leaks
Niels Thykier <niels@thykier.net>
parents:
32698
diff
changeset
|
1324 | PurpleCmdRet ret; |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32678
diff
changeset
|
1325 | PurpleConnection *gc = purple_conversation_get_connection(conv); |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1326 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc);; |
| 9896 | 1327 | if (!g_ascii_strcasecmp(args[0],"*")) |
| 15884 | 1328 | return PURPLE_CMD_RET_FAILED; /* "*" is not a valid argument */ |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1329 | else |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
1330 | recipient = zephyr_normalize_local_realm(zephyr, args[0]); |
| 9434 | 1331 | |
|
33694
dabb189b6ac9
zephyr.c: Fix multiple leaks
Niels Thykier <niels@thykier.net>
parents:
32698
diff
changeset
|
1332 | if (strlen(recipient) < 1) { |
|
dabb189b6ac9
zephyr.c: Fix multiple leaks
Niels Thykier <niels@thykier.net>
parents:
32698
diff
changeset
|
1333 | g_free(recipient); |
| 15884 | 1334 | return PURPLE_CMD_RET_FAILED; /* a null recipient is a chat message, not an IM */ |
|
33694
dabb189b6ac9
zephyr.c: Fix multiple leaks
Niels Thykier <niels@thykier.net>
parents:
32698
diff
changeset
|
1335 | } |
| 9478 | 1336 | |
| 9896 | 1337 | if (zephyr_send_message(zephyr,"MESSAGE","PERSONAL",recipient,args[1],zephyr_get_signature(),"")) |
|
33694
dabb189b6ac9
zephyr.c: Fix multiple leaks
Niels Thykier <niels@thykier.net>
parents:
32698
diff
changeset
|
1338 | ret = PURPLE_CMD_RET_OK; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1339 | else |
|
33694
dabb189b6ac9
zephyr.c: Fix multiple leaks
Niels Thykier <niels@thykier.net>
parents:
32698
diff
changeset
|
1340 | ret = PURPLE_CMD_RET_FAILED; |
|
dabb189b6ac9
zephyr.c: Fix multiple leaks
Niels Thykier <niels@thykier.net>
parents:
32698
diff
changeset
|
1341 | g_free(recipient); |
|
dabb189b6ac9
zephyr.c: Fix multiple leaks
Niels Thykier <niels@thykier.net>
parents:
32698
diff
changeset
|
1342 | return ret; |
| 9434 | 1343 | } |
| 1344 | ||
| 15884 | 1345 | static PurpleCmdRet zephyr_purple_cmd_zlocate(PurpleConversation *conv, |
| 9896 | 1346 | const char *cmd, char **args, char **error, void *data) |
| 9434 | 1347 | { |
|
40708
53a26c29d26c
Move the PurpleProtocolServer interface to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40703
diff
changeset
|
1348 | zephyr_zloc(NULL, purple_conversation_get_connection(conv),args[0]); |
| 15884 | 1349 | return PURPLE_CMD_RET_OK; |
| 9434 | 1350 | } |
| 1351 | ||
| 15884 | 1352 | static PurpleCmdRet zephyr_purple_cmd_instance(PurpleConversation *conv, |
| 9896 | 1353 | const char *cmd, char **args, char **error, void *data) |
| 9434 | 1354 | { |
| 9896 | 1355 | /* Currently it sets the instance with leading spaces and |
| 1356 | * all. This might not be the best thing to do, though having | |
| 1357 | * one word isn't ideal either. */ | |
| 9434 | 1358 | |
| 9896 | 1359 | const char* instance = args[0]; |
|
34643
e261a066d78d
Refactored zephyr protocol to use GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
1360 | zephyr_chat_set_topic(purple_conversation_get_connection(conv), |
|
e261a066d78d
Refactored zephyr protocol to use GObject conversation API
Ankit Vani <a@nevitus.org>
parents:
34625
diff
changeset
|
1361 | purple_chat_conversation_get_id(PURPLE_CHAT_CONVERSATION(conv)),instance); |
| 15884 | 1362 | return PURPLE_CMD_RET_OK; |
| 9434 | 1363 | } |
| 1364 | ||
| 15884 | 1365 | static PurpleCmdRet zephyr_purple_cmd_joinchat_cir(PurpleConversation *conv, |
| 9896 | 1366 | const char *cmd, char **args, char **error, void *data) |
| 9434 | 1367 | { |
| 9896 | 1368 | /* Join a new zephyr chat */ |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1369 | ZSubscription_t sub = { |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1370 | .zsub_class = args[0], |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1371 | .zsub_classinst = args[1], |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1372 | .zsub_recipient = args[2] |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1373 | }; |
|
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1374 | zephyr_join_chat(purple_conversation_get_connection(conv), &sub); |
| 15884 | 1375 | return PURPLE_CMD_RET_OK; |
| 9434 | 1376 | } |
| 1377 | ||
| 15884 | 1378 | static PurpleCmdRet zephyr_purple_cmd_zi(PurpleConversation *conv, |
| 9896 | 1379 | const char *cmd, char **args, char **error, void *data) |
| 9434 | 1380 | { |
| 9896 | 1381 | /* args = instance, message */ |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32678
diff
changeset
|
1382 | PurpleConnection *gc = purple_conversation_get_connection(conv); |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1383 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
| 9896 | 1384 | if ( zephyr_send_message(zephyr,"message",args[0],"",args[1],zephyr_get_signature(),"")) |
| 15884 | 1385 | return PURPLE_CMD_RET_OK; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1386 | else |
| 15884 | 1387 | return PURPLE_CMD_RET_FAILED; |
| 9434 | 1388 | } |
| 1389 | ||
| 15884 | 1390 | static PurpleCmdRet zephyr_purple_cmd_zci(PurpleConversation *conv, |
| 9896 | 1391 | const char *cmd, char **args, char **error, void *data) |
| 9434 | 1392 | { |
| 9896 | 1393 | /* args = class, instance, message */ |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32678
diff
changeset
|
1394 | PurpleConnection *gc = purple_conversation_get_connection(conv); |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1395 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
| 9896 | 1396 | if ( zephyr_send_message(zephyr,args[0],args[1],"",args[2],zephyr_get_signature(),"")) |
| 15884 | 1397 | return PURPLE_CMD_RET_OK; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1398 | else |
| 15884 | 1399 | return PURPLE_CMD_RET_FAILED; |
| 9434 | 1400 | } |
|
8644
ba37f1cc0006
[gaim-migrate @ 9396]
Mark Doliner <markdoliner@pidgin.im>
parents:
8641
diff
changeset
|
1401 | |
| 15884 | 1402 | static PurpleCmdRet zephyr_purple_cmd_zcir(PurpleConversation *conv, |
| 9896 | 1403 | const char *cmd, char **args, char **error, void *data) |
| 9434 | 1404 | { |
| 9896 | 1405 | /* args = class, instance, recipient, message */ |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32678
diff
changeset
|
1406 | PurpleConnection *gc = purple_conversation_get_connection(conv); |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1407 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1408 | if ( zephyr_send_message(zephyr,args[0],args[1],args[2],args[3],zephyr_get_signature(),"")) |
| 15884 | 1409 | return PURPLE_CMD_RET_OK; |
| 9896 | 1410 | else |
| 15884 | 1411 | return PURPLE_CMD_RET_FAILED; |
| 8212 | 1412 | } |
| 1413 | ||
| 15884 | 1414 | static PurpleCmdRet zephyr_purple_cmd_zir(PurpleConversation *conv, |
| 9896 | 1415 | const char *cmd, char **args, char **error, void *data) |
| 9434 | 1416 | { |
| 9896 | 1417 | /* args = instance, recipient, message */ |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32678
diff
changeset
|
1418 | PurpleConnection *gc = purple_conversation_get_connection(conv); |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1419 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1420 | if ( zephyr_send_message(zephyr,"message",args[0],args[1],args[2],zephyr_get_signature(),"")) |
| 15884 | 1421 | return PURPLE_CMD_RET_OK; |
| 9896 | 1422 | else |
| 15884 | 1423 | return PURPLE_CMD_RET_FAILED; |
| 9434 | 1424 | } |
| 1425 | ||
| 15884 | 1426 | static PurpleCmdRet zephyr_purple_cmd_zc(PurpleConversation *conv, |
| 9896 | 1427 | const char *cmd, char **args, char **error, void *data) |
| 9434 | 1428 | { |
| 9896 | 1429 | /* args = class, message */ |
|
32698
154e4a2a6287
Our API really shouldn't have a 'gc' in it anymore.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32678
diff
changeset
|
1430 | PurpleConnection *gc = purple_conversation_get_connection(conv); |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1431 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1432 | if ( zephyr_send_message(zephyr,args[0],"PERSONAL","",args[1],zephyr_get_signature(),"")) |
| 15884 | 1433 | return PURPLE_CMD_RET_OK; |
| 9896 | 1434 | else |
| 15884 | 1435 | return PURPLE_CMD_RET_FAILED; |
| 9434 | 1436 | } |
| 1437 | ||
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
20288
diff
changeset
|
1438 | static void zephyr_register_slash_commands(void) |
| 9434 | 1439 | { |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1440 | PurpleCmdId id; |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1441 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1442 | id = purple_cmd_register("msg","ws", PURPLE_CMD_P_PROTOCOL, |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1443 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 9896 | 1444 | "prpl-zephyr", |
| 15884 | 1445 | zephyr_purple_cmd_msg, _("msg <nick> <message>: Send a private message to a user"), NULL); |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1446 | cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id)); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1447 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1448 | id = purple_cmd_register("zlocate","w", PURPLE_CMD_P_PROTOCOL, |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1449 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 9896 | 1450 | "prpl-zephyr", |
| 15884 | 1451 | zephyr_purple_cmd_zlocate, _("zlocate <nick>: Locate user"), NULL); |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1452 | cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id)); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1453 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1454 | id = purple_cmd_register("zl","w", PURPLE_CMD_P_PROTOCOL, |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1455 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 9896 | 1456 | "prpl-zephyr", |
| 15884 | 1457 | zephyr_purple_cmd_zlocate, _("zl <nick>: Locate user"), NULL); |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1458 | cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id)); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1459 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1460 | id = purple_cmd_register("instance","s", PURPLE_CMD_P_PROTOCOL, |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1461 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 9896 | 1462 | "prpl-zephyr", |
| 15884 | 1463 | zephyr_purple_cmd_instance, _("instance <instance>: Set the instance to be used on this class"), NULL); |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1464 | cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id)); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1465 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1466 | id = purple_cmd_register("inst","s", PURPLE_CMD_P_PROTOCOL, |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1467 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 9896 | 1468 | "prpl-zephyr", |
| 15884 | 1469 | zephyr_purple_cmd_instance, _("inst <instance>: Set the instance to be used on this class"), NULL); |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1470 | cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id)); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1471 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1472 | id = purple_cmd_register("topic","s", PURPLE_CMD_P_PROTOCOL, |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1473 | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
|
10038
3589c2eed81c
[gaim-migrate @ 10997]
Luke Schierer <lschiere@pidgin.im>
parents:
10009
diff
changeset
|
1474 | "prpl-zephyr", |
| 15884 | 1475 | zephyr_purple_cmd_instance, _("topic <instance>: Set the instance to be used on this class"), NULL); |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1476 | cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id)); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1477 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1478 | id = purple_cmd_register("sub", "www", PURPLE_CMD_P_PROTOCOL, |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1479 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 9896 | 1480 | "prpl-zephyr", |
| 15884 | 1481 | zephyr_purple_cmd_joinchat_cir, |
| 9896 | 1482 | _("sub <class> <instance> <recipient>: Join a new chat"), NULL); |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1483 | cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id)); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1484 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1485 | id = purple_cmd_register("zi","ws", PURPLE_CMD_P_PROTOCOL, |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1486 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 9896 | 1487 | "prpl-zephyr", |
| 15884 | 1488 | zephyr_purple_cmd_zi, _("zi <instance>: Send a message to <message,<i>instance</i>,*>"), NULL); |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1489 | cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id)); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1490 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1491 | id = purple_cmd_register("zci","wws",PURPLE_CMD_P_PROTOCOL, |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1492 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 9896 | 1493 | "prpl-zephyr", |
| 15884 | 1494 | zephyr_purple_cmd_zci, |
| 9896 | 1495 | _("zci <class> <instance>: Send a message to <<i>class</i>,<i>instance</i>,*>"), NULL); |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1496 | cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id)); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1497 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1498 | id = purple_cmd_register("zcir","wwws",PURPLE_CMD_P_PROTOCOL, |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1499 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 9896 | 1500 | "prpl-zephyr", |
| 15884 | 1501 | zephyr_purple_cmd_zcir, |
| 9896 | 1502 | _("zcir <class> <instance> <recipient>: Send a message to <<i>class</i>,<i>instance</i>,<i>recipient</i>>"), NULL); |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1503 | cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id)); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1504 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1505 | id = purple_cmd_register("zir","wws",PURPLE_CMD_P_PROTOCOL, |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1506 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 9896 | 1507 | "prpl-zephyr", |
| 15884 | 1508 | zephyr_purple_cmd_zir, |
| 9896 | 1509 | _("zir <instance> <recipient>: Send a message to <MESSAGE,<i>instance</i>,<i>recipient</i>>"), NULL); |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1510 | cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id)); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1511 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1512 | id = purple_cmd_register("zc","ws", PURPLE_CMD_P_PROTOCOL, |
|
36545
23b59a16c808
Replaced some _prpl_ stuff with _protocol_
Ankit Vani <a@nevitus.org>
parents:
36544
diff
changeset
|
1513 | PURPLE_CMD_FLAG_IM | PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_PROTOCOL_ONLY, |
| 9896 | 1514 | "prpl-zephyr", |
| 15884 | 1515 | zephyr_purple_cmd_zc, _("zc <class>: Send a message to <<i>class</i>,PERSONAL,*>"), NULL); |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1516 | cmds = g_slist_prepend(cmds, GUINT_TO_POINTER(id)); |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1517 | } |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1518 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1519 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1520 | static void zephyr_unregister_slash_commands(void) |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1521 | { |
|
40052
cc03b5af25ea
Use GSList functions instead of manual iterations
qarkai <qarkai@gmail.com>
parents:
40045
diff
changeset
|
1522 | g_slist_free_full(cmds, (GDestroyNotify)purple_cmd_unregister); |
| 9434 | 1523 | } |
| 1524 | ||
| 1525 | ||
|
40703
153098577f8c
Inline zephyr_resubscribe
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40702
diff
changeset
|
1526 | /* Resubscribe to the in-memory list of subscriptions and also unsubscriptions */ |
|
153098577f8c
Inline zephyr_resubscribe
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40702
diff
changeset
|
1527 | static void |
|
153098577f8c
Inline zephyr_resubscribe
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40702
diff
changeset
|
1528 | zephyr_action_resubscribe(PurpleProtocolAction *action) |
| 9427 | 1529 | { |
|
40703
153098577f8c
Inline zephyr_resubscribe
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40702
diff
changeset
|
1530 | zephyr_account *zephyr = purple_connection_get_protocol_data(action->connection); |
|
153098577f8c
Inline zephyr_resubscribe
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40702
diff
changeset
|
1531 | |
|
40702
d036174d9e22
zephyr_subscribe_to refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40701
diff
changeset
|
1532 | for (GSList *s = zephyr->subscrips; s; s = s->next) { |
|
d036174d9e22
zephyr_subscribe_to refactoring
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40701
diff
changeset
|
1533 | zephyr_triple *zt = s->data; |
| 9896 | 1534 | /* XXX We really should care if this fails */ |
|
40733
1bad06536f81
Use ZSubscription_t in zephyr_triple
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40732
diff
changeset
|
1535 | zephyr->subscribe_to(zephyr, &zt->sub); |
| 9896 | 1536 | } |
| 1537 | /* XXX handle unsubscriptions */ | |
| 9427 | 1538 | } |
| 1539 | ||
| 1540 | ||
|
36535
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1541 | static void zephyr_action_get_subs_from_server(PurpleProtocolAction *action) |
| 9478 | 1542 | { |
|
36535
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1543 | PurpleConnection *gc = action->connection; |
|
32265
8007f413c665
Convert zephyr prpl to use accessor functions purple_connection_get_protocol_data() and purple_connection_set_protocol_data().
Andrew Victor <andrew.victor@mxit.com>
parents:
32191
diff
changeset
|
1544 | zephyr_account *zephyr = purple_connection_get_protocol_data(gc); |
|
40750
e87c321f05fa
Move tzc and zeph02 to own modules and some cleanup
Arkadiy Illarionov <qarkai@gmail.com>
parents:
40739
diff
changeset
|
1545 | zephyr->get_subs_from_server(zephyr, gc); |
| 9478 | 1546 | } |
| 1547 | ||
| 1548 | ||
|
40634
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40633
diff
changeset
|
1549 | static GList * |
|
4d3018b00ad4
Fix the PurpleProtocolClient interface and split it out to its own file.
Gary Kramlich <grim@reaperworld.com>
parents:
40633
diff
changeset
|
1550 | zephyr_get_actions(PurpleProtocolClient *client, PurpleConnection *gc) { |
| 9427 | 1551 | GList *list = NULL; |
|
36535
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1552 | PurpleProtocolAction *act = NULL; |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1553 | |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1554 | act = purple_protocol_action_new(_("Resubscribe"), zephyr_action_resubscribe); |
| 9427 | 1555 | list = g_list_append(list, act); |
| 1556 | ||
|
36535
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1557 | act = purple_protocol_action_new(_("Retrieve subscriptions from server"), zephyr_action_get_subs_from_server); |
| 9478 | 1558 | list = g_list_append(list,act); |
| 1559 | ||
| 9427 | 1560 | return list; |
| 1561 | } | |
| 1562 | ||
|
36600
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1563 | |
|
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1564 | static void |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1565 | zephyr_protocol_init(ZephyrProtocol *self) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1566 | { |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1567 | PurpleProtocol *protocol = PURPLE_PROTOCOL(self); |
| 15884 | 1568 | PurpleAccountOption *option; |
|
39831
c7e0d1617aae
zephyr: Fix const-ness of variable loading.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1569 | const gchar *tmp = get_exposure_level(); |
| 11033 | 1570 | |
| 37004 | 1571 | protocol->id = "prpl-zephyr"; |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
1572 | protocol->name = "Zephyr"; |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
1573 | protocol->options = OPT_PROTO_CHAT_TOPIC | OPT_PROTO_NO_PASSWORD; |
|
36600
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1574 | |
| 15884 | 1575 | option = purple_account_option_bool_new(_("Use tzc"), "use_tzc", FALSE); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37005
diff
changeset
|
1576 | protocol->account_options = g_list_append(protocol->account_options, option); |
| 9896 | 1577 | |
| 15884 | 1578 | option = purple_account_option_string_new(_("tzc command"), "tzc_command", "/usr/bin/tzc -e %s"); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37005
diff
changeset
|
1579 | protocol->account_options = g_list_append(protocol->account_options, option); |
| 9896 | 1580 | |
| 15884 | 1581 | option = purple_account_option_bool_new(_("Export to .anyone"), "write_anyone", FALSE); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37005
diff
changeset
|
1582 | protocol->account_options = g_list_append(protocol->account_options, option); |
| 8212 | 1583 | |
| 15884 | 1584 | option = purple_account_option_bool_new(_("Export to .zephyr.subs"), "write_zsubs", FALSE); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37005
diff
changeset
|
1585 | protocol->account_options = g_list_append(protocol->account_options, option); |
| 8212 | 1586 | |
| 15884 | 1587 | option = purple_account_option_bool_new(_("Import from .anyone"), "read_anyone", TRUE); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37005
diff
changeset
|
1588 | protocol->account_options = g_list_append(protocol->account_options, option); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1589 | |
| 15884 | 1590 | option = purple_account_option_bool_new(_("Import from .zephyr.subs"), "read_zsubs", TRUE); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37005
diff
changeset
|
1591 | protocol->account_options = g_list_append(protocol->account_options, option); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1592 | |
| 15884 | 1593 | option = purple_account_option_string_new(_("Realm"), "realm", ""); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37005
diff
changeset
|
1594 | protocol->account_options = g_list_append(protocol->account_options, option); |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
30138
diff
changeset
|
1595 | |
|
39913
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39896
diff
changeset
|
1596 | option = purple_account_option_string_new(_("Exposure"), "exposure_level", |
|
ce96d4639dc7
Remove redundant conditions.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39896
diff
changeset
|
1597 | tmp); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37005
diff
changeset
|
1598 | protocol->account_options = g_list_append(protocol->account_options, option); |
| 8212 | 1599 | |
| 15884 | 1600 | option = purple_account_option_string_new(_("Encoding"), "encoding", ZEPHYR_FALLBACK_CHARSET); |
|
37038
8832d14d7d0c
Rename 'protocol_options' field of PurpleProtocol to more appropriate 'account_options'
Ankit Vani <a@nevitus.org>
parents:
37005
diff
changeset
|
1601 | protocol->account_options = g_list_append(protocol->account_options, option); |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
1602 | } |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
1603 | |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
1604 | |
|
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
1605 | static void |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1606 | zephyr_protocol_class_init(ZephyrProtocolClass *klass) |
|
36684
ecc74498e088
Refactored other protocols to use instance init
Ankit Vani <a@nevitus.org>
parents:
36678
diff
changeset
|
1607 | { |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1608 | PurpleProtocolClass *protocol_class = PURPLE_PROTOCOL_CLASS(klass); |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1609 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1610 | protocol_class->login = zephyr_login; |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1611 | protocol_class->close = zephyr_close; |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1612 | protocol_class->status_types = zephyr_status_types; |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1613 | protocol_class->list_icon = zephyr_list_icon; |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1614 | } |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1615 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1616 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1617 | static void |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1618 | zephyr_protocol_class_finalize(G_GNUC_UNUSED ZephyrProtocolClass *klass) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1619 | { |
|
36663
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1620 | } |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1621 | |
|
c61b6dbc1f03
Make protocols unregister their commands when being removed
Ankit Vani <a@nevitus.org>
parents:
36653
diff
changeset
|
1622 | |
|
36600
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1623 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39665
diff
changeset
|
1624 | zephyr_protocol_client_iface_init(PurpleProtocolClientInterface *client_iface) |
|
36600
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1625 | { |
|
36737
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1626 | client_iface->get_actions = zephyr_get_actions; |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1627 | client_iface->normalize = zephyr_normalize; |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1628 | client_iface->find_blist_chat = zephyr_find_blist_chat; |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1629 | } |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1630 | |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1631 | |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1632 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39665
diff
changeset
|
1633 | zephyr_protocol_server_iface_init(PurpleProtocolServerInterface *server_iface) |
|
36737
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1634 | { |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1635 | server_iface->get_info = zephyr_zloc; |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1636 | server_iface->set_status = zephyr_set_status; |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1637 | |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1638 | server_iface->set_info = NULL; /* XXX Location? */ |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1639 | server_iface->set_buddy_icon = NULL; /* XXX */ |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1640 | } |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1641 | |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1642 | |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1643 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39665
diff
changeset
|
1644 | zephyr_protocol_im_iface_init(PurpleProtocolIMInterface *im_iface) |
|
36737
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1645 | { |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1646 | im_iface->send = zephyr_send_im; |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1647 | im_iface->send_typing = zephyr_send_typing; |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1648 | } |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1649 | |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1650 | |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1651 | static void |
|
39757
4a5ba806d8c9
Rename *Iface to more standard names.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39665
diff
changeset
|
1652 | zephyr_protocol_chat_iface_init(PurpleProtocolChatInterface *chat_iface) |
|
36737
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1653 | { |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1654 | chat_iface->info = zephyr_chat_info; |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1655 | chat_iface->join = zephyr_protocol_chat_join; |
|
36737
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1656 | chat_iface->get_name = zephyr_get_chat_name; |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1657 | chat_iface->leave = zephyr_chat_leave; |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1658 | chat_iface->send = zephyr_chat_send; |
|
40697
81f81f5d2f39
Split PurpleProtocolChat to its own file and clean up the API.
Gary Kramlich <grim@reaperworld.com>
parents:
40686
diff
changeset
|
1659 | chat_iface->set_topic = zephyr_protocol_chat_set_topic; |
|
36737
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1660 | |
|
1ce884985d2d
Refactored yahoo, zephyr to use the new protocol interfaces
Ankit Vani <a@nevitus.org>
parents:
36729
diff
changeset
|
1661 | chat_iface->get_user_real_name = NULL; /* XXX */ |
|
36600
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1662 | } |
|
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1663 | |
|
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1664 | |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1665 | G_DEFINE_DYNAMIC_TYPE_EXTENDED( |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1666 | ZephyrProtocol, zephyr_protocol, PURPLE_TYPE_PROTOCOL, 0, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1667 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1668 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_CLIENT, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1669 | zephyr_protocol_client_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1670 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1671 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_SERVER, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1672 | zephyr_protocol_server_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1673 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1674 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_IM, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1675 | zephyr_protocol_im_iface_init) |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1676 | |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1677 | G_IMPLEMENT_INTERFACE_DYNAMIC(PURPLE_TYPE_PROTOCOL_CHAT, |
|
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1678 | zephyr_protocol_chat_iface_init)); |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36684
diff
changeset
|
1679 | |
|
36535
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1680 | static PurplePluginInfo *plugin_query(GError **error) |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1681 | { |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1682 | return purple_plugin_info_new( |
|
36985
9faafe43603e
Rename protocol plugin IDs to prpl-*
Ankit Vani <a@nevitus.org>
parents:
36862
diff
changeset
|
1683 | "id", "prpl-zephyr", |
|
36638
5f6dcd83e8c1
Seperate plugin and protocol IDs. Protocol ID example: "msn". Plugin ID example: "protocol-msn".
Ankit Vani <a@nevitus.org>
parents:
36637
diff
changeset
|
1684 | "name", "Zephyr Protocol", |
|
36535
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1685 | "version", DISPLAY_VERSION, |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1686 | "category", N_("Protocol"), |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1687 | "summary", N_("Zephyr Protocol Plugin"), |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1688 | "description", N_("Zephyr Protocol Plugin"), |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1689 | "website", PURPLE_WEBSITE, |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1690 | "abi-version", PURPLE_ABI_VERSION, |
|
36653
4084c34c051d
Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1691 | "flags", PURPLE_PLUGIN_INFO_FLAGS_INTERNAL | |
|
4084c34c051d
Override gplugin info's "flags" property. Added PURPLE_PLUGIN_INFO_FLAGS_INTERNAL and PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD.
Ankit Vani <a@nevitus.org>
parents:
36638
diff
changeset
|
1692 | PURPLE_PLUGIN_INFO_FLAGS_AUTO_LOAD, |
|
36535
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1693 | NULL |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1694 | ); |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1695 | } |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1696 | |
|
36600
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1697 | |
|
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1698 | static gboolean |
|
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1699 | plugin_load(PurplePlugin *plugin, GError **error) |
|
5205
242b8aa81328
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5202
diff
changeset
|
1700 | { |
|
39894
7eab91ea30a1
Replace Purple type macros by GObject macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
39760
diff
changeset
|
1701 | zephyr_protocol_register_type(G_TYPE_MODULE(plugin)); |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36684
diff
changeset
|
1702 | |
|
36628
3d43ca8d69ee
Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents:
36616
diff
changeset
|
1703 | my_protocol = purple_protocols_add(ZEPHYR_TYPE_PROTOCOL, error); |
|
3d43ca8d69ee
Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents:
36616
diff
changeset
|
1704 | if (!my_protocol) |
|
36600
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1705 | return FALSE; |
|
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1706 | |
| 9896 | 1707 | zephyr_register_slash_commands(); |
|
36677
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36663
diff
changeset
|
1708 | |
|
36535
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1709 | return TRUE; |
| 2086 | 1710 | } |
| 1711 | ||
|
36600
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1712 | |
|
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1713 | static gboolean |
|
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1714 | plugin_unload(PurplePlugin *plugin, GError **error) |
|
36535
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1715 | { |
|
36677
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36663
diff
changeset
|
1716 | zephyr_unregister_slash_commands(); |
|
081733748bbc
Only initialize/finalize protocol class data in *_base_init/finalize for protocols.
Ankit Vani <a@nevitus.org>
parents:
36663
diff
changeset
|
1717 | |
|
36628
3d43ca8d69ee
Refactored the protocols to use the error argument of purple_protocols_{add/remove}
Ankit Vani <a@nevitus.org>
parents:
36616
diff
changeset
|
1718 | if (!purple_protocols_remove(my_protocol, error)) |
|
36600
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1719 | return FALSE; |
|
c7d2eee19333
Refactored zephyr to use the new protocol API
Ankit Vani <a@nevitus.org>
parents:
36583
diff
changeset
|
1720 | |
|
36535
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1721 | return TRUE; |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1722 | } |
|
66c2fb23888f
Refactored zephye to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
34864
diff
changeset
|
1723 | |
|
36714
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36684
diff
changeset
|
1724 | |
|
ec178f7d66da
Refactored protocols to use the new type definition macros
Ankit Vani <a@nevitus.org>
parents:
36684
diff
changeset
|
1725 | PURPLE_PLUGIN_INIT(zephyr, plugin_query, plugin_load, plugin_unload); |