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();
si = status.begin();
}
- bool iEnd() {
- return ci == conn.end();
- }
+ bool iEnd() { return ci == conn.end();}
void iNext() {
ci++;
}
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");
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
sock->inStream().setTimeout(timeoutms);
sock->outStream().setTimeout(timeoutms);
}
+
+char* VNCSConnectionST::getStartTime()
+{
+ char* result = ctime(&startTime);
+ result[24] = '\0';
+ return result;
+}
void approveConnectionOrClose(bool accept, const char* reason);
- char* getStartTime() { return ctime(&startTime); }
+ char* getStartTime();
private:
// SConnection callbacks
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
// are used, to save memory.
void setEconomicTranslate(bool et) { useEconomicTranslate = et; }
- bool getConnInfo(ListConnInfo * listConn);
+ void getConnInfo(ListConnInfo * listConn);
protected:
{
}
-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);
{
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);
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++;
}
}
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()
~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;
};
};
}
setIcon(thread.server.isServerInUse() ? thread.activeIcon : thread.inactiveIcon);
- thread.server.getClientsInfo(&LCInfo);
CPanel->UpdateListView(&LCInfo);
+ thread.server.getClientsInfo(&LCInfo);
return 0;