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 2.8KB

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