Changeset 5ebff60 for lib/events_glib.c
- Timestamp:
- 2015-02-20T22:50:54Z (9 years ago)
- Branches:
- master
- Children:
- 0b9daac, 3d45471, 7733b8c
- Parents:
- af359b4
- git-author:
- Indent <please@…> (19-02-15 05:47:20)
- git-committer:
- dequis <dx@…> (20-02-15 22:50:54)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lib/events_glib.c
raf359b4 r5ebff60 1 1 /********************************************************************\ 2 2 * BitlBee -- An IRC to other IM-networks gateway * 3 3 * * … … 50 50 void b_main_init() 51 51 { 52 if( loop == NULL ) 53 loop = g_main_new( FALSE ); 52 if (loop == NULL) { 53 loop = g_main_new(FALSE); 54 } 54 55 } 55 56 56 57 void b_main_run() 57 58 { 58 g_main_run( loop);59 g_main_run(loop); 59 60 } 60 61 61 62 void b_main_quit() 62 63 { 63 g_main_quit( loop);64 g_main_quit(loop); 64 65 } 65 66 … … 69 70 b_input_condition gaim_cond = 0; 70 71 gboolean st; 71 72 if (condition & G_IO_NVAL) 72 73 if (condition & G_IO_NVAL) { 73 74 return FALSE; 75 } 74 76 75 if (condition & GAIM_READ_COND) 77 if (condition & GAIM_READ_COND) { 76 78 gaim_cond |= B_EV_IO_READ; 77 if (condition & GAIM_WRITE_COND) 79 } 80 if (condition & GAIM_WRITE_COND) { 78 81 gaim_cond |= B_EV_IO_WRITE; 79 80 event_debug( "gaim_io_invoke( %d, %d, 0x%x )\n", g_io_channel_unix_get_fd(source), condition, data ); 82 } 83 84 event_debug("gaim_io_invoke( %d, %d, 0x%x )\n", g_io_channel_unix_get_fd(source), condition, data); 81 85 82 86 st = closure->function(closure->data, g_io_channel_unix_get_fd(source), gaim_cond); 83 84 if( !st ) 85 event_debug( "Returned FALSE, cancelling.\n" ); 86 87 if (closure->flags & B_EV_FLAG_FORCE_ONCE) 87 88 if (!st) { 89 event_debug("Returned FALSE, cancelling.\n"); 90 } 91 92 if (closure->flags & B_EV_FLAG_FORCE_ONCE) { 88 93 return FALSE; 89 else if (closure->flags & B_EV_FLAG_FORCE_REPEAT)94 } else if (closure->flags & B_EV_FLAG_FORCE_REPEAT) { 90 95 return TRUE; 91 else96 } else { 92 97 return st; 98 } 93 99 } 94 100 95 101 static void gaim_io_destroy(gpointer data) 96 102 { 97 event_debug( "gaim_io_destroy( 0x%x )\n", data);103 event_debug("gaim_io_destroy( 0x%x )\n", data); 98 104 g_free(data); 99 105 } … … 105 111 GIOCondition cond = 0; 106 112 int st; 107 113 108 114 closure->function = function; 109 115 closure->data = data; 110 116 closure->flags = condition; 111 112 if (condition & B_EV_IO_READ) 117 118 if (condition & B_EV_IO_READ) { 113 119 cond |= GAIM_READ_COND; 114 if (condition & B_EV_IO_WRITE) 120 } 121 if (condition & B_EV_IO_WRITE) { 115 122 cond |= GAIM_WRITE_COND; 116 123 } 124 117 125 channel = g_io_channel_unix_new(source); 118 126 st = g_io_add_watch_full(channel, G_PRIORITY_DEFAULT, cond, 119 127 gaim_io_invoke, closure, gaim_io_destroy); 120 121 event_debug( "b_input_add( %d, %d, 0x%x, 0x%x ) = %d (%p)\n", source, condition, function, data, st, closure);122 128 129 event_debug("b_input_add( %d, %d, 0x%x, 0x%x ) = %d (%p)\n", source, condition, function, data, st, closure); 130 123 131 g_io_channel_unref(channel); 124 132 return st; … … 131 139 for now, BitlBee only looks at the "data" argument. */ 132 140 gint st = g_timeout_add(timeout, (GSourceFunc) func, data); 133 134 event_debug( "b_timeout_add( %d, %d, %d ) = %d\n", timeout, func, data, st);135 141 142 event_debug("b_timeout_add( %d, %d, %d ) = %d\n", timeout, func, data, st); 143 136 144 return st; 137 145 } … … 139 147 void b_event_remove(gint tag) 140 148 { 141 event_debug( "b_event_remove( %d )\n", tag);142 143 if (tag > 0) 149 event_debug("b_event_remove( %d )\n", tag); 150 151 if (tag > 0) { 144 152 g_source_remove(tag); 153 } 145 154 } 146 155 147 void closesocket( int fd)156 void closesocket(int fd) 148 157 { 149 close( fd);158 close(fd); 150 159 }
Note: See TracChangeset
for help on using the changeset viewer.