1 |
/**************************************************************************** |
2 |
GLASHCtl - a simple tray applet for controlling lashd |
3 |
|
4 |
Copyright (C) 2006 Lars Luthman <lars.luthman@gmail.com> |
5 |
|
6 |
This program is free software; you can redistribute it and/or modify |
7 |
it under the terms of the GNU General Public License as published by |
8 |
the Free Software Foundation; either version 3 of the License, or |
9 |
(at your option) any later version. |
10 |
|
11 |
This program is distributed in the hope that it will be useful, |
12 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
14 |
GNU General Public License for more details. |
15 |
|
16 |
You should have received a copy of the GNU General Public License |
17 |
along with this program; if not, write to the Free Software Foundation, |
18 |
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
19 |
****************************************************************************/ |
20 |
|
21 |
#ifndef LASHSERVERINTERFACE_HPP |
22 |
#define LASHSERVERINTERFACE_HPP |
23 |
|
24 |
#include <list> |
25 |
#include <string> |
26 |
|
27 |
#include <sigc++/sigc++.h> |
28 |
#include <lash/lash.h> |
29 |
|
30 |
|
31 |
/** This class wraps parts of the LASH server interface API in a |
32 |
convenient class. */ |
33 |
class LASHServerInterface : public sigc::trackable { |
34 |
public: |
35 |
|
36 |
/** This constructor creates a new LASHServerInterface object and tries |
37 |
to connect to the LASH server. @c classname is the application class |
38 |
name that will be used when connecting, and @c timeout is the number |
39 |
of seconds it should try to connect before giving up .*/ |
40 |
LASHServerInterface(lash_args_t* args, const std::string& classname, |
41 |
int timeout); |
42 |
~LASHServerInterface(); |
43 |
|
44 |
/** This returns @c true if the LASH client was initialised OK and still is |
45 |
connected to the LASH server. */ |
46 |
bool is_valid() const; |
47 |
|
48 |
/** This returns @c true if there is an active session. */ |
49 |
bool has_session() const; |
50 |
|
51 |
/** This tells the server to restore the session in the given directory. */ |
52 |
void restore_session(const std::string& directory); |
53 |
|
54 |
/** This tells the server to set the directory for this session */ |
55 |
void set_session_dir(const std::string& directory); |
56 |
|
57 |
/** This tells the server to save the current session. */ |
58 |
void save_session(); |
59 |
|
60 |
/** This tells the server to close the current session. */ |
61 |
void close_session(); |
62 |
|
63 |
/** This tells the server to close all open sessions. */ |
64 |
void close_all_sessions(); |
65 |
|
66 |
/** This tells the server to rename the current session. */ |
67 |
void rename_session(const std::string& new_name); |
68 |
|
69 |
|
70 |
/** This signal is emitted when the active session changes, or its name |
71 |
changes. */ |
72 |
sigc::signal<void, const std::string&> signal_session_changed; |
73 |
|
74 |
/** This signal is emitted when a session has been saved. The first |
75 |
parameter is the session name and the second is the directory it |
76 |
was saved in. */ |
77 |
sigc::signal<void, const std::string&, const std::string&> |
78 |
signal_session_saved; |
79 |
|
80 |
/** This signal is emitted when an event is received. */ |
81 |
sigc::signal<void, const std::string&> signal_event_received; |
82 |
|
83 |
private: |
84 |
|
85 |
struct Project { |
86 |
std::string name; |
87 |
std::string dir; |
88 |
}; |
89 |
|
90 |
bool check_events(); |
91 |
|
92 |
std::list<Project> m_projects; |
93 |
|
94 |
sigc::connection m_connection; |
95 |
lash_client_t* m_client; |
96 |
}; |
97 |
|
98 |
|
99 |
#endif |