Mon, 16 Sep 2013 23:02:23 +0530
Use g_object_[sg]et_data in joinpart
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
1 | /** |
| 15884 | 2 | * purple |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
3 | * |
| 15884 | 4 | * Purple is the legal property of its developers, whose names are too numerous |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
6 | * source distribution. |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
7 | * |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
11 | * (at your option) any later version. |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
12 | * |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
16 | * GNU General Public License for more details. |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
17 | * |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
18 | * You should have received a copy of the GNU General Public License |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
19 | * 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:
18122
diff
changeset
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
21 | */ |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
22 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
23 | #include "internal.h" |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
24 | #include "conversation.h" |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
25 | #include "debug.h" |
|
36367
891eea799578
Renamed plugin.[ch] to plugins.[ch], since we (will) no longer have a PurplePlugin structure.
Ankit Vani <a@nevitus.org>
parents:
34728
diff
changeset
|
26 | #include "plugins.h" |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
27 | #include "version.h" |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
28 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
29 | #define JOINPART_PLUGIN_ID "core-rlaager-joinpart" |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
30 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
31 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
32 | /* Preferences */ |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
33 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
34 | /* The number of minutes before a person is considered |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
35 | * to have stopped being part of active conversation. */ |
| 16481 | 36 | #define DELAY_PREF "/plugins/core/joinpart/delay" |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
37 | #define DELAY_DEFAULT 10 |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
38 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
39 | /* The number of people that must be in a room for this |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
40 | * plugin to have any effect */ |
| 16481 | 41 | #define THRESHOLD_PREF "/plugins/core/joinpart/threshold" |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
42 | #define THRESHOLD_DEFAULT 20 |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
43 | |
|
24135
3998dcd1e2fb
In the Join/Part plugin, add the ability to apply the rules to
Richard Laager <rlaager@pidgin.im>
parents:
22606
diff
changeset
|
44 | /* Hide buddies */ |
|
3998dcd1e2fb
In the Join/Part plugin, add the ability to apply the rules to
Richard Laager <rlaager@pidgin.im>
parents:
22606
diff
changeset
|
45 | #define HIDE_BUDDIES_PREF "/plugins/core/joinpart/hide_buddies" |
|
3998dcd1e2fb
In the Join/Part plugin, add the ability to apply the rules to
Richard Laager <rlaager@pidgin.im>
parents:
22606
diff
changeset
|
46 | #define HIDE_BUDDIES_DEFAULT FALSE |
|
3998dcd1e2fb
In the Join/Part plugin, add the ability to apply the rules to
Richard Laager <rlaager@pidgin.im>
parents:
22606
diff
changeset
|
47 | |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
48 | struct joinpart_key |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
49 | { |
| 15884 | 50 | PurpleConversation *conv; |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
51 | char *user; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
52 | }; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
53 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
54 | static guint joinpart_key_hash(const struct joinpart_key *key) |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
55 | { |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
56 | g_return_val_if_fail(key != NULL, 0); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
57 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
58 | return g_direct_hash(key->conv) + g_str_hash(key->user); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
59 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
60 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
61 | static gboolean joinpart_key_equal(const struct joinpart_key *a, const struct joinpart_key *b) |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
62 | { |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
63 | if (a == NULL) |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
64 | return (b == NULL); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
65 | else if (b == NULL) |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
66 | return FALSE; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
67 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
68 | return (a->conv == b->conv) && !strcmp(a->user, b->user); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
69 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
70 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
71 | static void joinpart_key_destroy(struct joinpart_key *key) |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
72 | { |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
73 | g_return_if_fail(key != NULL); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
74 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
75 | g_free(key->user); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
76 | g_free(key); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
77 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
78 | |
| 15884 | 79 | static gboolean should_hide_notice(PurpleConversation *conv, const char *name, |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
80 | GHashTable *users) |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
81 | { |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
28060
diff
changeset
|
82 | PurpleChatConversation *chat; |
|
34304
faf0414a8b51
Fix most of libpurple warnings about -Wsign-compare
Tomasz Wasilczyk <tomkiewicz@cpw.pidgin.im>
parents:
28060
diff
changeset
|
83 | guint threshold; |
| 22606 | 84 | struct joinpart_key key; |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
85 | time_t *last_said; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
86 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
87 | g_return_val_if_fail(conv != NULL, FALSE); |
|
34626
b8b3186aff95
Refactored some libpurple plugins for GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34622
diff
changeset
|
88 | g_return_val_if_fail(PURPLE_IS_CHAT_CONVERSATION(conv), FALSE); |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
89 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
90 | /* If the room is small, don't bother. */ |
|
34628
014583658b51
Refactored libpurple/plugins to use the GObject-based PurpleConversation
Ankit Vani <a@nevitus.org>
parents:
34626
diff
changeset
|
91 | chat = PURPLE_CHAT_CONVERSATION(conv); |
| 15884 | 92 | threshold = purple_prefs_get_int(THRESHOLD_PREF); |
|
34622
753f46dd000f
Global replace - renamed functions and types according to GObject-based PurpleConversation API
Ankit Vani <a@nevitus.org>
parents:
28060
diff
changeset
|
93 | if (g_list_length(purple_chat_conversation_get_users(chat)) < threshold) |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
94 | return FALSE; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
95 | |
|
24135
3998dcd1e2fb
In the Join/Part plugin, add the ability to apply the rules to
Richard Laager <rlaager@pidgin.im>
parents:
22606
diff
changeset
|
96 | if (!purple_prefs_get_bool(HIDE_BUDDIES_PREF) && |
|
34728
8efd73063ecf
Renamed buddy list functions to more appropriate/simler names.
Ankit Vani <a@nevitus.org>
parents:
34670
diff
changeset
|
97 | purple_blist_find_buddy(purple_conversation_get_account(conv), name)) |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
98 | return FALSE; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
99 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
100 | /* Only show the notice if the user has spoken recently. */ |
| 22606 | 101 | key.conv = conv; |
| 102 | key.user = (gchar *)name; | |
| 103 | last_said = g_hash_table_lookup(users, &key); | |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
104 | if (last_said != NULL) |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
105 | { |
| 15884 | 106 | int delay = purple_prefs_get_int(DELAY_PREF); |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
107 | if (delay > 0 && (*last_said + (delay * 60)) >= time(NULL)) |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
108 | return FALSE; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
109 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
110 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
111 | return TRUE; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
112 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
113 | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34628
diff
changeset
|
114 | static gboolean chat_user_leaving_cb(PurpleConversation *conv, const char *name, |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
115 | const char *reason, GHashTable *users) |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
116 | { |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
117 | return should_hide_notice(conv, name, users); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
118 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
119 | |
|
34670
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34628
diff
changeset
|
120 | static gboolean chat_user_joining_cb(PurpleConversation *conv, const char *name, |
|
9bd5bd903dc7
Renamed chat buddies to chat users, and IM conversation typing state to IM typing state.
Ankit Vani <a@nevitus.org>
parents:
34628
diff
changeset
|
121 | PurpleChatUserFlags flags, |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
122 | GHashTable *users) |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
123 | { |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
124 | return should_hide_notice(conv, name, users); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
125 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
126 | |
| 15884 | 127 | static void received_chat_msg_cb(PurpleAccount *account, char *sender, |
| 128 | char *message, PurpleConversation *conv, | |
| 129 | PurpleMessageFlags flags, GHashTable *users) | |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
130 | { |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
131 | struct joinpart_key key; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
132 | time_t *last_said; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
133 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
134 | /* Most of the time, we'll already have tracked the user, |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
135 | * so we avoid memory allocation here. */ |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
136 | key.conv = conv; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
137 | key.user = sender; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
138 | last_said = g_hash_table_lookup(users, &key); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
139 | if (last_said != NULL) |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
140 | { |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
141 | /* They just said something, so update the time. */ |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
142 | time(last_said); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
143 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
144 | else |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
145 | { |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
146 | struct joinpart_key *key2; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
147 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
148 | key2 = g_new(struct joinpart_key, 1); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
149 | key2->conv = conv; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
150 | key2->user = g_strdup(sender); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
151 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
152 | last_said = g_new(time_t, 1); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
153 | time(last_said); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
154 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
155 | g_hash_table_insert(users, key2, last_said); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
156 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
157 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
158 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
159 | static gboolean check_expire_time(struct joinpart_key *key, |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
160 | time_t *last_said, time_t *limit) |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
161 | { |
|
17173
0ab8487ff12a
We can't be sure that the conv still exists, so don't dereference it.
Daniel Atallah <datallah@pidgin.im>
parents:
16745
diff
changeset
|
162 | purple_debug_info("joinpart", "Removing key for %s\n", key->user); |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
163 | return (*last_said < *limit); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
164 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
165 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
166 | static gboolean clean_users_hash(GHashTable *users) |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
167 | { |
| 15884 | 168 | int delay = purple_prefs_get_int(DELAY_PREF); |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
169 | time_t limit = time(NULL) - (60 * delay); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
170 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
171 | g_hash_table_foreach_remove(users, (GHRFunc)check_expire_time, &limit); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
172 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
173 | return TRUE; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
174 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
175 | |
| 15884 | 176 | static PurplePluginPrefFrame * |
| 177 | get_plugin_pref_frame(PurplePlugin *plugin) | |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
178 | { |
| 15884 | 179 | PurplePluginPrefFrame *frame; |
| 180 | PurplePluginPref *ppref; | |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
181 | |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
182 | g_return_val_if_fail(plugin != NULL, FALSE); |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
183 | |
| 15884 | 184 | frame = purple_plugin_pref_frame_new(); |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
185 | |
| 28060 | 186 | ppref = purple_plugin_pref_new_with_label(_("Hide Joins/Parts")); |
| 15884 | 187 | purple_plugin_pref_frame_add(frame, ppref); |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
188 | |
| 15884 | 189 | ppref = purple_plugin_pref_new_with_name_and_label(THRESHOLD_PREF, |
|
28059
176739c0bbc3
Clarify the preference strings for the Join/Part hiding plugin.
Paul Aurich <darkrain42@pidgin.im>
parents:
25716
diff
changeset
|
190 | /* Translators: Followed by an input request a number of people */ |
|
176739c0bbc3
Clarify the preference strings for the Join/Part hiding plugin.
Paul Aurich <darkrain42@pidgin.im>
parents:
25716
diff
changeset
|
191 | _("For rooms with more than this many people")); |
| 15884 | 192 | purple_plugin_pref_set_bounds(ppref, 0, 1000); |
| 193 | purple_plugin_pref_frame_add(frame, ppref); | |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
194 | |
| 15884 | 195 | ppref = purple_plugin_pref_new_with_name_and_label(DELAY_PREF, |
|
28059
176739c0bbc3
Clarify the preference strings for the Join/Part hiding plugin.
Paul Aurich <darkrain42@pidgin.im>
parents:
25716
diff
changeset
|
196 | _("If user has not spoken in this many minutes")); |
| 15884 | 197 | purple_plugin_pref_set_bounds(ppref, 0, 8 * 60); /* 8 Hours */ |
| 198 | purple_plugin_pref_frame_add(frame, ppref); | |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
199 | |
|
24135
3998dcd1e2fb
In the Join/Part plugin, add the ability to apply the rules to
Richard Laager <rlaager@pidgin.im>
parents:
22606
diff
changeset
|
200 | ppref = purple_plugin_pref_new_with_name_and_label(HIDE_BUDDIES_PREF, |
|
3998dcd1e2fb
In the Join/Part plugin, add the ability to apply the rules to
Richard Laager <rlaager@pidgin.im>
parents:
22606
diff
changeset
|
201 | _("Apply hiding rules to buddies")); |
|
3998dcd1e2fb
In the Join/Part plugin, add the ability to apply the rules to
Richard Laager <rlaager@pidgin.im>
parents:
22606
diff
changeset
|
202 | purple_plugin_pref_frame_add(frame, ppref); |
|
3998dcd1e2fb
In the Join/Part plugin, add the ability to apply the rules to
Richard Laager <rlaager@pidgin.im>
parents:
22606
diff
changeset
|
203 | |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
204 | return frame; |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
205 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
206 | |
|
36743
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
207 | static PurplePluginInfo * |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
208 | plugin_query(GError **error) |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
209 | { |
|
36743
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
210 | const gchar * const authors[] = { |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
211 | "Richard Laager <rlaager@pidgin.im>", |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
212 | NULL |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
213 | }; |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
214 | |
|
36743
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
215 | return purple_plugin_info_new( |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
216 | "id", JOINPART_PLUGIN_ID, |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
217 | "name", N_("Join/Part Hiding"), |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
218 | "version", DISPLAY_VERSION, |
|
36747
0b84912ce764
Refactored rest of libpurple C plugins to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36743
diff
changeset
|
219 | "category", N_("User interface"), |
|
36743
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
220 | "summary", N_("Hides extraneous join/part messages."), |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
221 | "description", N_("This plugin hides join/part messages in " |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
222 | "large rooms, except for those users actively " |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
223 | "taking part in a conversation."), |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
224 | "authors", authors, |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
225 | "website", PURPLE_WEBSITE, |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
226 | "abi-version", PURPLE_ABI_VERSION, |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
227 | "preferences-frame", get_plugin_pref_frame, |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
228 | NULL |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
229 | ); |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
230 | } |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
231 | |
|
36743
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
232 | static gboolean plugin_load(PurplePlugin *plugin, GError **error) |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
233 | { |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
234 | void *conv_handle; |
|
36753
a1d2fa3be516
Use g_object_[sg]et_data in joinpart
Ankit Vani <a@nevitus.org>
parents:
36747
diff
changeset
|
235 | GHashTable *users; |
|
a1d2fa3be516
Use g_object_[sg]et_data in joinpart
Ankit Vani <a@nevitus.org>
parents:
36747
diff
changeset
|
236 | guint id; |
|
16745
df2c3d6b609a
And the rest of the plugins that are compiling for me by default...
Gary Kramlich <grim@reaperworld.com>
parents:
16481
diff
changeset
|
237 | |
| 16481 | 238 | purple_prefs_add_none("/plugins/core/joinpart"); |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
239 | |
| 15884 | 240 | purple_prefs_add_int(DELAY_PREF, DELAY_DEFAULT); |
| 241 | purple_prefs_add_int(THRESHOLD_PREF, THRESHOLD_DEFAULT); | |
|
24135
3998dcd1e2fb
In the Join/Part plugin, add the ability to apply the rules to
Richard Laager <rlaager@pidgin.im>
parents:
22606
diff
changeset
|
242 | purple_prefs_add_bool(HIDE_BUDDIES_PREF, HIDE_BUDDIES_DEFAULT); |
|
36743
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
243 | |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
244 | users = g_hash_table_new_full((GHashFunc)joinpart_key_hash, |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
245 | (GEqualFunc)joinpart_key_equal, |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
246 | (GDestroyNotify)joinpart_key_destroy, |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
247 | g_free); |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
248 | |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
249 | conv_handle = purple_conversations_get_handle(); |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
250 | purple_signal_connect(conv_handle, "chat-user-joining", plugin, |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
251 | PURPLE_CALLBACK(chat_user_joining_cb), users); |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
252 | purple_signal_connect(conv_handle, "chat-user-leaving", plugin, |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
253 | PURPLE_CALLBACK(chat_user_leaving_cb), users); |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
254 | purple_signal_connect(conv_handle, "received-chat-msg", plugin, |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
255 | PURPLE_CALLBACK(received_chat_msg_cb), users); |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
256 | |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
257 | /* Cleanup every 5 minutes */ |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
258 | id = purple_timeout_add_seconds(60 * 5, (GSourceFunc)clean_users_hash, users); |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
259 | |
|
36753
a1d2fa3be516
Use g_object_[sg]et_data in joinpart
Ankit Vani <a@nevitus.org>
parents:
36747
diff
changeset
|
260 | g_object_set_data(G_OBJECT(plugin), "users", users); |
|
a1d2fa3be516
Use g_object_[sg]et_data in joinpart
Ankit Vani <a@nevitus.org>
parents:
36747
diff
changeset
|
261 | g_object_set_data(G_OBJECT(plugin), "id", GUINT_TO_POINTER(id)); |
|
a1d2fa3be516
Use g_object_[sg]et_data in joinpart
Ankit Vani <a@nevitus.org>
parents:
36747
diff
changeset
|
262 | |
|
36743
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
263 | return TRUE; |
|
15627
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
264 | } |
|
4be4b97cf1b7
I had this brilliant idea to deal with join/part notices "intelligently".
Richard Laager <rlaager@pidgin.im>
parents:
diff
changeset
|
265 | |
|
36743
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
266 | static gboolean plugin_unload(PurplePlugin *plugin, GError **error) |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
267 | { |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
268 | /* Destroy the hash table. The core plugin code will |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
269 | * disconnect the signals, and since Purple is single-threaded, |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
270 | * we don't have to worry one will be called after this. */ |
|
36753
a1d2fa3be516
Use g_object_[sg]et_data in joinpart
Ankit Vani <a@nevitus.org>
parents:
36747
diff
changeset
|
271 | g_hash_table_destroy((GHashTable *)g_object_get_data(G_OBJECT(plugin), "users")); |
|
36743
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
272 | |
|
36753
a1d2fa3be516
Use g_object_[sg]et_data in joinpart
Ankit Vani <a@nevitus.org>
parents:
36747
diff
changeset
|
273 | purple_timeout_remove(GPOINTER_TO_UINT(g_object_get_data(G_OBJECT(plugin), "id"))); |
|
36743
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
274 | |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
275 | return TRUE; |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
276 | } |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
277 | |
|
3d44db6dd9b4
Refactored joinpart to use the new plugin API
Ankit Vani <a@nevitus.org>
parents:
36574
diff
changeset
|
278 | PURPLE_PLUGIN_INIT(joinpart, plugin_query, plugin_load, plugin_unload); |