File: clientConnection.h

package info (click to toggle)
powersave 0.14.0-5
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 4,764 kB
  • ctags: 999
  • sloc: sh: 11,357; cpp: 8,103; ansic: 2,631; makefile: 388
file content (105 lines) | stat: -rw-r--r-- 4,167 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/***************************************************************************
 *                                                                         *
 *                         Powersave Daemon                                *
 *                                                                         *
 *          Copyright (C) 2004,2005,2006 SUSE Linux Products GmbH          *
 *                                                                         *
 *               Author(s): Holger Macht <hmacht@suse.de>                  *
 *                                                                         *
 * This program is free software; you can redistribute it and/or modify it *
 * under the terms of the GNU General Public License as published by the   *
 * Free Software Foundation; either version 2 of the License, or (at you   *
 * option) any later version.                                              *
 *                                                                         *
 * This program is distributed in the hope that it will be useful, but     *
 * WITHOUT ANY WARRANTY; without even the implied warranty of              *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU       *
 * General Public License for more details.                                *
 *                                                                         *
 * You should have received a copy of the GNU General Public License along *
 * with this program; if not, write to the Free Software Foundation, Inc., *
 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA                  *
 *                                                                         *
 ***************************************************************************/

#ifndef CLIENTCONNECTION_H
#define CLIENTCONNECTION_H

#include <list>
#include <string>

class CPUFreq_Interface;
struct PM_STATE;

/** @brief This struct represents a connected client */
typedef struct cNode {
	/** the clients name (dbus name)*/
	std::string name;
	/** The capabilities to which the message belongs @ref client_capabilities */
	int capabilities;
} cNode;

/** @brief  Base class for administrate clients
 *
 * Base class for administrate clients which connect to a server socket
 * provided by powersaved. Everytime one of the above defined states changes, 
 * all client which requested this state will be notified. Additionally it is
 * also possible that acpi_events occurring on /proc/acpi/events will be 
 * forwarded to the clients instead of changes.
 *
 * The class clientStorage is a list which holds all the registered clients.
*/
class ClientConnection {
public:
	/** @brief destructor clearing the class */
	~ClientConnection();

	/** @brief check if we have a connected client with a specific capability
	 *
	 * @param capability the capability to check for
	 *
	 * @return integer value representing result of function call
	 * @retval 1 on success
	 * @retval 0 otherwise
	*/
	bool checkClientCapabilities(int capability);

	/** @brief get number of clients connected
	 *
	 * @return integer with number of clients connected to the daemon
	 *
	 * invokes count() from class clientStorage and so returns the
	 * number of clients which are connected to the daemon
	 */
	int count() const;

	/** @brief adds a client to the list of connected clients
	 *
	 * @param name the dbus name of the client
	 * @param modes the modes the client is aware of
	 *
	 * @return true on success, false otherwise
	 */
	bool addClient(const char *name, int modes);

	/** @brief check if given client should get removed 
	 *
	 * @param name the dbus name of the client
	 *
	 * @return true when the client got removed, false otherwise
	 */
	bool checkClientRemoval(const char *name);

	/** @brief get all connected clients with their capabilities
	 *
	 * @param names stl list that gets filled with client names
	 * @param caps slt list that gets filled with client capabilities
	 */
	void getClients(std::list< std::string > &names, std::list< int > &caps);

private:
	/** list for storing all connected clients */
	std::list < cNode > _clients;
};

#endif // CLIENTCONNECTION_H