aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--rfb/DirManager.h7
-rw-r--r--rfb_win32/FolderManager.cxx150
-rw-r--r--rfb_win32/FolderManager.h8
-rw-r--r--vncviewer/FTListView.cxx177
-rw-r--r--vncviewer/FTListView.h63
-rw-r--r--vncviewer/vncviewer.dsp8
6 files changed, 329 insertions, 84 deletions
diff --git a/rfb/DirManager.h b/rfb/DirManager.h
index 4d673429..a331c5e3 100644
--- a/rfb/DirManager.h
+++ b/rfb/DirManager.h
@@ -29,12 +29,9 @@
namespace rfb {
class DirManager {
public:
- DirManager();
- virtual ~DirManager();
-
virtual bool createDir(char *pFullPath);
- virtual bool renameDir(char *pOldName, char *pNewName);
- virtual bool deleteDir(char *pFullPath);
+ virtual bool renameIt(char *pOldName, char *pNewName);
+ virtual bool deleteIt(char *pFullPath);
virtual bool getDirInfo(char *pPath, FileInfo *pFileInfo, unsigned int dirOnly);
};
diff --git a/rfb_win32/FolderManager.cxx b/rfb_win32/FolderManager.cxx
index c261427d..5e079d75 100644
--- a/rfb_win32/FolderManager.cxx
+++ b/rfb_win32/FolderManager.cxx
@@ -100,7 +100,7 @@ FolderManager::getFolderInfoWithPrefix(char *pPrefix, FileInfo *pFileInfo)
strcpy(prefix, pPrefix);
FileInfo tmpFileInfo;
- if (!getFolderInfo(prefix, &tmpFileInfo, 0)) {
+ if (!getDirInfo(prefix, &tmpFileInfo, 0)) {
tmpFileInfo.free();
return false;
} else {
@@ -115,99 +115,99 @@ FolderManager::getFolderInfoWithPrefix(char *pPrefix, FileInfo *pFileInfo)
}
bool
-FolderManager::getFolderInfo(char *pPath, FileInfo *pFileInfo, unsigned int dirOnly)
+FolderManager::getDirInfo(char *pPath, FileInfo *pFileInfo, unsigned int dirOnly)
{
- if (strlen(pPath) == 0) return getDrivesInfo(pFileInfo);
-
- char path[FT_FILENAME_SIZE];
- sprintf(path, "%s\\*", pPath);
-
- WIN32_FIND_DATA FindFileData;
- SetErrorMode(SEM_FAILCRITICALERRORS);
- HANDLE handle = FindFirstFile(path, &FindFileData);
- DWORD lastError = GetLastError();
- SetErrorMode(0);
-
- if (handle != INVALID_HANDLE_VALUE) {
- do {
- if (strcmp(FindFileData.cFileName, ".") != 0 &&
- strcmp(FindFileData.cFileName, "..") != 0) {
- unsigned int lastWriteTime = getTime70(FindFileData.ftLastWriteTime);
- if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
- pFileInfo->add(FindFileData.cFileName, 0, lastWriteTime, FT_ATTR_DIR);
- } else {
- if (!dirOnly)
- pFileInfo->add(FindFileData.cFileName, FindFileData.nFileSizeLow, lastWriteTime, FT_ATTR_FILE);
- }
- }
-
- } while (FindNextFile(handle, &FindFileData));
- } else {
- return false;
- }
- FindClose(handle);
- return true;
+ if (strlen(pPath) == 0) return getDrivesInfo(pFileInfo);
+
+ char path[FT_FILENAME_SIZE];
+ sprintf(path, "%s\\*", pPath);
+
+ WIN32_FIND_DATA FindFileData;
+ SetErrorMode(SEM_FAILCRITICALERRORS);
+ HANDLE handle = FindFirstFile(path, &FindFileData);
+ DWORD lastError = GetLastError();
+ SetErrorMode(0);
+
+ if (handle != INVALID_HANDLE_VALUE) {
+ do {
+ if (strcmp(FindFileData.cFileName, ".") != 0 &&
+ strcmp(FindFileData.cFileName, "..") != 0) {
+ unsigned int lastWriteTime = getTime70(FindFileData.ftLastWriteTime);
+ if ((FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)) {
+ pFileInfo->add(FindFileData.cFileName, 0, lastWriteTime, FT_ATTR_DIR);
+ } else {
+ if (!dirOnly)
+ pFileInfo->add(FindFileData.cFileName, FindFileData.nFileSizeLow, lastWriteTime, FT_ATTR_FILE);
+ }
+ }
+
+ } while (FindNextFile(handle, &FindFileData));
+ } else {
+ return false;
+ }
+ FindClose(handle);
+ return true;
}
bool
FolderManager::getDrivesInfo(FileInfo *pFileInfo)
{
- TCHAR szDrivesList[256];
- if (GetLogicalDriveStrings(255, szDrivesList) == 0)
- return false;
-
- int i = 0;
- while (szDrivesList[i] != '\0') {
- char *drive = strdup(&szDrivesList[i]);
- char *backslash = strrchr(drive, '\\');
- if (backslash != NULL)
- *backslash = '\0';
- pFileInfo->add(drive, 0, 0, FT_ATTR_DIR);
- free(drive);
- i += strcspn(&szDrivesList[i], "\0") + 1;
- }
- return true;
+ TCHAR szDrivesList[256];
+ if (GetLogicalDriveStrings(255, szDrivesList) == 0)
+ return false;
+
+ int i = 0;
+ while (szDrivesList[i] != '\0') {
+ char *drive = strdup(&szDrivesList[i]);
+ char *backslash = strrchr(drive, '\\');
+ if (backslash != NULL)
+ *backslash = '\0';
+ pFileInfo->add(drive, 0, 0, FT_ATTR_DIR);
+ free(drive);
+ i += strcspn(&szDrivesList[i], "\0") + 1;
+ }
+ return true;
}
bool
FolderManager::getInfo(char *pFullPath, FILEINFO *pFIStruct)
{
- WIN32_FIND_DATA FindFileData;
- SetErrorMode(SEM_FAILCRITICALERRORS);
- HANDLE hFile = FindFirstFile(pFullPath, &FindFileData);
- DWORD lastError = GetLastError();
- SetErrorMode(0);
- if (hFile != INVALID_HANDLE_VALUE) {
- FindClose(hFile);
- strcpy(pFIStruct->name, FindFileData.cFileName);
- pFIStruct->info.data = getTime70(FindFileData.ftLastWriteTime);
- if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
- pFIStruct->info.size = 0;
- pFIStruct->info.flags = FT_ATTR_DIR;
- return true;
- } else {
- pFIStruct->info.size = FindFileData.nFileSizeLow;
- pFIStruct->info.flags = FT_ATTR_FILE;
- return true;
- }
- }
- return false;
+ WIN32_FIND_DATA FindFileData;
+ SetErrorMode(SEM_FAILCRITICALERRORS);
+ HANDLE hFile = FindFirstFile(pFullPath, &FindFileData);
+ DWORD lastError = GetLastError();
+ SetErrorMode(0);
+ if (hFile != INVALID_HANDLE_VALUE) {
+ FindClose(hFile);
+ strcpy(pFIStruct->name, FindFileData.cFileName);
+ pFIStruct->info.data = getTime70(FindFileData.ftLastWriteTime);
+ if (FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
+ pFIStruct->info.size = 0;
+ pFIStruct->info.flags = FT_ATTR_DIR;
+ return true;
+ } else {
+ pFIStruct->info.size = FindFileData.nFileSizeLow;
+ pFIStruct->info.flags = FT_ATTR_FILE;
+ return true;
+ }
+ }
+ return false;
}
unsigned int
FolderManager::getTime70(FILETIME ftime)
{
- LARGE_INTEGER uli;
- uli.LowPart = ftime.dwLowDateTime;
- uli.HighPart = ftime.dwHighDateTime;
- uli.QuadPart = (uli.QuadPart - 116444736000000000) / 10000000;
- return uli.LowPart;
+ LARGE_INTEGER uli;
+ uli.LowPart = ftime.dwLowDateTime;
+ uli.HighPart = ftime.dwHighDateTime;
+ uli.QuadPart = (uli.QuadPart - 116444736000000000) / 10000000;
+ return uli.LowPart;
}
void
FolderManager::getFiletime(unsigned int time70, FILETIME *pftime)
{
- LONGLONG ll = Int32x32To64(time70, 10000000) + 116444736000000000;
- pftime->dwLowDateTime = (DWORD) ll;
- pftime->dwHighDateTime = (DWORD) (ll >> 32);
+ LONGLONG ll = Int32x32To64(time70, 10000000) + 116444736000000000;
+ pftime->dwLowDateTime = (DWORD) ll;
+ pftime->dwHighDateTime = (DWORD) (ll >> 32);
}
diff --git a/rfb_win32/FolderManager.h b/rfb_win32/FolderManager.h
index 2ef26655..ea2a716d 100644
--- a/rfb_win32/FolderManager.h
+++ b/rfb_win32/FolderManager.h
@@ -43,14 +43,14 @@ namespace rfb {
bool getInfo(char *pFullPath, FILEINFO *pFIStruct);
- bool getFolderInfo(char *pPath, FileInfo *pFileInfo, unsigned int dirOnly);
+ bool getDirInfo(char *pPath, FileInfo *pFileInfo, unsigned int dirOnly);
bool getDrivesInfo(FileInfo *pFI);
- private:
- bool getFolderInfoWithPrefix(char *pPrefix, FileInfo *pFileInfo);
-
+
unsigned int getTime70(FILETIME ftime);
void getFiletime(unsigned int time70, FILETIME *pftime);
+ private:
+ bool getFolderInfoWithPrefix(char *pPrefix, FileInfo *pFileInfo);
};
}
}
diff --git a/vncviewer/FTListView.cxx b/vncviewer/FTListView.cxx
new file mode 100644
index 00000000..162d7c1c
--- /dev/null
+++ b/vncviewer/FTListView.cxx
@@ -0,0 +1,177 @@
+/* Copyright (C) 2005 TightVNC Team. 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.
+*
+* TightVNC distribution homepage on the Web: http://www.tightvnc.com/
+*
+*/
+
+// -=- FTListView.cxx
+
+#include <vncviewer/FTListView.h>
+
+using namespace rfb;
+using namespace rfb::win32;
+
+FTListView::FTListView(HWND hLV)
+{
+ m_hListView = hLV;
+ m_fileInfo.free();
+}
+
+FTListView::~FTListView()
+{
+ m_fileInfo.free();
+}
+
+
+bool
+FTListView::initialize()
+{
+ return false;
+}
+
+void
+FTListView::onGetDispInfo(NMLVDISPINFO *pDI)
+{
+ if (m_fileInfo.getFlagsAt(pDI->item.iItem) & FT_ATTR_DIR) {
+ pDI->item.iImage = 0;
+ } else {
+ pDI->item.iImage = 1;
+ }
+
+ switch (pDI->item.iSubItem)
+ {
+ case 0:
+ pDI->item.pszText = m_fileInfo.getNameAt(pDI->item.iItem);
+ break;
+ case 1:
+ {
+ unsigned int flags = m_fileInfo.getFlagsAt(pDI->item.iItem);
+ switch(flags & 0x000000FF)
+ {
+ case FT_ATTR_FILE:
+ {
+ char buf[32];
+ unsigned int size = m_fileInfo.getSizeAt(pDI->item.iItem);
+ sprintf(buf, "%u", size);
+ pDI->item.pszText = buf;
+ }
+ break;
+ case FT_ATTR_DIR:
+ pDI->item.pszText = "";
+ break;
+ default:
+ pDI->item.pszText = "Unspecified";
+ }
+ }
+ break;
+ case 2:
+ {
+ unsigned int data = m_fileInfo.getDataAt(pDI->item.iItem);
+ if (data == 0) {
+ pDI->item.pszText = "Unspecified";
+ } else {
+ FILETIME ft;
+ FolderManager fm;
+ fm.getFiletime(data, &ft);
+
+ SYSTEMTIME st;
+ FileTimeToSystemTime(&ft, &st);
+
+ char pDateTimeStr[1024];
+ char timeFmt[128];
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, timeFmt, 128);
+ char dateFmt[128];
+ GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_SSHORTDATE, dateFmt, 128);
+
+ char timeStr[128];
+ GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &st, timeFmt, timeStr, 128);
+ char dateStr[128];
+ GetDateFormat(LOCALE_USER_DEFAULT, 0, &st, dateFmt, dateStr, 128);
+
+ sprintf(pDateTimeStr, "%s %s", dateStr, timeStr);
+ pDI->item.pszText = pDateTimeStr;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+void
+FTListView::addItems(FileInfo *pFI)
+{
+ m_fileInfo.add(pFI);
+ LVITEM LVItem;
+ LVItem.mask = LVIF_TEXT | LVIF_STATE | LVIF_IMAGE;
+ LVItem.state = 0;
+ LVItem.stateMask = 0;
+ for (unsigned int i = 0; i < m_fileInfo.getNumEntries(); i++) {
+ LVItem.iItem = i;
+ LVItem.iSubItem = 0;
+ LVItem.iImage = I_IMAGECALLBACK;
+ LVItem.pszText = LPSTR_TEXTCALLBACK;
+ ListView_InsertItem(m_hListView, &LVItem);
+ }
+}
+
+void
+FTListView::deleteAllItems()
+{
+ ListView_DeleteAllItems(m_hListView);
+ m_fileInfo.free();
+}
+
+char *
+FTListView::getActivateItemName(LPNMITEMACTIVATE lpnmia)
+{
+ return m_fileInfo.getNameAt(lpnmia->iItem);
+}
+
+int
+FTListView::getSelectedItems(FileInfo *pFI)
+{
+ int selCount = ListView_GetSelectedCount(m_hListView);
+ int selItem = ListView_GetSelectionMark(m_hListView);
+ if ((selCount < 1) || (selItem < 0)) return -1;
+
+ selItem = -1;
+ selItem = ListView_GetNextItem(m_hListView, selItem, LVNI_SELECTED);
+ do {
+ pFI->add(m_fileInfo.getFullDataAt(selItem));
+ selItem = ListView_GetNextItem(m_hListView, selItem, LVNI_SELECTED);
+ } while (selItem >= 0);
+
+ return selCount;
+}
+
+void
+FTListView::initImageList(HINSTANCE hInst)
+{
+ m_hImageList = ImageList_Create(16, 16, ILC_MASK, 2, 2);
+
+ HICON hiconItem = LoadIcon(hInst, MAKEINTRESOURCE(IDI_FTDIR));
+ ImageList_AddIcon(m_hImageList, hiconItem);
+ DestroyIcon(hiconItem);
+
+ hiconItem = LoadIcon(hInst, MAKEINTRESOURCE(IDI_FTFILE));
+ ImageList_AddIcon(m_hImageList, hiconItem);
+ DestroyIcon(hiconItem);
+
+ ListView_SetImageList(m_hListView, m_hImageList, LVSIL_SMALL);
+}
diff --git a/vncviewer/FTListView.h b/vncviewer/FTListView.h
new file mode 100644
index 00000000..ec140153
--- /dev/null
+++ b/vncviewer/FTListView.h
@@ -0,0 +1,63 @@
+/* Copyright (C) 2005 TightVNC Team. 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.
+ *
+ * TightVNC distribution homepage on the Web: http://www.tightvnc.com/
+ *
+ */
+
+// -=- FTListView.h
+
+#ifndef __RFB_WIN32_FTLISTVIEW_H__
+#define __RFB_WIN32_FTLISTVIEW_H__
+
+#include <windows.h>
+
+#include <rfb/FileInfo.h>
+#include <rfb_win32/FolderManager.h>
+#include <rfb_win32/ListViewControl.h>
+#include <vncviewer/resource.h>
+
+namespace rfb {
+ namespace win32{
+ class FTListView : private ListViewControl
+ {
+ public:
+ FTListView(HWND hLV);
+ ~FTListView();
+
+ bool initialize();
+
+ void onGetDispInfo(NMLVDISPINFO *di);
+ void addItems(FileInfo *pFI);
+ void deleteAllItems();
+ void initImageList(HINSTANCE hInst);
+
+ char *getActivateItemName(LPNMITEMACTIVATE lpnmia);
+ int getSelectedItems(FileInfo *pFI);
+
+ HWND getWndHandle() { return m_hListView; };
+
+ private:
+ HWND m_hListView;
+ FileInfo m_fileInfo;
+ HIMAGELIST m_hImageList;
+
+ };
+ }
+}
+
+#endif // __RFB_WIN32_FTLISTVIEW_H__
diff --git a/vncviewer/vncviewer.dsp b/vncviewer/vncviewer.dsp
index 63157732..a918698a 100644
--- a/vncviewer/vncviewer.dsp
+++ b/vncviewer/vncviewer.dsp
@@ -150,6 +150,10 @@ SOURCE=.\CViewOptions.cxx
# End Source File
# Begin Source File
+SOURCE=.\FTListView.cxx
+# End Source File
+# Begin Source File
+
SOURCE=.\InfoDialog.cxx
# End Source File
# Begin Source File
@@ -194,6 +198,10 @@ SOURCE=.\CViewOptions.h
# End Source File
# Begin Source File
+SOURCE=.\FTListView.h
+# End Source File
+# Begin Source File
+
SOURCE=.\InfoDialog.h
# End Source File
# Begin Source File