Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
session.h
Go to the documentation of this file.
1
7#ifndef session_h_included
8#define session_h_included
9#include <string>
10#include <vector>
11#include <map>
12#include <sys/types.h>
13
14#include "argparser.h"
15
16namespace Binc {
17
18 class Depot;
19
20 //--------------------------------------------------------------------
21 class Session {
22 public:
23 std::map<std::string, std::string> attrs;
24
26
27 struct {
28 bool help;
29 bool version;
30 bool ssl;
32
34
35 enum State {
38 SELECTED = 0x04,
39 LOGOUT = 0x00
40 };
41
43
44 int timeout() const;
45
46 bool hasEnv(const std::string &key) const;
47 std::string getEnv(const std::string &key);
48 void setEnv(const std::string &key, const std::string &value);
49
50 const int getState(void) const;
51 void setState(int n);
52 bool parseCommandLine(int argc, char * argv[]);
53 void assignCommandLineArgs(void);
54 int getWriteBytes(void) const;
55 int getReadBytes(void) const;
56 void addWriteBytes(int);
57 void addReadBytes(int);
58 int getBodies(void) const;
59 int getStatements(void) const;
60 void addBody(void);
61 void addStatement(void);
62 void setLogFacility(int facility);
63 int getLogFacility(void) const;
64
65 const std::string &getLastError(void) const;
66 const std::string &getResponseCode(void) const;
67 const std::string &getIP(void) const;
68 const std::string &getUserID() const;
69 pid_t getPid(void);
70 const std::string &getHostname(void);
71 void setLastError(const std::string &error) const;
72 void setResponseCode(const std::string &error) const;
73 void clearResponseCode(void) const;
74 void setIP(const std::string &ip);
75 void setUserID(const std::string &s);
76
77 inline Depot *getDepot(void) const;
78
79 //--
80 static Session &getInstance(void);
81
82 bool initialize(int argc, char *argv[]);
83
84 private:
85 //--
86 int state;
87 std::string userid;
88 std::string ip;
89 char **argv;
90 int argc;
91
92 int logfacility;
93
94 int readbytes;
95 int writebytes;
96 int statements;
97 int bodies;
98
99 Depot *depot;
100
101 mutable std::string lastError;
102 mutable std::string responseCode;
103
104 pid_t pid;
105 std::string hostname;
106
107 Session(void);
108 };
109
110 inline Depot *Session::getDepot(void) const
111 {
112 return depot;
113 }
114}
115
116#endif
Declaration of the argument parser class.
void setLogFacility(int facility)
Definition: session.cc:76
const int getState(void) const
Definition: session.cc:40
bool initialize(int argc, char *argv[])
int getLogFacility(void) const
Definition: session.cc:82
bool mailboxchanges
Definition: session.h:33
void setEnv(const std::string &key, const std::string &value)
Definition: session.cc:237
void assignCommandLineArgs(void)
Definition: session.cc:160
void setLastError(const std::string &error) const
Definition: session.cc:185
void addBody(void)
Definition: session.cc:88
CommandLineArgs args
Definition: session.h:42
const std::string & getIP(void) const
Definition: session.cc:64
void setUserID(const std::string &s)
Definition: session.cc:58
void setState(int n)
Definition: session.cc:46
const std::string & getLastError(void) const
Definition: session.cc:179
void setIP(const std::string &ip)
Definition: session.cc:70
std::map< std::string, std::string > attrs
Definition: session.h:23
char ** unparsedArgs
Definition: session.h:25
bool help
Definition: session.h:28
int timeout() const
Definition: session.cc:218
Depot * getDepot(void) const
Definition: session.h:110
@ NONAUTHENTICATED
Definition: session.h:36
@ AUTHENTICATED
Definition: session.h:37
const std::string & getUserID() const
Definition: session.cc:52
void addStatement(void)
Definition: session.cc:94
int getBodies(void) const
Definition: session.cc:112
void setResponseCode(const std::string &error) const
Definition: session.cc:197
int getWriteBytes(void) const
Definition: session.cc:124
void addReadBytes(int)
Definition: session.cc:100
int getReadBytes(void) const
Definition: session.cc:130
bool ssl
Definition: session.h:30
struct Binc::Session::@3 command
const std::string & getHostname(void)
int getStatements(void) const
Definition: session.cc:118
bool version
Definition: session.h:29
void addWriteBytes(int)
Definition: session.cc:106
void clearResponseCode(void) const
Definition: session.cc:203
pid_t getPid(void)
Definition: session.cc:209
bool parseCommandLine(int argc, char *argv[])
Definition: session.cc:136
static Session & getInstance(void)
Definition: session.cc:33
const std::string & getResponseCode(void) const
Definition: session.cc:191
std::string getEnv(const std::string &key)
Definition: session.cc:230
bool hasEnv(const std::string &key) const
Definition: session.cc:224
Definition: bincimapd.cc:9