blob: 44df9ec28833f3bb02d7f08e5d68c05d6f8505f5 [file] [log] [blame]
Oleg Sheikin641f7e52005-11-22 18:04:10 +00001/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
2 *
3 * This is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
7 *
8 * This software is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this software; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
17 */
18
19
20#ifndef __RFB_LISTCONNINFO_INCLUDED__
21#define __RFB_LISTCONNINFO_INCLUDED__
22
23namespace rfb {
24
25 struct ListConnInfo {
Oleg Sheikin5c642e92005-12-22 20:57:58 +000026 ListConnInfo() : disableClients(false) {}
Oleg Sheikin641f7e52005-11-22 18:04:10 +000027
28 void Clear() {
29 conn.clear();
30 IP_address.clear();
31 time_conn.clear();
32 status.clear();
Oleg Sheikin641f7e52005-11-22 18:04:10 +000033 }
34
Oleg Sheikinff43bfd2005-12-07 08:02:52 +000035 bool Empty() { return conn.empty();}
36
Oleg Sheikin641f7e52005-11-22 18:04:10 +000037 void iBegin() {
38 ci = conn.begin();
39 Ii = IP_address.begin();
40 ti = time_conn.begin();
41 si = status.begin();
42 }
43
Oleg Sheikinff43bfd2005-12-07 08:02:52 +000044 bool iEnd() { return ci == conn.end();}
Oleg Sheikin641f7e52005-11-22 18:04:10 +000045
46 void iNext() {
47 ci++;
48 Ii++;
49 ti++;
50 si++;
51 }
52
53 void addInfo(DWORD Conn, char* IP, char* Time, int Status) {
Oleg Sheikinff43bfd2005-12-07 08:02:52 +000054 conn.push_back(Conn);
55 IP_address.push_back(strDup(IP));
56 time_conn.push_back(strDup(Time));
57 status.push_back(Status);
Oleg Sheikin641f7e52005-11-22 18:04:10 +000058 }
59
60 void iGetCharInfo(char* buf[3]) {
Oleg Sheikinff43bfd2005-12-07 08:02:52 +000061 buf[0] = *Ii;
62 buf[1] = *ti;
Oleg Sheikin641f7e52005-11-22 18:04:10 +000063 switch (*si) {
64 case 0:
65 buf[2] = strDup("Full control");
66 break;
67 case 1:
68 buf[2] = strDup("View only");
69 break;
70 case 2:
71 buf[2] = strDup("Stop updating");
72 break;
73 default:
74 buf[2] = strDup("Unknown");
Oleg Sheikinff43bfd2005-12-07 08:02:52 +000075 }
Oleg Sheikin641f7e52005-11-22 18:04:10 +000076 }
77
Oleg Sheikinff43bfd2005-12-07 08:02:52 +000078 DWORD iGetConn() { return *ci;}
Oleg Sheikin641f7e52005-11-22 18:04:10 +000079
Oleg Sheikinff43bfd2005-12-07 08:02:52 +000080 int iGetStatus() { return *si;}
Oleg Sheikin641f7e52005-11-22 18:04:10 +000081
Oleg Sheikin4b0304f2005-12-09 10:59:12 +000082 void iSetStatus( int status) { *si = status;}
83
Oleg Sheikinff43bfd2005-12-07 08:02:52 +000084 void Copy(ListConnInfo* InputList) {
85 Clear();
86 if (InputList->Empty()) return;
87 for (InputList->iBegin(); !InputList->iEnd(); InputList->iNext()) {
88 iAdd(InputList);
89 }
90 }
91
92 void iAdd (ListConnInfo* InputList) {
93 char* buf[3];
94 InputList->iGetCharInfo(buf);
95 addInfo(InputList->iGetConn(), buf[0], buf[1], InputList->iGetStatus());
96 }
97
Oleg Sheikin5c642e92005-12-22 20:57:58 +000098 void setDisable(bool disable) {disableClients = disable;}
99
100 bool getDisable() {return disableClients;}
101
102 void setAllStatus(int stat) {
103 std::list<int>::iterator st;
104 for (st = status.begin(); st != status.end(); st++)
105 *st = stat;
106 }
107
Oleg Sheikinff43bfd2005-12-07 08:02:52 +0000108 private:
Oleg Sheikin641f7e52005-11-22 18:04:10 +0000109 std::list<DWORD> conn;
110 std::list<char*> IP_address;
111 std::list<char*> time_conn;
112 std::list<int> status;
113 std::list<DWORD>::iterator ci;
Oleg Sheikinff43bfd2005-12-07 08:02:52 +0000114 std::list<char*>::iterator Ii;
115 std::list<char*>::iterator ti;
Oleg Sheikin641f7e52005-11-22 18:04:10 +0000116 std::list<int>::iterator si;
Oleg Sheikin5c642e92005-12-22 20:57:58 +0000117 bool disableClients;
Oleg Sheikin641f7e52005-11-22 18:04:10 +0000118 };
Oleg Sheikinff43bfd2005-12-07 08:02:52 +0000119};
Oleg Sheikin641f7e52005-11-22 18:04:10 +0000120#endif
121