glib-integration.h
Go to the documentation of this file.
00001 /* 00002 * 00003 * D-Bus++ - C++ bindings for D-Bus 00004 * 00005 * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> 00006 * 00007 * 00008 * This library is free software; you can redistribute it and/or 00009 * modify it under the terms of the GNU Lesser General Public 00010 * License as published by the Free Software Foundation; either 00011 * version 2.1 of the License, or (at your option) any later version. 00012 * 00013 * This library is distributed in the hope that it will be useful, 00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00016 * Lesser General Public License for more details. 00017 * 00018 * You should have received a copy of the GNU Lesser General Public 00019 * License along with this library; if not, write to the Free Software 00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00021 * 00022 */ 00023 00024 00025 #ifndef __DBUSXX_GLIB_INTEGRATION_H 00026 #define __DBUSXX_GLIB_INTEGRATION_H 00027 00028 #include <glib.h> 00029 00030 #include "api.h" 00031 #include "dispatcher.h" 00032 00033 namespace DBus 00034 { 00035 00036 namespace Glib 00037 { 00038 00039 class BusDispatcher; 00040 00041 class DXXAPI BusTimeout : public Timeout 00042 { 00043 private: 00044 00045 BusTimeout(Timeout::Internal *, GMainContext *, int); 00046 00047 ~BusTimeout(); 00048 00049 void toggle(); 00050 00051 static gboolean timeout_handler(gpointer); 00052 00053 void _enable(); 00054 00055 void _disable(); 00056 00057 private: 00058 00059 GMainContext *_ctx; 00060 int _priority; 00061 GSource *_source; 00062 00063 friend class BusDispatcher; 00064 }; 00065 00066 class DXXAPI BusWatch : public Watch 00067 { 00068 private: 00069 00070 BusWatch(Watch::Internal *, GMainContext *, int); 00071 00072 ~BusWatch(); 00073 00074 void toggle(); 00075 00076 static gboolean watch_handler(gpointer); 00077 00078 void _enable(); 00079 00080 void _disable(); 00081 00082 private: 00083 00084 GMainContext *_ctx; 00085 int _priority; 00086 GSource *_source; 00087 00088 friend class BusDispatcher; 00089 }; 00090 00091 class DXXAPI BusDispatcher : public Dispatcher 00092 { 00093 public: 00094 00095 BusDispatcher(); 00096 ~BusDispatcher(); 00097 00098 void attach(GMainContext *); 00099 00100 void enter() {} 00101 00102 void leave() {} 00103 00104 Timeout *add_timeout(Timeout::Internal *); 00105 00106 void rem_timeout(Timeout *); 00107 00108 Watch *add_watch(Watch::Internal *); 00109 00110 void rem_watch(Watch *); 00111 00112 void set_priority(int priority); 00113 00114 private: 00115 00116 GMainContext *_ctx; 00117 int _priority; 00118 GSource *_source; 00119 }; 00120 00121 } /* namespace Glib */ 00122 00123 } /* namespace DBus */ 00124 00125 #endif//__DBUSXX_GLIB_INTEGRATION_H