Mercurial > pidgin
comparison libpurple/example/nullclient.c @ 23557:aaaff38e144f
Fix a double free when connecting to the sender of a bonjour file fails. Also plug a small leak. Fixes #5971.
| author | Daniel Atallah <daniel.atallah@gmail.com> |
|---|---|
| date | Thu, 17 Jul 2008 04:38:07 +0000 |
| parents | 68f8adb67470 |
| children | 05d3447fb34e |
comparison
equal
deleted
inserted
replaced
| 23556:d3fad795bba5 | 23557:aaaff38e144f |
|---|---|
| 25 | 25 |
| 26 #include <glib.h> | 26 #include <glib.h> |
| 27 | 27 |
| 28 #include <signal.h> | 28 #include <signal.h> |
| 29 #include <string.h> | 29 #include <string.h> |
| 30 #ifndef _WIN32 | |
| 30 #include <unistd.h> | 31 #include <unistd.h> |
| 32 #else | |
| 33 #include "win32/win32dep.h" | |
| 34 #endif | |
| 35 | |
| 31 | 36 |
| 32 #include "defines.h" | 37 #include "defines.h" |
| 33 | 38 |
| 34 /** | 39 /** |
| 35 * The following eventloop functions are used in both pidgin and purple-text. If your | 40 * The following eventloop functions are used in both pidgin and purple-text. If your |
| 78 if (condition & PURPLE_INPUT_READ) | 83 if (condition & PURPLE_INPUT_READ) |
| 79 cond |= PURPLE_GLIB_READ_COND; | 84 cond |= PURPLE_GLIB_READ_COND; |
| 80 if (condition & PURPLE_INPUT_WRITE) | 85 if (condition & PURPLE_INPUT_WRITE) |
| 81 cond |= PURPLE_GLIB_WRITE_COND; | 86 cond |= PURPLE_GLIB_WRITE_COND; |
| 82 | 87 |
| 88 #if defined _WIN32 && !defined WINPIDGIN_USE_GLIB_IO_CHANNEL | |
| 89 channel = wpurple_g_io_channel_win32_new_socket(fd); | |
| 90 #else | |
| 83 channel = g_io_channel_unix_new(fd); | 91 channel = g_io_channel_unix_new(fd); |
| 92 #endif | |
| 84 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, | 93 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, |
| 85 purple_glib_io_invoke, closure, purple_glib_io_destroy); | 94 purple_glib_io_invoke, closure, purple_glib_io_destroy); |
| 86 | 95 |
| 87 g_io_channel_unref(channel); | 96 g_io_channel_unref(channel); |
| 88 return closure->result; | 97 return closure->result; |
| 251 GMainLoop *loop = g_main_loop_new(NULL, FALSE); | 260 GMainLoop *loop = g_main_loop_new(NULL, FALSE); |
| 252 PurpleAccount *account; | 261 PurpleAccount *account; |
| 253 PurpleSavedStatus *status; | 262 PurpleSavedStatus *status; |
| 254 char *res; | 263 char *res; |
| 255 | 264 |
| 265 #ifndef _WIN32 | |
| 256 /* libpurple's built-in DNS resolution forks processes to perform | 266 /* libpurple's built-in DNS resolution forks processes to perform |
| 257 * blocking lookups without blocking the main process. It does not | 267 * blocking lookups without blocking the main process. It does not |
| 258 * handle SIGCHLD itself, so if the UI does not you quickly get an army | 268 * handle SIGCHLD itself, so if the UI does not you quickly get an army |
| 259 * of zombie subprocesses marching around. | 269 * of zombie subprocesses marching around. |
| 260 */ | 270 */ |
| 261 signal(SIGCHLD, SIG_IGN); | 271 signal(SIGCHLD, SIG_IGN); |
| 272 #endif | |
| 262 | 273 |
| 263 init_libpurple(); | 274 init_libpurple(); |
| 264 | 275 |
| 265 printf("libpurple initialized.\n"); | 276 printf("libpurple initialized.\n"); |
| 266 | 277 |
| 292 | 303 |
| 293 /* Create the account */ | 304 /* Create the account */ |
| 294 account = purple_account_new(name, prpl); | 305 account = purple_account_new(name, prpl); |
| 295 | 306 |
| 296 /* Get the password for the account */ | 307 /* Get the password for the account */ |
| 297 password = getpass("Password: "); | 308 //password = getpass("Password: "); |
| 309 password = ""; | |
| 298 purple_account_set_password(account, password); | 310 purple_account_set_password(account, password); |
| 299 | 311 |
| 300 /* It's necessary to enable the account first. */ | 312 /* It's necessary to enable the account first. */ |
| 301 purple_account_set_enabled(account, UI_ID, TRUE); | 313 purple_account_set_enabled(account, UI_ID, TRUE); |
| 302 | 314 |
