]> source.dussan.org Git - tigervnc.git/commitdiff
The code which realizes full functionality ListView Control
authorOleg Sheikin <olg@tightvnc.com>
Wed, 7 Dec 2005 08:02:52 +0000 (08:02 +0000)
committerOleg Sheikin <olg@tightvnc.com>
Wed, 7 Dec 2005 08:02:52 +0000 (08:02 +0000)
in Control Panel has been added.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@435 3789f03b-4d11-0410-bbf8-ca57d06f2519

rfb/ListConnInfo.h
rfb/VNCSConnectionST.cxx
rfb/VNCSConnectionST.h
rfb/VNCServerST.cxx
rfb/VNCServerST.h
rfb_win32/ListViewControl.cxx
rfb_win32/ListViewControl.h
winvnc/ControlPanel.cxx
winvnc/ControlPanel.h
winvnc/STrayIcon.cxx

index 4eacadd5adfe7fc852caaeb3274d2994c43a7204..029f2a49aec110a537b6416494026fb805629b88 100644 (file)
 namespace rfb {
 
   struct ListConnInfo  {
-    ListConnInfo() {
-      Clear();
-    };
+    ListConnInfo() {}
 
     void Clear() {
       conn.clear();
       IP_address.clear();
       time_conn.clear();
       status.clear();
-    };
-
-    bool Empty() {
-      return conn.empty();
     }
 
+    bool Empty() { return conn.empty();}
+
     void iBegin() {
       ci = conn.begin();
       Ii = IP_address.begin();
@@ -45,9 +41,7 @@ namespace rfb {
       si = status.begin();
     }
 
-    bool iEnd() {
-      return ci == conn.end();
-    }
+    bool iEnd() { return ci == conn.end();}
 
     void iNext() {
       ci++;
@@ -57,17 +51,15 @@ namespace rfb {
     }
 
     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);
+      conn.push_back(Conn);
+      IP_address.push_back(strDup(IP));
+      time_conn.push_back(strDup(Time));
+      status.push_back(Status);
     }
 
     void iGetCharInfo(char* buf[3]) {
-      if (Empty())
-        return;
-      buf[0] = (*Ii);
-      buf[1] = (*ti);
+      buf[0] = *Ii;
+      buf[1] = *ti;
       switch (*si) {
       case 0:
         buf[2] = strDup("Full control");
@@ -80,23 +72,37 @@ namespace rfb {
         break;
       default:
         buf[2] = strDup("Unknown");
-      };
+      }
     }
 
-    DWORD iGetConn() { return *ci;};
+    DWORD iGetConn() { return *ci;}
 
-    int iGetStatus() { return *si;};
+    int iGetStatus() { return *si;}
 
+    void Copy(ListConnInfo* InputList) {
+      Clear();
+      if (InputList->Empty()) return;
+      for (InputList->iBegin(); !InputList->iEnd(); InputList->iNext()) {
+        iAdd(InputList);
+      }
+    }
+
+    void iAdd (ListConnInfo* InputList) {
+      char* buf[3];
+      InputList->iGetCharInfo(buf);
+      addInfo(InputList->iGetConn(), buf[0], buf[1], InputList->iGetStatus());
+    }
+
+  private:
     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<char*>::iterator Ii;
+    std::list<char*>::iterator ti;
     std::list<int>::iterator si;
-
   };
-
-}
+};
 #endif
 
index 514ea10d52232706e74a0f42acbf402685fefad8..dce1a569a8f9fb6454d562349ef7423607e5820c 100644 (file)
@@ -667,3 +667,10 @@ void VNCSConnectionST::setSocketTimeouts()
   sock->inStream().setTimeout(timeoutms);
   sock->outStream().setTimeout(timeoutms);
 }
+
+char* VNCSConnectionST::getStartTime()
+{
+  char* result = ctime(&startTime);
+  result[24] = '\0';
+  return result; 
+}
index faf548894673eae88acf47995f1b3bf9facb057e..784ac291293a0e25bc37514ff18a69504e46c8c4 100644 (file)
@@ -103,7 +103,7 @@ namespace rfb {
 
     void approveConnectionOrClose(bool accept, const char* reason);
 
-    char* getStartTime() { return ctime(&startTime); }
+    char* getStartTime();
 
   private:
     // SConnection callbacks
index ae71a3771665efa7011e91e3580b3e57ed5ba8cd..c25543d0f4ac56fa2e8359cdb7c2ecc6a06758ce 100644 (file)
@@ -508,15 +508,14 @@ void VNCServerST::checkUpdate()
   comparer->clear();
 }
 
-bool VNCServerST::getConnInfo(ListConnInfo * listConn)
+void 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;
+    return;
+  int s=0;
+  std::list<VNCSConnectionST*>::iterator i;
+  for (i = clients.begin(); i != clients.end(); i++)
+    listConn->addInfo((DWORD)(*i), (*i)->getSock()->getPeerAddress(),
+                      (*i)->getStartTime(), s++);
 }
\ No newline at end of file
index b3e62a97aacbe030412d37b10dc24013f3c47a1f..596eaab932e91d48ffa3b860329d554d4d37d6e5 100644 (file)
@@ -189,7 +189,7 @@ namespace rfb {
     // are used, to save memory.
     void setEconomicTranslate(bool et) { useEconomicTranslate = et; }
 
-    bool getConnInfo(ListConnInfo * listConn);
+    void getConnInfo(ListConnInfo * listConn);
 
   protected:
 
index 492aa8b0de8199275f7138fcccf046dbe5a7ec39..12e04003aa770f83ca107f32b91c8585849ab3fd 100644 (file)
@@ -14,14 +14,14 @@ ListViewControl::ListViewControl()
 {
 }
 
-int ListViewControl::IsSelectedLVItem(DWORD idListView,
+bool ListViewControl::IsSelectedLVItem(DWORD idListView,
                                       HWND hDlg, int numberItem)
 {      
   return (ListView_GetItemState(GetDlgItem(hDlg, idListView),
     numberItem, LVIS_SELECTED) == LVIS_SELECTED);
 }
 
-void SelectLVItem(DWORD idListView, HWND hDlg, int numberItem)
+void ListViewControl::SelectLVItem(DWORD idListView, HWND hDlg, int numberItem)
 {
   ListView_SetItemState(GetDlgItem(hDlg, idListView),
     numberItem, LVIS_SELECTED, LVIS_SELECTED);
index aef916e0e3af0a5d536260b165ab3a7cdc39875b..8a16373853f449890c6ceb370cac394eec1151b2 100644 (file)
@@ -15,7 +15,7 @@ namespace rfb {
     {
     public:
       ListViewControl();
-      int IsSelectedLVItem(DWORD idListView, HWND hDlg, int numberItem);
+      bool IsSelectedLVItem(DWORD idListView, HWND hDlg, int numberItem);
       void SelectLVItem(DWORD idListView, HWND hDlg, int numberItem);
       BOOL InitLVColumns(DWORD idListView, HWND hDlg, int width, int columns,
         TCHAR * title[], DWORD mask, DWORD style, DWORD format);
index 134cc21138748e38d11051827fba6aca0575f3b3..fb379d6c27512c6ec9b380b723af9af0e3663378 100644 (file)
@@ -63,15 +63,24 @@ bool ControlPanel::onCommand(int cmd)
 
 void ControlPanel::UpdateListView(rfb::ListConnInfo* LCInfo)
 {
+  getSelConnInfo();
   DeleteAllLVItem(IDC_LIST_CONNECTIONS, handle);
-  if(LCInfo->Empty()) return;
+
+  if(LCInfo->Empty()) 
+    return;
+
+  ListConn.Copy(LCInfo);
 
   char* ItemString[3];
   int i = 0;
 
-  for (LCInfo->iBegin(); !LCInfo->iEnd(); LCInfo->iNext()) {
-    LCInfo->iGetCharInfo(ItemString);
+  for (ListConn.iBegin(); !ListConn.iEnd(); ListConn.iNext()) {
+    ListConn.iGetCharInfo(ItemString);
     InsertLVItem(IDC_LIST_CONNECTIONS, handle, i, ItemString, 3);
+    for (ListSelConn.iBegin(); !ListSelConn.iEnd(); ListSelConn.iNext()) {
+      if (ListSelConn.iGetConn() == ListConn.iGetConn())
+        SelectLVItem(IDC_LIST_CONNECTIONS, handle, i);
+    }
     i++;
   } 
 }
@@ -96,9 +105,16 @@ BOOL ControlPanel::dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
   return FALSE;
 }
 
-void ControlPanel::getSelConnInfo(std::list<DWORD>* conn, std::list<int>* status)
+void ControlPanel::getSelConnInfo()
 {
-  
+  int i = 0;
+  ListSelConn.Clear();
+  if(ListConn.Empty()) return;
+  for (ListConn.iBegin(); !ListConn.iEnd(); ListConn.iNext()) {
+    if (IsSelectedLVItem(IDC_LIST_CONNECTIONS, handle, i))
+      ListSelConn.iAdd(&ListConn);
+    i++;
+  }
 }
 
 ControlPanel::~ControlPanel()
index 51eb421335f3da6d4f17c31b6233511f63687abb..f291b9e6bed15d03cdb4dd2b35d86c2c4f7a8f5f 100644 (file)
@@ -31,9 +31,10 @@ namespace winvnc {
     ~ControlPanel();
   protected: 
     virtual BOOL dialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam);
-    void getSelConnInfo(std::list<DWORD>* conn, std::list<int>* status);
+    void getSelConnInfo();
     HWND m_hSTIcon;
-    std::list<DWORD> Conn;
+    rfb::ListConnInfo ListConn;
+    rfb::ListConnInfo ListSelConn;
   };
 };
 
index a883cabaa50c7425ee130b476f6645cefe8b052a..533c6a7150d6f987d3dd5379c7cd7d70340b8a21 100644 (file)
@@ -183,8 +183,8 @@ public:
       }
       setIcon(thread.server.isServerInUse() ? thread.activeIcon : thread.inactiveIcon);
 
-      thread.server.getClientsInfo(&LCInfo);
       CPanel->UpdateListView(&LCInfo);
+      thread.server.getClientsInfo(&LCInfo);
 
       return 0;