The description of structure ListConnInfo has been added in library rfb.
Also, codes which pass the information on connections for
Control Panel have been added.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@410 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/rfb/ListConnInfo.h b/rfb/ListConnInfo.h
new file mode 100644
index 0000000..4eacadd
--- /dev/null
+++ b/rfb/ListConnInfo.h
@@ -0,0 +1,102 @@
+/* Copyright (C) 2002-2003 RealVNC Ltd. All Rights Reserved.
+ *
+ * This is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+
+#ifndef __RFB_LISTCONNINFO_INCLUDED__
+#define __RFB_LISTCONNINFO_INCLUDED__
+
+namespace rfb {
+
+ struct ListConnInfo {
+ ListConnInfo() {
+ Clear();
+ };
+
+ void Clear() {
+ conn.clear();
+ IP_address.clear();
+ time_conn.clear();
+ status.clear();
+ };
+
+ bool Empty() {
+ return conn.empty();
+ }
+
+ void iBegin() {
+ ci = conn.begin();
+ Ii = IP_address.begin();
+ ti = time_conn.begin();
+ si = status.begin();
+ }
+
+ bool iEnd() {
+ return ci == conn.end();
+ }
+
+ void iNext() {
+ ci++;
+ Ii++;
+ ti++;
+ si++;
+ }
+
+ void addInfo(DWORD Conn, char* IP, char* Time, int Status) {
+ conn.push_front(Conn);
+ IP_address.push_front(IP);
+ time_conn.push_front(Time);
+ status.push_front(Status);
+ }
+
+ void iGetCharInfo(char* buf[3]) {
+ if (Empty())
+ return;
+ buf[0] = (*Ii);
+ buf[1] = (*ti);
+ switch (*si) {
+ case 0:
+ buf[2] = strDup("Full control");
+ break;
+ case 1:
+ buf[2] = strDup("View only");
+ break;
+ case 2:
+ buf[2] = strDup("Stop updating");
+ break;
+ default:
+ buf[2] = strDup("Unknown");
+ };
+ }
+
+ DWORD iGetConn() { return *ci;};
+
+ int iGetStatus() { return *si;};
+
+ std::list<DWORD> conn;
+ std::list<char*> IP_address;
+ std::list<char*> time_conn;
+ std::list<int> status;
+ std::list<DWORD>::iterator ci;
+ std::list<char*>::iterator Ii, ti;
+ std::list<int>::iterator si;
+
+ };
+
+}
+#endif
+
diff --git a/rfb/VNCSConnectionST.cxx b/rfb/VNCSConnectionST.cxx
index ce48b3e..514ea10 100644
--- a/rfb/VNCSConnectionST.cxx
+++ b/rfb/VNCSConnectionST.cxx
@@ -56,6 +56,7 @@
}
server->clients.push_front(this);
+ startTime = time(0);
}
diff --git a/rfb/VNCSConnectionST.h b/rfb/VNCSConnectionST.h
index ba480e5..faf5488 100644
--- a/rfb/VNCSConnectionST.h
+++ b/rfb/VNCSConnectionST.h
@@ -103,6 +103,8 @@
void approveConnectionOrClose(bool accept, const char* reason);
+ char* getStartTime() { return ctime(&startTime); }
+
private:
// SConnection callbacks
@@ -163,6 +165,7 @@
AccessRights accessRights;
CharArray closeReason;
+ time_t startTime;
};
}
#endif
diff --git a/rfb/VNCServerST.cxx b/rfb/VNCServerST.cxx
index c4e0283..ae71a37 100644
--- a/rfb/VNCServerST.cxx
+++ b/rfb/VNCServerST.cxx
@@ -507,3 +507,16 @@
comparer->clear();
}
+
+bool VNCServerST::getConnInfo(ListConnInfo * listConn)
+{
+ listConn->Clear();
+ if (clients.empty())
+ return false;
+ std::list<VNCSConnectionST*>::iterator ci;
+ for (ci = clients.begin(); ci != clients.end(); ci++) {
+ listConn->addInfo((DWORD)(*ci), (*ci)->getSock()->getPeerAddress(),
+ (*ci)->getStartTime(), 4);
+ }
+ return true;
+}
\ No newline at end of file
diff --git a/rfb/VNCServerST.h b/rfb/VNCServerST.h
index a6939c8..b3e62a9 100644
--- a/rfb/VNCServerST.h
+++ b/rfb/VNCServerST.h
@@ -31,7 +31,9 @@
#include <rfb/LogWriter.h>
#include <rfb/Blacklist.h>
#include <rfb/Cursor.h>
+#include <rfb/ListConnInfo.h>
#include <network/Socket.h>
+#include <rfb/ListConnInfo.h>
namespace rfb {
@@ -187,6 +189,8 @@
// are used, to save memory.
void setEconomicTranslate(bool et) { useEconomicTranslate = et; }
+ bool getConnInfo(ListConnInfo * listConn);
+
protected:
friend class VNCSConnectionST;
diff --git a/rfb/rfb.dsp b/rfb/rfb.dsp
index 281dd57..0662b42 100644
--- a/rfb/rfb.dsp
+++ b/rfb/rfb.dsp
@@ -488,6 +488,10 @@
# End Source File
# Begin Source File
+SOURCE=.\ListConnInfo.h
+# End Source File
+# Begin Source File
+
SOURCE=.\Logger.h
# End Source File
# Begin Source File