| 78 if (condition & PURPLE_INPUT_READ) |
82 if (condition & PURPLE_INPUT_READ) |
| 79 cond |= PURPLE_GLIB_READ_COND; |
83 cond |= PURPLE_GLIB_READ_COND; |
| 80 if (condition & PURPLE_INPUT_WRITE) |
84 if (condition & PURPLE_INPUT_WRITE) |
| 81 cond |= PURPLE_GLIB_WRITE_COND; |
85 cond |= PURPLE_GLIB_WRITE_COND; |
| 82 |
86 |
| |
87 #if defined _WIN32 && !defined WINPIDGIN_USE_GLIB_IO_CHANNEL |
| |
88 channel = wpurple_g_io_channel_win32_new_socket(fd); |
| |
89 #else |
| 83 channel = g_io_channel_unix_new(fd); |
90 channel = g_io_channel_unix_new(fd); |
| |
91 #endif |
| 84 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, |
92 closure->result = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, |
| 85 purple_glib_io_invoke, closure, purple_glib_io_destroy); |
93 purple_glib_io_invoke, closure, purple_glib_io_destroy); |
| 86 |
94 |
| 87 g_io_channel_unref(channel); |
95 g_io_channel_unref(channel); |
| 88 return closure->result; |
96 return closure->result; |
| 89 } |
97 } |
| 90 |
98 |
| 91 static PurpleEventLoopUiOps glib_eventloops = |
99 static PurpleEventLoopUiOps glib_eventloops = |
| 92 { |
100 { |
| 93 g_timeout_add, |
101 g_timeout_add, |
| 94 g_source_remove, |
102 g_source_remove, |
| 95 glib_input_add, |
103 glib_input_add, |
| 96 g_source_remove, |
104 g_source_remove, |
| 124 printf("(%s) %s %s: %s\n", purple_conversation_get_name(conv), |
132 printf("(%s) %s %s: %s\n", purple_conversation_get_name(conv), |
| 125 purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)), |
133 purple_utf8_strftime("(%H:%M:%S)", localtime(&mtime)), |
| 126 name, message); |
134 name, message); |
| 127 } |
135 } |
| 128 |
136 |
| 129 static PurpleConversationUiOps null_conv_uiops = |
137 static PurpleConversationUiOps null_conv_uiops = |
| 130 { |
138 { |
| 131 NULL, /* create_conversation */ |
139 NULL, /* create_conversation */ |
| 132 NULL, /* destroy_conversation */ |
140 NULL, /* destroy_conversation */ |
| 133 NULL, /* write_chat */ |
141 NULL, /* write_chat */ |
| 134 NULL, /* write_im */ |
142 NULL, /* write_im */ |
| 227 |
235 |
| 228 static void |
236 static void |
| 229 signed_on(PurpleConnection *gc, gpointer null) |
237 signed_on(PurpleConnection *gc, gpointer null) |
| 230 { |
238 { |
| 231 PurpleAccount *account = purple_connection_get_account(gc); |
239 PurpleAccount *account = purple_connection_get_account(gc); |
| 232 printf("Account connected: %s %s\n", account->username, account->protocol_id); |
240 printf("Account connected: %s %s\n", purple_account_get_username(account), purple_account_get_protocol_id(account)); |
| 233 } |
241 } |
| 234 |
242 |
| 235 static void |
243 static void |
| 236 connect_to_signals_for_demonstration_purposes_only(void) |
244 connect_to_signals_for_demonstration_purposes_only(void) |
| 237 { |
245 { |
| 251 GMainLoop *loop = g_main_loop_new(NULL, FALSE); |
259 GMainLoop *loop = g_main_loop_new(NULL, FALSE); |
| 252 PurpleAccount *account; |
260 PurpleAccount *account; |
| 253 PurpleSavedStatus *status; |
261 PurpleSavedStatus *status; |
| 254 char *res; |
262 char *res; |
| 255 |
263 |
| |
264 #ifndef _WIN32 |
| 256 /* libpurple's built-in DNS resolution forks processes to perform |
265 /* libpurple's built-in DNS resolution forks processes to perform |
| 257 * blocking lookups without blocking the main process. It does not |
266 * 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 |
267 * handle SIGCHLD itself, so if the UI does not you quickly get an army |
| 259 * of zombie subprocesses marching around. |
268 * of zombie subprocesses marching around. |
| 260 */ |
269 */ |
| 261 signal(SIGCHLD, SIG_IGN); |
270 signal(SIGCHLD, SIG_IGN); |
| |
271 #endif |
| 262 |
272 |
| 263 init_libpurple(); |
273 init_libpurple(); |
| 264 |
274 |
| 265 printf("libpurple initialized.\n"); |
275 printf("libpurple initialized.\n"); |
| 266 |
276 |