00001
00002
00003
00004
00005
00006
00007
#ifndef __UNICONFCONN_H
00008
#define __UNICONFCONN_H
00009
00010
#include "uniconfkey.h"
00011
#include "uniconfgen.h"
00012
#include "wvstreamclone.h"
00013
#include "wvistreamlist.h"
00014
#include "wvbuf.h"
00015
#include "wvlog.h"
00016
00017 #define DEFAULT_UNICONF_DAEMON_TCP_PORT 4111
00018 #define DEFAULT_UNICONF_DAEMON_SSL_PORT 4112
00019
00020
00021
00022
00023
00024
00025
00026 class UniClientConn :
public WvStreamClone
00027 {
00028
WvDynBuf msgbuf;
00029
00030
protected:
00031 WvLog log;
00032 bool closed;
00033
00034
public:
00035 WvConstStringBuffer payloadbuf;
00036 enum Command
00037 {
00038
NONE = -2,
00039
INVALID = -1,
00040
00041
00042
REQ_NOOP,
00043
REQ_GET,
00044
REQ_SET,
00045
REQ_REMOVE,
00046
REQ_SUBTREE,
00047
REQ_HASCHILDREN,
00048
REQ_QUIT,
00049
REQ_HELP,
00050
00051
00052
REPLY_OK,
00053
REPLY_FAIL,
00054
REPLY_CHILD,
00055
REPLY_ONEVAL,
00056
00057
00058
PART_VALUE,
00059
PART_TEXT,
00060
00061
00062
EVENT_HELLO,
00063
EVENT_NOTICE,
00064 };
00065 static const int NUM_COMMANDS =
EVENT_NOTICE + 1;
00066 struct CommandInfo
00067 {
00068 const char *
name;
00069 const char *
description;
00070 };
00071
static const CommandInfo cmdinfos[
NUM_COMMANDS];
00072
00073
00074
UniClientConn(
IWvStream *_s,
WvStringParm dst = WvString::null);
00075
virtual ~UniClientConn();
00076
00077
virtual bool pre_select(SelectInfo &si);
00078
virtual bool isok() const;
00079 virtual
void close();
00080
00081
00082
00083
00084
00085
00086 Command readcmd();
00087
00088
00089
00090
00091
00092
WvString readarg();
00093
00094
00095
00096
00097
00098
00099
void writecmd(Command command,
WvStringParm payload =
WvString::null);
00100
00101
00102
00103
00104
00105
void writeok(
WvStringParm payload = "");
00106
00107
00108
00109
00110
00111
void writefail(
WvStringParm payload = "");
00112
00113
00114
00115
00116
00117
00118
void writevalue(const
UniConfKey &key,
WvStringParm value);
00119
00120
00121
00122
00123
00124
00125
void writeonevalue(const
UniConfKey &key,
WvStringParm value);
00126
00127
00128
00129
00130
00131
void writetext(
WvStringParm text);
00132
00133 private:
00134
00135
WvString readmsg();
00136
00137
00138
void writemsg(
WvStringParm message);
00139 };
00140
00141 #endif