git-svn-id: svn://db.shs.com.ru/pip@8 12ceb7fc-bf1f-11e4-8940-5bc7170c53b5
96 lines
2.3 KiB
C++
96 lines
2.3 KiB
C++
#ifndef DAEMON_H
|
|
#define DAEMON_H
|
|
|
|
#include "piscreentiles.h"
|
|
#include "pipeer.h"
|
|
#include "pisystemmonitor.h"
|
|
|
|
extern PISystemMonitor sys_mon;
|
|
|
|
class Daemon: public PIPeer {
|
|
PIOBJECT(Daemon)
|
|
public:
|
|
Daemon();
|
|
|
|
struct HostInfo {
|
|
PIString execCommand;
|
|
PIString hostname;
|
|
PIString user;
|
|
PIString OS_name;
|
|
PIString OS_version;
|
|
PIString architecture;
|
|
PIDateTime execDateTime;
|
|
int processorsCount;
|
|
|
|
int ID;
|
|
int threads;
|
|
int priority;
|
|
ulong physical_memsize;
|
|
ulong share_memsize;
|
|
float cpu_load_system;
|
|
float cpu_load_user;
|
|
};
|
|
|
|
void enable() {enabled = true;}
|
|
void disable() {enabled = false;}
|
|
|
|
PIStringList availableDaemons() const;
|
|
void connectToDaemon(const PIString & dn);
|
|
void disconnect();
|
|
|
|
PIString connectedDaemon() const;
|
|
|
|
PIScreenTile * tile() const;
|
|
|
|
private:
|
|
enum PacketType {
|
|
RequestHostInfo = 10,
|
|
|
|
ReplyHostInfo = 20
|
|
|
|
};
|
|
|
|
EVENT_HANDLER1(void, keyEvent, PIKbdListener::KeyEvent, key);
|
|
EVENT_HANDLER2(void, timerEvent, void * , _d, int, delim);
|
|
EVENT(menuRequest);
|
|
void peerDisconnected(const PIString & name);
|
|
void dataReceived(const PIString & from, const PIByteArray & data);
|
|
void makeMyHostInfo();
|
|
void makeOtherHostInfo();
|
|
void updateConsole();
|
|
void tabConnectedHeader(int cols = 1);
|
|
void tabConnect();
|
|
void tabFeature();
|
|
void tabInfo();
|
|
|
|
mutable PIStringList available_daemons;
|
|
PITimer timer;
|
|
PIString conn_name;
|
|
PIMap<int, PIString> dnames;
|
|
PISystemMonitor sys_mon_other;
|
|
HostInfo info_my, info_other;
|
|
bool enabled;
|
|
int mode, offset, cur, height;
|
|
|
|
|
|
};
|
|
|
|
inline PIByteArray & operator <<(PIByteArray & b, const Daemon::HostInfo & v) {
|
|
b << v.execCommand << v.hostname << v.user << v.OS_name
|
|
<< v.OS_version << v.architecture << v.execDateTime
|
|
<< v.processorsCount << v.ID << v.threads << v.priority
|
|
<< v.physical_memsize << v.share_memsize
|
|
<< v.cpu_load_system << v.cpu_load_user;
|
|
return b;
|
|
}
|
|
inline PIByteArray & operator >>(PIByteArray & b, Daemon::HostInfo & v) {
|
|
b >> v.execCommand >> v.hostname >> v.user >> v.OS_name
|
|
>> v.OS_version >> v.architecture >> v.execDateTime
|
|
>> v.processorsCount >> v.ID >> v.threads >> v.priority
|
|
>> v.physical_memsize >> v.share_memsize
|
|
>> v.cpu_load_system >> v.cpu_load_user;
|
|
return b;
|
|
}
|
|
|
|
#endif // DAEMON_H
|