/* * Copyright 2000, 2003, 2004, 2005, 2008 Martin Fuchs * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library 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 * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */ #ifdef __WINE__ #include "config.h" #include "wine/port.h" /* for unix filesystem function calls */ #include #include #include #define heap_alloc(s) HeapAlloc(GetProcessHeap(),0,s) #define heap_free(p) HeapFree(GetProcessHeap(),0,p) #else /* __WINE__ */ #define heap_alloc(s) malloc(s) #define heap_free(p) free(p) #endif #define COBJMACROS #define WIN32_LEAN_AND_MEAN #define WIN32_EXTRA_LEAN #define NOSERVICE #define NOMCX #define NOIME #define NOCOMM #define NOKANJI #define NORPC #define NOPROXYSTUB #define NOIMAGE #define NOTAPE #define NONAMELESSUNION #include #include #include #include #ifdef UNICODE #define _UNICODE #endif #include #include #include #include #include #include /* for ShellExecute() */ #include /* for SHFormatDrive() */ #ifndef _NO_EXTENSIONS #define _SHELL_FOLDERS #endif /* _NO_EXTENSIONS */ #ifndef FILE_ATTRIBUTE_NOT_CONTENT_INDEXED #define FILE_ATTRIBUTE_ENCRYPTED 0x00000040 #define FILE_ATTRIBUTE_SPARSE_FILE 0x00000200 #define FILE_ATTRIBUTE_REPARSE_POINT 0x00000400 #define FILE_ATTRIBUTE_NOT_CONTENT_INDEXED 0x00002000 #endif #ifdef _DEBUG #define ASSERT(x) {if (!(x)) DebugBreak();} #else #define ASSERT(x) /* nothing */ #endif #define BUFFER_LEN 1024 enum IMAGE { IMG_NONE=-1, IMG_FILE=0, IMG_DOCUMENT, IMG_EXECUTABLE, IMG_FOLDER, IMG_OPEN_FOLDER, IMG_FOLDER_PLUS,IMG_OPEN_PLUS, IMG_OPEN_MINUS, IMG_FOLDER_UP, IMG_FOLDER_CUR }; #define IMAGE_WIDTH 16 #define IMAGE_HEIGHT 13 #define SPLIT_WIDTH 5 #define TREE_LINE_DX 3 #define IDW_STATUSBAR 0x100 #define IDW_TOOLBAR 0x101 #define IDW_DRIVEBAR 0x102 #define IDW_FIRST_CHILD 0xC000 /*0x200*/ #define IDW_TREE_LEFT 3 #define IDW_TREE_RIGHT 6 #define IDW_HEADER_LEFT 2 #define IDW_HEADER_RIGHT 5 #define WM_DISPATCH_COMMAND 0xBF80 #define COLOR_COMPRESSED RGB(0,0,255) #define COLOR_SELECTION RGB(0,0,128) #define COLOR_SELECTION_TXT RGB(255,255,255) #ifdef _NO_EXTENSIONS #define COLOR_SPLITBAR WHITE_BRUSH #else #define COLOR_SPLITBAR LTGRAY_BRUSH #endif #define FRM_CALC_CLIENT 0xBF83 #define Frame_CalcFrameClient(hwnd, prt) ((BOOL)SNDMSG(hwnd, FRM_CALC_CLIENT, 0, (LPARAM)(PRECT)prt)) typedef struct WINDOW_OPTIONS { int start_x; int start_y; int width; int height; }; typedef struct WINEFILE_GLOBALS { HANDLE hInstance; HACCEL haccel; ATOM hframeClass; HWND hMainWnd; HMENU hMenuFrame; HMENU hWindowsMenu; HMENU hLanguageMenu; HMENU hMenuView; HMENU hMenuOptions; HWND hmdiclient; HWND hstatusbar; HWND htoolbar; HWND hdrivebar; HFONT hfont; TCHAR num_sep; SIZE spaceSize; HIMAGELIST himl; TCHAR drives[BUFFER_LEN]; BOOL prescan_node; /*TODO*/ BOOL saveSettings; #ifdef _SHELL_FOLDERS IShellFolder* iDesktop; IMalloc* iMalloc; UINT cfStrFName; #endif }; extern struct WINEFILE_GLOBALS Globals; #ifdef __WINE__ #ifdef UNICODE extern void _wsplitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext); #define _tsplitpath _wsplitpath #define _stprintf msvcrt_swprintf #else extern void _splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ext); #define _tsplitpath _splitpath #define _stprintf sprintf //#error problems in format_bytes() because of incompatible sprintf() implementation in WINE #endif #else #include /* for _tsplitpath() */ #endif #ifdef _NO_EXTENSIONS #undef _LEFT_FILES #endif #ifndef _MAX_PATH #define _MAX_DRIVE 3 #define _MAX_FNAME 256 #define _MAX_DIR _MAX_FNAME #define _MAX_EXT _MAX_FNAME #define _MAX_PATH 260 #endif #ifdef NONAMELESSUNION #define UNION_MEMBER(x) DUMMYUNIONNAME.x #else #define UNION_MEMBER(x) x #endif #ifdef _MSC_VER #define inline __inline #endif /* resource string tools */ extern LPTSTR load_string(LPTSTR buffer, UINT id); #define RS(b, i) load_string(b, i) #ifdef _SHELL_FOLDERS #define DEFAULT_SPLIT_POS 300 #else #define DEFAULT_SPLIT_POS 200 #endif enum ENTRY_TYPE { ET_WINDOWS, ET_UNIX, #ifdef _SHELL_FOLDERS ET_SHELL #endif }; typedef struct _Entry { struct _Entry* next; struct _Entry* down; struct _Entry* up; BOOL expanded; BOOL scanned; int level; WIN32_FIND_DATA data; #ifndef _NO_EXTENSIONS BY_HANDLE_FILE_INFORMATION bhfi; BOOL bhfi_valid; enum ENTRY_TYPE etype; #endif #ifdef _SHELL_FOLDERS LPITEMIDLIST pidl; IShellFolder* folder; HICON hicon; #endif } Entry; typedef struct _Root { Entry entry; TCHAR path[MAX_PATH]; TCHAR volname[_MAX_FNAME]; TCHAR fs[_MAX_DIR]; DWORD drive_type; DWORD fs_flags; } Root; enum COLUMN_FLAGS { COL_SIZE = 0x01, COL_DATE = 0x02, COL_TIME = 0x04, COL_ATTRIBUTES = 0x08, COL_DOSNAMES = 0x10, #ifdef _NO_EXTENSIONS COL_ALL = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_DOSNAMES #else COL_INDEX = 0x20, COL_LINKS = 0x40, COL_ALL = COL_SIZE|COL_DATE|COL_TIME|COL_ATTRIBUTES|COL_DOSNAMES|COL_INDEX|COL_LINKS #endif }; enum SORT_ORDER { SORT_NAME, SORT_EXT, SORT_SIZE, SORT_DATE }; typedef struct _Pane { HWND hwnd; #ifndef _NO_EXTENSIONS HWND hwndHeader; #endif #ifndef _NO_EXTENSIONS #define COLUMNS 10 #else #define COLUMNS 5 #endif int widths[COLUMNS]; int positions[COLUMNS+1]; BOOL treePane; int visible_cols; Entry* root; Entry* cur; } Pane; typedef struct _ChildWnd { HWND hwnd; Pane left; Pane right; int focus_pane; /* 0: left 1: right */ WINDOWPLACEMENT pos; int split_pos; BOOL header_wdths_ok; TCHAR path[MAX_PATH]; TCHAR filter_pattern[MAX_PATH]; int filter_flags; Root root; enum SORT_ORDER sortOrder; } ChildWnd; /* flags to filter different file types */ enum TYPE_FILTER { TF_DIRECTORIES = 0x01, TF_PROGRAMS = 0x02, TF_DOCUMENTS = 0x04, TF_OTHERS = 0x08, TF_HIDDEN = 0x10, TF_ALL = 0x1F }; extern const TCHAR sEmpty[]; /* "" */ extern const TCHAR sSpace[]; /* " " */ extern const TCHAR sNumFmt[]; /* "%d" */ extern const TCHAR sQMarks[]; /* "???" */ extern const TCHAR sLongHexFmt[]; /* "%I64X" */ extern const TCHAR sLongNumFmt[]; /* "%I64d" */ /* entries.c */ extern Entry* alloc_entry(void); /*extern void free_entry(Entry* entry);*/ extern void free_entries(Entry* dir); extern Entry* read_tree(Root* root, LPCTSTR path, LPITEMIDLIST pidl, LPTSTR drv, enum SORT_ORDER sortOrder, HWND hwnd); extern void get_path(Entry* dir, PTSTR path); extern void format_date(const FILETIME* ft, TCHAR* buffer, int visible_cols); extern void read_directory(Entry* dir, LPCTSTR path, enum SORT_ORDER sortOrder, HWND hwnd); /* display error message for the specified WIN32 error code */ extern void display_error(HWND hwnd, DWORD error); /* display network error message using WNetGetLastError() */ extern void display_network_error(HWND hwnd); /* Windows file system namespace function declarations */ extern void read_directory_win(Entry* dir, LPCTSTR path); extern Entry* read_tree_win(Root* root, LPCTSTR path, enum SORT_ORDER sortOrder, HWND hwnd); /* Unix file system namespace function declarations */ #if !defined(_NO_EXTENSIONS) && defined(__WINE__) extern void read_directory_unix(Entry* dir, LPCTSTR path); extern Entry* read_tree_unix(Root* root, LPCTSTR path, enum SORT_ORDER sortOrder, HWND hwnd); #endif /* Shell file system namespace function declarations */ #ifdef _SHELL_FOLDERS extern void read_directory_shell(Entry* dir, HWND hwnd); extern Entry* read_tree_shell(Root* root, LPITEMIDLIST pidl, enum SORT_ORDER sortOrder, HWND hwnd); #ifdef UNICODE #define get_strret get_strretW #define path_from_pidl path_from_pidlW #else #define get_strret get_strretA #define path_from_pidl path_from_pidlA #endif extern LPITEMIDLIST get_path_pidl(LPCTSTR path, HWND hwnd); extern LPITEMIDLIST get_to_absolute_pidl(Entry* entry, HWND hwnd); extern HRESULT path_from_pidlA(IShellFolder* folder, LPITEMIDLIST pidl, LPSTR buffer, int len); extern HRESULT path_from_pidlW(IShellFolder* folder, LPITEMIDLIST pidl, LPWSTR buffer, int len); extern BOOL CtxMenu_HandleMenuMsg(UINT nmsg, WPARAM wparam, LPARAM lparam); extern HRESULT ShellFolderContextMenu(IShellFolder* shell_folder, HWND hwndParent, int cidl, LPCITEMIDLIST* apidl, int x, int y); extern IContextMenu3* s_pctxmenu3; #endif /* _SHELL_FOLDERS */ /* shelltools.c */ extern void save_registry_settings(void); extern void load_registry_settings(struct WINDOW_OPTIONS* pOpts); /* dialogs.c */ struct ExecuteDialog { TCHAR cmd[MAX_PATH]; int cmdshow; }; extern INT_PTR CALLBACK ExecuteDialogDlgProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam); struct FilterDialog { TCHAR pattern[MAX_PATH]; int flags; }; extern INT_PTR CALLBACK FilterDialogDlgProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam); extern void choose_font(HWND hwnd); extern void show_properties_dlg(Entry* entry, HWND hwnd); extern INT_PTR CALLBACK DestinationDlgProc(HWND hwnd, UINT nmsg, WPARAM wparam, LPARAM lparam); #include "resource.h"