You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ListConnInfo.h 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. #ifndef __RFB_LISTCONNINFO_INCLUDED__
  19. #define __RFB_LISTCONNINFO_INCLUDED__
  20. namespace rfb {
  21. struct ListConnInfo {
  22. ListConnInfo() : disableClients(false) {}
  23. void Clear() {
  24. conn.clear();
  25. IP_address.clear();
  26. time_conn.clear();
  27. status.clear();
  28. }
  29. bool Empty() { return conn.empty();}
  30. void iBegin() {
  31. ci = conn.begin();
  32. Ii = IP_address.begin();
  33. ti = time_conn.begin();
  34. si = status.begin();
  35. }
  36. bool iEnd() { return ci == conn.end();}
  37. void iNext() {
  38. ci++;
  39. Ii++;
  40. ti++;
  41. si++;
  42. }
  43. void addInfo(DWORD Conn, char* IP, char* Time, int Status) {
  44. conn.push_back(Conn);
  45. IP_address.push_back(strDup(IP));
  46. time_conn.push_back(strDup(Time));
  47. status.push_back(Status);
  48. }
  49. void iGetCharInfo(char* buf[3]) {
  50. buf[0] = *Ii;
  51. buf[1] = *ti;
  52. switch (*si) {
  53. case 0:
  54. buf[2] = strDup("Full control");
  55. break;
  56. case 1:
  57. buf[2] = strDup("View only");
  58. break;
  59. case 2:
  60. buf[2] = strDup("Stop updating");
  61. break;
  62. default:
  63. buf[2] = strDup("Unknown");
  64. }
  65. }
  66. DWORD iGetConn() { return *ci;}
  67. int iGetStatus() { return *si;}
  68. void iSetStatus( int status) { *si = status;}
  69. void Copy(ListConnInfo* InputList) {
  70. Clear();
  71. if (InputList->Empty()) return;
  72. for (InputList->iBegin(); !InputList->iEnd(); InputList->iNext()) {
  73. iAdd(InputList);
  74. }
  75. setDisable(InputList->getDisable());
  76. }
  77. void iAdd (ListConnInfo* InputList) {
  78. char* buf[3];
  79. InputList->iGetCharInfo(buf);
  80. addInfo(InputList->iGetConn(), buf[0], buf[1], InputList->iGetStatus());
  81. }
  82. void setDisable(bool disable) {disableClients = disable;}
  83. bool getDisable() {return disableClients;}
  84. void setAllStatus(int stat) {
  85. std::list<int>::iterator st;
  86. for (st = status.begin(); st != status.end(); st++)
  87. *st = stat;
  88. }
  89. private:
  90. std::list<DWORD> conn;
  91. std::list<char*> IP_address;
  92. std::list<char*> time_conn;
  93. std::list<int> status;
  94. std::list<DWORD>::iterator ci;
  95. std::list<char*>::iterator Ii;
  96. std::list<char*>::iterator ti;
  97. std::list<int>::iterator si;
  98. bool disableClients;
  99. };
  100. };
  101. #endif