Mercurial > pidgin
annotate finch/plugins/gnttinyurl.c @ 26533:b1b166fa99e2
Don't print 'no' twice if GADU libs are not found by pkg-config.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Fri, 10 Apr 2009 07:30:32 +0000 |
parents | c5920a8cf83f |
children | 0f1b41c2f835 |
rev | line source |
---|---|
26500
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
1 /** |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
2 * @file gnttinyurl.c |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
3 * |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
4 * Copyright (C) 2009 Richard Nelson <wabz@whatsbeef.net> |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
5 * |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
9 * (at your option) any later version. |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
10 * |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
15 * |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
19 */ |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
20 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
21 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
22 #include "internal.h" |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
23 #include <glib.h> |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
24 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
25 #define PLUGIN_STATIC_NAME TinyURL |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
26 #define PREFS_BASE "/plugins/gnt/tinyurl" |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
27 #define PREF_LENGTH PREFS_BASE "/length" |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
28 #define PREF_URL PREFS_BASE "/url" |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
29 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
30 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
31 #include <conversation.h> |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
32 #include <signals.h> |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
33 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
34 #include <glib.h> |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
35 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
36 #include <plugin.h> |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
37 #include <version.h> |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
38 #include <debug.h> |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
39 #include <notify.h> |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
40 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
41 #include <gntconv.h> |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
42 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
43 #include <gntplugin.h> |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
44 #include <gnttextview.h> |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
45 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
46 static int tag_num = 0; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
47 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
48 typedef struct |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
49 { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
50 PurpleConversation *conv; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
51 gchar *tag; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
52 int num; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
53 } CbInfo; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
54 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
55 /* 3 functions from util.c */ |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
56 static gboolean |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
57 badchar(char c) |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
58 { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
59 switch (c) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
60 case ' ': |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
61 case ',': |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
62 case '\0': |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
63 case '\n': |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
64 case '\r': |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
65 case '<': |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
66 case '>': |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
67 case '"': |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
68 case '\'': |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
69 return TRUE; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
70 default: |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
71 return FALSE; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
72 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
73 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
74 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
75 static gboolean |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
76 badentity(const char *c) |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
77 { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
78 if (!g_ascii_strncasecmp(c, "<", 4) || |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
79 !g_ascii_strncasecmp(c, ">", 4) || |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
80 !g_ascii_strncasecmp(c, """, 6)) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
81 return TRUE; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
82 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
83 return FALSE; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
84 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
85 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
86 static GList *extract_urls(char *text) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
87 const char *t, *c, *q = NULL; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
88 char *url_buf; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
89 GList *ret = NULL; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
90 gboolean inside_html = FALSE; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
91 int inside_paren = 0; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
92 c = text; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
93 while (*c) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
94 if (*c == '(' && !inside_html) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
95 inside_paren++; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
96 c++; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
97 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
98 if (inside_html) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
99 if (*c == '>') { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
100 inside_html = FALSE; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
101 } else if (!q && (*c == '\"' || *c == '\'')) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
102 q = c; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
103 } else if(q) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
104 if(*c == *q) |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
105 q = NULL; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
106 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
107 } else if (*c == '<') { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
108 inside_html = TRUE; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
109 if (!g_ascii_strncasecmp(c, "<A", 2)) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
110 while (1) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
111 if (*c == '>') { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
112 inside_html = FALSE; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
113 break; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
114 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
115 c++; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
116 if (!(*c)) |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
117 break; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
118 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
119 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
120 } else if ((*c=='h') && (!g_ascii_strncasecmp(c, "http://", 7) || |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
121 (!g_ascii_strncasecmp(c, "https://", 8)))) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
122 t = c; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
123 while (1) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
124 if (badchar(*t) || badentity(t)) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
125 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
126 if ((!g_ascii_strncasecmp(c, "http://", 7) && (t - c == 7)) || |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
127 (!g_ascii_strncasecmp(c, "https://", 8) && (t - c == 8))) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
128 break; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
129 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
130 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
131 if (*(t) == ',' && (*(t + 1) != ' ')) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
132 t++; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
133 continue; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
134 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
135 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
136 if (*(t - 1) == '.') |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
137 t--; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
138 if ((*(t - 1) == ')' && (inside_paren > 0))) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
139 t--; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
140 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
141 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
142 url_buf = g_strndup(c, t - c); |
26502
f9a923fde1e4
Remove usage of g_strcmp0 (which would bump the glib version requirement) where strcmp will do nicely
Richard Nelson <wabz@pidgin.im>
parents:
26500
diff
changeset
|
143 if (!g_list_find_custom(ret, url_buf, (GCompareFunc)strcmp)) { |
26500
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
144 purple_debug_info("TinyURL", "Added URL %s\n", url_buf); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
145 ret = g_list_append(ret, g_strdup(url_buf)); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
146 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
147 c = t; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
148 break; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
149 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
150 t++; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
151 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
152 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
153 } else if (!g_ascii_strncasecmp(c, "www.", 4) && (c == text || badchar(c[-1]) || badentity(c-1))) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
154 if (c[4] != '.') { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
155 t = c; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
156 while (1) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
157 if (badchar(*t) || badentity(t)) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
158 if (t - c == 4) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
159 break; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
160 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
161 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
162 if (*(t) == ',' && (*(t + 1) != ' ')) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
163 t++; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
164 continue; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
165 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
166 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
167 if (*(t - 1) == '.') |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
168 t--; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
169 if ((*(t - 1) == ')' && (inside_paren > 0))) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
170 t--; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
171 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
172 url_buf = g_strndup(c, t - c); |
26502
f9a923fde1e4
Remove usage of g_strcmp0 (which would bump the glib version requirement) where strcmp will do nicely
Richard Nelson <wabz@pidgin.im>
parents:
26500
diff
changeset
|
173 if (!g_list_find_custom(ret, url_buf, (GCompareFunc)strcmp)) { |
26500
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
174 purple_debug_info("TinyURL", "Added URL %s\n", url_buf); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
175 ret = g_list_append(ret, url_buf); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
176 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
177 c = t; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
178 break; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
179 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
180 t++; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
181 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
182 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
183 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
184 if (*c == ')' && !inside_html) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
185 inside_paren--; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
186 c++; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
187 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
188 if (*c == 0) |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
189 break; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
190 c++; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
191 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
192 return ret; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
193 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
194 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
195 static void url_fetched(PurpleUtilFetchUrlData *url_data, gpointer cb_data, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
196 const gchar *url_text, gsize len, const gchar *error_message) |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
197 { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
198 CbInfo *data = (CbInfo *)cb_data; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
199 PurpleConversation *conv = data->conv; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
200 GList *convs = purple_get_conversations(); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
201 /* ensure the conversation still exists */ |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
202 for (; convs; convs = convs->next) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
203 if ((PurpleConversation *)(convs->data) == conv) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
204 FinchConv *fconv = FINCH_CONV(conv); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
205 gchar *str = g_strdup_printf("[%d] %s", data->num, url_text); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
206 GntTextView *tv = GNT_TEXT_VIEW(fconv->tv); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
207 gnt_text_view_tag_change(tv, data->tag, str, FALSE); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
208 g_free(str); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
209 g_free(data->tag); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
210 return; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
211 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
212 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
213 g_free(data->tag); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
214 purple_debug_info("TinyURL", "Conversation no longer exists... :(\n"); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
215 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
216 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
217 static void free_urls(gpointer data, gpointer null) |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
218 { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
219 g_free(data); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
220 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
221 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
222 static gboolean receiving_msg(PurpleAccount *account, char **sender, char **message, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
223 PurpleConversation *conv, PurpleMessageFlags *flags) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
224 GString *t; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
225 GList *iter, *urls; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
226 int c = 0; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
227 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
228 if (!(*flags & PURPLE_MESSAGE_RECV) || *flags & PURPLE_MESSAGE_INVISIBLE) |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
229 return FALSE; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
230 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
231 t = g_string_new(*message); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
232 urls = purple_conversation_get_data(conv, "TinyURLs"); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
233 if (urls != NULL) /* message was cancelled somewhere? Reset. */ |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
234 g_list_foreach(urls, free_urls, NULL); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
235 g_list_free(urls); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
236 urls = extract_urls(t->str); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
237 g_free(*message); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
238 for (iter = urls; iter; iter = iter->next) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
239 if (g_utf8_strlen((char *)iter->data, -1) >= purple_prefs_get_int(PREF_LENGTH)) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
240 int pos, x = 0; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
241 gchar *j, *s, *str, *orig; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
242 glong len = g_utf8_strlen(iter->data, -1); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
243 s = g_strdup(t->str); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
244 orig = s; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
245 str = g_strdup_printf("[%d]", ++c); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
246 while ((j = strstr(s, iter->data))) { /* replace all occurrences */ |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
247 pos = j - orig + (x++ * 3); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
248 s = j + len; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
249 t = g_string_insert(t, pos + len, str); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
250 if (*s == '\0') break; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
251 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
252 g_free(orig); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
253 g_free(str); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
254 continue; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
255 } else { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
256 if (iter->prev) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
257 iter = iter->prev; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
258 g_free(iter->next->data); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
259 urls = g_list_delete_link(urls, iter->next); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
260 } else { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
261 g_free(iter->data); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
262 g_list_free(urls); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
263 urls = NULL; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
264 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
265 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
266 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
267 *message = t->str; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
268 g_string_free(t, FALSE); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
269 if (conv == NULL) |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
270 conv = purple_conversation_new(PURPLE_CONV_TYPE_IM, account, *sender); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
271 purple_conversation_set_data(conv, "TinyURLs", urls); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
272 return FALSE; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
273 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
274 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
275 static void received_msg(PurpleAccount *account, char *sender, char *message, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
276 PurpleConversation *conv, PurpleMessageFlags flags) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
277 int c; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
278 GList *urls, *iter; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
279 FinchConv *fconv = FINCH_CONV(conv); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
280 GntTextView *tv = GNT_TEXT_VIEW(fconv->tv); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
281 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
282 urls = purple_conversation_get_data(conv, "TinyURLs"); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
283 if (!(flags & PURPLE_MESSAGE_RECV) || urls == NULL) |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
284 return; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
285 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
286 for (iter = urls, c = 0; iter; iter = iter->next) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
287 int i; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
288 CbInfo *cbdata; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
289 gchar *url, *str, *tmp; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
290 cbdata = g_new(CbInfo, 1); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
291 cbdata->num = ++c; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
292 cbdata->tag = g_strdup_printf("%s%d", "tiny_", tag_num++); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
293 cbdata->conv = conv; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
294 tmp = purple_unescape_html((char *)iter->data); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
295 if (g_ascii_strncasecmp(tmp, "http://", 7) && g_ascii_strncasecmp(tmp, "https://", 8)) { |
26507
c5920a8cf83f
encode urls passed to tinyurl
Richard Nelson <wabz@pidgin.im>
parents:
26502
diff
changeset
|
296 url = g_strdup_printf("%shttp%%3A%%2F%%2F%s", purple_prefs_get_string(PREF_URL), purple_url_encode(tmp)); |
26500
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
297 } else { |
26507
c5920a8cf83f
encode urls passed to tinyurl
Richard Nelson <wabz@pidgin.im>
parents:
26502
diff
changeset
|
298 url = g_strdup_printf("%s%s", purple_prefs_get_string(PREF_URL), purple_url_encode(tmp)); |
26500
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
299 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
300 g_free(tmp); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
301 purple_util_fetch_url(url, TRUE, "finch", FALSE, url_fetched, cbdata); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
302 i = gnt_text_view_get_lines_below(tv); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
303 str = g_strdup_printf(_("\nFetching TinyURL...")); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
304 gnt_text_view_append_text_with_tag((tv), str, GNT_TEXT_FLAG_DIM, cbdata->tag); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
305 g_free(str); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
306 if (i == 0) |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
307 gnt_text_view_scroll(tv, 0); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
308 g_free(iter->data); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
309 g_free(url); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
310 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
311 g_list_free(urls); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
312 purple_conversation_set_data(conv, "TinyURLs", NULL); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
313 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
314 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
315 static void |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
316 free_conv_urls(PurpleConversation *conv) |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
317 { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
318 GList *urls = purple_conversation_get_data(conv, "TinyURLs"); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
319 if (urls) |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
320 g_list_foreach(urls, free_urls, NULL); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
321 g_list_free(urls); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
322 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
323 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
324 static gboolean |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
325 plugin_load(PurplePlugin *plugin) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
326 purple_signal_connect(purple_conversations_get_handle(), |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
327 "wrote-im-msg", |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
328 plugin, PURPLE_CALLBACK(received_msg), NULL); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
329 purple_signal_connect(purple_conversations_get_handle(), |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
330 "wrote-chat-msg", |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
331 plugin, PURPLE_CALLBACK(received_msg), NULL); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
332 purple_signal_connect(purple_conversations_get_handle(), |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
333 "receiving-im-msg", |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
334 plugin, PURPLE_CALLBACK(receiving_msg), NULL); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
335 purple_signal_connect(purple_conversations_get_handle(), |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
336 "receiving-chat-msg", |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
337 plugin, PURPLE_CALLBACK(receiving_msg), NULL); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
338 purple_signal_connect(purple_conversations_get_handle(), |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
339 "deleting-conversation", |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
340 plugin, PURPLE_CALLBACK(free_conv_urls), NULL); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
341 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
342 return TRUE; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
343 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
344 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
345 static PurplePluginPrefFrame * |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
346 get_plugin_pref_frame(PurplePlugin *plugin) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
347 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
348 PurplePluginPrefFrame *frame; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
349 PurplePluginPref *pref; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
350 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
351 frame = purple_plugin_pref_frame_new(); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
352 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
353 pref = purple_plugin_pref_new_with_name(PREF_LENGTH); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
354 purple_plugin_pref_set_label(pref, _("Only create TinyURL for urls" |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
355 " of this length or greater")); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
356 purple_plugin_pref_frame_add(frame, pref); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
357 pref = purple_plugin_pref_new_with_name(PREF_URL); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
358 purple_plugin_pref_set_label(pref, _("TinyURL (or other) address prefix")); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
359 purple_plugin_pref_frame_add(frame, pref); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
360 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
361 return frame; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
362 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
363 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
364 static PurplePluginUiInfo prefs_info = { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
365 get_plugin_pref_frame, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
366 0, /* page_num (Reserved) */ |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
367 NULL, /* frame (Reserved) */ |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
368 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
369 /* padding */ |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
370 NULL, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
371 NULL, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
372 NULL, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
373 NULL |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
374 }; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
375 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
376 static PurplePluginInfo info = |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
377 { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
378 PURPLE_PLUGIN_MAGIC, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
379 PURPLE_MAJOR_VERSION, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
380 PURPLE_MINOR_VERSION, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
381 PURPLE_PLUGIN_STANDARD, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
382 FINCH_PLUGIN_TYPE, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
383 0, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
384 NULL, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
385 PURPLE_PRIORITY_DEFAULT, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
386 "TinyURL", |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
387 N_("TinyURL"), |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
388 DISPLAY_VERSION, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
389 N_("TinyURL plugin"), |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
390 N_("When receiving a message with URL(s), TinyURL for easier copying"), |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
391 "Richard Nelson <wabz@whatsbeef.net>", |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
392 PURPLE_WEBSITE, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
393 plugin_load, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
394 NULL, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
395 NULL, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
396 NULL, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
397 NULL, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
398 &prefs_info, /**< prefs_info */ |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
399 NULL, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
400 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
401 /* padding */ |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
402 NULL, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
403 NULL, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
404 NULL, |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
405 NULL |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
406 }; |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
407 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
408 static void |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
409 init_plugin(PurplePlugin *plugin) { |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
410 purple_prefs_add_none(PREFS_BASE); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
411 purple_prefs_add_int(PREF_LENGTH, 30); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
412 purple_prefs_add_string(PREF_URL, "http://tinyurl.com/api-create.php?url="); |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
413 } |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
414 |
8986c3804ada
Add a gnt TinyURL plugin. Closes #2017
Richard Nelson <wabz@pidgin.im>
parents:
diff
changeset
|
415 PURPLE_INIT_PLUGIN(PLUGIN_STATIC_NAME, init_plugin, info) |