1 /* 2 * 3 * D-Bus++ - C++ bindings for D-Bus 4 * 5 * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> 6 * 7 * 8 * This library is free software; you can redistribute it and/or 9 * modify it under the terms of the GNU Lesser General Public 10 * License as published by the Free Software Foundation; either 11 * version 2.1 of the License, or (at your option) any later version. 12 * 13 * This library is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 * Lesser General Public License for more details. 17 * 18 * You should have received a copy of the GNU Lesser General Public 19 * License along with this library; if not, write to the Free Software 20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 21 * 22 */ 23 24 25 #ifndef __DBUSXX_GLIB_INTEGRATION_H 26 #define __DBUSXX_GLIB_INTEGRATION_H 27 28 #include <glib.h> 29 30 #include "api.h" 31 #include "dispatcher.h" 32 33 namespace DBus 34 { 35 36 namespace Glib 37 { 38 39 class BusDispatcher; 40 41 class DXXAPI BusTimeout : public Timeout 42 { 43 private: 44 45 BusTimeout(Timeout::Internal *, GMainContext *, int); 46 47 ~BusTimeout(); 48 49 void toggle(); 50 51 static gboolean timeout_handler(gpointer); 52 53 void _enable(); 54 55 void _disable(); 56 57 private: 58 59 GMainContext *_ctx; 60 int _priority; 61 GSource *_source; 62 63 friend class BusDispatcher; 64 }; 65 66 class DXXAPI BusWatch : public Watch 67 { 68 private: 69 70 BusWatch(Watch::Internal *, GMainContext *, int); 71 72 ~BusWatch(); 73 74 void toggle(); 75 76 static gboolean watch_handler(gpointer); 77 78 void _enable(); 79 80 void _disable(); 81 82 private: 83 84 GMainContext *_ctx; 85 int _priority; 86 GSource *_source; 87 88 friend class BusDispatcher; 89 }; 90 91 class DXXAPI BusDispatcher : public Dispatcher 92 { 93 public: 94 95 BusDispatcher(); 96 ~BusDispatcher(); 97 98 void attach(GMainContext *); 99 enter()100 void enter() {} 101 leave()102 void leave() {} 103 104 Timeout *add_timeout(Timeout::Internal *); 105 106 void rem_timeout(Timeout *); 107 108 Watch *add_watch(Watch::Internal *); 109 110 void rem_watch(Watch *); 111 112 void set_priority(int priority); 113 114 private: 115 116 GMainContext *_ctx; 117 int _priority; 118 GSource *_source; 119 }; 120 121 } /* namespace Glib */ 122 123 } /* namespace DBus */ 124 125 #endif//__DBUSXX_GLIB_INTEGRATION_H 126