blob: 029f2a49aec110a537b6416494026fb805629b88 [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 Sheikinff43bfd2005-12-07 08:02:52 +000026 ListConnInfo() {}
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 Sheikinff43bfd2005-12-07 08:02:52 +000082 void Copy(ListConnInfo* InputList) {
83 Clear();
84 if (InputList->Empty()) return;
85 for (InputList->iBegin(); !InputList->iEnd(); InputList->iNext()) {
86 iAdd(InputList);
87 }
88 }
89
90 void iAdd (ListConnInfo* InputList) {
91 char* buf[3];
92 InputList->iGetCharInfo(buf);
93 addInfo(InputList->iGetConn(), buf[0], buf[1], InputList->iGetStatus());
94 }
95
96 private:
Oleg Sheikin641f7e52005-11-22 18:04:10 +000097 std::list<DWORD> conn;
98 std::list<char*> IP_address;
99 std::list<char*> time_conn;
100 std::list<int> status;
101 std::list<DWORD>::iterator ci;
Oleg Sheikinff43bfd2005-12-07 08:02:52 +0000102 std::list<char*>::iterator Ii;
103 std::list<char*>::iterator ti;
Oleg Sheikin641f7e52005-11-22 18:04:10 +0000104 std::list<int>::iterator si;
Oleg Sheikin641f7e52005-11-22 18:04:10 +0000105 };
Oleg Sheikinff43bfd2005-12-07 08:02:52 +0000106};
Oleg Sheikin641f7e52005-11-22 18:04:10 +0000107#endif
108