comparison src/core.c @ 4793:677d3cb193a1

[gaim-migrate @ 5113] this removes all the remaining deprecated glib, gdk, gdk-pixbuf, and gtk function calls. Hopefully I didn't break anything. Most of this is due to the deprecation of g_strcasecmp and g_strncasecmp. Two functions I never thought would be deprecated, but apparently they're no good at comparing utf8 text. g_ascii_str{,n}casecmp is OK when you're sure that it's ASCII. Otherwise, we're supposed to use g_utf8_collate(), except that it is case sensitive. Since glib doesn't currently have a case-insensitive one, I wrote one. If you need to compare utf8 text, you can use gaim_utf8_strcasecmp(). I have to go do dishes now. committer: Tailor Script <tailor@pidgin.im>
author Nathan Walp <nwalp@pidgin.im>
date Sun, 16 Mar 2003 00:01:49 +0000
parents c4c28874ecd3
children 4af15fbcb00a
comparison
equal deleted inserted replaced
4792:9212d1c5b7dc 4793:677d3cb193a1
94 return buffer; 94 return buffer;
95 } 95 }
96 96
97 gint UI_write(struct UI *ui, guchar *data, gint len) 97 gint UI_write(struct UI *ui, guchar *data, gint len)
98 { 98 {
99 GError *error;
99 gint sent; 100 gint sent;
100 /* we'll let the write silently fail because the read will pick it up as dead */ 101 /* we'll let the write silently fail because the read will pick it up as dead */
101 g_io_channel_write(ui->channel, data, len, &sent); 102 g_io_channel_write_chars(ui->channel, data, len, &sent, &error);
103 g_free(error);
102 return sent; 104 return sent;
103 } 105 }
104 106
105 void UI_build_write(struct UI *ui, guchar type, guchar subtype, ...) 107 void UI_build_write(struct UI *ui, guchar type, guchar subtype, ...)
106 { 108 {
147 149
148 #ifndef _WIN32 150 #ifndef _WIN32
149 static void meta_handler(struct UI *ui, guchar subtype, guchar *data) 151 static void meta_handler(struct UI *ui, guchar subtype, guchar *data)
150 { 152 {
151 struct gaim_cui_packet *p; 153 struct gaim_cui_packet *p;
154 GError *error = NULL;
152 switch (subtype) { 155 switch (subtype) {
153 case CUI_META_LIST: 156 case CUI_META_LIST:
154 break; 157 break;
155 case CUI_META_QUIT: 158 case CUI_META_QUIT:
156 while (uis) { 159 while (uis) {
157 ui = uis->data; 160 ui = uis->data;
158 uis = g_slist_remove(uis, ui); 161 uis = g_slist_remove(uis, ui);
159 g_io_channel_close(ui->channel); 162 g_io_channel_shutdown(ui->channel, TRUE, &error);
160 g_source_remove(ui->inpa); 163 g_source_remove(ui->inpa);
161 g_free(ui); 164 g_free(ui);
162 } 165 }
163 do_quit(); 166 do_quit();
164 break; 167 break;
165 case CUI_META_DETACH: 168 case CUI_META_DETACH:
166 uis = g_slist_remove(uis, ui); 169 uis = g_slist_remove(uis, ui);
167 g_io_channel_close(ui->channel); 170 g_io_channel_shutdown(ui->channel, TRUE, &error);
168 g_source_remove(ui->inpa); 171 g_source_remove(ui->inpa);
169 g_free(ui); 172 g_free(ui);
170 break; 173 break;
171 case CUI_META_PING: 174 case CUI_META_PING:
172 p = cui_packet_new(CUI_TYPE_META, CUI_META_ACK); 175 p = cui_packet_new(CUI_TYPE_META, CUI_META_ACK);
175 break; 178 break;
176 default: 179 default:
177 debug_printf("unhandled meta subtype %d\n", subtype); 180 debug_printf("unhandled meta subtype %d\n", subtype);
178 break; 181 break;
179 } 182 }
183
184 if(error)
185 g_free(error);
180 } 186 }
181 187
182 static void plugin_handler(struct UI *ui, guchar subtype, guchar *data) 188 static void plugin_handler(struct UI *ui, guchar subtype, guchar *data)
183 { 189 {
184 #ifdef GAIM_PLUGINS 190 #ifdef GAIM_PLUGINS
290 static gint gaim_recv(GIOChannel *source, guchar *buf, gint len) 296 static gint gaim_recv(GIOChannel *source, guchar *buf, gint len)
291 { 297 {
292 gint total = 0; 298 gint total = 0;
293 gint cur; 299 gint cur;
294 300
301 GError *error;
302
295 while (total < len) { 303 while (total < len) {
296 if (g_io_channel_read(source, buf + total, len - total, &cur) != G_IO_ERROR_NONE) 304 if (g_io_channel_read_chars(source, buf + total, len - total, &cur, &error) != G_IO_STATUS_NORMAL) {
305 g_free(error);
297 return -1; 306 return -1;
307 }
298 if (cur == 0) 308 if (cur == 0)
299 return total; 309 return total;
300 total += cur; 310 total += cur;
301 } 311 }
302 312
330 340
331 guchar type; 341 guchar type;
332 guchar subtype; 342 guchar subtype;
333 guint32 len; 343 guint32 len;
334 344
345 GError *error;
346
335 guchar *in; 347 guchar *in;
336 348
337 /* no byte order worries! this'll change if we go to TCP */ 349 /* no byte order worries! this'll change if we go to TCP */
338 if (gaim_recv(source, &type, sizeof(type)) != sizeof(type)) { 350 if (gaim_recv(source, &type, sizeof(type)) != sizeof(type)) {
339 debug_printf("UI has abandoned us!\n"); 351 debug_printf("UI has abandoned us!\n");
340 uis = g_slist_remove(uis, ui); 352 uis = g_slist_remove(uis, ui);
341 g_io_channel_close(ui->channel); 353 g_io_channel_shutdown(ui->channel, TRUE, &error);
354 if(error)
355 g_free(error);
342 g_source_remove(ui->inpa); 356 g_source_remove(ui->inpa);
343 g_free(ui); 357 g_free(ui);
344 return FALSE; 358 return FALSE;
345 } 359 }
346 360
347 if (gaim_recv(source, &subtype, sizeof(subtype)) != sizeof(subtype)) { 361 if (gaim_recv(source, &subtype, sizeof(subtype)) != sizeof(subtype)) {
348 debug_printf("UI has abandoned us!\n"); 362 debug_printf("UI has abandoned us!\n");
349 uis = g_slist_remove(uis, ui); 363 uis = g_slist_remove(uis, ui);
350 g_io_channel_close(ui->channel); 364 g_io_channel_shutdown(ui->channel, TRUE, &error);
365 if(error)
366 g_free(error);
351 g_source_remove(ui->inpa); 367 g_source_remove(ui->inpa);
352 g_free(ui); 368 g_free(ui);
353 return FALSE; 369 return FALSE;
354 } 370 }
355 371
356 if (gaim_recv(source, (guchar *)&len, sizeof(len)) != sizeof(len)) { 372 if (gaim_recv(source, (guchar *)&len, sizeof(len)) != sizeof(len)) {
357 debug_printf("UI has abandoned us!\n"); 373 debug_printf("UI has abandoned us!\n");
358 uis = g_slist_remove(uis, ui); 374 uis = g_slist_remove(uis, ui);
359 g_io_channel_close(ui->channel); 375 g_io_channel_shutdown(ui->channel, TRUE, &error);
376 if(error)
377 g_free(error);
360 g_source_remove(ui->inpa); 378 g_source_remove(ui->inpa);
361 g_free(ui); 379 g_free(ui);
362 return FALSE; 380 return FALSE;
363 } 381 }
364 382
365 if (len) { 383 if (len) {
366 in = g_new0(guchar, len); 384 in = g_new0(guchar, len);
367 if (gaim_recv(source, in, len) != len) { 385 if (gaim_recv(source, in, len) != len) {
368 debug_printf("UI has abandoned us!\n"); 386 debug_printf("UI has abandoned us!\n");
369 uis = g_slist_remove(uis, ui); 387 uis = g_slist_remove(uis, ui);
370 g_io_channel_close(ui->channel); 388 g_io_channel_shutdown(ui->channel, TRUE, &error);
389 if(error)
390 g_free(error);
371 g_source_remove(ui->inpa); 391 g_source_remove(ui->inpa);
372 g_free(ui); 392 g_free(ui);
373 return FALSE; 393 return FALSE;
374 } 394 }
375 } else 395 } else