main_loop.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *                                                                         *
00003  *                         Powersave Daemon                                *
00004  *                                                                         *
00005  *              Copyright (C) 2005 SUSE Linux Products GmbH                *
00006  *                                                                         *
00007  *               Author(s): Holger Macht <hmacht@suse.de>                  *
00008  *                                                                         *
00009  * This program is free software; you can redistribute it and/or modify it *
00010  * under the terms of the GNU General Public License as published by the   *
00011  * Free Software Foundation; either version 2 of the License, or (at you   *
00012  * option) any later version.                                              *
00013  *                                                                         *
00014  * This program is distributed in the hope that it will be useful, but     *
00015  * WITHOUT ANY WARRANTY; without even the implied warranty of              *
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
00017  * General Public License for more details.                                *
00018  *                                                                         *
00019  * You should have received a copy of the GNU General Public License along *
00020  * with this program; if not, write to the Free Software Foundation, Inc., *
00021  * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA                  *
00022  *                                                                         *
00023  ***************************************************************************/
00024 
00025 #ifndef POWERSAVE_MAIN_LOOP_H
00026 #define POWERSAVE_MAIN_LOOP_H
00027 
00028 #include <list>
00029 #include "dbus_server.h"
00030 
00031 class PM_interface;
00032 
00038 class Callback {
00039 public:
00041         Callback();
00042 
00048         Callback(int interval, gboolean (*function)(gpointer data));
00049 
00051         int interval;
00052 
00054         gboolean (*function)(gpointer data);
00055 
00057         int id;
00058 };
00059 
00060 
00066 class MainLoop {
00067 public:
00073         MainLoop();
00074 
00079         void run();
00080 
00082         void quit();
00083 
00092         void updateCallbacks();
00093 
00101         int addCallback(int interval, gboolean (*function)(gpointer data));
00102 
00103 protected:
00104 
00105 private:
00119         static gboolean hwEvent_callback(GIOChannel *io_channel,
00120                                          GIOCondition io_condition,
00121                                          gpointer data);
00122 
00134         static gboolean hwEvent_reconnect(gpointer data);
00135 
00144         static gboolean hwEvent_connect();
00145 
00153         static gboolean checkThrottling_callback(gpointer data);
00154 
00164         static gboolean checkEventTimeouts_callback(gpointer data);
00165 
00178         static gboolean adjustSpeeds_callback(gpointer data);
00179 
00184         void setupCallbacks();
00185 
00187         GMainLoop *_gmain;
00188 
00190         std::list<Callback> _callback_functions;
00191 
00192         DBus_Server _dbus_server;
00193 };
00194 
00195 #endif // POWERSAVE_MAIN_LOOP_H

Generated on Mon Mar 27 09:27:19 2006 for Powersave Daemon by  doxygen 1.4.6