]> source.dussan.org Git - tigervnc.git/commitdiff
The description of structure ListConnInfo has been added in library rfb.
authorOleg Sheikin <olg@tightvnc.com>
Tue, 22 Nov 2005 18:04:10 +0000 (18:04 +0000)
committerOleg Sheikin <olg@tightvnc.com>
Tue, 22 Nov 2005 18:04:10 +0000 (18:04 +0000)
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

rfb/ListConnInfo.h [new file with mode: 0644]
rfb/VNCSConnectionST.cxx
rfb/VNCSConnectionST.h
rfb/VNCServerST.cxx
rfb/VNCServerST.h
rfb/rfb.dsp
winvnc/ControlPanel.cxx
winvnc/ControlPanel.h
winvnc/STrayIcon.cxx
winvnc/VNCServerWin32.cxx
winvnc/VNCServerWin32.h

diff --git a/rfb/ListConnInfo.h b/rfb/ListConnInfo.h
new file mode 100644 (file)
index 0000000..4eacadd
--- /dev/null
@@ -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
+
index ce48b3ecca39378bbc6ec33fd2472fd5693910d9..514ea10d52232706e74a0f42acbf402685fefad8 100644 (file)
@@ -56,6 +56,7 @@ VNCSConnectionST::VNCSConnectionST(VNCServerST* server_, network::Socket *s,
   }
 
   server->clients.push_front(this);
+  startTime = time(0);
 }
 
 
index ba480e5914ef041c06b830a7e9f2d060457a8c8b..faf548894673eae88acf47995f1b3bf9facb057e 100644 (file)
@@ -103,6 +103,8 @@ namespace rfb {
 
     void approveConnectionOrClose(bool accept, const char* reason);
 
+    char* getStartTime() { return ctime(&startTime); }
+
   private:
     // SConnection callbacks
 
@@ -163,6 +165,7 @@ namespace rfb {
     AccessRights accessRights;
 
     CharArray closeReason;
+    time_t startTime;
   };
 }
 #endif
index c4e028390b574ade9e4fb65e3271b39a10dca284..ae71a3771665efa7011e91e3580b3e57ed5ba8cd 100644 (file)
@@ -507,3 +507,16 @@ void VNCServerST::checkUpdate()
 
   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
index a6939c832f11eb509d4824acf646250953bbee59..b3e62a97aacbe030412d37b10dc24013f3c47a1f 100644 (file)
@@ -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 @@ namespace rfb {
     // are used, to save memory.
     void setEconomicTranslate(bool et) { useEconomicTranslate = et; }
 
+    bool getConnInfo(ListConnInfo * listConn);
+
   protected:
 
     friend class VNCSConnectionST;
index 281dd575bee68e39928d43d84847b584a850dc07..0662b427d51097d77e54b2b29cc9de4fe2d42cd3 100644 (file)
@@ -488,6 +488,10 @@ SOURCE=.\keysymdef.h
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=.\ListConnInfo.h\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=.\Logger.h\r
 # End Source File\r
 # Begin Source File\r
index 60624ce699701f479ffda40caf6fc2ae97a5ef43..134cc21138748e38d11051827fba6aca0575f3b3 100644 (file)
@@ -44,7 +44,11 @@ bool ControlPanel::onCommand(int cmd)
     }
   case IDC_KILL_ALL:
     {
-      m_server->disconnectClients();
+      COPYDATASTRUCT copyData;
+      copyData.dwData = 2;
+      copyData.lpData = 0;
+      copyData.cbData = 0;
+      SendMessage(m_hSTIcon, WM_COPYDATA, 0, (LPARAM)&copyData);
       return false;
     }
   case IDC_DISABLE_CLIENTS:
@@ -57,9 +61,19 @@ bool ControlPanel::onCommand(int cmd)
   
 }
 
-void ControlPanel::UpdateListView()
+void ControlPanel::UpdateListView(rfb::ListConnInfo* LCInfo)
 {
-  
+  DeleteAllLVItem(IDC_LIST_CONNECTIONS, handle);
+  if(LCInfo->Empty()) return;
+
+  char* ItemString[3];
+  int i = 0;
+
+  for (LCInfo->iBegin(); !LCInfo->iEnd(); LCInfo->iNext()) {
+    LCInfo->iGetCharInfo(ItemString);
+    InsertLVItem(IDC_LIST_CONNECTIONS, handle, i, ItemString, 3);
+    i++;
+  } 
 }
 
 BOOL ControlPanel::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
@@ -82,7 +96,7 @@ BOOL ControlPanel::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
   return FALSE;
 }
 
-void ControlPanel::getSelectedConn(std::list<network::Socket*>* selsockets)
+void ControlPanel::getSelConnInfo(std::list<DWORD>* conn, std::list<int>* status)
 {
   
 }
index 5f9bc2407eee03126402a16a71298d89b5dd28a9..51eb421335f3da6d4f17c31b6233511f63687abb 100644 (file)
 
 
 #include <list>
-
-#include <winvnc/VNCServerWin32.h>
 #include <winvnc/resource.h>
 #include <rfb_win32/Dialog.h>
 #include <rfb_win32/ListViewControl.h>
 #include <rfb_win32/Win32Util.h>
+#include <rfb/ListConnInfo.h>
 
 namespace winvnc {
   
   class ControlPanel : rfb::win32::Dialog, rfb::win32::ListViewControl {
   public:
-    ControlPanel(VNCServerWin32 * server, HWND hSTIcon) : Dialog(GetModuleHandle(0)), ListViewControl(){
-      m_server = server;
+    ControlPanel(HWND hSTIcon) : Dialog(GetModuleHandle(0)), ListViewControl(){
       m_hSTIcon = hSTIcon;
     };
     virtual bool showDialog();
     virtual void initDialog();
     virtual bool onCommand(int cmd);
-    void UpdateListView();
+    void UpdateListView(rfb::ListConnInfo* LCInfo);
     HWND GetHandle() {return handle;};
     ~ControlPanel();
   protected: 
     virtual BOOL dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-    void getSelectedConn(std::list<network::Socket*>* selsockets);
-    VNCServerWin32 * m_server;
-    std::list<network::Socket*> sockets;
+    void getSelConnInfo(std::list<DWORD>* conn, std::list<int>* status);
     HWND m_hSTIcon;
+    std::list<DWORD> Conn;
   };
 };
 
index 448f08fbf056e98a0590e17a57cbdca65a0ddbbc..a883cabaa50c7425ee130b476f6645cefe8b052a 100644 (file)
@@ -71,7 +71,7 @@ public:
     SetTimer(getHandle(), 1, 3000, 0);
     PostMessage(getHandle(), WM_TIMER, 1, 0);
     PostMessage(getHandle(), WM_SET_TOOLTIP, 0, 0);
-    CPanel = new ControlPanel(&thread.server, getHandle());
+    CPanel = new ControlPanel(getHandle());
   }
 
   virtual LRESULT processMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
@@ -182,6 +182,10 @@ public:
         return 0;
       }
       setIcon(thread.server.isServerInUse() ? thread.activeIcon : thread.inactiveIcon);
+
+      thread.server.getClientsInfo(&LCInfo);
+      CPanel->UpdateListView(&LCInfo);
+
       return 0;
 
     case WM_SET_TOOLTIP:
@@ -202,6 +206,7 @@ protected:
   LaunchProcess vncConnect;
   STrayIconThread& thread;
   ControlPanel * CPanel;
+  rfb::ListConnInfo LCInfo;
 };
 
 
index a24df12088fad9ec7425e70f76328cefcc00e7f9..7e562708162be77281cef82b870c744b690a0d94 100644 (file)
@@ -270,6 +270,9 @@ bool VNCServerWin32::addNewClient(const char* client) {
   return false;
 }
 
+bool VNCServerWin32::getClientsInfo(rfb::ListConnInfo* LCInfo) {
+  return queueCommand(GetClientsInfo, LCInfo, 0);
+}
 
 VNCServerST::queryResult VNCServerWin32::queryConnection(network::Socket* sock,
                                             const char* userName,
@@ -330,6 +333,9 @@ void VNCServerWin32::doCommand() {
                                 "Connection rejected by user");
     queryConnectDialog = 0;
     break;
+  case GetClientsInfo:
+    vncServer.getConnInfo((ListConnInfo*)commandData); 
+    break;
 
   default:
     vlog.error("unknown command %d queued", command);
index c824d5422e3ab1c232ccc6747d2f7ea06100a852..f6c67235bb335ac2d545574c0d94b9c7bd339208 100644 (file)
@@ -28,6 +28,7 @@
 #include <rfb_win32/TCharArray.h>
 #include <winvnc/QueryConnectDialog.h>
 #include <winvnc/JavaViewer.h>
+//#include <rfb/ListConnInfo.h>
 
 namespace winvnc {
 
@@ -66,13 +67,15 @@ namespace winvnc {
                                                           const char* userName,
                                                           char** reason);
 
+    bool getClientsInfo(rfb::ListConnInfo* LCInfo);
+
     // Where to read the configuration settings from
     static const TCHAR* RegConfigPath;
 
   protected:
 
     // Perform a particular internal function in the server thread
-    typedef enum {NoCommand, DisconnectClients, AddClient, QueryConnectionComplete} Command;
+    typedef enum {NoCommand, DisconnectClients, AddClient, QueryConnectionComplete, GetClientsInfo} Command;
     bool queueCommand(Command cmd, const void* data, int len);
     void doCommand();
     Command command;