Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 1 | /* 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 | |
| 23 | namespace rfb { |
| 24 | |
| 25 | struct ListConnInfo { |
Oleg Sheikin | ff43bfd | 2005-12-07 08:02:52 +0000 | [diff] [blame] | 26 | ListConnInfo() {} |
Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 27 | |
| 28 | void Clear() { |
| 29 | conn.clear(); |
| 30 | IP_address.clear(); |
| 31 | time_conn.clear(); |
| 32 | status.clear(); |
Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 33 | } |
| 34 | |
Oleg Sheikin | ff43bfd | 2005-12-07 08:02:52 +0000 | [diff] [blame] | 35 | bool Empty() { return conn.empty();} |
| 36 | |
Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 37 | void iBegin() { |
| 38 | ci = conn.begin(); |
| 39 | Ii = IP_address.begin(); |
| 40 | ti = time_conn.begin(); |
| 41 | si = status.begin(); |
| 42 | } |
| 43 | |
Oleg Sheikin | ff43bfd | 2005-12-07 08:02:52 +0000 | [diff] [blame] | 44 | bool iEnd() { return ci == conn.end();} |
Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 45 | |
| 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 Sheikin | ff43bfd | 2005-12-07 08:02:52 +0000 | [diff] [blame] | 54 | conn.push_back(Conn); |
| 55 | IP_address.push_back(strDup(IP)); |
| 56 | time_conn.push_back(strDup(Time)); |
| 57 | status.push_back(Status); |
Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | void iGetCharInfo(char* buf[3]) { |
Oleg Sheikin | ff43bfd | 2005-12-07 08:02:52 +0000 | [diff] [blame] | 61 | buf[0] = *Ii; |
| 62 | buf[1] = *ti; |
Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 63 | 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 Sheikin | ff43bfd | 2005-12-07 08:02:52 +0000 | [diff] [blame] | 75 | } |
Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Oleg Sheikin | ff43bfd | 2005-12-07 08:02:52 +0000 | [diff] [blame] | 78 | DWORD iGetConn() { return *ci;} |
Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 79 | |
Oleg Sheikin | ff43bfd | 2005-12-07 08:02:52 +0000 | [diff] [blame] | 80 | int iGetStatus() { return *si;} |
Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 81 | |
Oleg Sheikin | 4b0304f | 2005-12-09 10:59:12 +0000 | [diff] [blame^] | 82 | void iSetStatus( int status) { *si = status;} |
| 83 | |
Oleg Sheikin | ff43bfd | 2005-12-07 08:02:52 +0000 | [diff] [blame] | 84 | 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 | |
| 98 | private: |
Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 99 | std::list<DWORD> conn; |
| 100 | std::list<char*> IP_address; |
| 101 | std::list<char*> time_conn; |
| 102 | std::list<int> status; |
| 103 | std::list<DWORD>::iterator ci; |
Oleg Sheikin | ff43bfd | 2005-12-07 08:02:52 +0000 | [diff] [blame] | 104 | std::list<char*>::iterator Ii; |
| 105 | std::list<char*>::iterator ti; |
Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 106 | std::list<int>::iterator si; |
Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 107 | }; |
Oleg Sheikin | ff43bfd | 2005-12-07 08:02:52 +0000 | [diff] [blame] | 108 | }; |
Oleg Sheikin | 641f7e5 | 2005-11-22 18:04:10 +0000 | [diff] [blame] | 109 | #endif |
| 110 | |