annotate src/pounce.c @ 5998:b77c0feec150

[gaim-migrate @ 6446] open_url() now takes a const char * for the URL. committer: Tailor Script <tailor@pidgin.im>
author Christian Hammond <chipx86@chipx86.com>
date Thu, 03 Jul 2003 03:06:18 +0000
parents a4f2aba0848d
children a5a43d03cb51
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
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
3 *
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
4 * gaim
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
5 *
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
6 * Copyright (C) 2003 Christian Hammond <chipx86@gnupdate.org>
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
7 *
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
8 * This program is free software; you can redistribute it and/or modify
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
9 * 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
10 * the Free Software Foundation; either version 2 of the License, or
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
11 * (at your option) any later version.
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
12 *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
13 * This program is distributed in the hope that it will be useful,
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
16 * GNU General Public License for more details.
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
17 *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
18 * You should have received a copy of the GNU General Public License
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
19 * along with this program; if not, write to the Free Software
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
21 *
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
22 */
5872
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5866
diff changeset
23 #include "internal.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5866
diff changeset
24 #include "debug.h"
059d95c67cda [gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents: 5866
diff changeset
25 #include "pounce.h"
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
26
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
27 #include "debug.h"
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
28 #include "pounce.h"
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
29 #include "util.h"
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
30
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
31 typedef struct
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
32 {
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
33 GString *buffer;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
34
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
35 GaimPounce *pounce;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
36 GaimPounceEvent events;
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 char *ui_name;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
39 char *pouncee;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
40 char *protocol_id;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
41 char *event_type;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
42 char *action_name;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
43 char *param_name;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
44 char *account_name;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
45
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
46 } PounceParserData;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
47
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
48 typedef struct
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
49 {
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
50 char *name;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
51
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
52 gboolean enabled;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
53
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
54 GHashTable *atts;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
55
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
56 } GaimPounceActionData;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
57
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
58 typedef struct
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
59 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
60 char *ui;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
61 GaimPounceCb cb;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
62 void (*new_pounce)(GaimPounce *);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
63 void (*free_pounce)(GaimPounce *);
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
64
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
65 } GaimPounceHandler;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
66
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
67
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
68 static GHashTable *pounce_handlers = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
69 static GList *pounces = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
70 static guint pounces_save_timer = 0;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
71 static gboolean pounces_loaded = FALSE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
72
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
73
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
74 static GaimPounceActionData *
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
75 find_action_data(const GaimPounce *pounce, const char *name)
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
76 {
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
77 GaimPounceActionData *action;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
78
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
79 g_return_val_if_fail(pounce != NULL, NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
80 g_return_val_if_fail(name != NULL, NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
81
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
82 action = g_hash_table_lookup(pounce->actions, 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 return 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
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
87 static void
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
88 free_action_data(gpointer data)
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
89 {
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
90 GaimPounceActionData *action_data = data;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
91
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
92 g_free(action_data->name);
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 g_hash_table_destroy(action_data->atts);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
95
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
96 g_free(action_data);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
97 }
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
98
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
99 static gboolean
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
100 pounces_save_cb(gpointer unused)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
101 {
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
102 gaim_pounces_sync();
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
103 pounces_save_timer = 0;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
104
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
105 return FALSE;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
106 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
107
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
108 static void
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
109 schedule_pounces_save(void)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
110 {
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
111 if (!pounces_save_timer)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
112 pounces_save_timer = g_timeout_add(5000, pounces_save_cb, NULL);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
113 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
114
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
115 GaimPounce *
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
116 gaim_pounce_new(const char *ui_type, GaimAccount *pouncer,
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
117 const char *pouncee, GaimPounceEvent event)
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
118 {
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
119 GaimPounce *pounce;
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
120 GaimPounceHandler *handler;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
121
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
122 g_return_val_if_fail(ui_type != NULL, NULL);
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
123 g_return_val_if_fail(pouncer != NULL, NULL);
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
124 g_return_val_if_fail(pouncee != NULL, NULL);
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
125 g_return_val_if_fail(event != 0, NULL);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
126
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
127 pounce = g_new0(GaimPounce, 1);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
128
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
129 pounce->ui_type = g_strdup(ui_type);
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
130 pounce->pouncer = pouncer;
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
131 pounce->pouncee = g_strdup(pouncee);
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
132 pounce->events = event;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
133
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
134 pounce->actions = g_hash_table_new_full(g_str_hash, g_str_equal,
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
135 g_free, free_action_data);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
136
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
137 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
138
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
139 if (handler != NULL && handler->new_pounce != NULL)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
140 handler->new_pounce(pounce);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
141
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
142 pounces = g_list_append(pounces, pounce);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
143
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
144 return pounce;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
145 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
146
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
147 void
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
148 gaim_pounce_destroy(GaimPounce *pounce)
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
149 {
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
150 GaimPounceHandler *handler;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
151
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
152 g_return_if_fail(pounce != NULL);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
153
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
154 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
155
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
156 pounces = g_list_remove(pounces, pounce);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
157
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
158 if (pounce->ui_type != NULL) g_free(pounce->ui_type);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
159 if (pounce->pouncee != NULL) g_free(pounce->pouncee);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
160
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
161 g_hash_table_destroy(pounce->actions);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
162
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
163 if (handler != NULL && handler->free_pounce != NULL)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
164 handler->free_pounce(pounce);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
165
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
166 g_free(pounce);
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
167
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
168 schedule_pounces_save();
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
169 }
4696
abec345c8c92 [gaim-migrate @ 5007]
Nathan Walp <nwalp@pidgin.im>
parents: 4690
diff changeset
170
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
171 void
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
172 gaim_pounce_set_events(GaimPounce *pounce, GaimPounceEvent events)
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
173 {
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
174 g_return_if_fail(pounce != NULL);
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
175 g_return_if_fail(pounce != GAIM_POUNCE_NONE);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
176
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
177 pounce->events = events;
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
178
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
179 schedule_pounces_save();
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
180 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
181
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
182 void
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
183 gaim_pounce_set_pouncer(GaimPounce *pounce, GaimAccount *pouncer)
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
184 {
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
185 g_return_if_fail(pounce != NULL);
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
186 g_return_if_fail(pouncer != NULL);
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
187
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
188 pounce->pouncer = pouncer;
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
189
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
190 schedule_pounces_save();
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
191 }
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
192
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
193 void
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
194 gaim_pounce_set_pouncee(GaimPounce *pounce, const char *pouncee)
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
195 {
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
196 g_return_if_fail(pounce != NULL);
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
197 g_return_if_fail(pouncee != NULL);
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
198
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
199 if (pounce->pouncee != NULL)
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
200 g_free(pounce->pouncee);
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
201
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
202 pounce->pouncee = (pouncee == NULL ? NULL : g_strdup(pouncee));
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
203
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
204 schedule_pounces_save();
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
205 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
206
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
207 void
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
208 gaim_pounce_set_save(GaimPounce *pounce, gboolean save)
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
209 {
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
210 g_return_if_fail(pounce != NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
211
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
212 pounce->save = save;
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
213
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
214 schedule_pounces_save();
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
215 }
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
216
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
217 void
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
218 gaim_pounce_action_register(GaimPounce *pounce, const char *name)
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
219 {
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
220 GaimPounceActionData *action_data;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
221
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
222 g_return_if_fail(pounce != NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
223 g_return_if_fail(name != NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
224
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5940
diff changeset
225 if (g_hash_table_lookup(pounce->actions, name) != NULL)
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5940
diff changeset
226 return;
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5940
diff changeset
227
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
228 action_data = g_new0(GaimPounceActionData, 1);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
229
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
230 action_data->name = g_strdup(name);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
231 action_data->enabled = FALSE;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
232 action_data->atts = g_hash_table_new_full(g_str_hash, g_str_equal,
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
233 g_free, g_free);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
234
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
235 g_hash_table_insert(pounce->actions, g_strdup(name), action_data);
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
236
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
237 schedule_pounces_save();
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
238 }
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
239
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
240 void
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
241 gaim_pounce_action_set_enabled(GaimPounce *pounce, const char *action,
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
242 gboolean enabled)
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
243 {
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
244 GaimPounceActionData *action_data;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
245
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
246 g_return_if_fail(pounce != NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
247 g_return_if_fail(action != NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
248
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
249 action_data = find_action_data(pounce, action);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
250
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
251 g_return_if_fail(action_data != NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
252
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
253 action_data->enabled = enabled;
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
254
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
255 schedule_pounces_save();
5864
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
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
258 void
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
259 gaim_pounce_action_set_attribute(GaimPounce *pounce, const char *action,
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
260 const char *attr, const char *value)
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
261 {
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
262 GaimPounceActionData *action_data;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
263
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
264 g_return_if_fail(pounce != NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
265 g_return_if_fail(action != NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
266 g_return_if_fail(attr != NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
267
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
268 action_data = find_action_data(pounce, action);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
269
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
270 g_return_if_fail(action_data != NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
271
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
272 if (value == NULL)
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
273 g_hash_table_remove(action_data->atts, attr);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
274 else
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
275 g_hash_table_insert(action_data->atts, g_strdup(attr),
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
276 g_strdup(value));
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
277
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
278 schedule_pounces_save();
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
279 }
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
280
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
281 void
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
282 gaim_pounce_set_data(GaimPounce *pounce, void *data)
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
283 {
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
284 g_return_if_fail(pounce != NULL);
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
285
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
286 pounce->data = data;
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
287 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
288
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
289 GaimPounceEvent
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
290 gaim_pounce_get_events(const GaimPounce *pounce)
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
291 {
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
292 g_return_val_if_fail(pounce != NULL, GAIM_POUNCE_NONE);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
293
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
294 return pounce->events;
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
295 }
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
296
5563
9eb5b13fd412 [gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents: 5054
diff changeset
297 GaimAccount *
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
298 gaim_pounce_get_pouncer(const GaimPounce *pounce)
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
299 {
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
300 g_return_val_if_fail(pounce != NULL, NULL);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
301
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
302 return pounce->pouncer;
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
303 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
304
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
305 const char *
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
306 gaim_pounce_get_pouncee(const GaimPounce *pounce)
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
307 {
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
308 g_return_val_if_fail(pounce != NULL, NULL);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
309
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
310 return pounce->pouncee;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
311 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
312
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
313 gboolean
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
314 gaim_pounce_get_save(const GaimPounce *pounce)
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
315 {
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
316 g_return_val_if_fail(pounce != NULL, FALSE);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
317
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
318 return pounce->save;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
319 }
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
320
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
321 gboolean
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
322 gaim_pounce_action_is_enabled(const GaimPounce *pounce, const char *action)
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
323 {
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
324 GaimPounceActionData *action_data;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
325
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
326 g_return_val_if_fail(pounce != NULL, FALSE);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
327 g_return_val_if_fail(action != NULL, FALSE);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
328
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
329 action_data = find_action_data(pounce, action);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
330
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
331 g_return_val_if_fail(action_data != NULL, FALSE);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
332
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
333 return action_data->enabled;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
334 }
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
335
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
336 const char *
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
337 gaim_pounce_action_get_attribute(const GaimPounce *pounce,
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
338 const char *action, const char *attr)
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
339 {
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
340 GaimPounceActionData *action_data;
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
341
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
342 g_return_val_if_fail(pounce != NULL, NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
343 g_return_val_if_fail(action != NULL, NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
344 g_return_val_if_fail(attr != NULL, NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
345
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
346 action_data = find_action_data(pounce, action);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
347
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
348 g_return_val_if_fail(action_data != NULL, NULL);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
349
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
350 return g_hash_table_lookup(action_data->atts, attr);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
351 }
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
352
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
353 void *
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
354 gaim_pounce_get_data(const GaimPounce *pounce)
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
355 {
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
356 g_return_val_if_fail(pounce != NULL, NULL);
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
357
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
358 return pounce->data;
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
359 }
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
360
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
361 void
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
362 gaim_pounce_execute(const GaimAccount *pouncer, const char *pouncee,
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
363 GaimPounceEvent events)
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
364 {
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
365 GaimPounce *pounce;
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
366 GaimPounceHandler *handler;
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
367 GList *l, *l_next;
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
368
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
369 g_return_if_fail(pouncer != NULL);
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
370 g_return_if_fail(pouncee != NULL);
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
371 g_return_if_fail(events != GAIM_POUNCE_NONE);
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
372
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
373 for (l = gaim_pounces_get_all(); l != NULL; l = l_next) {
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
374 pounce = (GaimPounce *)l->data;
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
375 l_next = l->next;
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
376
5043
494a050318c7 [gaim-migrate @ 5390]
Christian Hammond <chipx86@chipx86.com>
parents: 5032
diff changeset
377 if ((gaim_pounce_get_events(pounce) & events) &&
494a050318c7 [gaim-migrate @ 5390]
Christian Hammond <chipx86@chipx86.com>
parents: 5032
diff changeset
378 (gaim_pounce_get_pouncer(pounce) == pouncer) &&
494a050318c7 [gaim-migrate @ 5390]
Christian Hammond <chipx86@chipx86.com>
parents: 5032
diff changeset
379 !strcmp(gaim_pounce_get_pouncee(pounce), pouncee)) {
494a050318c7 [gaim-migrate @ 5390]
Christian Hammond <chipx86@chipx86.com>
parents: 5032
diff changeset
380
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
381 handler = g_hash_table_lookup(pounce_handlers, pounce->ui_type);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
382
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
383 if (handler != NULL && handler->cb != NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
384 handler->cb(pounce, events, gaim_pounce_get_data(pounce));
5864
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
385
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
386 if (!gaim_pounce_get_save(pounce))
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
387 gaim_pounce_destroy(pounce);
417b1001d2b1 [gaim-migrate @ 6295]
Christian Hammond <chipx86@chipx86.com>
parents: 5857
diff changeset
388 }
5043
494a050318c7 [gaim-migrate @ 5390]
Christian Hammond <chipx86@chipx86.com>
parents: 5032
diff changeset
389 }
494a050318c7 [gaim-migrate @ 5390]
Christian Hammond <chipx86@chipx86.com>
parents: 5032
diff changeset
390 }
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
391 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
392
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
393 GaimPounce *
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
394 gaim_find_pounce(const GaimAccount *pouncer, const char *pouncee,
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
395 GaimPounceEvent events)
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
396 {
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
397 GaimPounce *pounce;
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
398 GList *l;
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
399
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
400 g_return_val_if_fail(pouncer != NULL, NULL);
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
401 g_return_val_if_fail(pouncee != NULL, NULL);
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
402 g_return_val_if_fail(events != GAIM_POUNCE_NONE, NULL);
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
403
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
404 for (l = gaim_pounces_get_all(); l != NULL; l = l->next) {
5857
2fa4aa9c1885 [gaim-migrate @ 6288]
Christian Hammond <chipx86@chipx86.com>
parents: 5563
diff changeset
405 pounce = (GaimPounce *)l->data;
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
406
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
407 if ((gaim_pounce_get_events(pounce) & events) &&
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
408 (gaim_pounce_get_pouncer(pounce) == pouncer) &&
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
409 !strcmp(gaim_pounce_get_pouncee(pounce), pouncee)) {
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
410
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
411 return pounce;
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
412 }
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
413 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
414
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
415 return NULL;
4687
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
416 }
283fb289c510 [gaim-migrate @ 4998]
Sean Egan <seanegan@gmail.com>
parents:
diff changeset
417
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
418 /* XML Stuff */
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
419 static void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
420 free_parser_data(gpointer user_data)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
421 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
422 PounceParserData *data = user_data;
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 if (data->buffer != NULL)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
425 g_string_free(data->buffer, TRUE);
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 if (data->ui_name != NULL) g_free(data->ui_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
428 if (data->pouncee != NULL) g_free(data->pouncee);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
429 if (data->protocol_id != NULL) g_free(data->protocol_id);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
430 if (data->event_type != NULL) g_free(data->event_type);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
431 if (data->action_name != NULL) g_free(data->action_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
432 if (data->param_name != NULL) g_free(data->param_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
433 if (data->account_name != NULL) g_free(data->account_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
434
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
435 g_free(data);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
436 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
437
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
438 static void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
439 start_element_handler(GMarkupParseContext *context,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
440 const gchar *element_name,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
441 const gchar **attribute_names,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
442 const gchar **attribute_values,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
443 gpointer user_data, GError **error)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
444 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
445 PounceParserData *data = user_data;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
446 GHashTable *atts;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
447 int i;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
448
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
449 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
450
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
451 for (i = 0; attribute_names[i] != NULL; i++) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
452 g_hash_table_insert(atts, g_strdup(attribute_names[i]),
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
453 g_strdup(attribute_values[i]));
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
454 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
455
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
456 if (data->buffer != NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
457 g_string_free(data->buffer, TRUE);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
458 data->buffer = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
459 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
460
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
461 if (!strcmp(element_name, "pounce")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
462 const char *ui = g_hash_table_lookup(atts, "ui");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
463
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
464 if (ui == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
465 gaim_debug(GAIM_DEBUG_ERROR, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
466 "Unset 'ui' parameter for pounce!\n");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
467 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
468 else
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
469 data->ui_name = g_strdup(ui);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
470
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
471 data->events = 0;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
472 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
473 else if (!strcmp(element_name, "account")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
474 const char *protocol_id = g_hash_table_lookup(atts, "protocol");
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 (protocol_id == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
477 gaim_debug(GAIM_DEBUG_ERROR, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
478 "Unset 'protocol' parameter for account!\n");
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 else
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
481 data->protocol_id = g_strdup(protocol_id);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
482 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
483 else if (!strcmp(element_name, "event")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
484 const char *type = g_hash_table_lookup(atts, "type");
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 (type == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
487 gaim_debug(GAIM_DEBUG_ERROR, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
488 "Unset 'type' parameter for event!\n");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
489 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
490 else
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
491 data->event_type = g_strdup(type);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
492 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
493 else if (!strcmp(element_name, "action")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
494 const char *type = g_hash_table_lookup(atts, "type");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
495
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
496 if (type == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
497 gaim_debug(GAIM_DEBUG_ERROR, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
498 "Unset 'type' parameter for action!\n");
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 else
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
501 data->action_name = g_strdup(type);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
502 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
503 else if (!strcmp(element_name, "param")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
504 const char *param_name = g_hash_table_lookup(atts, "name");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
505
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
506 if (param_name == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
507 gaim_debug(GAIM_DEBUG_ERROR, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
508 "Unset 'name' parameter for param!\n");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
509 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
510 else
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
511 data->param_name = g_strdup(param_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
512 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
513
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
514 g_hash_table_destroy(atts);
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
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
517 static void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
518 end_element_handler(GMarkupParseContext *context, const gchar *element_name,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
519 gpointer user_data, GError **error)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
520 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
521 PounceParserData *data = user_data;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
522 gchar *buffer = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
523
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
524 if (data->buffer != NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
525 buffer = g_string_free(data->buffer, FALSE);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
526 data->buffer = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
527 }
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 if (!strcmp(element_name, "account")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
530 data->account_name = g_strdup(buffer);
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 else if (!strcmp(element_name, "pouncee")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
533 data->pouncee = g_strdup(buffer);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
534 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
535 else if (!strcmp(element_name, "event")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
536 if (!strcmp(data->event_type, "sign-on"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
537 data->events |= GAIM_POUNCE_SIGNON;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
538 else if (!strcmp(data->event_type, "sign-off"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
539 data->events |= GAIM_POUNCE_SIGNOFF;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
540 else if (!strcmp(data->event_type, "away"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
541 data->events |= GAIM_POUNCE_AWAY;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
542 else if (!strcmp(data->event_type, "return-from-away"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
543 data->events |= GAIM_POUNCE_AWAY_RETURN;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
544 else if (!strcmp(data->event_type, "idle"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
545 data->events |= GAIM_POUNCE_IDLE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
546 else if (!strcmp(data->event_type, "return-from-idle"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
547 data->events |= GAIM_POUNCE_IDLE_RETURN;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
548 else if (!strcmp(data->event_type, "typing"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
549 data->events |= GAIM_POUNCE_TYPING;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
550 else if (!strcmp(data->event_type, "stop-typing"))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
551 data->events |= GAIM_POUNCE_TYPING_STOPPED;
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 g_free(data->event_type);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
554 data->event_type = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
555 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
556 else if (!strcmp(element_name, "action")) {
5943
a4f2aba0848d [gaim-migrate @ 6384]
Christian Hammond <chipx86@chipx86.com>
parents: 5940
diff changeset
557 gaim_pounce_action_register(data->pounce, data->action_name);
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
558 gaim_pounce_action_set_enabled(data->pounce, data->action_name, TRUE);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
559
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
560 g_free(data->action_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
561 data->action_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
562 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
563 else if (!strcmp(element_name, "param")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
564 gaim_pounce_action_set_attribute(data->pounce, data->action_name,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
565 data->param_name, buffer);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
566
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
567 g_free(data->param_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
568 data->param_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
569 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
570 else if (!strcmp(element_name, "events")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
571 GList *l;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
572 GaimAccount *account;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
573 GaimProtocol protocol = -1;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
574
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
575 for (l = gaim_plugins_get_protocols(); l != NULL; l = l->next) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
576 GaimPlugin *plugin = (GaimPlugin *)l->data;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
577
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
578 if (GAIM_IS_PROTOCOL_PLUGIN(plugin)) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
579 if (!strcmp(plugin->info->id, data->protocol_id)) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
580 protocol = GAIM_PLUGIN_PROTOCOL_INFO(plugin)->protocol;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
581
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
582 break;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
583 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
584 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
585 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
586
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
587 account = gaim_accounts_find(data->account_name, protocol);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
588
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
589 g_free(data->account_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
590 g_free(data->protocol_id);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
591
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
592 data->account_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
593 data->protocol_id = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
594
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
595 if (account == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
596 gaim_debug(GAIM_DEBUG_ERROR, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
597 "Account for pounce not found!\n");
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
598 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
599 else {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
600 gaim_debug(GAIM_DEBUG_INFO, "pounce",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
601 "Creating pounce: %s, %s\n", data->ui_name,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
602 data->pouncee);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
603
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
604 data->pounce = gaim_pounce_new(data->ui_name, account,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
605 data->pouncee, data->events);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
606 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
607
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
608 g_free(data->pouncee);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
609 data->pouncee = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
610 }
5878
9e54bb2ee3b5 [gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents: 5875
diff changeset
611 else if (!strcmp(element_name, "save")) {
9e54bb2ee3b5 [gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents: 5875
diff changeset
612 gaim_pounce_set_save(data->pounce, TRUE);
9e54bb2ee3b5 [gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents: 5875
diff changeset
613 }
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
614 else if (!strcmp(element_name, "pounce")) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
615 data->pounce = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
616 data->events = 0;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
617
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
618 if (data->ui_name != NULL) g_free(data->ui_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
619 if (data->pouncee != NULL) g_free(data->pouncee);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
620 if (data->protocol_id != NULL) g_free(data->protocol_id);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
621 if (data->event_type != NULL) g_free(data->event_type);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
622 if (data->action_name != NULL) g_free(data->action_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
623 if (data->param_name != NULL) g_free(data->param_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
624 if (data->account_name != NULL) g_free(data->account_name);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
625
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
626 data->ui_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
627 data->pounce = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
628 data->protocol_id = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
629 data->event_type = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
630 data->action_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
631 data->param_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
632 data->account_name = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
633 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
634
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
635 if (buffer != NULL)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
636 g_free(buffer);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
637 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
638
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
639 static void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
640 text_handler(GMarkupParseContext *context, const gchar *text,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
641 gsize text_len, gpointer user_data, GError **error)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
642 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
643 PounceParserData *data = user_data;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
644
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
645 if (data->buffer == NULL)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
646 data->buffer = g_string_new_len(text, text_len);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
647 else
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
648 g_string_append_len(data->buffer, text, text_len);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
649 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
650
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
651 static GMarkupParser pounces_parser =
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
652 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
653 start_element_handler,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
654 end_element_handler,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
655 text_handler,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
656 NULL,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
657 NULL
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
658 };
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
659
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
660 gboolean
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
661 gaim_pounces_load(void)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
662 {
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
663 gchar *filename = g_build_filename(gaim_user_dir(), "pounces.xml", NULL);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
664 gchar *contents = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
665 gsize length;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
666 GMarkupParseContext *context;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
667 GError *error = NULL;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
668 PounceParserData *parser_data;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
669
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
670 if (filename == NULL) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
671 pounces_loaded = TRUE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
672 return FALSE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
673 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
674
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
675 if (!g_file_get_contents(filename, &contents, &length, &error)) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
676 gaim_debug(GAIM_DEBUG_ERROR, "pounces",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
677 "Error reading pounces: %s\n", error->message);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
678
5940
94ad4d45346a [gaim-migrate @ 6380]
Nathan Walp <nwalp@pidgin.im>
parents: 5878
diff changeset
679 g_free(filename);
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
680 g_error_free(error);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
681
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
682 pounces_loaded = TRUE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
683 return FALSE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
684 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
685
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
686 parser_data = g_new0(PounceParserData, 1);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
687
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
688 context = g_markup_parse_context_new(&pounces_parser, 0,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
689 parser_data, free_parser_data);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
690
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
691 if (!g_markup_parse_context_parse(context, contents, length, NULL)) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
692 g_markup_parse_context_free(context);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
693 g_free(contents);
5940
94ad4d45346a [gaim-migrate @ 6380]
Nathan Walp <nwalp@pidgin.im>
parents: 5878
diff changeset
694 g_free(filename);
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
695
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
696 pounces_loaded = TRUE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
697
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
698 return FALSE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
699 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
700
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
701 if (!g_markup_parse_context_end_parse(context, NULL)) {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
702 gaim_debug(GAIM_DEBUG_ERROR, "pounces", "Error parsing %s\n",
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
703 filename);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
704
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
705 g_markup_parse_context_free(context);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
706 g_free(contents);
5940
94ad4d45346a [gaim-migrate @ 6380]
Nathan Walp <nwalp@pidgin.im>
parents: 5878
diff changeset
707 g_free(filename);
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
708 pounces_loaded = TRUE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
709
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
710 return FALSE;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
711 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
712
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
713 g_markup_parse_context_free(context);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
714 g_free(contents);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
715 g_free(filename);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
716
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
717 pounces_loaded = TRUE;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
718
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
719 return TRUE;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
720 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
721
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
722 static void
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
723 write_action_parameter(gpointer key, gpointer value, gpointer user_data)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
724 {
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
725 const char *name, *param_value;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
726 FILE *fp;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
727
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
728 param_value = (const char *)value;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
729 name = (const char *)key;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
730 fp = (FILE *)user_data;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
731
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
732 fprintf(fp, " <param name='%s'>%s</param>\n", name, param_value);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
733 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
734
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
735 static void
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
736 write_action_parameter_list(gpointer key, gpointer value, gpointer user_data)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
737 {
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
738 GaimPounceActionData *action_data;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
739 const char *action;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
740 FILE *fp;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
741
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
742 action_data = (GaimPounceActionData *)value;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
743 action = (const char *)key;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
744 fp = (FILE *)user_data;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
745
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
746 if (!action_data->enabled)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
747 return;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
748
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
749 fprintf(fp, " <action type='%s'", action);
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 if (g_hash_table_size(action_data->atts) == 0) {
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
752 fprintf(fp, "/>\n");
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
753 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
754 else {
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
755 fprintf(fp, ">\n");
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
756
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
757 g_hash_table_foreach(action_data->atts, write_action_parameter, fp);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
758
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
759 fprintf(fp, " </action>\n");
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
760 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
761 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
762
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
763 static void
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
764 gaim_pounces_write(FILE *fp, GaimPounce *pounce)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
765 {
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
766 GaimAccount *pouncer;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
767 GaimPounceEvent events;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
768 char *pouncer_name;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
769
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
770 pouncer = gaim_pounce_get_pouncer(pounce);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
771 events = gaim_pounce_get_events(pounce);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
772
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
773 pouncer_name = g_markup_escape_text(gaim_account_get_username(pouncer), -1);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
774
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
775 fprintf(fp, " <pounce ui='%s'>\n", pounce->ui_type);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
776 fprintf(fp, " <account protocol='%s'>%s</account>\n",
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
777 pouncer->protocol_id, pouncer_name);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
778 fprintf(fp, " <pouncee>%s</pouncee>\n", gaim_pounce_get_pouncee(pounce));
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
779 fprintf(fp, " <events>\n");
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
780
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
781 if (events & GAIM_POUNCE_SIGNON)
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
782 fprintf(fp, " <event type='sign-on'/>\n");
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
783 if (events & GAIM_POUNCE_SIGNOFF)
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
784 fprintf(fp, " <event type='sign-off'/>\n");
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
785 if (events & GAIM_POUNCE_AWAY)
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
786 fprintf(fp, " <event type='away'/>\n");
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
787 if (events & GAIM_POUNCE_AWAY_RETURN)
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
788 fprintf(fp, " <event type='return-from-away'/>\n");
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
789 if (events & GAIM_POUNCE_IDLE)
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
790 fprintf(fp, " <event type='idle'/>\n");
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
791 if (events & GAIM_POUNCE_IDLE_RETURN)
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
792 fprintf(fp, " <event type='return-from-idle'/>\n");
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
793 if (events & GAIM_POUNCE_TYPING)
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
794 fprintf(fp, " <event type='start-typing'/>\n");
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
795 if (events & GAIM_POUNCE_TYPING_STOPPED)
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
796 fprintf(fp, " <event type='stop-typing'/>\n");
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
797
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
798 fprintf(fp, " </events>\n");
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
799 fprintf(fp, " <actions>\n");
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
800
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
801 g_hash_table_foreach(pounce->actions, write_action_parameter_list, fp);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
802
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
803 fprintf(fp, " </actions>\n");
5878
9e54bb2ee3b5 [gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents: 5875
diff changeset
804
9e54bb2ee3b5 [gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents: 5875
diff changeset
805 if (gaim_pounce_get_save(pounce))
9e54bb2ee3b5 [gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents: 5875
diff changeset
806 fprintf(fp, " <save/>\n");
9e54bb2ee3b5 [gaim-migrate @ 6310]
Christian Hammond <chipx86@chipx86.com>
parents: 5875
diff changeset
807
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
808 fprintf(fp, " </pounce>\n");
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
809
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
810 g_free(pouncer_name);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
811 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
812
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
813 void
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
814 gaim_pounces_sync(void)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
815 {
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
816 FILE *fp;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
817 const char *user_dir = gaim_user_dir();
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
818 char *filename;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
819 char *filename_real;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
820
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
821 if (!pounces_loaded) {
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
822 gaim_debug(GAIM_DEBUG_WARNING, "pounces",
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
823 "Writing pounces to disk.\n");
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
824 schedule_pounces_save();
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
825 return;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
826 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
827
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
828 if (user_dir == NULL)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
829 return;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
830
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
831 gaim_debug(GAIM_DEBUG_INFO, "pounces", "Writing pounces to disk.\n");
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
832
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
833 fp = fopen(user_dir, "r");
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
834
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
835 if (fp == NULL)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
836 mkdir(user_dir, S_IRUSR | S_IWUSR | S_IXUSR);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
837 else
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
838 fclose(fp);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
839
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
840 filename = g_build_filename(user_dir, "pounces.xml.save", NULL);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
841
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
842 if ((fp = fopen(filename, "w")) != NULL) {
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
843 GList *l;
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
844
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
845 fprintf(fp, "<?xml version='1.0' encoding='UTF-8' ?>\n\n");
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
846 fprintf(fp, "<pounces>\n");
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
847
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
848 for (l = gaim_pounces_get_all(); l != NULL; l = l->next)
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
849 gaim_pounces_write(fp, l->data);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
850
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
851 fprintf(fp, "</pounces>\n");
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
852
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
853 fclose(fp);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
854 chmod(filename, S_IRUSR | S_IWUSR);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
855 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
856 else {
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
857 gaim_debug(GAIM_DEBUG_ERROR, "pounces", "Unable to write %s\n",
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
858 filename);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
859 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
860
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
861 filename_real = g_build_filename(user_dir, "pounces.xml", NULL);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
862
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
863 if (rename(filename, filename_real) < 0) {
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
864 gaim_debug(GAIM_DEBUG_ERROR, "pounces", "Error renaming %s to %s\n",
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
865 filename, filename_real);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
866 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
867
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
868 g_free(filename);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
869 g_free(filename_real);
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
870 }
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
871
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
872 void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
873 gaim_pounces_register_handler(const char *ui, GaimPounceCb cb,
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
874 void (*new_pounce)(GaimPounce *pounce),
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
875 void (*free_pounce)(GaimPounce *pounce))
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
876 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
877 GaimPounceHandler *handler;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
878
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
879 g_return_if_fail(ui != NULL);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
880 g_return_if_fail(cb != NULL);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
881
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
882 handler = g_new0(GaimPounceHandler, 1);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
883
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
884 handler->ui = g_strdup(ui);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
885 handler->cb = cb;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
886 handler->new_pounce = new_pounce;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
887 handler->free_pounce = free_pounce;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
888
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
889 g_hash_table_insert(pounce_handlers, g_strdup(ui), handler);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
890 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
891
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
892 void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
893 gaim_pounces_unregister_handler(const char *ui)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
894 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
895 g_return_if_fail(ui != NULL);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
896
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
897 g_hash_table_remove(pounce_handlers, ui);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
898 }
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
899
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
900 GList *
5866
d6b5cab288bb [gaim-migrate @ 6297]
Christian Hammond <chipx86@chipx86.com>
parents: 5864
diff changeset
901 gaim_pounces_get_all(void)
5032
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
902 {
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
903 return pounces;
cb700c07ee07 [gaim-migrate @ 5375]
Christian Hammond <chipx86@chipx86.com>
parents: 4793
diff changeset
904 }
5875
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
905
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
906 static void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
907 free_pounce_handler(gpointer user_data)
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
908 {
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
909 GaimPounceHandler *handler = (GaimPounceHandler *)user_data;
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
910
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
911 g_free(handler->ui);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
912 g_free(handler);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
913 }
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 void
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
916 gaim_pounces_init(void)
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 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
919 g_free, free_pounce_handler);
448f2f4ca3ec [gaim-migrate @ 6307]
Christian Hammond <chipx86@chipx86.com>
parents: 5872
diff changeset
920 }