Mercurial > pidgin.yaz
comparison libpurple/protocols/msn/error.c @ 24836:bd2f4c6add99
These translated strings don't need to be duplicated with g_snprintf. And
since the function is called on error only, I really don't think we need to
keep around such large (8K) static buffers.
References #7910.
author | Elliott Sales de Andrade <qulogic@pidgin.im> |
---|---|
date | Sat, 27 Dec 2008 08:41:35 +0000 |
parents | c427d9c147ee |
children | 9381188c362b |
comparison
equal
deleted
inserted
replaced
24834:41e69c65b006 | 24836:bd2f4c6add99 |
---|---|
25 #include "error.h" | 25 #include "error.h" |
26 | 26 |
27 const char * | 27 const char * |
28 msn_error_get_text(unsigned int type, gboolean *debug) | 28 msn_error_get_text(unsigned int type, gboolean *debug) |
29 { | 29 { |
30 static char msg[MSN_BUF_LEN]; | 30 static char msg[256]; |
31 const char *result; | |
31 *debug = FALSE; | 32 *debug = FALSE; |
32 | 33 |
33 switch (type) { | 34 switch (type) { |
34 case 0: | 35 case 0: |
35 g_snprintf(msg, sizeof(msg), | 36 result = _("Unable to parse message"); |
36 _("Unable to parse message")); | |
37 *debug = TRUE; | 37 *debug = TRUE; |
38 break; | 38 break; |
39 case 200: | 39 case 200: |
40 g_snprintf(msg, sizeof(msg), | 40 result = _("Syntax Error (probably a client bug)"); |
41 _("Syntax Error (probably a client bug)")); | |
42 *debug = TRUE; | 41 *debug = TRUE; |
43 break; | 42 break; |
44 case 201: | 43 case 201: |
45 g_snprintf(msg, sizeof(msg), | 44 result = _("Invalid email address"); |
46 _("Invalid email address")); | |
47 break; | 45 break; |
48 case 205: | 46 case 205: |
49 g_snprintf(msg, sizeof(msg), _("User does not exist")); | 47 result = _("User does not exist"); |
50 break; | 48 break; |
51 case 206: | 49 case 206: |
52 g_snprintf(msg, sizeof(msg), | 50 result = _("Fully qualified domain name missing"); |
53 _("Fully qualified domain name missing")); | |
54 break; | 51 break; |
55 case 207: | 52 case 207: |
56 g_snprintf(msg, sizeof(msg), _("Already logged in")); | 53 result = _("Already logged in"); |
57 break; | 54 break; |
58 case 208: | 55 case 208: |
59 g_snprintf(msg, sizeof(msg), _("Invalid username")); | 56 result = _("Invalid username"); |
60 break; | 57 break; |
61 case 209: | 58 case 209: |
62 g_snprintf(msg, sizeof(msg), _("Invalid friendly name")); | 59 result = _("Invalid friendly name"); |
63 break; | 60 break; |
64 case 210: | 61 case 210: |
65 g_snprintf(msg, sizeof(msg), _("List full")); | 62 result = _("List full"); |
66 break; | 63 break; |
67 case 215: | 64 case 215: |
68 g_snprintf(msg, sizeof(msg), _("Already there")); | 65 result = _("Already there"); |
69 *debug = TRUE; | 66 *debug = TRUE; |
70 break; | 67 break; |
71 case 216: | 68 case 216: |
72 g_snprintf(msg, sizeof(msg), _("Not on list")); | 69 result = _("Not on list"); |
73 break; | 70 break; |
74 case 217: | 71 case 217: |
75 g_snprintf(msg, sizeof(msg), _("User is offline")); | 72 result = _("User is offline"); |
76 break; | 73 break; |
77 case 218: | 74 case 218: |
78 g_snprintf(msg, sizeof(msg), _("Already in the mode")); | 75 result = _("Already in the mode"); |
79 *debug = TRUE; | 76 *debug = TRUE; |
80 break; | 77 break; |
81 case 219: | 78 case 219: |
82 g_snprintf(msg, sizeof(msg), _("Already in opposite list")); | 79 result = _("Already in opposite list"); |
83 *debug = TRUE; | 80 *debug = TRUE; |
84 break; | 81 break; |
85 case 223: | 82 case 223: |
86 g_snprintf(msg, sizeof(msg), _("Too many groups")); | 83 result = _("Too many groups"); |
87 break; | 84 break; |
88 case 224: | 85 case 224: |
89 g_snprintf(msg, sizeof(msg), _("Invalid group")); | 86 result = _("Invalid group"); |
90 break; | 87 break; |
91 case 225: | 88 case 225: |
92 g_snprintf(msg, sizeof(msg), _("User not in group")); | 89 result = _("User not in group"); |
93 break; | 90 break; |
94 case 229: | 91 case 229: |
95 g_snprintf(msg, sizeof(msg), _("Group name too long")); | 92 result = _("Group name too long"); |
96 break; | 93 break; |
97 case 230: | 94 case 230: |
98 g_snprintf(msg, sizeof(msg), _("Cannot remove group zero")); | 95 result = _("Cannot remove group zero"); |
99 *debug = TRUE; | 96 *debug = TRUE; |
100 break; | 97 break; |
101 case 231: | 98 case 231: |
102 g_snprintf(msg, sizeof(msg), | 99 result = _("Tried to add a user to a group that doesn't exist"); |
103 _("Tried to add a user to a group " | |
104 "that doesn't exist")); | |
105 break; | 100 break; |
106 case 280: | 101 case 280: |
107 g_snprintf(msg, sizeof(msg), _("Switchboard failed")); | 102 result = _("Switchboard failed"); |
108 *debug = TRUE; | 103 *debug = TRUE; |
109 break; | 104 break; |
110 case 281: | 105 case 281: |
111 g_snprintf(msg, sizeof(msg), _("Notify transfer failed")); | 106 result = _("Notify transfer failed"); |
112 *debug = TRUE; | 107 *debug = TRUE; |
113 break; | 108 break; |
114 | 109 |
115 case 300: | 110 case 300: |
116 g_snprintf(msg, sizeof(msg), _("Required fields missing")); | 111 result = _("Required fields missing"); |
117 *debug = TRUE; | 112 *debug = TRUE; |
118 break; | 113 break; |
119 case 301: | 114 case 301: |
120 g_snprintf(msg, sizeof(msg), _("Too many hits to a FND")); | 115 result = _("Too many hits to a FND"); |
121 *debug = TRUE; | 116 *debug = TRUE; |
122 break; | 117 break; |
123 case 302: | 118 case 302: |
124 g_snprintf(msg, sizeof(msg), _("Not logged in")); | 119 result = _("Not logged in"); |
125 break; | 120 break; |
126 | 121 |
127 case 500: | 122 case 500: |
128 g_snprintf(msg, sizeof(msg), | 123 result = _("Service temporarily unavailable"); |
129 _("Service temporarily unavailable")); | |
130 break; | 124 break; |
131 case 501: | 125 case 501: |
132 g_snprintf(msg, sizeof(msg), _("Database server error")); | 126 result = _("Database server error"); |
133 *debug = TRUE; | 127 *debug = TRUE; |
134 break; | 128 break; |
135 case 502: | 129 case 502: |
136 g_snprintf(msg, sizeof(msg), _("Command disabled")); | 130 result = _("Command disabled"); |
137 *debug = TRUE; | 131 *debug = TRUE; |
138 break; | 132 break; |
139 case 510: | 133 case 510: |
140 g_snprintf(msg, sizeof(msg), _("File operation error")); | 134 result = _("File operation error"); |
141 *debug = TRUE; | 135 *debug = TRUE; |
142 break; | 136 break; |
143 case 520: | 137 case 520: |
144 g_snprintf(msg, sizeof(msg), _("Memory allocation error")); | 138 result = _("Memory allocation error"); |
145 *debug = TRUE; | 139 *debug = TRUE; |
146 break; | 140 break; |
147 case 540: | 141 case 540: |
148 g_snprintf(msg, sizeof(msg), | 142 result = _("Wrong CHL value sent to server"); |
149 _("Wrong CHL value sent to server")); | |
150 *debug = TRUE; | 143 *debug = TRUE; |
151 break; | 144 break; |
152 | 145 |
153 case 600: | 146 case 600: |
154 g_snprintf(msg, sizeof(msg), _("Server busy")); | 147 result = _("Server busy"); |
155 break; | 148 break; |
156 case 601: | 149 case 601: |
157 g_snprintf(msg, sizeof(msg), _("Server unavailable")); | 150 result = _("Server unavailable"); |
158 break; | 151 break; |
159 case 602: | 152 case 602: |
160 g_snprintf(msg, sizeof(msg), | 153 result = _("Peer notification server down"); |
161 _("Peer notification server down")); | |
162 *debug = TRUE; | 154 *debug = TRUE; |
163 break; | 155 break; |
164 case 603: | 156 case 603: |
165 g_snprintf(msg, sizeof(msg), _("Database connect error")); | 157 result = _("Database connect error"); |
166 *debug = TRUE; | 158 *debug = TRUE; |
167 break; | 159 break; |
168 case 604: | 160 case 604: |
169 g_snprintf(msg, sizeof(msg), | 161 result = _("Server is going down (abandon ship)"); |
170 _("Server is going down (abandon ship)")); | |
171 break; | 162 break; |
172 case 605: | 163 case 605: |
173 g_snprintf(msg, sizeof(msg), _("Server unavailable")); | 164 result = _("Server unavailable"); |
174 break; | 165 break; |
175 | 166 |
176 case 707: | 167 case 707: |
177 g_snprintf(msg, sizeof(msg), | 168 result = _("Error creating connection"); |
178 _("Error creating connection")); | |
179 *debug = TRUE; | 169 *debug = TRUE; |
180 break; | 170 break; |
181 case 710: | 171 case 710: |
182 g_snprintf(msg, sizeof(msg), | 172 result = _("CVR parameters are either unknown or not allowed"); |
183 _("CVR parameters are either unknown " | |
184 "or not allowed")); | |
185 *debug = TRUE; | 173 *debug = TRUE; |
186 break; | 174 break; |
187 case 711: | 175 case 711: |
188 g_snprintf(msg, sizeof(msg), _("Unable to write")); | 176 result = _("Unable to write"); |
189 break; | 177 break; |
190 case 712: | 178 case 712: |
191 g_snprintf(msg, sizeof(msg), _("Session overload")); | 179 result = _("Session overload"); |
192 *debug = TRUE; | 180 *debug = TRUE; |
193 break; | 181 break; |
194 case 713: | 182 case 713: |
195 g_snprintf(msg, sizeof(msg), _("User is too active")); | 183 result = _("User is too active"); |
196 break; | 184 break; |
197 case 714: | 185 case 714: |
198 g_snprintf(msg, sizeof(msg), _("Too many sessions")); | 186 result = _("Too many sessions"); |
199 break; | 187 break; |
200 case 715: | 188 case 715: |
201 g_snprintf(msg, sizeof(msg), _("Passport not verified")); | 189 result = _("Passport not verified"); |
202 break; | 190 break; |
203 case 717: | 191 case 717: |
204 g_snprintf(msg, sizeof(msg), _("Bad friend file")); | 192 result = _("Bad friend file"); |
205 *debug = TRUE; | 193 *debug = TRUE; |
206 break; | 194 break; |
207 case 731: | 195 case 731: |
208 g_snprintf(msg, sizeof(msg), _("Not expected")); | 196 result = _("Not expected"); |
209 *debug = TRUE; | 197 *debug = TRUE; |
210 break; | 198 break; |
211 | 199 |
212 case 800: | 200 case 800: |
213 g_snprintf(msg, sizeof(msg), | 201 result = _("Friendly name changes too rapidly"); |
214 _("Friendly name changes too rapidly")); | |
215 break; | 202 break; |
216 | 203 |
217 case 910: | 204 case 910: |
218 case 912: | 205 case 912: |
219 case 918: | 206 case 918: |
220 case 919: | 207 case 919: |
221 case 921: | 208 case 921: |
222 case 922: | 209 case 922: |
223 g_snprintf(msg, sizeof(msg), _("Server too busy")); | 210 result = _("Server too busy"); |
224 break; | 211 break; |
225 case 911: | 212 case 911: |
226 case 917: | 213 case 917: |
227 g_snprintf(msg, sizeof(msg), _("Authentication failed")); | 214 result = _("Authentication failed"); |
228 break; | 215 break; |
229 case 913: | 216 case 913: |
230 g_snprintf(msg, sizeof(msg), _("Not allowed when offline")); | 217 result = _("Not allowed when offline"); |
231 break; | 218 break; |
232 case 914: | 219 case 914: |
233 case 915: | 220 case 915: |
234 case 916: | 221 case 916: |
235 g_snprintf(msg, sizeof(msg), _("Server unavailable")); | 222 result = _("Server unavailable"); |
236 break; | 223 break; |
237 case 920: | 224 case 920: |
238 g_snprintf(msg, sizeof(msg), _("Not accepting new users")); | 225 result = _("Not accepting new users"); |
239 break; | 226 break; |
240 case 923: | 227 case 923: |
241 g_snprintf(msg, sizeof(msg), | 228 result = _("Kids Passport without parental consent"); |
242 _("Kids Passport without parental consent")); | |
243 break; | 229 break; |
244 case 924: | 230 case 924: |
245 g_snprintf(msg, sizeof(msg), | 231 result = _("Passport account not yet verified"); |
246 _("Passport account not yet verified")); | |
247 break; | 232 break; |
248 case 927: | 233 case 927: |
249 g_snprintf(msg, sizeof(msg), | 234 result = _("Passport account suspended"); |
250 _("Passport account suspended")); | |
251 break; | 235 break; |
252 case 928: | 236 case 928: |
253 g_snprintf(msg, sizeof(msg), _("Bad ticket")); | 237 result = _("Bad ticket"); |
254 *debug = TRUE; | 238 *debug = TRUE; |
255 break; | 239 break; |
256 | 240 |
257 default: | 241 default: |
258 g_snprintf(msg, sizeof(msg), | 242 g_snprintf(msg, sizeof(msg), |
259 _("Unknown Error Code %d"), type); | 243 _("Unknown Error Code %d"), type); |
260 *debug = TRUE; | 244 *debug = TRUE; |
245 result = msg; | |
261 break; | 246 break; |
262 } | 247 } |
263 | 248 |
264 return msg; | 249 return result; |
265 } | 250 } |
266 | 251 |
267 void | 252 void |
268 msn_error_handle(MsnSession *session, unsigned int type) | 253 msn_error_handle(MsnSession *session, unsigned int type) |
269 { | 254 { |
270 char buf[MSN_BUF_LEN]; | 255 char *buf; |
271 gboolean debug; | 256 gboolean debug; |
272 | 257 |
273 g_snprintf(buf, sizeof(buf), _("MSN Error: %s\n"), | 258 buf = g_strdup_printf(_("MSN Error: %s\n"), |
274 msn_error_get_text(type, &debug)); | 259 msn_error_get_text(type, &debug)); |
275 if (debug) | 260 if (debug) |
276 purple_debug_warning("msn", "error %d: %s\n", type, buf); | 261 purple_debug_warning("msn", "error %d: %s\n", type, buf); |
277 else | 262 else |
278 purple_notify_error(session->account->gc, NULL, buf, NULL); | 263 purple_notify_error(session->account->gc, NULL, buf, NULL); |
264 g_free(buf); | |
279 } | 265 } |
280 | 266 |