From: <arn...@us...> - 2007-02-27 09:39:08
|
Revision: 701 http://svn.sourceforge.net/dcplusplus/?rev=701&view=rev Author: arnetheduck Date: 2007-02-27 01:39:02 -0800 (Tue, 27 Feb 2007) Log Message: ----------- beginnings of smartwin port Modified Paths: -------------- dcplusplus/trunk/Doxyfile dcplusplus/trunk/License.txt dcplusplus/trunk/client/ClientManager.h dcplusplus/trunk/client/CryptoManager.cpp dcplusplus/trunk/client/DCPlusPlus.h dcplusplus/trunk/client/File.cpp dcplusplus/trunk/client/HashManager.cpp dcplusplus/trunk/client/Thread.h dcplusplus/trunk/client/Util.cpp dcplusplus/trunk/client/stdinc.cpp dcplusplus/trunk/client/stdinc.h dcplusplus/trunk/yassl/src/crypto_wrapper.cpp dcplusplus/trunk/yassl/src/handshake.cpp dcplusplus/trunk/yassl/src/ssl.cpp dcplusplus/trunk/yassl/src/yassl_imp.cpp dcplusplus/trunk/yassl/taocrypt/src/asn.cpp Added Paths: ----------- dcplusplus/trunk/SConstruct dcplusplus/trunk/build_util.py dcplusplus/trunk/bzip2/SConscript dcplusplus/trunk/client/SConscript dcplusplus/trunk/gch.py dcplusplus/trunk/smartwin/ dcplusplus/trunk/stlport/ dcplusplus/trunk/win32/ dcplusplus/trunk/win32/ADLSProperties.cpp dcplusplus/trunk/win32/ADLSProperties.h dcplusplus/trunk/win32/ADLSearchFrame.cpp dcplusplus/trunk/win32/ADLSearchFrame.h dcplusplus/trunk/win32/AboutDlg.h dcplusplus/trunk/win32/Advanced3Page.cpp dcplusplus/trunk/win32/Advanced3Page.h dcplusplus/trunk/win32/AdvancedPage.cpp dcplusplus/trunk/win32/AdvancedPage.h dcplusplus/trunk/win32/Appearance2Page.cpp dcplusplus/trunk/win32/Appearance2Page.h dcplusplus/trunk/win32/AppearancePage.cpp dcplusplus/trunk/win32/AppearancePage.h dcplusplus/trunk/win32/CertificatesPage.cpp dcplusplus/trunk/win32/CertificatesPage.h dcplusplus/trunk/win32/CommandDlg.cpp dcplusplus/trunk/win32/CommandDlg.h dcplusplus/trunk/win32/DirectoryListingFrm.cpp dcplusplus/trunk/win32/DirectoryListingFrm.h dcplusplus/trunk/win32/DownloadPage.cpp dcplusplus/trunk/win32/DownloadPage.h dcplusplus/trunk/win32/ExListViewCtrl.cpp dcplusplus/trunk/win32/ExListViewCtrl.h dcplusplus/trunk/win32/ExtendedTrace.cpp dcplusplus/trunk/win32/ExtendedTrace.h dcplusplus/trunk/win32/FavHubProperties.cpp dcplusplus/trunk/win32/FavHubProperties.h dcplusplus/trunk/win32/FavoriteDirsPage.cpp dcplusplus/trunk/win32/FavoriteDirsPage.h dcplusplus/trunk/win32/FavoritesFrm.cpp dcplusplus/trunk/win32/FavoritesFrm.h dcplusplus/trunk/win32/FinishedFrame.cpp dcplusplus/trunk/win32/FinishedFrame.h dcplusplus/trunk/win32/FinishedFrameBase.h dcplusplus/trunk/win32/FinishedULFrame.cpp dcplusplus/trunk/win32/FinishedULFrame.h dcplusplus/trunk/win32/FlatTabCtrl.h dcplusplus/trunk/win32/GeneralPage.cpp dcplusplus/trunk/win32/GeneralPage.h dcplusplus/trunk/win32/HashProgressDlg.h dcplusplus/trunk/win32/HubFrame.cpp dcplusplus/trunk/win32/HubFrame.h dcplusplus/trunk/win32/LineDlg.h dcplusplus/trunk/win32/ListViewArrows.h dcplusplus/trunk/win32/LogPage.cpp dcplusplus/trunk/win32/LogPage.h dcplusplus/trunk/win32/MagnetDlg.h dcplusplus/trunk/win32/MainFrm.cpp dcplusplus/trunk/win32/MainFrm.h dcplusplus/trunk/win32/MemDC.h dcplusplus/trunk/win32/NetworkPage.cpp dcplusplus/trunk/win32/NetworkPage.h dcplusplus/trunk/win32/NotepadFrame.cpp dcplusplus/trunk/win32/NotepadFrame.h dcplusplus/trunk/win32/PrivateFrame.cpp dcplusplus/trunk/win32/PrivateFrame.h dcplusplus/trunk/win32/PropPage.cpp dcplusplus/trunk/win32/PropPage.h dcplusplus/trunk/win32/PropertiesDlg.cpp dcplusplus/trunk/win32/PropertiesDlg.h dcplusplus/trunk/win32/PublicHubsFrm.cpp dcplusplus/trunk/win32/PublicHubsFrm.h dcplusplus/trunk/win32/PublicHubsListDlg.h dcplusplus/trunk/win32/QueueFrame.cpp dcplusplus/trunk/win32/QueueFrame.h dcplusplus/trunk/win32/QueuePage.cpp dcplusplus/trunk/win32/QueuePage.h dcplusplus/trunk/win32/SConscript dcplusplus/trunk/win32/SearchFrm.cpp dcplusplus/trunk/win32/SearchFrm.h dcplusplus/trunk/win32/ShellContextMenu.cpp dcplusplus/trunk/win32/ShellContextMenu.h dcplusplus/trunk/win32/SingleInstance.h dcplusplus/trunk/win32/SpyFrame.cpp dcplusplus/trunk/win32/SpyFrame.h dcplusplus/trunk/win32/StatsFrame.cpp dcplusplus/trunk/win32/StatsFrame.h dcplusplus/trunk/win32/SystemFrame.cpp dcplusplus/trunk/win32/SystemFrame.h dcplusplus/trunk/win32/TabsPage.cpp dcplusplus/trunk/win32/TabsPage.h dcplusplus/trunk/win32/TextFrame.cpp dcplusplus/trunk/win32/TextFrame.h dcplusplus/trunk/win32/TransferView.cpp dcplusplus/trunk/win32/TransferView.h dcplusplus/trunk/win32/TreePropertySheet.cpp dcplusplus/trunk/win32/TreePropertySheet.h dcplusplus/trunk/win32/TypedListViewCtrl.h dcplusplus/trunk/win32/UCHandler.h dcplusplus/trunk/win32/UCPage.cpp dcplusplus/trunk/win32/UCPage.h dcplusplus/trunk/win32/UPnP.cpp dcplusplus/trunk/win32/UPnP.h dcplusplus/trunk/win32/UploadPage.cpp dcplusplus/trunk/win32/UploadPage.h dcplusplus/trunk/win32/UsersFrame.cpp dcplusplus/trunk/win32/UsersFrame.h dcplusplus/trunk/win32/WaitingUsersFrame.cpp dcplusplus/trunk/win32/WaitingUsersFrame.h dcplusplus/trunk/win32/WinUtil.cpp dcplusplus/trunk/win32/WinUtil.h dcplusplus/trunk/win32/WindowsPage.cpp dcplusplus/trunk/win32/WindowsPage.h dcplusplus/trunk/win32/main.cpp dcplusplus/trunk/win32/resource.h dcplusplus/trunk/win32/stdafx.cpp dcplusplus/trunk/win32/stdafx.h dcplusplus/trunk/yassl/src/SConscript dcplusplus/trunk/yassl/taocrypt/src/SConscript dcplusplus/trunk/zlib/SConscript Property Changed: ---------------- dcplusplus/trunk/ dcplusplus/trunk/client/ Property changes on: dcplusplus/trunk ___________________________________________________________________ Name: svn:ignore - vc7 ADC* App* DCPlusPlus.aps DCPlusPlus.ncb DCPlusPlus.suo .* *.vcproj.* Example.xml + vc7 ADC* App* DCPlusPlus.aps DCPlusPlus.ncb DCPlusPlus.suo .* *.vcproj.* Example.xml build Modified: dcplusplus/trunk/Doxyfile =================================================================== --- dcplusplus/trunk/Doxyfile 2006-12-27 22:45:57 UTC (rev 700) +++ dcplusplus/trunk/Doxyfile 2007-02-27 09:39:02 UTC (rev 701) @@ -1,4 +1,4 @@ -# Doxyfile 1.4.2 +# Doxyfile 1.4.7 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project @@ -161,13 +161,6 @@ INHERIT_DOCS = YES -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. @@ -195,13 +188,29 @@ OPTIMIZE_OUTPUT_FOR_C = NO -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources -# only. Doxygen will then generate output that is more tailored for Java. +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for Java. # For instance, namespaces will be presented as packages, qualified scopes # will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to +# include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = NO + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to @@ -376,7 +385,7 @@ # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. +# in the documentation. The default is NO. SHOW_DIRECTORIES = YES @@ -385,7 +394,7 @@ # version control system). Doxygen will invoke the program by executing (via # popen()) the command <command> <input-file>, where <command> is the value of # the FILE_VERSION_FILTER tag, and <input-file> is the name of an input file -# provided by doxygen. Whatever the progam writes to standard output +# provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = @@ -458,7 +467,7 @@ # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py FILE_PATTERNS = @@ -482,7 +491,9 @@ # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. +# certain files from those directories. Note that the wildcards are matched +# against the file with absolute path, so to exclude all test directories +# for example use the pattern */test/* EXCLUDE_PATTERNS = @@ -571,6 +582,21 @@ REFERENCES_RELATION = YES +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentstion. + +REFERENCES_LINK_SOURCE = YES + +# If the USE_HTAGS tag is set to YES then the references to source code +# will point to the HTML generated by the htags(1) tool instead of doxygen +# built-in source browser. The htags tool is part of GNU's global source +# tagging system (see http://www.gnu.org/software/global/global.html). You +# will need version 4.8.6 or higher. + +USE_HTAGS = NO + # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. @@ -957,7 +983,7 @@ # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_PREDEFINED tags. +# PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = YES @@ -970,9 +996,7 @@ # contain include files that are not input files but should be processed by # the preprocessor. -INCLUDE_PATH = c:\documents\vcprojects\include\wtl70 \ - c:\documents\vcprojects\include\stlport \ - c:\documents\vcprojects\include +INCLUDE_PATH = wtl # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the @@ -1130,6 +1154,14 @@ CALL_GRAPH = YES +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then doxygen will +# generate a caller dependency graph for every global function or class method. +# Note that enabling this option will significantly increase the time of a run. +# So in most cases it will be better to enable caller graphs for selected +# functions only using the \callergraph command. + +CALLER_GRAPH = YES + # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. Modified: dcplusplus/trunk/License.txt =================================================================== --- dcplusplus/trunk/License.txt 2006-12-27 22:45:57 UTC (rev 700) +++ dcplusplus/trunk/License.txt 2007-02-27 09:39:02 UTC (rev 701) @@ -1,5 +1,5 @@ DC++ -Copyright (C) 2001-2004 Jacek Sieka, j_s at telia com +Copyright (C) 2001-2006 Jacek Sieka, arnetheduck at gmail dot com This program is licensed under GPL-2 with the notable exception that you may compile it with WTL (sf.net/projects/wtl). Added: dcplusplus/trunk/SConstruct =================================================================== --- dcplusplus/trunk/SConstruct (rev 0) +++ dcplusplus/trunk/SConstruct 2007-02-27 09:39:02 UTC (rev 701) @@ -0,0 +1,121 @@ +# vim: set filetype: py + +from build_util import Dev + +gcc_flags = { + 'common': ['-ggdb3', '-Wall', '-Wextra', '-pipe'], + 'debug': [], + 'release' : ['-O3'] +} + +msvc_flags = { + 'common' : ['/W4', '/EHsc', '/Zi', '/GR'], + 'debug' : ['/MD'], + 'release' : ['/O2', '/MD'] +} + +gcc_link_flags = { + 'common' : ['-ggdb3', '-Wl,--no-undefined'], + 'debug' : [], + 'release' : [] +} + +msvc_link_flags = { + 'common' : ['/DEBUG', '/FIXED:NO', '/INCREMENTAL:NO'], + 'debug' : [], + 'release' : [] +} + +msvc_defs = { + 'common' : ['_REENTRANT', 'USE_SYS_STL=1'], + 'debug' : [''], + 'release' : ['NDEBUG'] +} + +gcc_defs = { + 'common' : ['_REENTRANT', 'USE_SYS_STL=1'], + 'debug' : ['_DEBUG'], + 'release' : ['NDEBUG'] +} + +# --- cut --- + +import os,sys + +if sys.platform == 'win32': + tooldef = 'mingw' +else: + tooldef = 'default' + +mode = ARGUMENTS.get('mode', 'debug') +tools = ARGUMENTS.get('tools', tooldef) + +if mode not in gcc_flags: + print "Unknown mode, exiting" + Exit(1) + +toolset = [tools, 'swig'] + +env = Environment(tools = toolset, ENV=os.environ) + +dev = Dev(mode, tools, env) +dev.prepare() + +env.SConsignFile() +env.Tool("gch", toolpath=".") + +if 'mingw' not in env['TOOLS']: + env.Append(CCFLAGS=['-fvisibility=hidden']) + +if 'mingw' in env['TOOLS']: + env.Append(CPPPATH = ['#/stlport/stlport/']) + #env.Append(LIBPATH = ['#/stlport/lib/']) + env.Append(CPPDEFINES = ['HAVE_STLPORT']) + + gcc_link_flags['common'].append("-Wl,--enable-runtime-pseudo-reloc") + #if mode == 'debug': + # env.Append(LIBS = ['stlportg.5.0']) + #else: + # env.Append(LIBS = ['stlport.5.0']) + +if env['CC'] == 'cl': + flags = msvc_flags + link_flags = msvc_link_flags + defs = msvc_defs + + # This is for msvc8 + # Embed generated manifest in file + env['SHLINKCOM'] = [env['SHLINKCOM'], 'mt.exe -manifest ${TARGET}.manifest -outputresource:$TARGET;2'] + env['LINKCOM'] = [env['LINKCOM'], 'mt.exe -manifest ${TARGET}.manifest -outputresource:$TARGET;1'] +else: + flags = gcc_flags + link_flags = gcc_link_flags + defs = gcc_defs + +env.Append(CPPDEFINES = defs[mode]) +env.Append(CPPDEFINES = defs['common']) + +env.Append(CCFLAGS = flags[mode]) +env.Append(CCFLAGS = flags['common']) + +env.Append(LINKFLAGS = link_flags[mode]) +env.Append(LINKFLAGS = link_flags['common']) + +env.SourceCode('.', None) +env.SetOption('implicit_cache', '1') +env.SetOption('max_drift', 60*10) + +import SCons.Scanner +SWIGScanner = SCons.Scanner.ClassicCPP( + "SWIGScan", + ".i", + "CPPPATH", + '^[ \t]*[%,#][ \t]*(?:include|import)[ \t]*(<|")([^>"]+)(>|")' +) +env.Append(SCANNERS=[SWIGScanner]) + +dev.build('zlib/') +dev.build('bzip2/') +dev.build('yassl/') +dev.build('client/') +dev.build('win32/') Added: dcplusplus/trunk/build_util.py =================================================================== --- dcplusplus/trunk/build_util.py (rev 0) +++ dcplusplus/trunk/build_util.py 2007-02-27 09:39:02 UTC (rev 701) @@ -0,0 +1,83 @@ +import glob +import sys + +class Dev: + def __init__(self, mode, tools, env): + + self.mode = mode + self.tools = tools + self.env = env + + def prepare(self): + self.env['CCCOMSTR'] = "Compiling $TARGET (static)" + self.env['SHCCCOMSTR'] = "Compiling $TARGET (shared)" + self.env['CXXCOMSTR'] = "Compiling $TARGET (static)" + self.env['SHCXXCOMSTR'] = "Compiling $TARGET (shared)" + #self.env['SHLINKCOMSTR'] = "Linking $TARGET (shared)" + #self.env['LINKCOMSTR'] = "Linking $TARGET (static)" + self.env['ARCOMSTR'] = "Archiving $TARGET" + + self.env.SConsignFile() + self.env.SetOption('implicit_cache', '1') + self.env.SetOption('max_drift', 60*10) + + if 'mingw' in self.env['TOOLS']: + self.env.Append(LINKFLAGS=["-Wl,--enable-runtime-pseudo-reloc"]) + + if sys.platform != 'win32': + if self.env.get('MINGW_PREFIX') is not None: + prefix = self.env['MINGW_PREFIX'] + else: + prefix = 'i386-mingw32' + self.env['CC'] = prefix + '-gcc' + self.env['CXX'] = prefix + '-g++' + self.env['LINK'] = prefix + '-g++' + self.env['AR'] = prefix + '-ar' + self.env['RANLIB'] = prefix + '-ranlib' + self.env['PROGSUFFIX'] = '.exe' + self.env['LIBPREFIX'] = 'lib' + self.env['LIBSUFFIX'] = '.a' + + def get_build_root(self): + return '#/build/' + self.mode + '-' + self.tools + '/' + + def get_build_path(self, source_path): + return self.get_build_root() + source_path + + def get_target(self, source_path, name, in_bin = True): + if in_bin: + return self.get_build_root() + 'bin/' + name + else: + return self.get_build_root() + source_path + name + + def get_sources(self, source_path, source_glob): + return map(lambda x: self.get_build_path(source_path) + x, glob.glob(source_glob)) + + def prepare_build(self, source_path, name, source_glob = '*.cpp', in_bin = True): + local_env = self.env.Copy() + + local_env.BuildDir(self.get_build_path(source_path), '.', duplicate = 0) + + return (local_env, self.get_target(source_path, name, in_bin), self.get_sources(source_path, source_glob)) + + def build(self, source_path, local_env = None): + if not local_env: + local_env = self.env + full_path = local_env.Dir('.').path + '/' + source_path + return local_env.SConscript(source_path + 'SConscript', exports={'dev' : self, 'source_path' : full_path }) + +def CheckPKGConfig(context, version): + context.Message( 'Checking for pkg-config... ' ) + ret = context.TryAction('pkg-config --atleast-pkgconfig-version=%s' % version)[0] + context.Result( ret ) + return ret + +def CheckPKG(context, name): + context.Message( 'Checking for %s... ' % name ) + ret = context.TryAction('pkg-config --exists "%s"' % name)[0] + if ret: + context.env.ParseConfig('pkg-config --cflags --libs "%s"' % name) + + context.Result( ret ) + return ret + Added: dcplusplus/trunk/bzip2/SConscript =================================================================== --- dcplusplus/trunk/bzip2/SConscript (rev 0) +++ dcplusplus/trunk/bzip2/SConscript 2007-02-27 09:39:02 UTC (rev 701) @@ -0,0 +1,11 @@ +# vim: set filetype=py + +Import('dev source_path') + +env, target, sources = dev.prepare_build(source_path, 'dcpp-bzip', in_bin=False) + +ret = env.StaticLibrary(target, sources) + +dev.env.Append(LIBPATH = [dev.get_build_path(source_path)]) + +Return('ret') Property changes on: dcplusplus/trunk/client ___________________________________________________________________ Name: svn:ignore - StringDefs.cpp + StringDefs.cpp stdinc.h.gch Modified: dcplusplus/trunk/client/ClientManager.h =================================================================== --- dcplusplus/trunk/client/ClientManager.h 2006-12-27 22:45:57 UTC (rev 700) +++ dcplusplus/trunk/client/ClientManager.h 2007-02-27 09:39:02 UTC (rev 701) @@ -28,6 +28,7 @@ #include "Client.h" #include "Singleton.h" #include "SettingsManager.h" +#include "User.h" #include "ClientManagerListener.h" Modified: dcplusplus/trunk/client/CryptoManager.cpp =================================================================== --- dcplusplus/trunk/client/CryptoManager.cpp 2006-12-27 22:45:57 UTC (rev 700) +++ dcplusplus/trunk/client/CryptoManager.cpp 2007-02-27 09:39:02 UTC (rev 701) @@ -104,23 +104,23 @@ } #ifdef _WIN32 - wstring cmd = L"openssl.exe genrsa -out \"" + Text::utf8ToWide(SETTING(TLS_PRIVATE_KEY_FILE)) + L"\" 2048"; + tstring cmd = _T("openssl.exe genrsa -out \"") + Text::toT(SETTING(TLS_PRIVATE_KEY_FILE)) + _T("\" 2048"); PROCESS_INFORMATION pi = { 0 }; STARTUPINFO si = { 0 }; si.cb = sizeof(si); - if(!CreateProcess(0, const_cast<wchar_t*>(cmd.c_str()), 0, 0, FALSE, 0, 0, 0, &si, &pi)) { + if(!CreateProcess(0, const_cast<TCHAR*>(cmd.c_str()), 0, 0, FALSE, 0, 0, 0, &si, &pi)) { throw CryptoException(Util::translateError(::GetLastError())); } WaitForSingleObject(pi.hProcess, INFINITE); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); - cmd = L"openssl.exe req -x509 -new -batch -days 3650 -key \"" + Text::utf8ToWide(SETTING(TLS_PRIVATE_KEY_FILE)) + - L"\" -out \"" + Text::utf8ToWide(SETTING(TLS_CERTIFICATE_FILE)) + L"\" -subj \"/CN=" + - Text::utf8ToWide(ClientManager::getInstance()->getMyCID().toBase32()) + L"\""; + cmd = _T("openssl.exe req -x509 -new -batch -days 3650 -key \"") + Text::toT(SETTING(TLS_PRIVATE_KEY_FILE)) + + _T("\" -out \"") + Text::toT(SETTING(TLS_CERTIFICATE_FILE)) + _T("\" -subj \"/CN=") + + Text::toT(ClientManager::getInstance()->getMyCID().toBase32()) + _T("\""); - if(!CreateProcess(0, const_cast<wchar_t*>(cmd.c_str()), 0, 0, FALSE, 0, 0, 0, &si, &pi)) { + if(!CreateProcess(0, const_cast<TCHAR*>(cmd.c_str()), 0, 0, FALSE, 0, 0, 0, &si, &pi)) { throw CryptoException(Util::translateError(::GetLastError())); } Modified: dcplusplus/trunk/client/DCPlusPlus.h =================================================================== --- dcplusplus/trunk/client/DCPlusPlus.h 2006-12-27 22:45:57 UTC (rev 700) +++ dcplusplus/trunk/client/DCPlusPlus.h 2007-02-27 09:39:02 UTC (rev 701) @@ -46,7 +46,7 @@ } #define dcdebug debugTrace -#ifdef _WIN32 +#ifdef _MSC_VER #define dcassert(exp) \ do { if (!(exp)) { \ dcdebug("Assertion hit in %s(%d): " #exp "\n", __FILE__, __LINE__); \ @@ -54,7 +54,6 @@ _CrtDbgBreak(); } } while(false) #define dcasserta(exp) dcassert(0) #else -#include <assert.h> #define dcasserta(exp) assert(exp) #define dcassert(exp) assert(exp) #endif Modified: dcplusplus/trunk/client/File.cpp =================================================================== --- dcplusplus/trunk/client/File.cpp 2006-12-27 22:45:57 UTC (rev 700) +++ dcplusplus/trunk/client/File.cpp 2007-02-27 09:39:02 UTC (rev 701) @@ -40,7 +40,7 @@ } } - h = ::CreateFile(Text::utf8ToWide(aFileName).c_str(), access, FILE_SHARE_READ, NULL, m, FILE_FLAG_SEQUENTIAL_SCAN, NULL); + h = ::CreateFile(Text::toT(aFileName).c_str(), access, FILE_SHARE_READ, NULL, m, FILE_FLAG_SEQUENTIAL_SCAN, NULL); if(h == INVALID_HANDLE_VALUE) { throw FileException(Util::translateError(GetLastError())); @@ -176,21 +176,21 @@ } } -void File::ensureDirectory(const string& aFile) { +void File::ensureDirectory(const string& aFile) throw() { // Skip the first dir... tstring file; Text::toT(aFile, file); - wstring::size_type start = file.find_first_of(L"\\/"); + tstring::size_type start = file.find_first_of(_T("\\/")); if(start == string::npos) return; start++; - while( (start = file.find_first_of(L"\\/", start)) != string::npos) { - CreateDirectory(file.substr(0, start+1).c_str(), NULL); + while( (start = file.find_first_of(_T("\\/"), start)) != string::npos) { + ::CreateDirectory(file.substr(0, start+1).c_str(), NULL); start++; } } -bool File::isAbsolute(const string& path) { +bool File::isAbsolute(const string& path) throw() { return path.size() > 2 && (path[1] == ':' || path[0] == '/' || path[0] == '\\'); } Modified: dcplusplus/trunk/client/HashManager.cpp =================================================================== --- dcplusplus/trunk/client/HashManager.cpp 2006-12-27 22:45:57 UTC (rev 700) +++ dcplusplus/trunk/client/HashManager.cpp 2007-02-27 09:39:02 UTC (rev 701) @@ -500,6 +500,7 @@ uint8_t* rbuf = buf; OVERLAPPED over = { 0 }; + BOOL res = TRUE; over.hEvent = CreateEvent(NULL, FALSE, TRUE, NULL); bool ok = false; @@ -523,7 +524,6 @@ over.Offset = hn; size -= hn; - BOOL res = TRUE; for(;;) { if(size > 0) { // Start a new overlapped read Added: dcplusplus/trunk/client/SConscript =================================================================== --- dcplusplus/trunk/client/SConscript (rev 0) +++ dcplusplus/trunk/client/SConscript 2007-02-27 09:39:02 UTC (rev 701) @@ -0,0 +1,42 @@ +# vim: set filetype=py + +from os import popen4 +import re + +def getRevision(): + cmd = 'svn info -R "' + env.Dir("#").abspath + '"' + stdin, stdout = popen4(cmd) + stdin.close() + maxver = 0 + matcher = re.compile(ur'Revision: (\d+)') + for line in stdout.readlines(): + match = matcher.match(line) + if not match: + continue + ver = int(match.group(1)) + if ver > maxver: + maxver = ver + + stdout.close() + print "Building revision " + str(maxver) + + return str(maxver) + +Import('dev source_path') + +env, target, sources = dev.prepare_build(source_path, 'dcpp', in_bin=False) + +env.Append(CPPPATH = ['.','../yassl/include', '../bzip2', '../zlib']) + +for i, source in enumerate(sources): + if source.find("version.cpp") != -1: + rev = ['DCPP_REVISION=' + getRevision()] + sources[i] = env.StaticObject(source, CPPDEFINES=env['CPPDEFINES'] + rev) + +env['Gch'] = env.Gch('stdinc.h')[0] + +ret = env.StaticLibrary(target, sources) + +dev.env.Append(LIBPATH = [dev.get_build_path(source_path)]) + +Return('ret') Modified: dcplusplus/trunk/client/Thread.h =================================================================== --- dcplusplus/trunk/client/Thread.h 2006-12-27 22:45:57 UTC (rev 700) +++ dcplusplus/trunk/client/Thread.h 2007-02-27 09:39:02 UTC (rev 701) @@ -64,9 +64,17 @@ static void sleep(uint32_t millis) { ::Sleep(millis); } static void yield() { ::Sleep(1); } + +#ifdef __MINGW32__ + static long safeInc(volatile long& v) { return InterlockedIncrement((long*)&v); } + static long safeDec(volatile long& v) { return InterlockedDecrement((long*)&v); } + static long safeExchange(volatile long& target, long value) { return InterlockedExchange((long*)&target, value); } + +#else static long safeInc(volatile long& v) { return InterlockedIncrement(&v); } static long safeDec(volatile long& v) { return InterlockedDecrement(&v); } static long safeExchange(volatile long& target, long value) { return InterlockedExchange(&target, value); } +#endif #else Modified: dcplusplus/trunk/client/Util.cpp =================================================================== --- dcplusplus/trunk/client/Util.cpp 2006-12-27 22:45:57 UTC (rev 700) +++ dcplusplus/trunk/client/Util.cpp 2007-02-27 09:39:02 UTC (rev 701) @@ -30,9 +30,7 @@ #include "File.h" #include "SimpleXML.h" -#ifdef _WIN32 -#include <ShlObj.h> -#else +#ifndef _WIN32 #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> @@ -366,7 +364,7 @@ nf.lpDecimalSep = _T(","); GetLocaleInfo( LOCALE_SYSTEM_DEFAULT, LOCALE_SGROUPING, Dummy, 16 ); - nf.Grouping = _tstoi(Dummy); + nf.Grouping = Util::toInt(Dummy); GetLocaleInfo( LOCALE_SYSTEM_DEFAULT, LOCALE_STHOUSAND, Dummy, 16 ); nf.lpThousandSep = Dummy; Modified: dcplusplus/trunk/client/stdinc.cpp =================================================================== --- dcplusplus/trunk/client/stdinc.cpp 2006-12-27 22:45:57 UTC (rev 700) +++ dcplusplus/trunk/client/stdinc.cpp 2007-02-27 09:39:02 UTC (rev 701) @@ -20,5 +20,5 @@ // Hm...version not updated it seems #if defined(HAVE_STLPORT) && (_STLPORT_VERSION != 0x501) -#error I use STLport 5.0.2. Remove this if you know what you're doing. +#error I use STLport 5.0.3. Remove this if you know what you're doing. #endif Modified: dcplusplus/trunk/client/stdinc.h =================================================================== --- dcplusplus/trunk/client/stdinc.h 2006-12-27 22:45:57 UTC (rev 700) +++ dcplusplus/trunk/client/stdinc.h 2007-02-27 09:39:02 UTC (rev 701) @@ -37,15 +37,13 @@ #define USE_SYS_STL 1 #endif -#ifdef HAVE_STLPORT -# define _STLP_DONT_USE_SHORT_STRING_OPTIM 1 // Lots of memory issues with this undefined...wonder what's up with that.. -# define _STLP_USE_PTR_SPECIALIZATIONS 1 -# define _STLP_NO_ANACHRONISMS 1 -# define _STLP_NO_CUSTOM_IO 1 -# define _STLP_NO_IOSTREAMS 1 -# ifndef _DEBUG -# define _STLP_DONT_USE_EXCEPTIONS 1 -# endif +#define _STLP_DONT_USE_SHORT_STRING_OPTIM 1 // Lots of memory issues with this undefined...wonder what's up with that.. +#define _STLP_USE_PTR_SPECIALIZATIONS 1 +#define _STLP_NO_ANACHRONISMS 1 +#define _STLP_NO_CUSTOM_IO 1 +#define _STLP_NO_IOSTREAMS 1 +#ifndef _DEBUG +# define _STLP_DONT_USE_EXCEPTIONS 1 #endif #ifdef _MSC_VER @@ -98,17 +96,24 @@ #define _ATL_NO_HOSTING #define _ATL_NO_OLD_NAMES -#include <Winsock2.h> +#include <winsock2.h> #include <windows.h> -#include <crtdbg.h> #include <tchar.h> +#include <shlobj.h> #else #include <unistd.h> #include <stdint.h> #endif +#ifdef _MSC_VER +#include <crtdbg.h> +#else +#include <assert.h> +#endif + +#include <ctype.h> #include <stdio.h> #include <stdarg.h> #include <memory.h> Added: dcplusplus/trunk/gch.py =================================================================== --- dcplusplus/trunk/gch.py (rev 0) +++ dcplusplus/trunk/gch.py 2007-02-27 09:39:02 UTC (rev 701) @@ -0,0 +1,106 @@ +# $Id: gch.py 320 2006-07-18 15:58:09Z tim $ +# +# SCons builder for gcc's precompiled headers +# Copyright (C) 2006 Tim Blechmann +# +# This program 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 program 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 program; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, +# Boston, MA 02111-1307, USA. + +# $Revision: 320 $ +# $LastChangedRevision: 320 $ +# $LastChangedDate: 2006-07-18 17:58:09 +0200 (tis, 18 jul 2006) $ +# $LastChangedBy: tim $ + +import SCons.Action +import SCons.Builder +import SCons.Scanner.C +import SCons.Util +import SCons + +GchAction = SCons.Action.Action('$GCHCOM') +GchShAction = SCons.Action.Action('$GCHSHCOM') + +def gen_suffix(env, sources): + return sources[0].get_suffix() + env['GCHSUFFIX'] + +if SCons.__version__ == "0.96.1": + scanner = SCons.Scanner.C.CScan() +else: + scanner = SCons.Scanner.C.CScanner() + +GchShBuilder = SCons.Builder.Builder(action = GchShAction, + source_scanner = scanner, + suffix = gen_suffix) + +GchBuilder = SCons.Builder.Builder(action = GchAction, + source_scanner = scanner, + suffix = gen_suffix) + +def static_pch_emitter(target,source,env): + SCons.Defaults.StaticObjectEmitter( target, source, env ) + + path = scanner.path(env) + deps = scanner(source[0], env, path) + if env.has_key('Gch') and env['Gch']: + if env['Gch'].path[:-4] in [x.path for x in deps]: + env.Depends(target, env['Gch']) + + return (target, source) + +def shared_pch_emitter(target,source,env): + SCons.Defaults.SharedObjectEmitter( target, source, env ) + + path = scanner.path(env) + deps = scanner(source[0], env, path) + if env.has_key('GchSh') and env['GchSh']: + if env['GchSh'].path[:-4] in [x.path for x in deps]: + env.Depends(target, env['GchSh']) + return (target, source) + +def generate(env): + """ + Add builders and construction variables for the DistTar builder. + """ + env.Append(BUILDERS = { + 'gch': env.Builder( + action = GchAction, + target_factory = env.fs.File, + ), + 'gchsh': env.Builder( + action = GchShAction, + target_factory = env.fs.File, + ), + }) + + try: + bld = env['BUILDERS']['Gch'] + bldsh = env['BUILDERS']['GchSh'] + except KeyError: + bld = GchBuilder + bldsh = GchShBuilder + env['BUILDERS']['Gch'] = bld + env['BUILDERS']['GchSh'] = bldsh + + env['GCHCOM'] = '$CXX $CXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET -x c++-header -c $SOURCE' + env['GCHSHCOM'] = '$CXX $SHCXXFLAGS $CPPFLAGS $_CPPDEFFLAGS $_CPPINCFLAGS -o $TARGET -x c++-header -c $SOURCE' + env['GCHSUFFIX'] = '.gch' + + for suffix in SCons.Util.Split('.c .C .cc .cxx .cpp .c++'): + env['BUILDERS']['StaticObject'].add_emitter( suffix, static_pch_emitter ) + env['BUILDERS']['SharedObject'].add_emitter( suffix, shared_pch_emitter ) + + +def exists(env): + return env.Detect('g++') Property changes on: dcplusplus/trunk/smartwin ___________________________________________________________________ Name: svn:ignore + * Property changes on: dcplusplus/trunk/stlport ___________________________________________________________________ Name: svn:ignore + * Copied: dcplusplus/trunk/win32/ADLSProperties.cpp (from rev 700, dcplusplus/trunk/windows/ADLSProperties.cpp) =================================================================== --- dcplusplus/trunk/win32/ADLSProperties.cpp (rev 0) +++ dcplusplus/trunk/win32/ADLSProperties.cpp 2007-02-27 09:39:02 UTC (rev 701) @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2001-2006 Jacek Sieka, arnetheduck on gmail point com + * + * This program 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 program 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 program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#ifdef PORT_ME + +#include "stdafx.h" +#include "../client/DCPlusPlus.h" +#include "Resource.h" + +#include "ADLSProperties.h" +#include "../client/ADLSearch.h" +#include "../client/FavoriteManager.h" +#include "WinUtil.h" + +// Initialize dialog +LRESULT ADLSProperties::OnInitDialog(UINT, WPARAM, LPARAM, BOOL&) { + // Translate the texts + SetWindowText(CTSTRING(ADLS_PROPERTIES)); + SetDlgItemText(IDC_ADLSP_SEARCH, CTSTRING(ADLS_SEARCH_STRING)); + SetDlgItemText(IDC_ADLSP_TYPE, CTSTRING(ADLS_TYPE)); + SetDlgItemText(IDC_ADLSP_SIZE_MIN, CTSTRING(ADLS_SIZE_MIN)); + SetDlgItemText(IDC_ADLSP_SIZE_MAX, CTSTRING(ADLS_SIZE_MAX)); + SetDlgItemText(IDC_ADLSP_UNITS, CTSTRING(ADLS_UNITS)); + SetDlgItemText(IDC_ADLSP_DESTINATION, CTSTRING(ADLS_DESTINATION)); + SetDlgItemText(IDC_IS_ACTIVE, CTSTRING(ADLS_ENABLED)); + SetDlgItemText(IDC_AUTOQUEUE, CTSTRING(ADLS_DOWNLOAD)); + + // Initialize dialog items + ctrlSearch.Attach(GetDlgItem(IDC_SEARCH_STRING)); + ctrlDestDir.Attach(GetDlgItem(IDC_DEST_DIR)); + ctrlMinSize.Attach(GetDlgItem(IDC_MIN_FILE_SIZE)); + ctrlMaxSize.Attach(GetDlgItem(IDC_MAX_FILE_SIZE)); + ctrlActive.Attach(GetDlgItem(IDC_IS_ACTIVE)); + ctrlAutoQueue.Attach(GetDlgItem(IDC_AUTOQUEUE)); + + ctrlSearchType.Attach(GetDlgItem(IDC_SOURCE_TYPE)); + ctrlSearchType.AddString(CTSTRING(FILENAME)); + ctrlSearchType.AddString(CTSTRING(DIRECTORY)); + ctrlSearchType.AddString(CTSTRING(ADLS_FULL_PATH)); + + ctrlSizeType.Attach(GetDlgItem(IDC_SIZE_TYPE)); + ctrlSizeType.AddString(CTSTRING(B)); + ctrlSizeType.AddString(CTSTRING(KiB)); + ctrlSizeType.AddString(CTSTRING(MiB)); + ctrlSizeType.AddString(CTSTRING(GiB)); + + // Load search data + ctrlSearch.SetWindowText(Text::toT(search->searchString).c_str()); + ctrlDestDir.SetWindowText(Text::toT(search->destDir).c_str()); + ctrlMinSize.SetWindowText(Text::toT(search->minFileSize > 0 ? Util::toString(search->minFileSize) : "").c_str()); + ctrlMaxSize.SetWindowText(Text::toT(search->maxFileSize > 0 ? Util::toString(search->maxFileSize) : "").c_str()); + ctrlActive.SetCheck(search->isActive ? 1 : 0); + ctrlAutoQueue.SetCheck(search->isAutoQueue ? 1 : 0); + ctrlSearchType.SetCurSel(search->sourceType); + ctrlSizeType.SetCurSel(search->typeFileSize); + + // Center dialog + CenterWindow(GetParent()); + + return FALSE; +} + +// Exit dialog +LRESULT ADLSProperties::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +{ + if(wID == IDOK) { + // Update search + TCHAR buf[256]; + + ctrlSearch.GetWindowText(buf, 256); + search->searchString = Text::fromT(buf); + ctrlDestDir.GetWindowText(buf, 256); + search->destDir = Text::fromT(buf); + + ctrlMinSize.GetWindowText(buf, 256); + search->minFileSize = (_tcslen(buf) == 0 ? -1 : Util::toInt64(Text::fromT(buf))); + ctrlMaxSize.GetWindowText(buf, 256); + search->maxFileSize = (_tcslen(buf) == 0 ? -1 : Util::toInt64(Text::fromT(buf))); + + search->isActive = (ctrlActive.GetCheck() == 1); + search->isAutoQueue = (ctrlAutoQueue.GetCheck() == 1); + + search->sourceType = (ADLSearch::SourceType)ctrlSearchType.GetCurSel(); + search->typeFileSize = (ADLSearch::SizeType)ctrlSizeType.GetCurSel(); + } + + EndDialog(wID); + return 0; +} +#endif Copied: dcplusplus/trunk/win32/ADLSProperties.h (from rev 700, dcplusplus/trunk/windows/ADLSProperties.h) =================================================================== --- dcplusplus/trunk/win32/ADLSProperties.h (rev 0) +++ dcplusplus/trunk/win32/ADLSProperties.h 2007-02-27 09:39:02 UTC (rev 701) @@ -0,0 +1,70 @@ +/* + * Copyright (C) 2001-2006 Jacek Sieka, arnetheduck on gmail point com + * + * This program 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 program 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 program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +#if !defined(ADLS_PROPERTIES_H) +#define ADLS_PROPERTIES_H + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +class ADLSearch; + +/////////////////////////////////////////////////////////////////////////////// +// +// Dialog for new/edit ADL searches +// +/////////////////////////////////////////////////////////////////////////////// +class ADLSProperties : public CDialogImpl<ADLSProperties> +{ +public: + + // Constructor/destructor + ADLSProperties::ADLSProperties(ADLSearch *_search) : search(_search) { } + virtual ~ADLSProperties() { } + + // Dilaog unique id + enum { IDD = IDD_ADLS_PROPERTIES }; + + // Inline message map + BEGIN_MSG_MAP(ADLSProperties) + MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) + COMMAND_ID_HANDLER(IDOK, OnCloseCmd) + COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd) + END_MSG_MAP() + + // Message handlers + LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + +private: + + // Current search + ADLSearch* search; + + CEdit ctrlSearch; + CEdit ctrlDestDir; + CEdit ctrlMinSize; + CEdit ctrlMaxSize; + CButton ctrlActive; + CButton ctrlAutoQueue; + CComboBox ctrlSearchType; + CComboBox ctrlSizeType; +}; + +#endif // !defined(ADLS_PROPERTIES_H) Copied: dcplusplus/trunk/win32/ADLSearchFrame.cpp (from rev 700, dcplusplus/trunk/windows/ADLSearchFrame.cpp) =================================================================== --- dcplusplus/trunk/win32/ADLSearchFrame.cpp (rev 0) +++ dcplusplus/trunk/win32/ADLSearchFrame.cpp 2007-02-27 09:39:02 UTC (rev 701) @@ -0,0 +1,549 @@ +/* + * Copyright (C) 2001-2006 Jacek Sieka, arnetheduck on gmail point com + * + * This program 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 program 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 program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* + * Automatic Directory Listing Search + * Henrik Engstr�m, henrikengstrom at home se + */ + +#ifdef PORT_ME + +#include "stdafx.h" +#include "Resource.h" +#include "../client/DCPlusPlus.h" +#include "../client/Client.h" +#include "ADLSearchFrame.h" +#include "AdlsProperties.h" + +int ADLSearchFrame::columnIndexes[] = { + COLUMN_ACTIVE_SEARCH_STRING, + COLUMN_SOURCE_TYPE, + COLUMN_DEST_DIR, + COLUMN_MIN_FILE_SIZE, + COLUMN_MAX_FILE_SIZE +}; +int ADLSearchFrame::columnSizes[] = { + 120, + 90, + 90, + 90, + 90 +}; +static ResourceManager::Strings columnNames[] = { + ResourceManager::ACTIVE_SEARCH_STRING, + ResourceManager::SOURCE_TYPE, + ResourceManager::DESTINATION, + ResourceManager::MIN_SIZE, + ResourceManager::MAX_SIZE, +}; + +// Frame creation +LRESULT ADLSearchFrame::onCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) +{ + // Create status bar + CreateSimpleStatusBar(ATL_IDS_IDLEMESSAGE, WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | SBARS_SIZEGRIP); + ctrlStatus.Attach(m_hWndStatusBar); + int w[1] = { 0 }; + ctrlStatus.SetParts(1, w); + + // Create list control + ctrlList.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | + WS_HSCROLL | WS_VSCROLL | LVS_REPORT | LVS_SHOWSELALWAYS, WS_EX_CLIENTEDGE, IDC_ADLLIST); + ctrlList.SetExtendedListViewStyle(LVS_EX_LABELTIP | LVS_EX_HEADERDRAGDROP | LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT); + + // Set background color + ctrlList.SetBkColor(WinUtil::bgColor); + ctrlList.SetTextBkColor(WinUtil::bgColor); + ctrlList.SetTextColor(WinUtil::textColor); + + // Create listview columns + WinUtil::splitTokens(columnIndexes, SETTING(ADLSEARCHFRAME_ORDER), COLUMN_LAST); + WinUtil::splitTokens(columnSizes, SETTING(ADLSEARCHFRAME_WIDTHS), COLUMN_LAST); + for(int j = 0; j < COLUMN_LAST; j++) + { + int fmt = LVCFMT_LEFT; + ctrlList.InsertColumn(j, CTSTRING_I(columnNames[j]), fmt, columnSizes[j], j); + } + ctrlList.SetColumnOrderArray(COLUMN_LAST, columnIndexes); + + // Create buttons + ctrlAdd.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | + BS_PUSHBUTTON , 0, IDC_ADD); + ctrlAdd.SetWindowText(CTSTRING(NEW)); + ctrlAdd.SetFont(WinUtil::font); + + ctrlEdit.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | + BS_PUSHBUTTON , 0, IDC_EDIT); + ctrlEdit.SetWindowText(CTSTRING(PROPERTIES)); + ctrlEdit.SetFont(WinUtil::font); + + ctrlRemove.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | + BS_PUSHBUTTON , 0, IDC_REMOVE); + ctrlRemove.SetWindowText(CTSTRING(REMOVE)); + ctrlRemove.SetFont(WinUtil::font); + + ctrlMoveUp.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | + BS_PUSHBUTTON , 0, IDC_MOVE_UP); + ctrlMoveUp.SetWindowText(CTSTRING(MOVE_UP)); + ctrlMoveUp.SetFont(WinUtil::font); + + ctrlMoveDown.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | + BS_PUSHBUTTON , 0, IDC_MOVE_DOWN); + ctrlMoveDown.SetWindowText(CTSTRING(MOVE_DOWN)); + ctrlMoveDown.SetFont(WinUtil::font); + + ctrlHelp.Create(m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | + BS_PUSHBUTTON , 0, IDC_HELP_FAQ); + ctrlHelp.SetWindowText(CTSTRING(MENU_HELP)); + ctrlHelp.SetFont(WinUtil::font); + + // Create context menu + contextMenu.CreatePopupMenu(); + contextMenu.AppendMenu(MF_STRING, IDC_ADD, CTSTRING(NEW)); + contextMenu.AppendMenu(MF_STRING, IDC_REMOVE, CTSTRING(REMOVE)); + contextMenu.AppendMenu(MF_STRING, IDC_EDIT, CTSTRING(PROPERTIES)); + + // Load all searches + LoadAll(); + + bHandled = FALSE; + return TRUE; +} + +// Close window +LRESULT ADLSearchFrame::onClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled) +{ + ADLSearchManager::getInstance()->Save(); + + WinUtil::saveHeaderOrder(ctrlList, SettingsManager::ADLSEARCHFRAME_ORDER, + SettingsManager::ADLSEARCHFRAME_WIDTHS, COLUMN_LAST, columnIndexes, columnSizes); + + bHandled = FALSE; + return 0; +} + +// Recalculate frame control layout +void ADLSearchFrame::UpdateLayout(BOOL bResizeBars /* = TRUE */) +{ + RECT rect; + GetClientRect(&rect); + + // Position bars and offset their dimensions + UpdateBarsPosition(rect, bResizeBars); + if(ctrlStatus.IsWindow()) + { + CRect sr; + int w[1]; + ctrlStatus.GetClientRect(sr); + w[0] = sr.Width() - 16; + ctrlStatus.SetParts(1, w); + } + + // Position list control + CRect rc = rect; + rc.top += 2; + rc.bottom -= 28; + ctrlList.MoveWindow(rc); + + // Position buttons + const long bwidth = 90; + const long bspace = 10; + rc = rect; + rc.bottom -= 2; + rc.top = rc.bottom - 22; + + rc.left = 2; + rc.right = rc.left + bwidth; + ctrlAdd.MoveWindow(rc); + + rc.left += bwidth + 2; + rc.right = rc.left + bwidth; + ctrlEdit.MoveWindow(rc); + + rc.left += bwidth + 2; + rc.right = rc.left + bwidth; + ctrlRemove.MoveWindow(rc); + + rc.left += bspace; + + rc.left += bwidth + 2; + rc.right = rc.left + bwidth; + ctrlMoveUp.MoveWindow(rc); + + rc.left += bwidth + 2; + rc.right = rc.left + bwidth; + ctrlMoveDown.MoveWindow(rc); + + rc.left += bspace; + + rc.left += bwidth + 2; + rc.right = rc.left + bwidth; + ctrlHelp.MoveWindow(rc); + +} + +// Keyboard shortcuts +LRESULT ADLSearchFrame::onKeyDown(int /*idCtrl*/, LPNMHDR pnmh, BOOL& bHandled) +{ + NMLVKEYDOWN* kd = (NMLVKEYDOWN*) pnmh; + switch(kd->wVKey) + { + case VK_INSERT: + PostMessage(WM_COMMAND, IDC_ADD, 0); + break; + case VK_DELETE: + PostMessage(WM_COMMAND, IDC_REMOVE, 0); + break; + case VK_RETURN: + PostMessage(WM_COMMAND, IDC_EDIT, 0); + break; + default: + bHandled = FALSE; + } + return 0; +} + +LRESULT ADLSearchFrame::onContextMenu(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) { + if(reinterpret_cast<HWND>(wParam) == ctrlList) { + POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; + + if(pt.x == -1 && pt.y == -1) { + WinUtil::getContextMenuPos(ctrlList, pt); + } + + int status = ctrlList.GetSelectedCount() > 0 ? MFS_ENABLED : MFS_GRAYED; + contextMenu.EnableMenuItem(IDC_EDIT, status); + contextMenu.EnableMenuItem(IDC_REMOVE, status); + contextMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, m_hWnd); + return TRUE; + } + bHandled = FALSE; + return FALSE; +} + +// Add new search +LRESULT ADLSearchFrame::onAdd(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +{ + // Invoke edit dialog with fresh search + ADLSearch search; + ADLSProperties dlg(&search); + if(dlg.DoModal((HWND)*this) == IDOK) + { + // Add new search to the end or if selected, just before + ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection; + + + int i = ctrlList.GetNextItem(-1, LVNI_SELECTED); + if(i < 0) + { + // Add to end + collection.push_back(search); + i = collection.size() - 1; + } + else + { + // Add before selection + collection.insert(collection.begin() + i, search); + } + + // Update list control + int j = i; + while(j < (int)collection.size()) + { + UpdateSearch(j++); + } + ctrlList.EnsureVisible(i, FALSE); + } + + return 0; +} + +// Edit existing search +LRESULT ADLSearchFrame::onEdit(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +{ + // Get selection info + int i = ctrlList.GetNextItem(-1, LVNI_SELECTED); + if(i < 0) + { + // Nothing selected + return 0; + } + + // Edit existing + ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection; + ADLSearch search = collection[i]; + + // Invoke dialog with selected search + ADLSProperties dlg(&search); + if(dlg.DoModal((HWND)*this) == IDOK) + { + // Update search collection + collection[i] = search; + + // Update list control + UpdateSearch(i); + } + + return 0; +} + +// Remove searches +LRESULT ADLSearchFrame::onRemove(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +{ + ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection; + + // Loop over all selected items + int i; + while((i = ctrlList.GetNextItem(-1, LVNI_SELECTED)) >= 0) + { + collection.erase(collection.begin() + i); + ctrlList.DeleteItem(i); + } + return 0; +} + +// Help + +LRESULT ADLSearchFrame::onHelpButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) { + HtmlHelp(m_hWnd, WinUtil::getHelpFile().c_str(), HH_HELP_CONTEXT, IDR_ADLSEARCH); + return 0; +} + +LRESULT ADLSearchFrame::onHelpKey(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) +{ + HtmlHelp(m_hWnd, WinUtil::getHelpFile().c_str(), HH_HELP_CONTEXT, IDR_ADLSEARCH); + return 0; +} + +// Move selected entries up one step +LRESULT ADLSearchFrame::onMoveUp(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +{ + ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection; + + // Get selection + vector<int> sel; + int i = -1; + while((i = ctrlList.GetNextItem(i, LVNI_SELECTED)) >= 0) + { + sel.push_back(i); + } + if(sel.size() < 1) + { + return 0; + } + + // Find out where to insert + int i0 = sel[0]; + if(i0 > 0) + { + i0 = i0 - 1; + } + + // Backup selected searches + ADLSearchManager::SearchCollection backup; + for(i = 0; i < (int)sel.size(); ++i) + { + backup.push_back(collection[sel[i]]); + } + + // Erase selected searches + for(i = sel.size() - 1; i >= 0; --i) + { + collection.erase(collection.begin() + sel[i]); + } + + // Insert (grouped together) + for(i = 0; i < (int)sel.size(); ++i) + { + collection.insert(collection.begin() + i0 + i, backup[i]); + } + + // Update UI + LoadAll(); + + // Restore selection + for(i = 0; i < (int)sel.size(); ++i) + { + ctrlList.SetItemState(i0 + i, LVNI_SELECTED, LVNI_SELECTED); + } + + return 0; +} + +// Move selected entries down one step +LRESULT ADLSearchFrame::onMoveDown(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) +{ + ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection; + + // Get selection + vector<int> sel; + int i = -1; + while((i = ctrlList.GetNextItem(i, LVNI_SELECTED)) >= 0) + { + sel.push_back(i); + } + if(sel.size() < 1) + { + return 0; + } + + // Find out where to insert + int i0 = sel[sel.size() - 1] + 2; + if(i0 > (int)collection.size()) + { + i0 = collection.size(); + } + + // Backup selected searches + ADLSearchManager::SearchCollection backup; + for(i = 0; i < (int)sel.size(); ++i) + { + backup.push_back(collection[sel[i]]); + } + + // Erase selected searches + for(i = sel.size() - 1; i >= 0; --i) + { + collection.erase(collection.begin() + sel[i]); + if(i < i0) + { + i0--; + } + } + + // Insert (grouped together) + for(i = 0; i < (int)sel.size(); ++i) + { + collection.insert(collection.begin() + i0 + i, backup[i]); + } + + // Update UI + LoadAll(); + + // Restore selection + for(i = 0; i < (int)sel.size(); ++i) + { + ctrlList.SetItemState(i0 + i, LVNI_SELECTED, LVNI_SELECTED); + } + ctrlList.EnsureVisible(i0, FALSE); + + return 0; +} + +// Clicked 'Active' check box +LRESULT ADLSearchFrame::onItemChanged(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) +{ + NMITEMACTIVATE* item = (NMITEMACTIVATE*)pnmh; + + if((item->uChanged & LVIF_STATE) == 0) + return 0; + if((item->uOldState & INDEXTOSTATEIMAGEMASK(0xf)) == 0) + return 0; + if((item->uNewState & INDEXTOSTATEIMAGEMASK(0xf)) == 0) + return 0; + + if(item->iItem >= 0) + { + // Set new active status check box + ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection; + ADLSearch& search = collection[item->iItem]; + search.isActive = (ctrlList.GetCheckState(item->iItem) != 0); + } + return 0; +} + +// Double-click on list control +LRESULT ADLSearchFrame::onDoubleClickList(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/) +{ + NMITEMACTIVATE* item = (NMITEMACTIVATE*)pnmh; + + if(item->iItem >= 0) { + // Treat as onEdit command + PostMessage(WM_COMMAND, IDC_EDIT, 0); + } else if(item->iItem == -1) { + PostMessage(WM_COMMAND, IDC_ADD, 0); + } + + return 0; +} + +// Load all searches from manager +void ADLSearchFrame::LoadAll() +{ + // Clear current contents + ctrlList.DeleteAllItems(); + + // Load all searches + ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection; + for(unsigned long l = 0; l < collection.size(); l++) + { + UpdateSearch(l, FALSE); + } +} + +// Update a specific search item +void ADLSearchFrame::UpdateSearch(int index, BOOL doDelete) +{ + ADLSearchManager::SearchCollection& collection = ADLSearchManager::getInstance()->collection; + + // Check args + if(index >= (int)collection.size()) + { + return; + } + ADLSearch& search = collection[index]; + + // Delete from list control + if(doDelete) + { + ctrlList.DeleteItem(index); + } + + // Generate values + TStringList line; + tstring fs; + line.push_back(Text::toT(search.searchString)); + line.push_back(search.SourceTypeToDisplayString(search.sourceType)); + line.push_back(Text::toT(search.destDir)); + + fs = _T(""); + if(search.minFileSize >= 0) + { + fs = Text::toT(Util::toString(search.minFileSize)); + fs += _T(" "); + fs += search.SizeTypeToDisplayString(search.typeFileSize); + } + line.push_back(fs); + + fs = _T(""); + if(search.maxFileSize >= 0) + { + fs = Text::toT(Util::toString(search.maxFileSize)); + fs += _T(" "); + fs += search.SizeTypeToDisplayString(search.typeFileSize); + } + line.push_back(fs); + + // Insert in list control + ctrlList.insert(index, line); + + // Update 'Active' check box + ctrlList.SetCheckState(index, search.isActive); +} + +#endif#endif Copied: dcplusplus/trunk/win32/ADLSearchFrame.h (from rev 700, dcplusplus/trunk/windows/ADLSearchFrame.h) =================================================================== --- dcplusplus/trunk/win32/ADLSearchFrame.h (rev 0) +++ dcplusplus/trunk/win32/ADLSearchFrame.h 2007-02-27 09:39:02 UTC (rev 701) @@ -0,0 +1,144 @@ +/* + * Copyright (C) 2001-2006 Jacek Sieka, arnetheduck on gmail point com + * + * This program 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 program 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 program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/* + * Automatic Directory Listing Search + * Henrik Engstr�m, henrikengstrom on home point se + */ + +#if !defined(ADL_SEARCH_FRAME_H) +#define ADL_SEARCH_FRAME_H + +#if _MSC_VER > 1000 +#pragma once +#endif // _MSC_VER > 1000 + +#include "FlatTabCtrl.h" +#include "ExListViewCtrl.h" +#include "WinUtil.h" + +#include "../client/ADLSearch.h" + +/////////////////////////////////////////////////////////////////////////////// +// +// Class that represent an ADL search manager interface +// +/////////////////////////////////////////////////////////////////////////////// +class ADLSearchFrame : public MDITabChildWindowImpl<ADLSearchFrame>, public StaticFrame<ADLSearchFrame, ResourceManager::ADL_SEARCH> +{ +public: + + // Base class typedef + typedef MDITabChildWindowImpl<ADLSearchFrame> baseClass; + + // Constructor/destructor + ADLSearchFrame() {} + virtual ~ADLSearchFrame() { } + + // Frame window declaration + DECLARE_FRAME_WND_CLASS_EX(_T("ADLSearchFrame"), IDR_ADLSEARCH, 0, COLOR_3DFACE); + + // Inline message map + BEGIN_MSG_MAP(ADLSearchFrame) + MESSAGE_HANDLER(WM_CREATE, onCreate) + MESSAGE_HANDLER(WM_CLOSE, onClose) + MESSAGE_HANDLER(WM_CTLCOLOREDIT, onCtlColor) + MESSAGE_HANDLER(WM_CTLCOLORSTATIC, onCtlColor) + MESSAGE_HANDLER(WM_CONTEXTMENU, onContextMenu) + MESSAGE_HANDLER(WM_HELP, onHelpKey) + COMMAND_ID_HANDLER(IDC_ADD, onAdd) + COMMAND_ID_HANDLER(IDC_EDIT, onEdit) + COMMAND_ID_HANDLER(IDC_REMOVE, onRemove) + COMMAND_ID_HANDLER(IDC_HELP_FAQ, onHelpButton) + COMMAND_ID_HANDLER(IDC_MOVE_UP, onMoveUp) + COMMAND_ID_HANDLER(IDC_MOVE_DOWN, onMoveDown) + NOTIFY_HANDLER(IDC_ADLLIST, NM_DBLCLK, onDoubleClickList) + NOTIFY_HANDLER(IDC_ADLLIST, LVN_ITEMCHANGED, onItemChanged) + NOTIFY_HANDLER(IDC_ADLLIST, LVN_KEYDOWN, onKeyDown) + CHAIN_MSG_MAP(baseClass) + END_MSG_MAP() + + // Message handlers + LRESULT onCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT onClose(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled); + LRESULT onAdd(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT onEdit(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT onRemove(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT onHelpButton(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); + LRESULT onHelpKey(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); + LRESULT onMoveUp(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT onMoveDown(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled); + LRESULT onDoubleClickList(int idCtrl, LPNMHDR pnmh, BOOL& bHandled); + LRESULT onItemChanged(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/); + LRESULT onKeyDown(int /*idCtrl*/, LPNMHDR pnmh, BOOL& /*bHandled*/); + LRESULT onContextMenu(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& bHandled); + LRESULT onChar(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& bHandled); + + // Update colors + LRESULT onCtlColor(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled) + { + HWND hWnd = (HWND)lParam; + HDC hDC = (HDC)wParam; + if(hWnd == ctrlList.m_hWnd) + { + ::SetBkColor(hDC, WinUtil::bgColor); + ::SetTextColor(hDC, WinUtil::textColor); + return (LRESULT)WinUtil::bgBrush; + } + bHandled = FALSE; + return FALSE; + } + + // Update control layouts + void UpdateLayout(BOOL bResizeBars = TRUE); + +private: + + // Communication with manager + void LoadAll(); + void UpdateSearch(int index, BOOL doDelete = TRUE); + + // Contained controls + CStatusBarCtrl ctrlStatus; + ExListViewCtrl ctrlList; + CButton ctrlAdd; + CButto... [truncated message content] |