annotate src/pounce.c @ 12522:560ddc8d26f3

[gaim-migrate @ 14834] Connect the account-modified signal to a callback to update the menu bar. This ensures the Accounts menu is in sync when changes are made to an account. committer: Tailor Script <tailor@pidgin.im>
author Richard Laager <rlaager@wiktel.com>
date Sat, 17 Dec 2005 06:16:35 +0000
parents 06065a4847ff
children ebed1bbedb04
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
1 /**
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
2 * @file pounce.c Buddy Pounce API
6837
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
3 * @ingroup core
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
4 *
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 * gaim
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
6 *
8046
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7627
diff changeset
7 * Gaim is the legal property of its developers, whose names are too numerous
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7627
diff changeset
8 * to list here. Please refer to the COPYRIGHT file distributed with this
fa6395637e2c [gaim-migrate @ 8730]
Sean Egan <seanegan@gmail.com>
parents: 7627
diff changeset
9 * source distribution.
6837
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
10 *
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * This program is free software; you can redistribute it and/or modify
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 * it under the terms of the GNU General Public License as published by
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * the Free Software Foundation; either version 2 of the License, or
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * (at your option) any later version.
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * This program is distributed in the hope that it will be useful,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * GNU General Public License for more details.
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 * You should have received a copy of the GNU General Public License
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 * along with this program; if not, write to the Free Software
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
24 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5866
diff changeset
25 #include "internal.h"
6837
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
26 #include "conversation.h"
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5866
diff changeset
27 #include "debug.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5866
diff changeset
28 #include "pounce.h"
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
29
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
30 #include "debug.h"
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
31 #include "pounce.h"
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
32 #include "util.h"
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
33
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
34 typedef struct
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
35 {
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
36 GString *buffer;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
37
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
38 GaimPounce *pounce;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
39 GaimPounceEvent events;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
40
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
41 char *ui_name;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
42 char *pouncee;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
43 char *protocol_id;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
44 char *event_type;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
45 char *action_name;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
46 char *param_name;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
47 char *account_name;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
48
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
49 } PounceParserData;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
50
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
51 typedef struct
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
52 {
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
53 char *name;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
54
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
55 gboolean enabled;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
56
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
57 GHashTable *atts;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
58
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
59 } GaimPounceActionData;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
60
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
61 typedef struct
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
62 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
63 char *ui;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
64 GaimPounceCb cb;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
65 void (*new_pounce)(GaimPounce *);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
66 void (*free_pounce)(GaimPounce *);
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
67
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
68 } GaimPounceHandler;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
69
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
70
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
71 static GHashTable *pounce_handlers = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
72 static GList *pounces = NULL;
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
73 static guint save_timer = 0;
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
74 static gboolean pounces_loaded = FALSE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
75
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
76
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
77 /*********************************************************************
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
78 * Private utility functions *
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
79 *********************************************************************/
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
80
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
81 static GaimPounceActionData *
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
82 find_action_data(const GaimPounce *pounce, const char *name)
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
83 {
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
84 GaimPounceActionData *action;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
85
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
86 g_return_val_if_fail(pounce != NULL, NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
87 g_return_val_if_fail(name != NULL, NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
88
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
89 action = g_hash_table_lookup(pounce->actions, name);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
90
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
91 return action;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
92 }
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
93
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
94 static void
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
95 free_action_data(gpointer data)
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
96 {
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
97 GaimPounceActionData *action_data = data;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
98
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
99 g_free(action_data->name);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
100
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
101 g_hash_table_destroy(action_data->atts);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
102
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
103 g_free(action_data);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
104 }
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
105
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
106
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
107 /*********************************************************************
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
108 * Writing to disk *
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
109 *********************************************************************/
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
110
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
111 static void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
112 action_parameter_to_xmlnode(gpointer key, gpointer value, gpointer user_data)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
113 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
114 const char *name, *param_value;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
115 xmlnode *node, *child;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
116
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
117 name = (const char *)key;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
118 param_value = (const char *)value;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
119 node = (xmlnode *)user_data;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
120
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
121 child = xmlnode_new_child(node, "param");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
122 xmlnode_set_attrib(child, "name", name);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
123 xmlnode_insert_data(child, param_value, -1);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
124 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
125
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
126 static void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
127 action_parameter_list_to_xmlnode(gpointer key, gpointer value, gpointer user_data)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
128 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
129 const char *action;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
130 GaimPounceActionData *action_data;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
131 xmlnode *node, *child;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
132
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
133 action = (const char *)key;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
134 action_data = (GaimPounceActionData *)value;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
135 node = (xmlnode *)user_data;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
136
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
137 if (!action_data->enabled)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
138 return;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
139
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
140 child = xmlnode_new_child(node, "action");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
141 xmlnode_set_attrib(child, "type", action);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
142
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
143 g_hash_table_foreach(action_data->atts, action_parameter_to_xmlnode, child);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
144 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
145
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
146 static void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
147 add_event_to_xmlnode(xmlnode *node, const char *type)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
148 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
149 xmlnode *child;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
150
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
151 child = xmlnode_new_child(node, "event");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
152 xmlnode_set_attrib(child, "type", type);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
153 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
154
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
155 static xmlnode *
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
156 pounce_to_xmlnode(GaimPounce *pounce)
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
157 {
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
158 xmlnode *node, *child;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
159 GaimAccount *pouncer;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
160 GaimPounceEvent events;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
161
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
162 pouncer = gaim_pounce_get_pouncer(pounce);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
163 events = gaim_pounce_get_events(pounce);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
164
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
165 node = xmlnode_new("pounce");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
166 xmlnode_set_attrib(node, "ui", pounce->ui_type);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
167
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
168 child = xmlnode_new_child(node, "account");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
169 xmlnode_set_attrib(child, "protocol", pouncer->protocol_id);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
170 xmlnode_insert_data(child, gaim_account_get_username(pouncer), -1);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
171
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
172 child = xmlnode_new_child(node, "pouncee");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
173 xmlnode_insert_data(child, gaim_pounce_get_pouncee(pounce), -1);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
174
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
175 /* Write pounce events */
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
176 child = xmlnode_new_child(node, "events");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
177 if (events & GAIM_POUNCE_SIGNON)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
178 add_event_to_xmlnode(child, "sign-on");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
179 if (events & GAIM_POUNCE_SIGNOFF)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
180 add_event_to_xmlnode(child, "sign-off");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
181 if (events & GAIM_POUNCE_AWAY)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
182 add_event_to_xmlnode(child, "away");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
183 if (events & GAIM_POUNCE_AWAY_RETURN)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
184 add_event_to_xmlnode(child, "return-from-away");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
185 if (events & GAIM_POUNCE_IDLE)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
186 add_event_to_xmlnode(child, "idle");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
187 if (events & GAIM_POUNCE_IDLE_RETURN)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
188 add_event_to_xmlnode(child, "return-from-idle");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
189 if (events & GAIM_POUNCE_TYPING)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
190 add_event_to_xmlnode(child, "start-typing");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
191 if (events & GAIM_POUNCE_TYPING_STOPPED)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
192 add_event_to_xmlnode(child, "stop-typing");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
193
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
194 /* Write pounce actions */
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
195 child = xmlnode_new_child(node, "actions");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
196 g_hash_table_foreach(pounce->actions, action_parameter_list_to_xmlnode, child);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
197
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
198 if (gaim_pounce_get_save(pounce))
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
199 child = xmlnode_new_child(node, "save");
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
200
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
201 return node;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
202 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
203
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
204 static xmlnode *
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
205 pounces_to_xmlnode(void)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
206 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
207 xmlnode *node, *child;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
208 GList *cur;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
209
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
210 node = xmlnode_new("pounces");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
211 xmlnode_set_attrib(node, "version", "1.0");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
212
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
213 for (cur = gaim_pounces_get_all(); cur != NULL; cur = cur->next)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
214 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
215 child = pounce_to_xmlnode(cur->data);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
216 xmlnode_insert_child(node, child);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
217 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
218
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
219 return node;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
220 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
221
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
222 static void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
223 sync_pounces(void)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
224 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
225 xmlnode *node;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
226 char *data;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
227
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
228 if (!pounces_loaded)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
229 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
230 gaim_debug_error("pounce", "Attempted to save buddy pounces before "
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
231 "they were read!\n");
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
232 return;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
233 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
234
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
235 node = pounces_to_xmlnode();
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
236 data = xmlnode_to_formatted_str(node, NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
237 gaim_util_write_data_to_file("pounces.xml", data, -1);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
238 g_free(data);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
239 xmlnode_free(node);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
240 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
241
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
242 static gboolean
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
243 save_cb(gpointer data)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
244 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
245 sync_pounces();
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
246 save_timer = 0;
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
247 return FALSE;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
248 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
249
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
250 static void
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
251 schedule_pounces_save(void)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
252 {
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
253 if (save_timer == 0)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
254 save_timer = gaim_timeout_add(5000, save_cb, NULL);
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
255 }
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
256
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
257
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
258 /*********************************************************************
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
259 * Reading from disk *
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
260 *********************************************************************/
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
261
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
262 static void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
263 free_parser_data(gpointer user_data)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
264 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
265 PounceParserData *data = user_data;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
266
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
267 if (data->buffer != NULL)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
268 g_string_free(data->buffer, TRUE);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
269
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
270 if (data->ui_name != NULL) g_free(data->ui_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
271 if (data->pouncee != NULL) g_free(data->pouncee);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
272 if (data->protocol_id != NULL) g_free(data->protocol_id);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
273 if (data->event_type != NULL) g_free(data->event_type);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
274 if (data->action_name != NULL) g_free(data->action_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
275 if (data->param_name != NULL) g_free(data->param_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
276 if (data->account_name != NULL) g_free(data->account_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
277
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
278 g_free(data);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
279 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
280
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
281 static void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
282 start_element_handler(GMarkupParseContext *context,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
283 const gchar *element_name,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
284 const gchar **attribute_names,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
285 const gchar **attribute_values,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
286 gpointer user_data, GError **error)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
287 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
288 PounceParserData *data = user_data;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
289 GHashTable *atts;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
290 int i;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
291
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
292 atts = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
293
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
294 for (i = 0; attribute_names[i] != NULL; i++) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
295 g_hash_table_insert(atts, g_strdup(attribute_names[i]),
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
296 g_strdup(attribute_values[i]));
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
297 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
298
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
299 if (data->buffer != NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
300 g_string_free(data->buffer, TRUE);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
301 data->buffer = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
302 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
303
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
304 if (!strcmp(element_name, "pounce")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
305 const char *ui = g_hash_table_lookup(atts, "ui");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
306
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
307 if (ui == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
308 gaim_debug(GAIM_DEBUG_ERROR, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
309 "Unset 'ui' parameter for pounce!\n");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
310 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
311 else
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
312 data->ui_name = g_strdup(ui);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
313
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
314 data->events = 0;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
315 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
316 else if (!strcmp(element_name, "account")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
317 const char *protocol_id = g_hash_table_lookup(atts, "protocol");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
318
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
319 if (protocol_id == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
320 gaim_debug(GAIM_DEBUG_ERROR, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
321 "Unset 'protocol' parameter for account!\n");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
322 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
323 else
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
324 data->protocol_id = g_strdup(protocol_id);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
325 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
326 else if (!strcmp(element_name, "event")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
327 const char *type = g_hash_table_lookup(atts, "type");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
328
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
329 if (type == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
330 gaim_debug(GAIM_DEBUG_ERROR, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
331 "Unset 'type' parameter for event!\n");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
332 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
333 else
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
334 data->event_type = g_strdup(type);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
335 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
336 else if (!strcmp(element_name, "action")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
337 const char *type = g_hash_table_lookup(atts, "type");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
338
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
339 if (type == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
340 gaim_debug(GAIM_DEBUG_ERROR, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
341 "Unset 'type' parameter for action!\n");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
342 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
343 else
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
344 data->action_name = g_strdup(type);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
345 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
346 else if (!strcmp(element_name, "param")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
347 const char *param_name = g_hash_table_lookup(atts, "name");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
348
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
349 if (param_name == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
350 gaim_debug(GAIM_DEBUG_ERROR, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
351 "Unset 'name' parameter for param!\n");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
352 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
353 else
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
354 data->param_name = g_strdup(param_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
355 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
356
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
357 g_hash_table_destroy(atts);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
358 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
359
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
360 static void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
361 end_element_handler(GMarkupParseContext *context, const gchar *element_name,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
362 gpointer user_data, GError **error)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
363 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
364 PounceParserData *data = user_data;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
365 gchar *buffer = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
366
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
367 if (data->buffer != NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
368 buffer = g_string_free(data->buffer, FALSE);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
369 data->buffer = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
370 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
371
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
372 if (!strcmp(element_name, "account")) {
9598
0ad01d743f60 [gaim-migrate @ 10441]
Mark Doliner <mark@kingant.net>
parents: 8549
diff changeset
373 g_free(data->account_name);
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
374 data->account_name = g_strdup(buffer);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
375 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
376 else if (!strcmp(element_name, "pouncee")) {
9598
0ad01d743f60 [gaim-migrate @ 10441]
Mark Doliner <mark@kingant.net>
parents: 8549
diff changeset
377 g_free(data->pouncee);
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
378 data->pouncee = g_strdup(buffer);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
379 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
380 else if (!strcmp(element_name, "event")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
381 if (!strcmp(data->event_type, "sign-on"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
382 data->events |= GAIM_POUNCE_SIGNON;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
383 else if (!strcmp(data->event_type, "sign-off"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
384 data->events |= GAIM_POUNCE_SIGNOFF;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
385 else if (!strcmp(data->event_type, "away"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
386 data->events |= GAIM_POUNCE_AWAY;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
387 else if (!strcmp(data->event_type, "return-from-away"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
388 data->events |= GAIM_POUNCE_AWAY_RETURN;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
389 else if (!strcmp(data->event_type, "idle"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
390 data->events |= GAIM_POUNCE_IDLE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
391 else if (!strcmp(data->event_type, "return-from-idle"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
392 data->events |= GAIM_POUNCE_IDLE_RETURN;
6444
601c2a52d74a [gaim-migrate @ 6953]
Christian Hammond <chipx86@chipx86.com>
parents: 6271
diff changeset
393 else if (!strcmp(data->event_type, "start-typing"))
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
394 data->events |= GAIM_POUNCE_TYPING;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
395 else if (!strcmp(data->event_type, "stop-typing"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
396 data->events |= GAIM_POUNCE_TYPING_STOPPED;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
397
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
398 g_free(data->event_type);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
399 data->event_type = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
400 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
401 else if (!strcmp(element_name, "action")) {
9598
0ad01d743f60 [gaim-migrate @ 10441]
Mark Doliner <mark@kingant.net>
parents: 8549
diff changeset
402 if (data->pounce != NULL) {
0ad01d743f60 [gaim-migrate @ 10441]
Mark Doliner <mark@kingant.net>
parents: 8549
diff changeset
403 gaim_pounce_action_register(data->pounce, data->action_name);
0ad01d743f60 [gaim-migrate @ 10441]
Mark Doliner <mark@kingant.net>
parents: 8549
diff changeset
404 gaim_pounce_action_set_enabled(data->pounce, data->action_name, TRUE);
0ad01d743f60 [gaim-migrate @ 10441]
Mark Doliner <mark@kingant.net>
parents: 8549
diff changeset
405 }
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
406
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
407 g_free(data->action_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
408 data->action_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
409 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
410 else if (!strcmp(element_name, "param")) {
9598
0ad01d743f60 [gaim-migrate @ 10441]
Mark Doliner <mark@kingant.net>
parents: 8549
diff changeset
411 if (data->pounce != NULL) {
0ad01d743f60 [gaim-migrate @ 10441]
Mark Doliner <mark@kingant.net>
parents: 8549
diff changeset
412 gaim_pounce_action_set_attribute(data->pounce, data->action_name,
0ad01d743f60 [gaim-migrate @ 10441]
Mark Doliner <mark@kingant.net>
parents: 8549
diff changeset
413 data->param_name, buffer);
0ad01d743f60 [gaim-migrate @ 10441]
Mark Doliner <mark@kingant.net>
parents: 8549
diff changeset
414 }
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
415
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
416 g_free(data->param_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
417 data->param_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
418 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
419 else if (!strcmp(element_name, "events")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
420 GaimAccount *account;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
421
7132
d17a587efeb3 [gaim-migrate @ 7699]
Nathan Walp <nwalp@pidgin.im>
parents: 7118
diff changeset
422 account = gaim_accounts_find(data->account_name, data->protocol_id);
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
423
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
424 g_free(data->account_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
425 g_free(data->protocol_id);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
426
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
427 data->account_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
428 data->protocol_id = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
429
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
430 if (account == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
431 gaim_debug(GAIM_DEBUG_ERROR, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
432 "Account for pounce not found!\n");
12002
06065a4847ff [gaim-migrate @ 14295]
Mark Doliner <mark@kingant.net>
parents: 11935
diff changeset
433 /*
06065a4847ff [gaim-migrate @ 14295]
Mark Doliner <mark@kingant.net>
parents: 11935
diff changeset
434 * This pounce has effectively been removed, so make
06065a4847ff [gaim-migrate @ 14295]
Mark Doliner <mark@kingant.net>
parents: 11935
diff changeset
435 * sure that we save the changes to pounces.xml
06065a4847ff [gaim-migrate @ 14295]
Mark Doliner <mark@kingant.net>
parents: 11935
diff changeset
436 */
06065a4847ff [gaim-migrate @ 14295]
Mark Doliner <mark@kingant.net>
parents: 11935
diff changeset
437 schedule_pounces_save();
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
438 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
439 else {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
440 gaim_debug(GAIM_DEBUG_INFO, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
441 "Creating pounce: %s, %s\n", data->ui_name,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
442 data->pouncee);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
443
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
444 data->pounce = gaim_pounce_new(data->ui_name, account,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
445 data->pouncee, data->events);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
446 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
447
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
448 g_free(data->pouncee);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
449 data->pouncee = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
450 }
5878
9e54bb2ee3b5 [gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents: 5875
diff changeset
451 else if (!strcmp(element_name, "save")) {
12002
06065a4847ff [gaim-migrate @ 14295]
Mark Doliner <mark@kingant.net>
parents: 11935
diff changeset
452 if (data->pounce != NULL)
06065a4847ff [gaim-migrate @ 14295]
Mark Doliner <mark@kingant.net>
parents: 11935
diff changeset
453 gaim_pounce_set_save(data->pounce, TRUE);
5878
9e54bb2ee3b5 [gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents: 5875
diff changeset
454 }
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
455 else if (!strcmp(element_name, "pounce")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
456 data->pounce = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
457 data->events = 0;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
458
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
459 if (data->ui_name != NULL) g_free(data->ui_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
460 if (data->pouncee != NULL) g_free(data->pouncee);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
461 if (data->protocol_id != NULL) g_free(data->protocol_id);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
462 if (data->event_type != NULL) g_free(data->event_type);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
463 if (data->action_name != NULL) g_free(data->action_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
464 if (data->param_name != NULL) g_free(data->param_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
465 if (data->account_name != NULL) g_free(data->account_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
466
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
467 data->ui_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
468 data->pounce = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
469 data->protocol_id = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
470 data->event_type = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
471 data->action_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
472 data->param_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
473 data->account_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
474 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
475
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
476 if (buffer != NULL)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
477 g_free(buffer);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
478 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
479
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
480 static void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
481 text_handler(GMarkupParseContext *context, const gchar *text,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
482 gsize text_len, gpointer user_data, GError **error)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
483 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
484 PounceParserData *data = user_data;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
485
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
486 if (data->buffer == NULL)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
487 data->buffer = g_string_new_len(text, text_len);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
488 else
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
489 g_string_append_len(data->buffer, text, text_len);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
490 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
491
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
492 static GMarkupParser pounces_parser =
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
493 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
494 start_element_handler,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
495 end_element_handler,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
496 text_handler,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
497 NULL,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
498 NULL
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
499 };
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
500
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
501 gboolean
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
502 gaim_pounces_load(void)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
503 {
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
504 gchar *filename = g_build_filename(gaim_user_dir(), "pounces.xml", NULL);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
505 gchar *contents = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
506 gsize length;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
507 GMarkupParseContext *context;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
508 GError *error = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
509 PounceParserData *parser_data;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
510
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
511 if (filename == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
512 pounces_loaded = TRUE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
513 return FALSE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
514 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
515
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
516 if (!g_file_get_contents(filename, &contents, &length, &error)) {
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10432
diff changeset
517 gaim_debug(GAIM_DEBUG_ERROR, "pounce",
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
518 "Error reading pounces: %s\n", error->message);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
519
5940
94ad4d45346a [gaim-migrate @ 6380]
Nathan Walp <nwalp@pidgin.im>
parents: 5878
diff changeset
520 g_free(filename);
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
521 g_error_free(error);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
522
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
523 pounces_loaded = TRUE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
524 return FALSE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
525 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
526
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
527 parser_data = g_new0(PounceParserData, 1);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
528
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
529 context = g_markup_parse_context_new(&pounces_parser, 0,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
530 parser_data, free_parser_data);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
531
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
532 if (!g_markup_parse_context_parse(context, contents, length, NULL)) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
533 g_markup_parse_context_free(context);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
534 g_free(contents);
5940
94ad4d45346a [gaim-migrate @ 6380]
Nathan Walp <nwalp@pidgin.im>
parents: 5878
diff changeset
535 g_free(filename);
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
536
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
537 pounces_loaded = TRUE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
538
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
539 return FALSE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
540 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
541
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
542 if (!g_markup_parse_context_end_parse(context, NULL)) {
11033
50224ac8184d [gaim-migrate @ 12919]
Etan Reisner <pidgin@unreliablesource.net>
parents: 10432
diff changeset
543 gaim_debug(GAIM_DEBUG_ERROR, "pounce", "Error parsing %s\n",
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
544 filename);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
545
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
546 g_markup_parse_context_free(context);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
547 g_free(contents);
5940
94ad4d45346a [gaim-migrate @ 6380]
Nathan Walp <nwalp@pidgin.im>
parents: 5878
diff changeset
548 g_free(filename);
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
549 pounces_loaded = TRUE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
550
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
551 return FALSE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
552 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
553
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
554 g_markup_parse_context_free(context);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
555 g_free(contents);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
556 g_free(filename);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
557
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
558 pounces_loaded = TRUE;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
559
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
560 return TRUE;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
561 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
562
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
563
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
564 GaimPounce *
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
565 gaim_pounce_new(const char *ui_type, GaimAccount *pouncer,
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
566 const char *pouncee, GaimPounceEvent event)
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
567 {
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
568 GaimPounce *pounce;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
569 GaimPounceHandler *handler;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
570
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
571 g_return_val_if_fail(ui_type != NULL, NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
572 g_return_val_if_fail(pouncer != NULL, NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
573 g_return_val_if_fail(pouncee != NULL, NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
574 g_return_val_if_fail(event != 0, NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
575
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
576 pounce = g_new0(GaimPounce, 1);
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
577
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
578 pounce->ui_type = g_strdup(ui_type);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
579 pounce->pouncer = pouncer;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
580 pounce->pouncee = g_strdup(pouncee);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
581 pounce->events = event;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
582
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
583 pounce->actions = g_hash_table_new_full(g_str_hash, g_str_equal,
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
584 g_free, free_action_data);
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
585
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
586 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
587
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
588 if (handler != NULL && handler->new_pounce != NULL)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
589 handler->new_pounce(pounce);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
590
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
591 pounces = g_list_append(pounces, pounce);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
592
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
593 schedule_pounces_save();
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
594
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
595 return pounce;
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
596 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
597
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
598 void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
599 gaim_pounce_destroy(GaimPounce *pounce)
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
600 {
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
601 GaimPounceHandler *handler;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
602
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
603 g_return_if_fail(pounce != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
604
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
605 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
606
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
607 pounces = g_list_remove(pounces, pounce);
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
608
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
609 if (pounce->ui_type != NULL) g_free(pounce->ui_type);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
610 if (pounce->pouncee != NULL) g_free(pounce->pouncee);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
611
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
612 g_hash_table_destroy(pounce->actions);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
613
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
614 if (handler != NULL && handler->free_pounce != NULL)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
615 handler->free_pounce(pounce);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
616
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
617 g_free(pounce);
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
618
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
619 schedule_pounces_save();
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
620 }
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
621
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
622 void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
623 gaim_pounce_destroy_all_by_account(GaimAccount *account)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
624 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
625 GaimAccount *pouncer;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
626 GaimPounce *pounce;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
627 GList *l, *l_next;
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
628
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
629 g_return_if_fail(account != NULL);
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
630
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
631 for (l = gaim_pounces_get_all(); l != NULL; l = l_next)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
632 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
633 pounce = (GaimPounce *)l->data;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
634 l_next = l->next;
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
635
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
636 pouncer = gaim_pounce_get_pouncer(pounce);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
637 if (pouncer == account)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
638 gaim_pounce_destroy(pounce);
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
639 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
640 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
641
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
642 void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
643 gaim_pounce_set_events(GaimPounce *pounce, GaimPounceEvent events)
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
644 {
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
645 g_return_if_fail(pounce != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
646 g_return_if_fail(pounce != GAIM_POUNCE_NONE);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
647
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
648 pounce->events = events;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
649
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
650 schedule_pounces_save();
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
651 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
652
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
653 void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
654 gaim_pounce_set_pouncer(GaimPounce *pounce, GaimAccount *pouncer)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
655 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
656 g_return_if_fail(pounce != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
657 g_return_if_fail(pouncer != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
658
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
659 pounce->pouncer = pouncer;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
660
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
661 schedule_pounces_save();
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
662 }
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
663
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
664 void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
665 gaim_pounce_set_pouncee(GaimPounce *pounce, const char *pouncee)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
666 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
667 g_return_if_fail(pounce != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
668 g_return_if_fail(pouncee != NULL);
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
669
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
670 if (pounce->pouncee != NULL)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
671 g_free(pounce->pouncee);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
672
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
673 pounce->pouncee = (pouncee == NULL ? NULL : g_strdup(pouncee));
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
674
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
675 schedule_pounces_save();
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
676 }
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
677
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
678 void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
679 gaim_pounce_set_save(GaimPounce *pounce, gboolean save)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
680 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
681 g_return_if_fail(pounce != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
682
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
683 pounce->save = save;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
684
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
685 schedule_pounces_save();
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
686 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
687
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
688 void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
689 gaim_pounce_action_register(GaimPounce *pounce, const char *name)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
690 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
691 GaimPounceActionData *action_data;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
692
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
693 g_return_if_fail(pounce != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
694 g_return_if_fail(name != NULL);
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
695
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
696 if (g_hash_table_lookup(pounce->actions, name) != NULL)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
697 return;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
698
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
699 action_data = g_new0(GaimPounceActionData, 1);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
700
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
701 action_data->name = g_strdup(name);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
702 action_data->enabled = FALSE;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
703 action_data->atts = g_hash_table_new_full(g_str_hash, g_str_equal,
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
704 g_free, g_free);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
705
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
706 g_hash_table_insert(pounce->actions, g_strdup(name), action_data);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
707
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
708 schedule_pounces_save();
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
709 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
710
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
711 void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
712 gaim_pounce_action_set_enabled(GaimPounce *pounce, const char *action,
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
713 gboolean enabled)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
714 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
715 GaimPounceActionData *action_data;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
716
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
717 g_return_if_fail(pounce != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
718 g_return_if_fail(action != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
719
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
720 action_data = find_action_data(pounce, action);
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
721
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
722 g_return_if_fail(action_data != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
723
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
724 action_data->enabled = enabled;
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
725
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
726 schedule_pounces_save();
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
727 }
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
728
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
729 void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
730 gaim_pounce_action_set_attribute(GaimPounce *pounce, const char *action,
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
731 const char *attr, const char *value)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
732 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
733 GaimPounceActionData *action_data;
5878
9e54bb2ee3b5 [gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents: 5875
diff changeset
734
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
735 g_return_if_fail(pounce != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
736 g_return_if_fail(action != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
737 g_return_if_fail(attr != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
738
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
739 action_data = find_action_data(pounce, action);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
740
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
741 g_return_if_fail(action_data != NULL);
5878
9e54bb2ee3b5 [gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents: 5875
diff changeset
742
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
743 if (value == NULL)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
744 g_hash_table_remove(action_data->atts, attr);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
745 else
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
746 g_hash_table_insert(action_data->atts, g_strdup(attr),
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
747 g_strdup(value));
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
748
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
749 schedule_pounces_save();
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
750 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
751
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
752 void
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
753 gaim_pounce_set_data(GaimPounce *pounce, void *data)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
754 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
755 g_return_if_fail(pounce != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
756
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
757 pounce->data = data;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
758
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
759 schedule_pounces_save();
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
760 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
761
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
762 GaimPounceEvent
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
763 gaim_pounce_get_events(const GaimPounce *pounce)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
764 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
765 g_return_val_if_fail(pounce != NULL, GAIM_POUNCE_NONE);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
766
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
767 return pounce->events;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
768 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
769
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
770 GaimAccount *
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
771 gaim_pounce_get_pouncer(const GaimPounce *pounce)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
772 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
773 g_return_val_if_fail(pounce != NULL, NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
774
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
775 return pounce->pouncer;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
776 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
777
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
778 const char *
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
779 gaim_pounce_get_pouncee(const GaimPounce *pounce)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
780 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
781 g_return_val_if_fail(pounce != NULL, NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
782
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
783 return pounce->pouncee;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
784 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
785
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
786 gboolean
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
787 gaim_pounce_get_save(const GaimPounce *pounce)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
788 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
789 g_return_val_if_fail(pounce != NULL, FALSE);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
790
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
791 return pounce->save;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
792 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
793
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
794 gboolean
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
795 gaim_pounce_action_is_enabled(const GaimPounce *pounce, const char *action)
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
796 {
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
797 GaimPounceActionData *action_data;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
798
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
799 g_return_val_if_fail(pounce != NULL, FALSE);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
800 g_return_val_if_fail(action != NULL, FALSE);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
801
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
802 action_data = find_action_data(pounce, action);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
803
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
804 g_return_val_if_fail(action_data != NULL, FALSE);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
805
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
806 return action_data->enabled;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
807 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
808
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
809 const char *
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
810 gaim_pounce_action_get_attribute(const GaimPounce *pounce,
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
811 const char *action, const char *attr)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
812 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
813 GaimPounceActionData *action_data;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
814
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
815 g_return_val_if_fail(pounce != NULL, NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
816 g_return_val_if_fail(action != NULL, NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
817 g_return_val_if_fail(attr != NULL, NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
818
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
819 action_data = find_action_data(pounce, action);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
820
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
821 g_return_val_if_fail(action_data != NULL, NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
822
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
823 return g_hash_table_lookup(action_data->atts, attr);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
824 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
825
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
826 void *
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
827 gaim_pounce_get_data(const GaimPounce *pounce)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
828 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
829 g_return_val_if_fail(pounce != NULL, NULL);
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
830
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
831 return pounce->data;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
832 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
833
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
834 void
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
835 gaim_pounce_execute(const GaimAccount *pouncer, const char *pouncee,
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
836 GaimPounceEvent events)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
837 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
838 GaimPounce *pounce;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
839 GaimPounceHandler *handler;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
840 GList *l, *l_next;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
841 char *norm_pouncee;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
842
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
843 g_return_if_fail(pouncer != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
844 g_return_if_fail(pouncee != NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
845 g_return_if_fail(events != GAIM_POUNCE_NONE);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
846
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
847 norm_pouncee = g_strdup(gaim_normalize(pouncer, pouncee));
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
848
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
849 for (l = gaim_pounces_get_all(); l != NULL; l = l_next)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
850 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
851 pounce = (GaimPounce *)l->data;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
852 l_next = l->next;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
853
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
854 if ((gaim_pounce_get_events(pounce) & events) &&
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
855 (gaim_pounce_get_pouncer(pounce) == pouncer) &&
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
856 !gaim_utf8_strcasecmp(gaim_normalize(pouncer, gaim_pounce_get_pouncee(pounce)),
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
857 norm_pouncee))
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
858 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
859 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
860
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
861 if (handler != NULL && handler->cb != NULL)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
862 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
863 handler->cb(pounce, events, gaim_pounce_get_data(pounce));
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
864
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
865 if (!gaim_pounce_get_save(pounce))
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
866 gaim_pounce_destroy(pounce);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
867 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
868 }
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
869 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
870
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
871 g_free(norm_pouncee);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
872 }
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
873
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
874 GaimPounce *
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
875 gaim_find_pounce(const GaimAccount *pouncer, const char *pouncee,
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
876 GaimPounceEvent events)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
877 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
878 GaimPounce *pounce = NULL;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
879 GList *l;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
880 char *norm_pouncee;
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
881
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
882 g_return_val_if_fail(pouncer != NULL, NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
883 g_return_val_if_fail(pouncee != NULL, NULL);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
884 g_return_val_if_fail(events != GAIM_POUNCE_NONE, NULL);
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
885
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
886 norm_pouncee = g_strdup(gaim_normalize(pouncer, pouncee));
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
887
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
888 for (l = gaim_pounces_get_all(); l != NULL; l = l->next)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
889 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
890 pounce = (GaimPounce *)l->data;
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
891
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
892 if ((gaim_pounce_get_events(pounce) & events) &&
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
893 (gaim_pounce_get_pouncer(pounce) == pouncer) &&
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
894 !gaim_utf8_strcasecmp(gaim_normalize(pouncer, gaim_pounce_get_pouncee(pounce)),
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
895 norm_pouncee))
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
896 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
897 break;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
898 }
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
899
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
900 pounce = NULL;
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
901 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
902
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
903 g_free(norm_pouncee);
10399
aab0c9508318 [gaim-migrate @ 11630]
Stu Tomlinson <stu@nosnilmot.com>
parents: 9598
diff changeset
904
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
905 return pounce;
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
906 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
907
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
908 void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
909 gaim_pounces_register_handler(const char *ui, GaimPounceCb cb,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
910 void (*new_pounce)(GaimPounce *pounce),
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
911 void (*free_pounce)(GaimPounce *pounce))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
912 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
913 GaimPounceHandler *handler;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
914
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
915 g_return_if_fail(ui != NULL);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
916 g_return_if_fail(cb != NULL);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
917
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
918 handler = g_new0(GaimPounceHandler, 1);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
919
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
920 handler->ui = g_strdup(ui);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
921 handler->cb = cb;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
922 handler->new_pounce = new_pounce;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
923 handler->free_pounce = free_pounce;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
924
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
925 g_hash_table_insert(pounce_handlers, g_strdup(ui), handler);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
926 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
927
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
928 void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
929 gaim_pounces_unregister_handler(const char *ui)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
930 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
931 g_return_if_fail(ui != NULL);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
932
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
933 g_hash_table_remove(pounce_handlers, ui);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
934 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
935
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
936 GList *
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
937 gaim_pounces_get_all(void)
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
938 {
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
939 return pounces;
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
940 }
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
941
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
942 static void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
943 free_pounce_handler(gpointer user_data)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
944 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
945 GaimPounceHandler *handler = (GaimPounceHandler *)user_data;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
946
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
947 g_free(handler->ui);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
948 g_free(handler);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
949 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
950
6837
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
951 static void
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
952 buddy_state_cb(GaimBuddy *buddy, GaimPounceEvent event)
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
953 {
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
954 gaim_pounce_execute(buddy->account, buddy->name, event);
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
955 }
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
956
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
957 static void
11935
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
958 buddy_status_changed_cb(GaimBuddy *buddy, GaimStatus *old_status,
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
959 GaimStatus *status)
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
960 {
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
961 gboolean old_available, available;
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
962
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
963 available = gaim_status_is_available(status);
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
964 old_available = gaim_status_is_available(old_status);
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
965
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
966 if (available && !old_available)
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
967 gaim_pounce_execute(buddy->account, buddy->name,
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
968 GAIM_POUNCE_AWAY_RETURN);
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
969 else if (!available && old_available)
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
970 gaim_pounce_execute(buddy->account, buddy->name,
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
971 GAIM_POUNCE_AWAY);
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
972 }
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
973
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
974 static void
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
975 buddy_idle_changed_cb(GaimBuddy *buddy, gboolean old_idle, gboolean idle)
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
976 {
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
977 if (idle && !old_idle)
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
978 gaim_pounce_execute(buddy->account, buddy->name,
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
979 GAIM_POUNCE_IDLE);
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
980 else if (!idle && old_idle)
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
981 gaim_pounce_execute(buddy->account, buddy->name,
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
982 GAIM_POUNCE_IDLE_RETURN);
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
983 }
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
984
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
985 static void
11706
bcc49c25ef90 [gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents: 11256
diff changeset
986 buddy_typing_cb(GaimAccount *account, const char *name, void *data)
6837
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
987 {
11710
c9bd6decdec4 [gaim-migrate @ 14001]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11708
diff changeset
988 GaimConversation *conv;
6837
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
989
11710
c9bd6decdec4 [gaim-migrate @ 14001]
Daniel Atallah <daniel.atallah@gmail.com>
parents: 11708
diff changeset
990 conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, name, account);
11706
bcc49c25ef90 [gaim-migrate @ 13997]
Richard Laager <rlaager@wiktel.com>
parents: 11256
diff changeset
991 if (conv != NULL)
6837
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
992 {
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
993 GaimPounceEvent event;
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
994
7118
bf630f7dfdcd [gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents: 7107
diff changeset
995 event = (gaim_conv_im_get_typing_state(GAIM_CONV_IM(conv)) == GAIM_TYPING
6837
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
996 ? GAIM_POUNCE_TYPING : GAIM_POUNCE_TYPING_STOPPED);
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
997
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
998 gaim_pounce_execute(account, name, event);
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
999 }
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1000 }
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1001
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1002 void *
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1003 gaim_pounces_get_handle(void)
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1004 {
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1005 static int pounce_handle;
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1006
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1007 return &pounce_handle;
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1008 }
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1009
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1010 void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1011 gaim_pounces_init(void)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1012 {
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1013 void *handle = gaim_pounces_get_handle();
6837
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1014 void *blist_handle = gaim_blist_get_handle();
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1015 void *conv_handle = gaim_conversations_get_handle();
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1016
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1017 pounce_handlers = g_hash_table_new_full(g_str_hash, g_str_equal,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1018 g_free, free_pounce_handler);
6837
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1019
11935
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
1020 gaim_signal_connect(blist_handle, "buddy-idle-changed",
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
1021 handle, GAIM_CALLBACK(buddy_idle_changed_cb), NULL);
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
1022 gaim_signal_connect(blist_handle, "buddy-status-changed",
cb73483c9f63 [gaim-migrate @ 14226]
Etan Reisner <pidgin@unreliablesource.net>
parents: 11710
diff changeset
1023 handle, GAIM_CALLBACK(buddy_status_changed_cb), NULL);
6837
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1024 gaim_signal_connect(blist_handle, "buddy-signed-on",
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1025 handle, GAIM_CALLBACK(buddy_state_cb),
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1026 GINT_TO_POINTER(GAIM_POUNCE_SIGNON));
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1027 gaim_signal_connect(blist_handle, "buddy-signed-off",
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1028 handle, GAIM_CALLBACK(buddy_state_cb),
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1029 GINT_TO_POINTER(GAIM_POUNCE_SIGNOFF));
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1030
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1031 gaim_signal_connect(conv_handle, "buddy-typing",
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1032 handle, GAIM_CALLBACK(buddy_typing_cb), NULL);
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1033 gaim_signal_connect(conv_handle, "buddy-typing-stopped",
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1034 handle, GAIM_CALLBACK(buddy_typing_cb), NULL);
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
1035 }
6837
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1036
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1037 void
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1038 gaim_pounces_uninit()
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1039 {
10432
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1040 if (save_timer != 0)
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1041 {
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1042 gaim_timeout_remove(save_timer);
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1043 save_timer = 0;
dc4475bf718f [gaim-migrate @ 11684]
Mark Doliner <mark@kingant.net>
parents: 10423
diff changeset
1044 sync_pounces();
8235
63c7a16a2c09 [gaim-migrate @ 8958]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
1045 }
63c7a16a2c09 [gaim-migrate @ 8958]
Mark Doliner <mark@kingant.net>
parents: 8046
diff changeset
1046
6837
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1047 gaim_signals_disconnect_by_handle(gaim_pounces_get_handle());
f098765ac919 [gaim-migrate @ 7382]
Christian Hammond <chipx86@chipx86.com>
parents: 6719
diff changeset
1048 }