Mercurial > pidgin
annotate plugins/perl/common/Util.xs @ 13219:d0f7f698b6de
[gaim-migrate @ 15583]
SF Patch #1428591 from Sadrul
"This is a new signal, emitted when request for a
file-transfer comes in. I have written a trivial plugin
(which I plan on adding under plugin_pack in a couple
of days) that uses this signal to auto-accept
file-transfers. I have tested the plugin to auto-accept
or auto-reject file-transfer requests."
I also noticed that the file transfer signals weren't using a subtype for
GaimXfer pointers, so I added one.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Sat, 11 Feb 2006 05:24:30 +0000 |
parents | fcde3faa1f57 |
children | 554575d1f9b5 |
rev | line source |
---|---|
11118 | 1 #include "module.h" |
2 | |
11290 | 3 typedef struct { |
4 char *cb; | |
5 } GaimPerlUrlData; | |
6 | |
12412
a88ca6da0b38
[gaim-migrate @ 14719]
Richard Laager <rlaager@wiktel.com>
parents:
11920
diff
changeset
|
7 static void gaim_perl_util_url_cb(void *data, const char *url_data, size_t size) { |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
8 GaimPerlUrlData *gpr = (GaimPerlUrlData *)data; |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
9 dSP; |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
10 ENTER; |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
11 SAVETMPS; |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
12 PUSHMARK(sp); |
11118 | 13 |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
14 XPUSHs(sv_2mortal(newSVpv(url_data, 0))); |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
15 PUTBACK; |
11290 | 16 |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
17 call_pv(gpr->cb, G_EVAL | G_SCALAR); |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
18 SPAGAIN; |
11118 | 19 |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
20 PUTBACK; |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
21 FREETMPS; |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
22 LEAVE; |
11290 | 23 } |
11118 | 24 |
25 MODULE = Gaim::Util PACKAGE = Gaim::Util PREFIX = gaim_ | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
26 PROTOTYPES: ENABLE |
11290 | 27 |
28 void | |
29 gaim_url_fetch(handle, url, full, user_agent, http11, cb) | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
30 Gaim::Plugin handle |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
31 const char *url |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
32 gboolean full |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
33 const char *user_agent |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
34 gboolean http11 |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
35 SV * cb |
11290 | 36 CODE: |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
37 GaimPerlUrlData *gpr; |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
38 STRLEN len; |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
39 char *basename, *package; |
11290 | 40 |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
41 basename = g_path_get_basename(handle->path); |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
42 gaim_perl_normalize_script_name(basename); |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
43 package = g_strdup_printf("Gaim::Script::%s", basename); |
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
44 gpr = g_new(GaimPerlUrlData, 1); |
11290 | 45 |
46 gpr->cb = g_strdup_printf("%s::%s", package, SvPV(cb, len)); | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
47 gaim_url_fetch(url, full, user_agent, http11, gaim_perl_util_url_cb, gpr); |
11118 | 48 |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
49 int |
11118 | 50 gaim_build_dir(path, mode) |
51 const char *path | |
52 int mode | |
53 | |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
54 const char * |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
55 gaim_date_format_full(tm) |
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
56 const struct tm *tm |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
57 |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
58 const char * |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
59 gaim_date_format_long(tm) |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
60 const struct tm *tm |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
61 |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
62 const char * |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
63 gaim_date_format_short(tm) |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
64 const struct tm *tm |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
65 |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
66 gboolean |
11118 | 67 gaim_email_is_valid(address) |
68 const char *address | |
69 | |
70 const char * | |
71 gaim_escape_filename(str) | |
72 const char *str | |
73 | |
74 char * | |
75 gaim_fd_get_ip(fd) | |
76 int fd | |
77 | |
78 const gchar * | |
79 gaim_home_dir() | |
80 | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
81 gboolean |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
82 gaim_markup_extract_info_field(str, len, dest, start_token, skip, end_token, check_value, no_value_token, display_name, is_link, link_prefix, format_cb) |
11118 | 83 const char *str |
84 int len | |
85 GString *dest | |
86 const char *start_token | |
87 int skip | |
88 const char *end_token | |
89 char check_value | |
90 const char *no_value_token | |
91 const char *display_name | |
92 gboolean is_link | |
93 const char *link_prefix | |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
94 Gaim::Util::InfoFieldFormatCallback format_cb |
11118 | 95 |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
96 gboolean |
11118 | 97 gaim_markup_find_tag(needle, haystack, start, end, attributes) |
98 const char *needle | |
99 const char *haystack | |
100 const char **start | |
101 const char **end | |
102 GData **attributes | |
103 | |
104 char * | |
105 gaim_markup_get_tag_name(tag) | |
106 const char *tag | |
107 | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
108 void |
11118 | 109 gaim_markup_html_to_xhtml(html, dest_xhtml, dest_plain) |
110 const char *html | |
111 char **dest_xhtml | |
112 char **dest_plain | |
113 | |
114 char * | |
115 gaim_markup_linkify(str) | |
116 const char *str | |
117 | |
118 char * | |
119 gaim_markup_slice(str, x, y) | |
120 const char *str | |
121 guint x | |
122 guint y | |
123 | |
124 char * | |
125 gaim_markup_strip_html(str) | |
126 const char *str | |
127 | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
128 gboolean |
11118 | 129 gaim_message_meify(message, len) |
130 char *message | |
131 size_t len | |
132 | |
133 FILE * | |
134 gaim_mkstemp(path, binary) | |
135 char **path | |
136 gboolean binary | |
137 | |
138 const char * | |
139 gaim_normalize(account, str) | |
140 Gaim::Account account | |
141 const char *str | |
142 | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
143 gboolean |
11118 | 144 gaim_program_is_valid(program) |
145 const char *program | |
146 | |
147 char * | |
148 gaim_str_add_cr(str) | |
149 const char *str | |
150 | |
151 char * | |
152 gaim_str_binary_to_ascii(binary, len) | |
153 const unsigned char *binary | |
154 guint len | |
155 | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
156 gboolean |
11118 | 157 gaim_str_has_prefix(s, p) |
158 const char *s | |
159 const char *p | |
160 | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
161 gboolean |
11118 | 162 gaim_str_has_suffix(s, x) |
163 const char *s | |
164 const char *x | |
165 | |
166 char * | |
167 gaim_str_seconds_to_string(sec) | |
168 guint sec | |
169 | |
170 char * | |
171 gaim_str_size_to_units(size) | |
172 size_t size | |
173 | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
174 void |
11920 | 175 gaim_str_strip_char(str, thechar) |
11118 | 176 char *str |
11920 | 177 char thechar |
11118 | 178 |
179 gchar * | |
180 gaim_str_sub_away_formatters(str, name) | |
181 const char *str | |
182 const char *name | |
183 | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
184 time_t |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
185 gaim_str_to_time(timestamp, utc = FALSE, tm = NULL, tz_off = NULL, rest = NULL) |
11118 | 186 const char *timestamp |
187 gboolean utc | |
13119
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
188 struct tm *tm |
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
189 long *tz_off |
fcde3faa1f57
[gaim-migrate @ 15481]
Richard Laager <rlaager@wiktel.com>
parents:
13104
diff
changeset
|
190 const char **rest |
11118 | 191 |
192 gchar * | |
193 gaim_strcasereplace(string, delimiter, replacement) | |
194 const char *string | |
195 const char *delimiter | |
196 const char *replacement | |
197 | |
198 const char * | |
199 gaim_strcasestr(haystack, needle) | |
200 const char *haystack | |
201 const char *needle | |
202 | |
203 gchar * | |
204 gaim_strdup_withhtml(src) | |
205 const gchar *src | |
206 | |
207 gchar * | |
208 gaim_strreplace(string, delimiter, replacement) | |
209 const char *string | |
210 const char *delimiter | |
211 const char *replacement | |
212 | |
213 char * | |
214 gaim_text_strip_mnemonic(in) | |
215 const char *in | |
216 | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
217 time_t |
11118 | 218 gaim_time_build(year, month, day, hour, min, sec) |
219 int year | |
220 int month | |
221 int day | |
222 int hour | |
223 int min | |
224 int sec | |
225 | |
226 const char * | |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
227 gaim_time_format(tm) |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
228 const struct tm *tm |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
229 |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
230 const char * |
11118 | 231 gaim_unescape_filename(str) |
232 const char *str | |
233 | |
234 char * | |
235 gaim_unescape_html(html) | |
236 const char *html | |
237 | |
238 const char * | |
239 gaim_url_decode(str) | |
240 const char *str | |
241 | |
242 const char * | |
243 gaim_url_encode(str) | |
244 const char *str | |
245 | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
246 gboolean |
11118 | 247 gaim_url_parse(url, ret_host, ret_port, ret_path, ret_user, ret_passwd) |
248 const char *url | |
249 char **ret_host | |
250 int *ret_port | |
251 char **ret_path | |
252 char **ret_user | |
253 char **ret_passwd | |
254 | |
255 const char * | |
256 gaim_user_dir() | |
257 | |
13104
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
258 const char * |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
259 gaim_utf8_strftime(const char *format, const struct tm *tm); |
e1e5462b7d81
[gaim-migrate @ 15466]
Richard Laager <rlaager@wiktel.com>
parents:
13033
diff
changeset
|
260 |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
261 void |
11118 | 262 gaim_util_set_user_dir(dir) |
263 const char *dir | |
264 | |
12783
520d9abca2aa
[gaim-migrate @ 15130]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12412
diff
changeset
|
265 gboolean |
11118 | 266 gaim_util_write_data_to_file(filename, data, size) |
267 const char *filename | |
268 const char *data | |
269 size_t size |