pywin32-checkins Mailing List for Python for Windows Extensions (Page 144)
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
You can subscribe to this list here.
2003 |
Jan
|
Feb
|
Mar
|
Apr
(2) |
May
(1) |
Jun
(6) |
Jul
(50) |
Aug
(11) |
Sep
(24) |
Oct
(184) |
Nov
(118) |
Dec
(22) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2004 |
Jan
(31) |
Feb
(25) |
Mar
(34) |
Apr
(105) |
May
(49) |
Jun
(38) |
Jul
(39) |
Aug
(7) |
Sep
(98) |
Oct
(79) |
Nov
(20) |
Dec
(17) |
2005 |
Jan
(66) |
Feb
(32) |
Mar
(43) |
Apr
(30) |
May
(58) |
Jun
(30) |
Jul
(16) |
Aug
(4) |
Sep
(21) |
Oct
(42) |
Nov
(11) |
Dec
(14) |
2006 |
Jan
(42) |
Feb
(30) |
Mar
(22) |
Apr
(1) |
May
(9) |
Jun
(15) |
Jul
(20) |
Aug
(9) |
Sep
(8) |
Oct
(1) |
Nov
(9) |
Dec
(43) |
2007 |
Jan
(52) |
Feb
(45) |
Mar
(20) |
Apr
(12) |
May
(59) |
Jun
(39) |
Jul
(35) |
Aug
(31) |
Sep
(17) |
Oct
(20) |
Nov
(4) |
Dec
(4) |
2008 |
Jan
(28) |
Feb
(111) |
Mar
(4) |
Apr
(27) |
May
(40) |
Jun
(27) |
Jul
(32) |
Aug
(94) |
Sep
(87) |
Oct
(153) |
Nov
(336) |
Dec
(331) |
2009 |
Jan
(298) |
Feb
(127) |
Mar
(20) |
Apr
(8) |
May
|
Jun
(10) |
Jul
(6) |
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
2010 |
Jan
(7) |
Feb
(1) |
Mar
|
Apr
|
May
(15) |
Jun
(4) |
Jul
(3) |
Aug
(28) |
Sep
(1) |
Oct
(19) |
Nov
(16) |
Dec
(6) |
2011 |
Jan
(2) |
Feb
(18) |
Mar
(17) |
Apr
(12) |
May
(5) |
Jun
(11) |
Jul
(7) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(4) |
Dec
|
2012 |
Jan
(6) |
Feb
(2) |
Mar
|
Apr
(8) |
May
(4) |
Jun
(3) |
Jul
(13) |
Aug
(27) |
Sep
(8) |
Oct
(9) |
Nov
(3) |
Dec
(2) |
2013 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
(10) |
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(9) |
2014 |
Jan
(2) |
Feb
(4) |
Mar
(4) |
Apr
(1) |
May
(4) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
(2) |
Nov
|
Dec
(1) |
2015 |
Jan
(1) |
Feb
|
Mar
|
Apr
(6) |
May
(2) |
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
(3) |
Feb
(2) |
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: <mha...@us...> - 2003-11-25 10:46:12
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers In directory sc8-pr-cvs1:/tmp/cvs-serv9966 Modified Files: shell_view.py Log Message: Implement GetDisplayNameOf correctly for our classes/methods, remove a scintilla "Colourise" call that isn't needed, and add lots of comments about PIDLs. Index: shell_view.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers/shell_view.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** shell_view.py 24 Nov 2003 09:25:17 -0000 1.3 --- shell_view.py 25 Nov 2003 02:02:47 -0000 1.4 *************** *** 9,13 **** # display the file using Scintilla. # Known problems: ! # * Classes and methods don't have icons import sys, os --- 9,49 ---- # display the file using Scintilla. # Known problems: ! # * Classes and methods don't have icons - this is a demo, so we keep it small ! # See icon_handler.py for examples of how to work with icons. ! # ! # ! # Notes on PIDLs ! # PIDLS are complicated, but fairly well documented in MSDN. If you need to ! # do much with these shell extensions, you must understand their concept. ! # Here is a short-course, as it applies to this sample: ! # A PIDL identifies an item, much in the same way that a filename does ! # (however, the shell is not limited to displaying "files"). ! # An "ItemID" is a single string, each being an item in the hierarchy. ! # A "PIDL" is a list of these strings. ! # All shell etc functions work with PIDLs, so even in the case where ! # an ItemID is conceptually used, a 1-item list is always used. ! # Conceptually, think of: ! # pidl = pathname.split("\\") # pidl is a list of "parent" items. ! # # each item is a string 'item id', but these are ever used directly ! # As there is no concept of passing a single item, to open a file using only ! # a relative filename, conceptually you would say: ! # open_file([filename]) # Pass a single-itemed relative "PIDL" ! # and continuing the analogy, a "listdir" type function would return a list ! # of single-itemed lists - each list containing the relative PIDL of the child. ! # ! # Each PIDL entry is a binary string, and may contain any character. For ! # PIDLs not created by you, they can not be interpreted - they are just ! # blobs. PIDLs created by you (ie, children of your IShellFolder) can ! # store and interpret the string however makes most sense for your application. ! # (but within PIDL rules - they must be persistable, etc) ! # There is no reason that pickled strings, for example, couldn't be used ! # as an EntryID. ! # This application takes a simple approach - each PIDL is a string of form ! # "directory\0directory_name", "file\0file_name" or ! # "object\0file_name\0class_name[.method_name" ! # The first string in each example is literal (ie, the word 'directory', ! # 'file' or 'object', and every other string is variable. We use '\0' as ! # a field sep just 'cos we can (and 'cos it can't possibly conflict with the ! # string content) import sys, os *************** *** 22,25 **** --- 58,63 ---- from pywin.scintilla import scintillacon + # Set this to 1 to cause debug version to be registered and used. A debug + # version will spew output to win32traceutil. debug=0 *************** *** 209,213 **** assert len(pidl)==1, "Expecting relative PIDL" typ, fname, obname = pidl[0].split('\0') ! return obname def CreateViewObject(self, hwnd, iid): --- 247,257 ---- assert len(pidl)==1, "Expecting relative PIDL" typ, fname, obname = pidl[0].split('\0') ! fqname = os.path.splitext(fname)[0] + "." + obname ! if flags & shellcon.SHGDN_INFOLDER: ! ret = obname ! else: # SHGDN_NORMAL is the default ! ret = fqname ! # No need to look at the SHGDN_FOR* modifiers. ! return ret def CreateViewObject(self, hwnd, iid): *************** *** 246,251 **** assert len(pidl)==1, "Expecting relative PIDL" typ, fname, obname = pidl[0].split('\0') ! class_name, method_name = obname.split('.') ! return method_name def GetAttributesOf(self, pidls, attrFlags): ret_flags = -1 --- 290,301 ---- assert len(pidl)==1, "Expecting relative PIDL" typ, fname, obname = pidl[0].split('\0') ! class_name, method_name = obname.split(".") ! fqname = os.path.splitext(fname)[0] + "." + obname ! if flags & shellcon.SHGDN_INFOLDER: ! ret = method_name ! else: # SHGDN_NORMAL is the default ! ret = fqname ! # No need to look at the SHGDN_FOR* modifiers. ! return ret def GetAttributesOf(self, pidls, attrFlags): ret_flags = -1 *************** *** 259,262 **** --- 309,313 ---- # The "Root" folder of our namespace. As all children are directories, # it is derived from ShellFolderFileSystem + # This is the only COM object actually registered and externally created. class ShellFolderRoot(ShellFolderFileSystem): _reg_progid_ = "Python.ShellExtension.Folder" *************** *** 266,269 **** --- 317,323 ---- return self._reg_clsid_ def Initialize(self, pidl): + # This is the PIDL of us, as created by the shell. This is our + # top-level ID. All other items under us have PIDLs defined + # by us - see the notes at the top of the file. #print "Initialize called with pidl", repr(pidl) pass *************** *** 276,280 **** # A Simple shell view implementation ! # Our shell extension. class ScintillaShellView: _public_methods_ = IShellView_Methods --- 330,335 ---- # A Simple shell view implementation ! # This uses scintilla to display a filename, and optionally jump to a line ! # number. class ScintillaShellView: _public_methods_ = IShellView_Methods *************** *** 289,293 **** def _SendSci(self, msg, wparam=0, lparam=0): return win32gui.SendMessage(self.hwnd, msg, wparam, lparam) - # IShellView def CreateViewWindow(self, prev, settings, browser, rect): --- 344,347 ---- *************** *** 318,325 **** self._SetupLexer() self._SendSci(scintillacon.SCI_SETTEXT, 0, file_data) - self._SendSci(scintillacon.SCI_COLOURISE, 0, -1) if self.lineno != None: self._SendSci(scintillacon.SCI_GOTOLINE, self.lineno) ! print "Made scintilla", self.hwnd def _SetupLexer(self): --- 372,378 ---- self._SetupLexer() self._SendSci(scintillacon.SCI_SETTEXT, 0, file_data) if self.lineno != None: self._SendSci(scintillacon.SCI_GOTOLINE, self.lineno) ! print "Scintilla's hwnd is", self.hwnd def _SetupLexer(self): *************** *** 343,347 **** self._SendSci(scintillacon.SCI_SETLEXER, scintillacon.SCLEX_PYTHON, 0) self._SendSci(scintillacon.SCI_SETSTYLEBITS, 5) - print "Got back lexer", win32gui.SendMessage(self.hwnd, scintillacon.SCI_GETLEXER) baseFormat = (-402653169, 0, 200, 0, 0, 0, 49, 'Courier New') for f, bg, stylenum in styles: --- 396,399 ---- |
From: <mha...@us...> - 2003-11-25 10:43:16
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1:/tmp/cvs-serv7399/win32/lib Modified Files: pywintypes.py Log Message: Try and locate the extension on os.environ["PATH"], rather than relying on LoadLibrary, as LoadLib uses the System32 directory before PATH. Mainly for distutils, which can ensure the SYSTEM32 pywintypes is *not* loaded. Index: pywintypes.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/pywintypes.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** pywintypes.py 31 Oct 2003 23:47:46 -0000 1.6 --- pywintypes.py 25 Nov 2003 10:26:23 -0000 1.7 *************** *** 15,19 **** else: suffix = "" ! filename = "%s%d%d%s.dll" % (modname, sys.version_info[0], sys.version_info[1], suffix) if hasattr(sys, "frozen"): # If we are running from a frozen program (py2exe, McMillan, freeze) --- 15,20 ---- else: suffix = "" ! filename = "%s%d%d%s.dll" % \ ! (modname, sys.version_info[0], sys.version_info[1], suffix) if hasattr(sys, "frozen"): # If we are running from a frozen program (py2exe, McMillan, freeze) *************** *** 28,47 **** break else: ! raise ImportError, "Module '%s' isn't in frozen sys.path directories" % modname else: ! if os.path.isfile(os.path.join(sys.prefix, filename)): ! found = os.path.join(sys.prefix, filename) else: ! # We could still avoid win32api here, but... import win32api # Normal Python needs these files in a directory somewhere on ! # %PATH%, so let Windows search it out for us ! h = win32api.LoadLibrary(filename) found = win32api.GetModuleFileName(h) # Python can load the module ! mod = imp.load_module(modname, None, found, ('.dll', 'rb', imp.C_EXTENSION)) # and fill our namespace with it. globs.update(mod.__dict__) __import_pywin32_system_module__("pywintypes", globals()) - --- 29,55 ---- break else: ! raise ImportError, \ ! "Module '%s' isn't in frozen sys.path directories" % modname else: ! search_dirs = [sys.prefix] + \ ! os.environ.get("PATH", "").split(os.pathsep) ! for d in search_dirs: ! found = os.path.join(d, filename) ! if os.path.isfile(found): ! break else: ! # Eeek - can't find on the path. Try "LoadLibrary", as it ! # has slightly different semantics than a simple sys.path search import win32api # Normal Python needs these files in a directory somewhere on ! # %PATH%, so let Windows search it out for us. As win32api ! # loads pywintypes, we can simple get the module after the import ! h = win32api.GetModuleHandle(filename) found = win32api.GetModuleFileName(h) # Python can load the module ! mod = imp.load_module(modname, None, found, ! ('.dll', 'rb', imp.C_EXTENSION)) # and fill our namespace with it. globs.update(mod.__dict__) __import_pywin32_system_module__("pywintypes", globals()) |
From: <mha...@us...> - 2003-11-25 10:43:16
|
Update of /cvsroot/pywin32/pywin32/com/win32com/client In directory sc8-pr-cvs1:/tmp/cvs-serv11339 Modified Files: genpy.py build.py Log Message: Fix a bug where function names that were also builtin names were changed, causing needless errors in existing code that used functions called, eg, "open". Constant names that maktch builtin names are still mangled. Index: genpy.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/genpy.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** genpy.py 28 Oct 2003 21:26:45 -0000 1.36 --- genpy.py 25 Nov 2003 10:43:10 -0000 1.37 *************** *** 24,28 **** error = "makepy.error" ! makepy_version = "0.4.8" # Written to generated file. GEN_FULL="full" --- 24,28 ---- error = "makepy.error" ! makepy_version = "0.4.9" # Written to generated file. GEN_FULL="full" *************** *** 215,219 **** else: use = repr(str(val)) ! print "\t%-30s=%-10s # from enum %s" % (build.MakePublicAttributeName(name), use, enumName) class VTableItem(build.VTableItem, WritableItem): --- 215,220 ---- else: use = repr(str(val)) ! print "\t%-30s=%-10s # from enum %s" % \ ! (build.MakePublicAttributeName(name, True), use, enumName) class VTableItem(build.VTableItem, WritableItem): Index: build.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/client/build.py,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** build.py 23 Oct 2003 07:15:30 -0000 1.24 --- build.py 25 Nov 2003 10:43:11 -0000 1.25 *************** *** 494,498 **** # Given a "public name" (eg, the name of a class, function, etc) # make sure it is a legal (and reasonable!) Python name. ! def MakePublicAttributeName(className): # Given a class attribute that needs to be public, convert it to a # reasonable name. --- 494,498 ---- # Given a "public name" (eg, the name of a class, function, etc) # make sure it is a legal (and reasonable!) Python name. ! def MakePublicAttributeName(className, is_global = False): # Given a class attribute that needs to be public, convert it to a # reasonable name. *************** *** 500,508 **** # create duplicates - eg, just removing a leading "_" is likely to cause # a clash. if className[:2]=='__' and className[-2:]!='__': return className[1:] + '_' # First '_' moved at the end. elif iskeyword(className): # all keywords are lower case return string.capitalize(className) ! elif __builtins__.has_key(className): # builtins may be mixed case. If capitalizing it doesn't change it, # force to all uppercase (eg, "None", "True" become "NONE", "TRUE" --- 500,510 ---- # create duplicates - eg, just removing a leading "_" is likely to cause # a clash. + # if is_global is True, then the name is a global variable that may + # overwrite a builtin - eg, "None" if className[:2]=='__' and className[-2:]!='__': return className[1:] + '_' # First '_' moved at the end. elif iskeyword(className): # all keywords are lower case return string.capitalize(className) ! elif is_global and __builtins__.has_key(className): # builtins may be mixed case. If capitalizing it doesn't change it, # force to all uppercase (eg, "None", "True" become "NONE", "TRUE" |
From: <mha...@us...> - 2003-11-25 06:29:35
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1:/tmp/cvs-serv23049 Modified Files: PyWinTypes.h Log Message: Oops - forgot the return type on function proto (and msvc didn't complain!) Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PyWinTypes.h 24 Nov 2003 09:13:11 -0000 1.18 --- PyWinTypes.h 25 Nov 2003 03:24:02 -0000 1.19 *************** *** 172,176 **** #ifndef MS_WINCE // String support for buffers allocated via a function of your choice. ! PYWINTYPES_EXPORT PyWinObject_AsPfnAllocatedWCHAR(PyObject *stringObject, void *(*pfnAllocator)(ULONG), WCHAR **ppResult, --- 172,176 ---- #ifndef MS_WINCE // String support for buffers allocated via a function of your choice. ! PYWINTYPES_EXPORT BOOL PyWinObject_AsPfnAllocatedWCHAR(PyObject *stringObject, void *(*pfnAllocator)(ULONG), WCHAR **ppResult, |
From: <mha...@us...> - 2003-11-25 06:29:25
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1:/tmp/cvs-serv8756 Modified Files: testall.py Log Message: Print a row of markers to save me trying to estimate the no of dots :) Index: testall.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/testall.py,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** testall.py 10 Nov 2003 00:49:29 -0000 1.19 --- testall.py 25 Nov 2003 05:07:24 -0000 1.20 *************** *** 172,175 **** --- 172,178 ---- print "Executing level %d tests - %d test cases will be run" \ % (testLevel, suite.countTestCases()) + if verbosity==1: + # A little row of markers so the dots show how close to finished + print '|' * suite.countTestCases() testRunner = unittest.TextTestRunner(verbosity=verbosity) testResult = testRunner.run(suite) |
From: <ru...@us...> - 2003-11-25 06:28:44
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1:/tmp/cvs-serv12082/win32/src Modified Files: PyACL.cpp PySecurityObjects.h PyWinTypesmodule.cpp Log Message: Add AddAccessAllowedAceEx, AddAccessDeniedAceEx, and AddAuditAccessAceEx Index: PyACL.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyACL.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyACL.cpp 7 Nov 2003 03:58:17 -0000 1.6 --- PyACL.cpp 25 Nov 2003 05:19:58 -0000 1.7 *************** *** 10,13 **** --- 10,17 ---- #include "aclapi.h" + BOOL (WINAPI *addaccessallowedaceex)(PACL, DWORD, DWORD, DWORD, PSID)=NULL; + BOOL (WINAPI *addaccessdeniedaceex)(PACL, DWORD, DWORD, DWORD, PSID)=NULL; + BOOL (WINAPI *addauditaccessaceex)(PACL, DWORD, DWORD, DWORD, PSID, BOOL, BOOL)=NULL; + // @pymethod <o PyACL>|pywintypes|ACL|Creates a new ACL object PyObject *PyWinMethod_NewACL(PyObject *self, PyObject *args) *************** *** 406,409 **** --- 410,455 ---- } + // @pymethod |PyACL|AddAccessAllowedAceEx|Add access allowed ACE to an ACL with ACE flags (Requires Win2k or higher) + PyObject *PyACL::AddAccessAllowedAceEx(PyObject *self, PyObject *args) + { + DWORD access,revision,aceflags; + PyObject *obSID; + PSID psid; + PyACL *This = (PyACL *)self; + PACL pdacl = This->GetACL(); + PACL pdacl_padded=NULL; + if (addaccessallowedaceex==NULL) + return PyErr_Format(PyExc_NotImplementedError,"AddAccessAllowedAceEx not supported by this version of Windows"); + // @pyparm int|revision||Must be at least ACL_REVISION_DS + // @pyparm int|aceflags||Combination of ACE inheritance flags (CONTAINER_INHERIT_ACE,INHERIT_ONLY_ACE,INHERITED_ACE,NO_PROPAGATE_INHERIT_ACE, and OBJECT_INHERIT_ACE) + // @pyparm int|access||Specifies the mask of access rights to be granted to the specified SID. + // @pyparm <o PySID>|sid||A SID object representing a user, group, or logon account being granted access. + if (!PyArg_ParseTuple(args, "lllO:AddAccessAllowedAceEx", &revision, &aceflags, &access, &obSID)) + return NULL; + if (!PyWinObject_AsSID(obSID, &psid, FALSE)) + return NULL; + if (!(*addaccessallowedaceex)(pdacl, revision, aceflags, access, psid)){ + DWORD err=GetLastError(); + if (err != ERROR_ALLOTTED_SPACE_EXCEEDED) + return PyWin_SetAPIError("AddAccessAllowedAceEx", err); + // resize if dacl too small + unsigned short required_size=pdacl->AclSize + sizeof(ACCESS_ALLOWED_ACE) + GetLengthSid(psid); + pdacl_padded = (ACL *)malloc(required_size); + ZeroMemory (pdacl_padded, required_size); + memcpy(pdacl_padded,pdacl,pdacl->AclSize); + pdacl_padded->AclSize = required_size; + if (!(*addaccessallowedaceex)(pdacl_padded, revision, aceflags, access, psid)){ + free (pdacl_padded); + return PyWin_SetAPIError("AddAccessAllowedAceEx"); + } + This->SetACL(pdacl_padded); + } + if (pdacl_padded) + free(pdacl_padded); + Py_INCREF(Py_None); + return Py_None; + + } + // @pymethod |PyACL|AddAccessDeniedAce|Adds an access-denied ACE to an ACL object. The access is denied to a specified SID. PyObject *PyACL::AddAccessDeniedAce(PyObject *self, PyObject *args) *************** *** 471,474 **** --- 517,570 ---- } + // @pymethod |PyACL|AddAccessDeniedAceEx|Add access denied ACE to an ACL with ACE flags (Requires Win2k or higher) + PyObject *PyACL::AddAccessDeniedAceEx(PyObject *self, PyObject *args) + { + DWORD access,revision,aceflags; + PyObject *obSID=NULL, *ret=NULL; + PSID psid; + PyACL *This = (PyACL *)self; + PACL pdacl = This->GetACL(); + PACL pdacl_padded=NULL; + if (addaccessdeniedaceex==NULL) + return PyErr_Format(PyExc_NotImplementedError,"AddAccessDeniedAceEx not supported by this version of Windows"); + // @pyparm int|revision||Must be at least ACL_REVISION_DS + // @pyparm int|aceflags||Combination of ACE inheritance flags (CONTAINER_INHERIT_ACE,INHERIT_ONLY_ACE,INHERITED_ACE,NO_PROPAGATE_INHERIT_ACE, and OBJECT_INHERIT_ACE) + // @pyparm int|access||Specifies the mask of access rights to be denied to the specified SID. + // @pyparm <o PySID>|sid||A SID object representing a user, group, or logon account being denied access. + if (!PyArg_ParseTuple(args, "lllO:AddAccessDeniedAceEx", &revision, &aceflags, &access, &obSID)) + return NULL; + if (!PyWinObject_AsSID(obSID, &psid, FALSE)) + return NULL; + if (!(*addaccessdeniedaceex)(pdacl, revision, aceflags, access, psid)){ + DWORD err=GetLastError(); + if (err != ERROR_ALLOTTED_SPACE_EXCEEDED) + return PyWin_SetAPIError("AddAccessDeniedAceEx", err); + // resize if dacl too small + unsigned short required_size=pdacl->AclSize + sizeof(ACCESS_DENIED_ACE) + GetLengthSid(psid); + pdacl_padded = (ACL *)malloc(required_size); + ZeroMemory (pdacl_padded, required_size); + memcpy(pdacl_padded,pdacl,pdacl->AclSize); + pdacl_padded->AclSize = required_size; + if (!(*addaccessdeniedaceex)(pdacl_padded, revision, aceflags, access, psid)){ + free (pdacl_padded); + return PyWin_SetAPIError("AddAccessDeniedAceEx"); + } + if (!_ReorderACL(pdacl_padded)) + goto done; + This->SetACL(pdacl_padded); + } + else{ + if (!_ReorderACL(pdacl)) + goto done; + } + ret=Py_None; + done: + if (pdacl_padded) + free(pdacl_padded); + Py_XINCREF(ret); + return ret; + + } + // AddAuditAccessAce // @pymethod |PyACL|AddAuditAccessAce|Adds an audit ACE to a Sacl *************** *** 516,519 **** --- 612,662 ---- } + // @pymethod |PyACL|AddAuditAccessAceEx|Adds an audit ACE to an Sacl, includes ace flags + PyObject *PyACL::AddAuditAccessAceEx(PyObject *self, PyObject *args) + { + DWORD accessmask,acerevision, aceflags; + BOOL bAuditSuccess, bAuditFailure; + PyObject *obSID; + PSID psid; + PACL psacl; + PyACL *This = (PyACL *)self; + psacl = This->GetACL(); + PACL psacl_padded=NULL; + if (addauditaccessaceex==NULL) + return PyErr_Format(PyExc_NotImplementedError,"AddAuditAccessAceEx not supported by this version of Windows"); + + // @pyparm int|dwAceRevision||Revision of ACL: Must be at least ACL_REVISION_DS + // @pyparm int|AceFlags||Combination of FAILED_ACCESS_ACE_FLAG,SUCCESSFUL_ACCESS_ACE_FLAG,CONTAINER_INHERIT_ACE,INHERIT_ONLY_ACE,INHERITED_ACE,NO_PROPAGATE_INHERIT_ACE and OBJECT_INHERIT_ACE + // @pyparm int|dwAccessMask||Bitmask of access types to be audited + // @pyparm <o PySID>|sid||SID for whom system audit messages will be generated + // @pyparm int|bAuditSuccess||Set to 1 if access success should be audited, else 0 + // @pyparm int|bAuditFailure||Set to 1 if access failure should be audited, else 0 + + if (!PyArg_ParseTuple(args, "lllOii:AddAuditAccessAceEx", &acerevision, &aceflags, &accessmask, &obSID, &bAuditSuccess, &bAuditFailure)) + return NULL; + if (!PyWinObject_AsSID(obSID, &psid, FALSE)) + return NULL; + if (!(*addauditaccessaceex)(psacl, acerevision, aceflags, accessmask, psid, bAuditSuccess, bAuditFailure)){ + DWORD err=GetLastError(); + if (err != ERROR_ALLOTTED_SPACE_EXCEEDED) + return PyWin_SetAPIError("AddAuditAccessAceEx", err); + // resize if acl too small + unsigned short required_size=psacl->AclSize + sizeof(SYSTEM_AUDIT_ACE) + GetLengthSid(psid); + psacl_padded = (ACL *)malloc(required_size); + ZeroMemory (psacl_padded, required_size); + memcpy(psacl_padded,psacl,psacl->AclSize); + psacl_padded->AclSize = required_size; + if (!(*addauditaccessaceex)(psacl_padded, acerevision, aceflags, accessmask, psid, bAuditSuccess, bAuditFailure)){ + free (psacl_padded); + return PyWin_SetAPIError("AddAuditAccessAceEx"); + } + This->SetACL(psacl_padded); + } + if (psacl_padded) + free(psacl_padded); + Py_INCREF(Py_None); + return Py_None; + } + // @pymethod |PyACL|GetAclSize|Returns the storage size of the ACL. PyObject *PyACL::GetAclSize(PyObject *self, PyObject *args) *************** *** 529,533 **** } ! // @pymethod |PyACL|GetAclSize|Returns the storage size of the ACL. PyObject *PyACL::GetAclRevision(PyObject *self, PyObject *args) { --- 672,676 ---- } ! // @pymethod |PyACL|GetAclRevision|Returns revision of the ACL. PyObject *PyACL::GetAclRevision(PyObject *self, PyObject *args) { *************** *** 641,646 **** {"IsValid", PyACL::IsValid, 1}, // @pymeth IsValid|Validate the ACL. {"AddAccessAllowedAce", PyACL::AddAccessAllowedAce, 1}, // @pymeth AddAccessAllowedAce|Adds an access-allowed ACE to an ACL object. ! {"AddAccessDeniedAce", PyACL::AddAccessDeniedAce, 1}, // @pymeth AddAccessDeniedAce|Adds an access-denied ACE to an ACL object. ! {"AddAuditAccessAce", PyACL::AddAuditAccessAce, 1}, // @pymeth AddAuditAccessAce|Adds an audit entry to a system access control list (SACL) {"GetAclSize", PyACL::GetAclSize, 1}, // @pymeth GetAclSize|Returns the storage size of the ACL. {"GetAclRevision", PyACL::GetAclRevision, 1}, // @pymeth GetAclRevision|Returns the revision nbr of the ACL. --- 784,792 ---- {"IsValid", PyACL::IsValid, 1}, // @pymeth IsValid|Validate the ACL. {"AddAccessAllowedAce", PyACL::AddAccessAllowedAce, 1}, // @pymeth AddAccessAllowedAce|Adds an access-allowed ACE to an ACL object. ! {"AddAccessAllowedAceEx", PyACL::AddAccessAllowedAceEx, 1}, // @pymeth AddAccessAllowedAceEx|Same as AddAccessAllowedAce, with addition of ace flags ! {"AddAccessDeniedAce", PyACL::AddAccessDeniedAce, 1}, // @pymeth AddAccessDeniedAce|Adds an access-denied ACE to an ACL object. ! {"AddAccessDeniedAceEx", PyACL::AddAccessDeniedAceEx, 1}, // @pymeth AddAccessDeniedAceEx|Adds an access-denied ACE to an ACL object ! {"AddAuditAccessAce", PyACL::AddAuditAccessAce, 1}, // @pymeth AddAuditAccessAce|Adds an audit entry to a system access control list (SACL) ! {"AddAuditAccessAceEx", PyACL::AddAuditAccessAceEx, 1}, // @pymeth AddAuditAccessAceEx|Adds an audit ACE to an SACL with inheritance flags {"GetAclSize", PyACL::GetAclSize, 1}, // @pymeth GetAclSize|Returns the storage size of the ACL. {"GetAclRevision", PyACL::GetAclRevision, 1}, // @pymeth GetAclRevision|Returns the revision nbr of the ACL. Index: PySecurityObjects.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PySecurityObjects.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PySecurityObjects.h 10 Mar 2003 01:18:16 -0000 1.7 --- PySecurityObjects.h 25 Nov 2003 05:19:58 -0000 1.8 *************** *** 4,7 **** --- 4,11 ---- #ifndef MS_WINCE /* Not on CE */ + extern BOOL (WINAPI *addaccessallowedaceex)(PACL, DWORD, DWORD, DWORD, PSID); + extern BOOL (WINAPI *addaccessdeniedaceex)(PACL, DWORD, DWORD, DWORD, PSID); + extern BOOL (WINAPI *addauditaccessaceex)(PACL, DWORD, DWORD, DWORD, PSID, BOOL, BOOL); + // To do - rationalize PySECURITY_ATTRIBUTES and SECURITY_DESCRIPTOR // objects. *************** *** 157,162 **** --- 161,169 ---- static PyObject *IsValid(PyObject *self, PyObject *args); static PyObject *AddAccessAllowedAce(PyObject *self, PyObject *args); + static PyObject *AddAccessAllowedAceEx(PyObject *self, PyObject *args); static PyObject *AddAccessDeniedAce(PyObject *self, PyObject *args); + static PyObject *AddAccessDeniedAceEx(PyObject *self, PyObject *args); static PyObject *AddAuditAccessAce(PyObject *self, PyObject *args); + static PyObject *AddAuditAccessAceEx(PyObject *self, PyObject *args); static PyObject *GetAclSize(PyObject *self, PyObject *args); static PyObject *GetAclRevision(PyObject *self, PyObject *args); Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PyWinTypesmodule.cpp 7 Nov 2003 03:58:17 -0000 1.12 --- PyWinTypesmodule.cpp 25 Nov 2003 05:19:58 -0000 1.13 *************** *** 486,489 **** --- 486,491 ---- PyDict_SetItemString(dict, "HANDLEType", (PyObject *)&PyHANDLEType); PyDict_SetItemString(dict, "OVERLAPPEDType", (PyObject *)&PyHANDLEType); + + } *************** *** 493,496 **** --- 495,515 ---- BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID lpReserved) { + FARPROC fp; + // dll usually will already be loaded + HMODULE hmodule=GetModuleHandle("AdvAPI32.dll"); + if (hmodule==NULL) + hmodule=LoadLibrary("AdvAPI32.dll"); + if (hmodule){ + fp=GetProcAddress(hmodule,"AddAccessAllowedAceEx"); + if (fp) + addaccessallowedaceex=(BOOL (WINAPI *)(PACL, DWORD, DWORD, DWORD, PSID))(fp); + fp=GetProcAddress(hmodule,"AddAccessDeniedAceEx"); + if (fp) + addaccessdeniedaceex=(BOOL (WINAPI *)(PACL, DWORD, DWORD, DWORD, PSID))(fp); + fp=GetProcAddress(hmodule,"AddAuditAccessAceEx"); + if (fp) + addauditaccessaceex=(BOOL (WINAPI *)(PACL, DWORD, DWORD, DWORD, PSID, BOOL, BOOL))(fp); + } + switch (dwReason) { case DLL_PROCESS_ATTACH: { |
From: <mha...@us...> - 2003-11-24 09:28:13
|
Update of /cvsroot/pywin32/pywin32/com/win32com/server In directory sc8-pr-cvs1:/tmp/cvs-serv11002 Modified Files: util.py Log Message: Allow the enumerator class to implement any nominated interface, and to allow debugging. Index: util.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/server/util.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** util.py 8 Nov 2003 00:37:32 -0000 1.3 --- util.py 24 Nov 2003 09:28:10 -0000 1.4 *************** *** 55,64 **** """ _public_methods_ = [ 'Next', 'Skip', 'Reset', 'Clone' ] - _com_interfaces_ = [ pythoncom.IID_IEnumVARIANT ] ! def __init__(self, data, index=0): self._list_ = data self.index = index def Next(self, count): result = self._list_[self.index:self.index+count] --- 55,67 ---- """ _public_methods_ = [ 'Next', 'Skip', 'Reset', 'Clone' ] ! def __init__(self, data, index=0, iid = pythoncom.IID_IEnumVARIANT): self._list_ = data self.index = index + self._iid_ = iid + def _query_interface_(self, iid): + if iid == self._iid_: + return 1 def Next(self, count): result = self._list_[self.index:self.index+count] *************** *** 98,102 **** ! def NewEnum(seq, cls=ListEnumerator): """Creates a new enumerator COM server. --- 101,109 ---- ! def NewEnum(seq, ! cls=ListEnumerator, ! iid=pythoncom.IID_IEnumVARIANT, ! usePolicy=None, ! useDispatcher=None): """Creates a new enumerator COM server. *************** *** 107,115 **** created, then wrapped up for return through the COM framework. Optionally, a custom COM server for enumeration can be passed ! (the default is @ListEnumerator@). """ ! return pythoncom.WrapObject(policy.DefaultPolicy(cls(seq)), ! pythoncom.IID_IEnumVARIANT, ! pythoncom.IID_IEnumVARIANT) --- 114,122 ---- created, then wrapped up for return through the COM framework. Optionally, a custom COM server for enumeration can be passed ! (the default is @ListEnumerator@), and the specific IEnum ! interface can be specified. """ ! ob = cls(seq, iid=iid) ! return wrap(ob, iid, usePolicy=usePolicy, useDispatcher=useDispatcher) |
From: <mha...@us...> - 2003-11-24 09:27:36
|
Update of /cvsroot/pywin32/pywin32/com/win32com/server In directory sc8-pr-cvs1:/tmp/cvs-serv10913 Modified Files: policy.py Log Message: Oops - used 'index' instead of 'find' to locate substring Index: policy.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/server/policy.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** policy.py 8 Nov 2003 00:42:41 -0000 1.15 --- policy.py 24 Nov 2003 09:27:33 -0000 1.16 *************** *** 544,548 **** # Particularly nasty is "wrong number of args" type error # This helps you see what 'func' and 'args' actually is ! if str(v).index("arguments")>=0: print "** TypeError calling function %r(%r)" % (func, args) raise --- 544,548 ---- # Particularly nasty is "wrong number of args" type error # This helps you see what 'func' and 'args' actually is ! if str(v).find("arguments")>=0: print "** TypeError calling function %r(%r)" % (func, args) raise |
From: <mha...@us...> - 2003-11-24 09:26:41
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell In directory sc8-pr-cvs1:/tmp/cvs-serv10756 Modified Files: shellcon.py Log Message: Avoid longs and hex constants. Index: shellcon.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/shellcon.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** shellcon.py 6 Nov 2003 06:14:12 -0000 1.6 --- shellcon.py 24 Nov 2003 09:26:38 -0000 1.7 *************** *** 294,320 **** SFGAO_CANMOVE = DROPEFFECT_MOVE SFGAO_CANLINK = DROPEFFECT_LINK ! SFGAO_CANRENAME = 0x00000010L ! SFGAO_CANDELETE = 0x00000020L ! SFGAO_HASPROPSHEET = 0x00000040L ! SFGAO_DROPTARGET = 0x00000100L ! SFGAO_CAPABILITYMASK = 0x00000177L ! SFGAO_LINK = 0x00010000L ! SFGAO_SHARE = 0x00020000L ! SFGAO_READONLY = 0x00040000L ! SFGAO_GHOSTED = 0x00080000L ! SFGAO_HIDDEN = 0x00080000L ! SFGAO_DISPLAYATTRMASK = 0x000F0000L ! SFGAO_FILESYSANCESTOR = 0x10000000L ! SFGAO_FOLDER = 0x20000000L ! SFGAO_FILESYSTEM = 0x40000000L SFGAO_HASSUBFOLDER = (-2147483648) SFGAO_CONTENTSMASK = (-2147483648) ! SFGAO_VALIDATE = 0x01000000L ! SFGAO_REMOVABLE = 0x02000000L ! SFGAO_COMPRESSED = 0x04000000L ! SFGAO_BROWSABLE = 0x08000000L ! SFGAO_NONENUMERATED = 0x00100000L ! SFGAO_NEWCONTENT = 0x00200000L ! SFGAO_STORAGE = 0x00000008L DWFRF_NORMAL = 0 DWFRF_DELETECONFIGDATA = 1 --- 294,320 ---- SFGAO_CANMOVE = DROPEFFECT_MOVE SFGAO_CANLINK = DROPEFFECT_LINK ! SFGAO_CANRENAME = 16 ! SFGAO_CANDELETE = 32 ! SFGAO_HASPROPSHEET = 64 ! SFGAO_DROPTARGET = 256 ! SFGAO_CAPABILITYMASK = 375 ! SFGAO_LINK = 65536 ! SFGAO_SHARE = 131072 ! SFGAO_READONLY = 262144 ! SFGAO_GHOSTED = 524288 ! SFGAO_HIDDEN = 524288 ! SFGAO_DISPLAYATTRMASK = 983040 ! SFGAO_FILESYSANCESTOR = 268435456 ! SFGAO_FOLDER = 536870912 ! SFGAO_FILESYSTEM = 1073741824 SFGAO_HASSUBFOLDER = (-2147483648) SFGAO_CONTENTSMASK = (-2147483648) ! SFGAO_VALIDATE = 16777216 ! SFGAO_REMOVABLE = 33554432 ! SFGAO_COMPRESSED = 67108864 ! SFGAO_BROWSABLE = 134217728 ! SFGAO_NONENUMERATED = 1048576 ! SFGAO_NEWCONTENT = 2097152 ! SFGAO_STORAGE = 8 DWFRF_NORMAL = 0 DWFRF_DELETECONFIGDATA = 1 *************** *** 387,416 **** CFSTR_FILENAMEMAP = CFSTR_FILENAMEMAPA DVASPECT_SHORTNAME = 2 ! SHCNE_RENAMEITEM = 0x00000001L ! SHCNE_CREATE = 0x00000002L ! SHCNE_DELETE = 0x00000004L ! SHCNE_MKDIR = 0x00000008L ! SHCNE_RMDIR = 0x00000010L ! SHCNE_MEDIAINSERTED = 0x00000020L ! SHCNE_MEDIAREMOVED = 0x00000040L ! SHCNE_DRIVEREMOVED = 0x00000080L ! SHCNE_DRIVEADD = 0x00000100L ! SHCNE_NETSHARE = 0x00000200L ! SHCNE_NETUNSHARE = 0x00000400L ! SHCNE_ATTRIBUTES = 0x00000800L ! SHCNE_UPDATEDIR = 0x00001000L ! SHCNE_UPDATEITEM = 0x00002000L ! SHCNE_SERVERDISCONNECT = 0x00004000L ! SHCNE_UPDATEIMAGE = 0x00008000L ! SHCNE_DRIVEADDGUI = 0x00010000L ! SHCNE_RENAMEFOLDER = 0x00020000L ! SHCNE_FREESPACE = 0x00040000L ! SHCNE_EXTENDED_EVENT = 0x04000000L ! SHCNE_ASSOCCHANGED = 0x08000000L ! SHCNE_DISKEVENTS = 0x0002381FL ! SHCNE_GLOBALEVENTS = 0x0C0581E0L ! SHCNE_ALLEVENTS = 0x7FFFFFFFL ! SHCNE_INTERRUPT = 0x80000000L ! SHCNEE_ORDERCHANGED = 0x00000002L SHCNF_IDLIST = 0 SHCNF_PATHA = 1 --- 387,416 ---- CFSTR_FILENAMEMAP = CFSTR_FILENAMEMAPA DVASPECT_SHORTNAME = 2 ! SHCNE_RENAMEITEM = 1 ! SHCNE_CREATE = 2 ! SHCNE_DELETE = 4 ! SHCNE_MKDIR = 8 ! SHCNE_RMDIR = 16 ! SHCNE_MEDIAINSERTED = 32 ! SHCNE_MEDIAREMOVED = 64 ! SHCNE_DRIVEREMOVED = 128 ! SHCNE_DRIVEADD = 256 ! SHCNE_NETSHARE = 512 ! SHCNE_NETUNSHARE = 1024 ! SHCNE_ATTRIBUTES = 2048 ! SHCNE_UPDATEDIR = 4096 ! SHCNE_UPDATEITEM = 8192 ! SHCNE_SERVERDISCONNECT = 16384 ! SHCNE_UPDATEIMAGE = 32768 ! SHCNE_DRIVEADDGUI = 65536 ! SHCNE_RENAMEFOLDER = 131072 ! SHCNE_FREESPACE = 262144 ! SHCNE_EXTENDED_EVENT = 67108864 ! SHCNE_ASSOCCHANGED = 134217728 ! SHCNE_DISKEVENTS = 145439 ! SHCNE_GLOBALEVENTS = 201687520 ! SHCNE_ALLEVENTS = 2147483647 ! SHCNE_INTERRUPT = -2147483648 ! SHCNEE_ORDERCHANGED = 2 SHCNF_IDLIST = 0 SHCNF_PATHA = 1 *************** *** 428,434 **** QIF_CACHED = 1 QIF_DONTEXPANDFOLDER = 2 ! SHARD_PIDL = 0x00000001L ! SHARD_PATHA = 0x00000002L ! SHARD_PATHW = 0x00000003L SHARD_PATH = SHARD_PATHW SHARD_PATH = SHARD_PATHA --- 428,434 ---- QIF_CACHED = 1 QIF_DONTEXPANDFOLDER = 2 ! SHARD_PIDL = 1 ! SHARD_PATHA = 2 ! SHARD_PATHW = 3 SHARD_PATH = SHARD_PATHW SHARD_PATH = SHARD_PATHA *************** *** 534,540 **** SHGDN_NORMAL = 0 # default (display purpose) SHGDN_INFOLDER = 1 # displayed under a folder (relative) ! SHGDN_INCLUDE_NONFILESYS = 0x2000 # if not set, display names for shell name space items that are not in the file system will fail. ! SHGDN_FORADDRESSBAR = 0x4000 # for displaying in the address (drives dropdown) bar ! SHGDN_FORPARSING = 0x8000 # for ParseDisplayName or path SHCONTF_FOLDERS = 32 # for shell browser --- 534,540 ---- SHGDN_NORMAL = 0 # default (display purpose) SHGDN_INFOLDER = 1 # displayed under a folder (relative) ! SHGDN_INCLUDE_NONFILESYS = 8192 # if not set, display names for shell name space items that are not in the file system will fail. ! SHGDN_FORADDRESSBAR = 16384 # for displaying in the address (drives dropdown) bar ! SHGDN_FORPARSING = 32768 # for ParseDisplayName or path SHCONTF_FOLDERS = 32 # for shell browser *************** *** 543,563 **** BFO_NONE = 0 ! BFO_BROWSER_PERSIST_SETTINGS = 0x1 ! BFO_RENAME_FOLDER_OPTIONS_TOINTERNET = 0x2 ! BFO_BOTH_OPTIONS = 0x4 ! BIF_PREFER_INTERNET_SHORTCUT = 0x8 ! BFO_BROWSE_NO_IN_NEW_PROCESS = 0x10 ! BFO_ENABLE_HYPERLINK_TRACKING = 0x20 ! BFO_USE_IE_OFFLINE_SUPPORT = 0x40 ! BFO_SUBSTITUE_INTERNET_START_PAGE = 0x80 ! BFO_USE_IE_LOGOBANDING = 0x100 ! BFO_ADD_IE_TOCAPTIONBAR = 0x200 ! BFO_USE_DIALUP_REF = 0x400 ! BFO_USE_IE_TOOLBAR = 0x800 ! BFO_NO_PARENT_FOLDER_SUPPORT = 0x1000 ! BFO_NO_REOPEN_NEXT_RESTART = 0x2000 ! BFO_GO_HOME_PAGE = 0x4000 ! BFO_PREFER_IEPROCESS = 0x8000 ! BFO_SHOW_NAVIGATION_CANCELLED = 0x10000 BFO_QUERY_ALL = -1 # From ShlGuid.h --- 543,563 ---- BFO_NONE = 0 ! BFO_BROWSER_PERSIST_SETTINGS = 1 ! BFO_RENAME_FOLDER_OPTIONS_TOINTERNET = 2 ! BFO_BOTH_OPTIONS = 4 ! BIF_PREFER_INTERNET_SHORTCUT = 8 ! BFO_BROWSE_NO_IN_NEW_PROCESS = 16 ! BFO_ENABLE_HYPERLINK_TRACKING = 32 ! BFO_USE_IE_OFFLINE_SUPPORT = 64 ! BFO_SUBSTITUE_INTERNET_START_PAGE = 128 ! BFO_USE_IE_LOGOBANDING = 256 ! BFO_ADD_IE_TOCAPTIONBAR = 512 ! BFO_USE_DIALUP_REF = 1024 ! BFO_USE_IE_TOOLBAR = 2048 ! BFO_NO_PARENT_FOLDER_SUPPORT = 4096 ! BFO_NO_REOPEN_NEXT_RESTART = 8192 ! BFO_GO_HOME_PAGE = 16384 ! BFO_PREFER_IEPROCESS = 32768 ! BFO_SHOW_NAVIGATION_CANCELLED = 65536 BFO_QUERY_ALL = -1 # From ShlGuid.h *************** *** 591,613 **** PIDDRSI_PLAYSTARTS = 5 PIDDRSI_PLAYEXPIRES = 6 ! PIDVSI_STREAM_NAME = 0x00000002 ! PIDVSI_FRAME_WIDTH = 0x00000003 ! PIDVSI_FRAME_HEIGHT = 0x00000004 ! PIDVSI_TIMELENGTH = 0x00000007 ! PIDVSI_FRAME_COUNT = 0x00000005 ! PIDVSI_FRAME_RATE = 0x00000006 ! PIDVSI_DATA_RATE = 0x00000008 ! PIDVSI_SAMPLE_SIZE = 0x00000009 ! PIDVSI_COMPRESSION = 0x0000000A ! PIDVSI_STREAM_NUMBER = 0x0000000B ! PIDASI_FORMAT = 0x00000002 ! PIDASI_TIMELENGTH = 0x00000003 ! PIDASI_AVG_DATA_RATE = 0x00000004 ! PIDASI_SAMPLE_RATE = 0x00000005 ! PIDASI_SAMPLE_SIZE = 0x00000006 ! PIDASI_CHANNEL_COUNT = 0x00000007 ! PIDASI_STREAM_NUMBER = 0x00000008 ! PIDASI_STREAM_NAME = 0x00000009 ! PIDASI_COMPRESSION = 0x0000000A PID_CONTROLPANEL_CATEGORY = 2 PID_VOLUME_FREE = 2 --- 591,613 ---- PIDDRSI_PLAYSTARTS = 5 PIDDRSI_PLAYEXPIRES = 6 ! PIDVSI_STREAM_NAME = 2 ! PIDVSI_FRAME_WIDTH = 3 ! PIDVSI_FRAME_HEIGHT = 4 ! PIDVSI_TIMELENGTH = 7 ! PIDVSI_FRAME_COUNT = 5 ! PIDVSI_FRAME_RATE = 6 ! PIDVSI_DATA_RATE = 8 ! PIDVSI_SAMPLE_SIZE = 9 ! PIDVSI_COMPRESSION = 10 ! PIDVSI_STREAM_NUMBER = 11 ! PIDASI_FORMAT = 2 ! PIDASI_TIMELENGTH = 3 ! PIDASI_AVG_DATA_RATE = 4 ! PIDASI_SAMPLE_RATE = 5 ! PIDASI_SAMPLE_SIZE = 6 ! PIDASI_CHANNEL_COUNT = 7 ! PIDASI_STREAM_NUMBER = 8 ! PIDASI_STREAM_NAME = 9 ! PIDASI_COMPRESSION = 10 PID_CONTROLPANEL_CATEGORY = 2 PID_VOLUME_FREE = 2 *************** *** 625,631 **** PROPSET_BEHAVIOR_CASE_SENSITIVE = ( 1 ) PID_DICTIONARY = ( 0 ) ! PID_CODEPAGE = ( 0x1 ) ! PID_FIRST_USABLE = ( 0x2 ) ! PID_FIRST_NAME_DEFAULT = ( 0xfff ) PID_LOCALE = ( (-2147483648) ) PID_MODIFY_TIME = ( (-2147483647) ) --- 625,631 ---- PROPSET_BEHAVIOR_CASE_SENSITIVE = ( 1 ) PID_DICTIONARY = ( 0 ) ! PID_CODEPAGE = ( 1 ) ! PID_FIRST_USABLE = ( 2 ) ! PID_FIRST_NAME_DEFAULT = ( 4095 ) PID_LOCALE = ( (-2147483648) ) PID_MODIFY_TIME = ( (-2147483647) ) *************** *** 635,682 **** PID_MIN_READONLY = ( (-2147483648) ) PID_MAX_READONLY = ( (-1073741825) ) ! PIDDI_THUMBNAIL = 0x00000002L ! PIDSI_TITLE = 0x00000002L ! PIDSI_SUBJECT = 0x00000003L ! PIDSI_AUTHOR = 0x00000004L ! PIDSI_KEYWORDS = 0x00000005L ! PIDSI_COMMENTS = 0x00000006L ! PIDSI_TEMPLATE = 0x00000007L ! PIDSI_LASTAUTHOR = 0x00000008L ! PIDSI_REVNUMBER = 0x00000009L ! PIDSI_EDITTIME = 0x0000000aL ! PIDSI_LASTPRINTED = 0x0000000bL ! PIDSI_CREATE_DTM = 0x0000000cL ! PIDSI_LASTSAVE_DTM = 0x0000000dL ! PIDSI_PAGECOUNT = 0x0000000eL ! PIDSI_WORDCOUNT = 0x0000000fL ! PIDSI_CHARCOUNT = 0x00000010L ! PIDSI_THUMBNAIL = 0x00000011L ! PIDSI_APPNAME = 0x00000012L ! PIDSI_DOC_SECURITY = 0x00000013L ! PIDDSI_CATEGORY = 0x00000002 ! PIDDSI_PRESFORMAT = 0x00000003 ! PIDDSI_BYTECOUNT = 0x00000004 ! PIDDSI_LINECOUNT = 0x00000005 ! PIDDSI_PARCOUNT = 0x00000006 ! PIDDSI_SLIDECOUNT = 0x00000007 ! PIDDSI_NOTECOUNT = 0x00000008 ! PIDDSI_HIDDENCOUNT = 0x00000009 ! PIDDSI_MMCLIPCOUNT = 0x0000000A ! PIDDSI_SCALE = 0x0000000B ! PIDDSI_HEADINGPAIR = 0x0000000C ! PIDDSI_DOCPARTS = 0x0000000D ! PIDDSI_MANAGER = 0x0000000E ! PIDDSI_COMPANY = 0x0000000F ! PIDDSI_LINKSDIRTY = 0x00000010 ! PIDMSI_EDITOR = 0x00000002L ! PIDMSI_SUPPLIER = 0x00000003L ! PIDMSI_SOURCE = 0x00000004L ! PIDMSI_SEQUENCE_NO = 0x00000005L ! PIDMSI_PROJECT = 0x00000006L ! PIDMSI_STATUS = 0x00000007L ! PIDMSI_OWNER = 0x00000008L ! PIDMSI_RATING = 0x00000009L ! PIDMSI_PRODUCTION = 0x0000000AL ! PIDMSI_COPYRIGHT = 0x0000000BL PRSPEC_INVALID = ( (-1) ) PRSPEC_LPWSTR = ( 0 ) --- 635,682 ---- PID_MIN_READONLY = ( (-2147483648) ) PID_MAX_READONLY = ( (-1073741825) ) ! PIDDI_THUMBNAIL = 2 ! PIDSI_TITLE = 2 ! PIDSI_SUBJECT = 3 ! PIDSI_AUTHOR = 4 ! PIDSI_KEYWORDS = 5 ! PIDSI_COMMENTS = 6 ! PIDSI_TEMPLATE = 7 ! PIDSI_LASTAUTHOR = 8 ! PIDSI_REVNUMBER = 9 ! PIDSI_EDITTIME = 10 ! PIDSI_LASTPRINTED = 11 ! PIDSI_CREATE_DTM = 12 ! PIDSI_LASTSAVE_DTM = 13 ! PIDSI_PAGECOUNT = 14 ! PIDSI_WORDCOUNT = 15 ! PIDSI_CHARCOUNT = 16 ! PIDSI_THUMBNAIL = 17 ! PIDSI_APPNAME = 18 ! PIDSI_DOC_SECURITY = 19 ! PIDDSI_CATEGORY = 2 ! PIDDSI_PRESFORMAT = 3 ! PIDDSI_BYTECOUNT = 4 ! PIDDSI_LINECOUNT = 5 ! PIDDSI_PARCOUNT = 6 ! PIDDSI_SLIDECOUNT = 7 ! PIDDSI_NOTECOUNT = 8 ! PIDDSI_HIDDENCOUNT = 9 ! PIDDSI_MMCLIPCOUNT = 10 ! PIDDSI_SCALE = 11 ! PIDDSI_HEADINGPAIR = 12 ! PIDDSI_DOCPARTS = 13 ! PIDDSI_MANAGER = 14 ! PIDDSI_COMPANY = 15 ! PIDDSI_LINKSDIRTY = 16 ! PIDMSI_EDITOR = 2 ! PIDMSI_SUPPLIER = 3 ! PIDMSI_SOURCE = 4 ! PIDMSI_SEQUENCE_NO = 5 ! PIDMSI_PROJECT = 6 ! PIDMSI_STATUS = 7 ! PIDMSI_OWNER = 8 ! PIDMSI_RATING = 9 ! PIDMSI_PRODUCTION = 10 ! PIDMSI_COPYRIGHT = 11 PRSPEC_INVALID = ( (-1) ) PRSPEC_LPWSTR = ( 0 ) *************** *** 684,740 **** # From ShObjIdl.h SHCIDS_ALLFIELDS = (-2147483648) ! SHCIDS_CANONICALONLY = 0x10000000L SHCIDS_BITMASK = (-65536) ! SHCIDS_COLUMNMASK = 0x0000FFFFL ! SFGAO_CANMONIKER = 0x00400000L ! SFGAO_HASSTORAGE = 0x00400000L ! SFGAO_STREAM = 0x00400000L ! SFGAO_STORAGEANCESTOR = 0x00800000L ! SFGAO_STORAGECAPMASK = 0x70C50008L MAXPROPPAGES = 100 ! PSP_DEFAULT = 0x00000000 ! PSP_DLGINDIRECT = 0x00000001 ! PSP_USEHICON = 0x00000002 ! PSP_USEICONID = 0x00000004 ! PSP_USETITLE = 0x00000008 ! PSP_RTLREADING = 0x00000010 ! PSP_HASHELP = 0x00000020 ! PSP_USEREFPARENT = 0x00000040 ! PSP_USECALLBACK = 0x00000080 ! PSP_PREMATURE = 0x00000400 ! PSP_HIDEHEADER = 0x00000800 ! PSP_USEHEADERTITLE = 0x00001000 ! PSP_USEHEADERSUBTITLE = 0x00002000 ! PSP_USEFUSIONCONTEXT = 0x00004000 PSPCB_ADDREF = 0 PSPCB_RELEASE = 1 PSPCB_CREATE = 2 ! PSH_DEFAULT = 0x00000000 ! PSH_PROPTITLE = 0x00000001 ! PSH_USEHICON = 0x00000002 ! PSH_USEICONID = 0x00000004 ! PSH_PROPSHEETPAGE = 0x00000008 ! PSH_WIZARDHASFINISH = 0x00000010 ! PSH_WIZARD = 0x00000020 ! PSH_USEPSTARTPAGE = 0x00000040 ! PSH_NOAPPLYNOW = 0x00000080 ! PSH_USECALLBACK = 0x00000100 ! PSH_HASHELP = 0x00000200 ! PSH_MODELESS = 0x00000400 ! PSH_RTLREADING = 0x00000800 ! PSH_WIZARDCONTEXTHELP = 0x00001000 ! PSH_WIZARD97 = 0x00002000 ! PSH_WIZARD97 = 0x01000000 ! PSH_WATERMARK = 0x00008000 ! PSH_USEHBMWATERMARK = 0x00010000 ! PSH_USEHPLWATERMARK = 0x00020000 ! PSH_STRETCHWATERMARK = 0x00040000 ! PSH_HEADER = 0x00080000 ! PSH_USEHBMHEADER = 0x00100000 ! PSH_USEPAGELANG = 0x00200000 ! PSH_WIZARD_LITE = 0x00400000 ! PSH_NOCONTEXTHELP = 0x02000000 PSCB_INITIALIZED = 1 --- 684,740 ---- # From ShObjIdl.h SHCIDS_ALLFIELDS = (-2147483648) ! SHCIDS_CANONICALONLY = 268435456 SHCIDS_BITMASK = (-65536) ! SHCIDS_COLUMNMASK = 65535 ! SFGAO_CANMONIKER = 4194304 ! SFGAO_HASSTORAGE = 4194304 ! SFGAO_STREAM = 4194304 ! SFGAO_STORAGEANCESTOR = 8388608 ! SFGAO_STORAGECAPMASK = 1891958792 MAXPROPPAGES = 100 ! PSP_DEFAULT = 0 ! PSP_DLGINDIRECT = 1 ! PSP_USEHICON = 2 ! PSP_USEICONID = 4 ! PSP_USETITLE = 8 ! PSP_RTLREADING = 16 ! PSP_HASHELP = 32 ! PSP_USEREFPARENT = 64 ! PSP_USECALLBACK = 128 ! PSP_PREMATURE = 1024 ! PSP_HIDEHEADER = 2048 ! PSP_USEHEADERTITLE = 4096 ! PSP_USEHEADERSUBTITLE = 8192 ! PSP_USEFUSIONCONTEXT = 16384 PSPCB_ADDREF = 0 PSPCB_RELEASE = 1 PSPCB_CREATE = 2 ! PSH_DEFAULT = 0 ! PSH_PROPTITLE = 1 ! PSH_USEHICON = 2 ! PSH_USEICONID = 4 ! PSH_PROPSHEETPAGE = 8 ! PSH_WIZARDHASFINISH = 16 ! PSH_WIZARD = 32 ! PSH_USEPSTARTPAGE = 64 ! PSH_NOAPPLYNOW = 128 ! PSH_USECALLBACK = 256 ! PSH_HASHELP = 512 ! PSH_MODELESS = 1024 ! PSH_RTLREADING = 2048 ! PSH_WIZARDCONTEXTHELP = 4096 ! PSH_WIZARD97 = 8192 ! PSH_WIZARD97 = 16777216 ! PSH_WATERMARK = 32768 ! PSH_USEHBMWATERMARK = 65536 ! PSH_USEHPLWATERMARK = 131072 ! PSH_STRETCHWATERMARK = 262144 ! PSH_HEADER = 524288 ! PSH_USEHBMHEADER = 1048576 ! PSH_USEPAGELANG = 2097152 ! PSH_WIZARD_LITE = 4194304 ! PSH_NOCONTEXTHELP = 33554432 PSCB_INITIALIZED = 1 *************** *** 746,753 **** PSNRET_MESSAGEHANDLED = 3 ! PSWIZB_BACK = 0x00000001 ! PSWIZB_NEXT = 0x00000002 ! PSWIZB_FINISH = 0x00000004 ! PSWIZB_DISABLEDFINISH = 0x00000008 PSBTN_BACK = 0 PSBTN_NEXT = 1 --- 746,753 ---- PSNRET_MESSAGEHANDLED = 3 ! PSWIZB_BACK = 1 ! PSWIZB_NEXT = 2 ! PSWIZB_FINISH = 4 ! PSWIZB_DISABLEDFINISH = 8 PSBTN_BACK = 0 PSBTN_NEXT = 1 *************** *** 759,764 **** PSBTN_MAX = 6 ! ID_PSRESTARTWINDOWS = 0x2 ! ID_PSREBOOTSYSTEM = (ID_PSRESTARTWINDOWS | 0x1) WIZ_CXDLG = 276 WIZ_CYDLG = 140 --- 759,764 ---- PSBTN_MAX = 6 ! ID_PSRESTARTWINDOWS = 2 ! ID_PSREBOOTSYSTEM = (ID_PSRESTARTWINDOWS | 1) WIZ_CXDLG = 276 WIZ_CYDLG = 140 *************** *** 775,808 **** ISOLATION_AWARE_BUILD_STATIC_LIBRARY = 0 ! SHCOLSTATE_TYPE_STR = 0x1 ! SHCOLSTATE_TYPE_INT = 0x2 ! SHCOLSTATE_TYPE_DATE = 0x3 ! SHCOLSTATE_TYPEMASK = 0xf ! SHCOLSTATE_ONBYDEFAULT = 0x10 ! SHCOLSTATE_SLOW = 0x20 ! SHCOLSTATE_EXTENDED = 0x40 ! SHCOLSTATE_SECONDARYUI = 0x80 ! SHCOLSTATE_HIDDEN = 0x100 ! SHCOLSTATE_PREFER_VARCMP = 0x200 ! FWF_AUTOARRANGE = 0x1 ! FWF_ABBREVIATEDNAMES = 0x2 ! FWF_SNAPTOGRID = 0x4 ! FWF_OWNERDATA = 0x8 ! FWF_BESTFITWINDOW = 0x10 ! FWF_DESKTOP = 0x20 ! FWF_SINGLESEL = 0x40 ! FWF_NOSUBFOLDERS = 0x80 ! FWF_TRANSPARENT = 0x100 ! FWF_NOCLIENTEDGE = 0x200 ! FWF_NOSCROLL = 0x400 ! FWF_ALIGNLEFT = 0x800 ! FWF_NOICONS = 0x1000 ! FWF_SHOWSELALWAYS = 0x2000 ! FWF_NOVISIBLE = 0x4000 ! FWF_SINGLECLICKACTIVATE = 0x8000 ! FWF_NOWEBVIEW = 0x10000 ! FWF_HIDEFILENAMES = 0x20000 ! FWF_CHECKSELECT = 0x40000 FVM_FIRST = 1 --- 775,808 ---- ISOLATION_AWARE_BUILD_STATIC_LIBRARY = 0 ! SHCOLSTATE_TYPE_STR = 1 ! SHCOLSTATE_TYPE_INT = 2 ! SHCOLSTATE_TYPE_DATE = 3 ! SHCOLSTATE_TYPEMASK = 15 ! SHCOLSTATE_ONBYDEFAULT = 16 ! SHCOLSTATE_SLOW = 32 ! SHCOLSTATE_EXTENDED = 64 ! SHCOLSTATE_SECONDARYUI = 128 ! SHCOLSTATE_HIDDEN = 256 ! SHCOLSTATE_PREFER_VARCMP = 512 ! FWF_AUTOARRANGE = 1 ! FWF_ABBREVIATEDNAMES = 2 ! FWF_SNAPTOGRID = 4 ! FWF_OWNERDATA = 8 ! FWF_BESTFITWINDOW = 16 ! FWF_DESKTOP = 32 ! FWF_SINGLESEL = 64 ! FWF_NOSUBFOLDERS = 128 ! FWF_TRANSPARENT = 256 ! FWF_NOCLIENTEDGE = 512 ! FWF_NOSCROLL = 1024 ! FWF_ALIGNLEFT = 2048 ! FWF_NOICONS = 4096 ! FWF_SHOWSELALWAYS = 8192 ! FWF_NOVISIBLE = 16384 ! FWF_SINGLECLICKACTIVATE = 32768 ! FWF_NOWEBVIEW = 65536 ! FWF_HIDEFILENAMES = 131072 ! FWF_CHECKSELECT = 262144 FVM_FIRST = 1 |
From: <mha...@us...> - 2003-11-24 09:25:20
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers In directory sc8-pr-cvs1:/tmp/cvs-serv10424 Modified Files: shell_view.py Log Message: A shell folder and shell view implementation - adds a new top-level namespace for Python's sys.path, and uses scintilla to display the file. Index: shell_view.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers/shell_view.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** shell_view.py 6 Nov 2003 06:11:51 -0000 1.2 --- shell_view.py 24 Nov 2003 09:25:17 -0000 1.3 *************** *** 3,23 **** # To demostrate: # * Execute this script to register the namespace. ! # * Open Windows Explorer ! # * Note the new folder hanging off "My Computer" ! # This is still incomplete - but we *do* create a view window - we just do ! # nothing with it. import sys, os import pythoncom from win32com.shell import shell, shellcon ! import win32gui ! import win32con ! import winerror ! from win32com.server.util import wrap ! debug=1 ! if debug: ! import win32com.server.dispatcher ! defaultDispatcher = win32com.server.dispatcher.DefaultDebugDispatcher IOleWindow_Methods = "GetWindow ContextSensitiveHelp".split() IShellView_Methods = IOleWindow_Methods + \ --- 3,55 ---- # To demostrate: # * Execute this script to register the namespace. ! # * Open Windows Explorer, and locate the new "Python Path Shell Browser" ! # folder off "My Computer" ! # * Browse this tree - .py files are shown expandable, with classes and ! # methods selectable. Selecting a Python file, or a class/method, will ! # display the file using Scintilla. ! # Known problems: ! # * Classes and methods don't have icons ! import sys, os + import thread + import pyclbr import pythoncom + import win32gui, win32api, win32con, winerror from win32com.shell import shell, shellcon ! from win32com.server.util import wrap, NewEnum ! from win32com.server.exception import COMException ! from win32com.util import IIDToInterfaceName ! from pywin.scintilla import scintillacon ! debug=0 ! ! # Helper function to get a system IShellFolder interface, and the PIDL within ! # that folder for an existing file/directory. ! def GetFolderAndPIDLForPath(filename): ! desktop = shell.SHGetDesktopFolder() ! info = desktop.ParseDisplayName(0, None, os.path.abspath(filename)) ! cchEaten, pidl, attr = info ! # We must walk the ID list, looking for one child at a time. ! folder = desktop ! while len(pidl) > 1: ! this = pidl.pop(0) ! folder = folder.BindToObject([this], None, shell.IID_IShellFolder) ! # We are left with the pidl for the specific item. Leave it as ! # a list, so it remains a valid PIDL. ! return folder, pidl + # A cache of pyclbr module objects, so we only parse a given filename once. + clbr_modules = {} # Indexed by path, item is dict as returned from pyclbr + def get_clbr_for_file(path): + try: + objects = clbr_modules[path] + except KeyError: + dir, filename = os.path.split(path) + base, ext = os.path.splitext(filename) + objects = pyclbr.readmodule_ex(base, [dir]) + clbr_modules[path] = objects + return objects + + # Our COM interfaces. IOleWindow_Methods = "GetWindow ContextSensitiveHelp".split() IShellView_Methods = IOleWindow_Methods + \ *************** *** 26,29 **** --- 58,62 ---- GetCurrentInfo AddPropertySheetPages SaveViewState SelectItem GetItemObject""".split() + IShellFolder_Methods = """ParseDisplayName EnumObjects BindToObject BindToStorage CompareIDs CreateViewObject *************** *** 36,65 **** IPersistFolder_Methods = IPersist_Methods + ["Initialize"] ! # Our shell extension. ! class ShellView: ! # _reg_progid_ = "Python.ShellExtension.View" ! # _reg_desc_ = "Python Sample Shell Extension (View)" ! _public_methods_ = IShellView_Methods ! _com_interfaces_ = [pythoncom.IID_IOleWindow, ! shell.IID_IShellView, ! ] ! def __init__(self, hwnd): ! self.hwnd_parent = hwnd ! # IShellView ! def CreateViewWindow(self, prev, settings, browser, rect): ! print "CreateViewWindow", prev, settings, browser, rect ! import win32ui ! style = win32con.WS_VISIBLE|win32con.WS_CHILD ! l = win32ui.CreateListCtrl() ! l.CreateWindow(style, rect, self.hwnd_parent, 1) ! l.InsertItem(0, "Hello") ! return l.GetSafeHwnd() ! def TranslateAccelerator(self, msg): ! return winerror.S_FALSE ! ! class ShellFolder: ! _reg_progid_ = "Python.ShellExtension.Folder" ! _reg_desc_ = "Python Sample Shell Extension (Folder)" ! _reg_clsid_ = "{f6287035-3074-4cb5-a8a6-d3c80e206944}" _com_interfaces_ = [shell.IID_IBrowserFrameOptions, pythoncom.IID_IPersist, --- 69,76 ---- IPersistFolder_Methods = IPersist_Methods + ["Initialize"] ! # Base class for a shell folder. ! # All child classes use a simple PIDL of the form: ! # "object_type\0object_name[\0extra ...]" ! class ShellFolderBase: _com_interfaces_ = [shell.IID_IBrowserFrameOptions, pythoncom.IID_IPersist, *************** *** 71,87 **** IPersistFolder_Methods + \ IShellFolder_Methods ! # IPersistFolder def GetFrameOptions(self, mask): return 0 def GetClassID(self): return self._reg_clsid_ - # IPersist def Initialize(self, pidl): ! print "Got pidl", repr(pidl) ! # IShellFolder def CreateViewObject(self, hwnd, iid): ! print "CreateViewObject", hwnd, iid ! return wrap(ShellView(hwnd), useDispatcher=defaultDispatcher) ! def DllRegisterServer(): import _winreg --- 82,368 ---- IPersistFolder_Methods + \ IShellFolder_Methods ! def GetFrameOptions(self, mask): + #print "GetFrameOptions", self, mask return 0 + def ParseDisplayName(self, hwnd, reserved, displayName): + print "ParseDisplayName", displayName + # return cchEaten, pidl, attr + def BindToStorage(self, pidl, bc, iid): + print "BTS", iid, IIDToInterfaceName(iid) + def BindToObject(self, pidl, bc, iid): + # We may be passed a set of relative PIDLs here - ie + # [pidl_of_dir, pidl_of_child_dir, pidl_of_file, pidl_of_function] + # But each of our PIDLs keeps the fully qualified name anyway - so + # just jump directly to the last. + final_pidl = pidl[-1] + typ, extra = final_pidl.split('\0', 1) + if typ == "directory": + klass = ShellFolderDirectory + elif typ == "file": + klass = ShellFolderFile + elif typ == "object": + klass = ShellFolderObject + else: + raise RuntimeError, "What is " + repr(typ) + ret = wrap(klass(extra), iid, useDispatcher = (debug>0)) + return ret + + # A ShellFolder for an object with CHILDREN on the file system + # Note that this means our "File" folder is *not* a 'FileSystem' folder, + # as it's children (functions and classes) are not on the file system. + # + class ShellFolderFileSystem(ShellFolderBase): + def _GetFolderAndPIDLForPIDL(self, my_idl): + typ, name = my_idl[0].split('\0') + return GetFolderAndPIDLForPath(name) + # Interface methods + def CompareIDs(self, param, id1, id2): + return cmp(id1, id2) + def GetUIObjectOf(self, hwndOwner, pidls, iid, inout): + # delegate to the shell. + assert len(pidls)==1, "oops - arent expecting more than one!)" + pidl = pidls[0] + folder, child_pidl = self._GetFolderAndPIDLForPIDL(pidl) + try: + inout, ret = folder.GetUIObjectOf(hwndOwner, [child_pidl], iid, + inout, pythoncom.IID_IUnknown) + except pythoncom.com_error, (hr, desc, exc, arg): + raise COMException(hresult=hr) + return inout, ret + # return object of IID + def GetDisplayNameOf(self, pidl, flags): + # delegate to the shell. + folder, child_pidl = self._GetFolderAndPIDLForPIDL(pidl) + ret = folder.GetDisplayNameOf(child_pidl, flags) + return ret + def GetAttributesOf(self, pidls, attrFlags): + ret_flags = -1 + for pidl in pidls: + pidl = pidl[0] # ?? + typ, name = pidl.split('\0') + flags = shellcon.SHGFI_ATTRIBUTES + info = shell.SHGetFileInfo(name, 0, flags) + hIcon, iIcon, dwAttr, name, typeName = info + # All our items, even files, have sub-items + extras = shellcon.SFGAO_HASSUBFOLDER | \ + shellcon.SFGAO_FOLDER | \ + shellcon.SFGAO_FILESYSANCESTOR + ret_flags &= (dwAttr | extras) + return ret_flags + + class ShellFolderDirectory(ShellFolderFileSystem): + def __init__(self, path): + self.path = os.path.abspath(path) + def CreateViewObject(self, hwnd, iid): + # delegate to the shell. + folder, child_pidl = GetFolderAndPIDLForPath(self.path) + return folder.CreateViewObject(hwnd, iid) + def EnumObjects(self, hwndOwner, flags): + pidls = [] + for fname in os.listdir(self.path): + fqn = os.path.join(self.path, fname) + if os.path.isdir(fqn): + type_name = "directory" + type_class = ShellFolderDirectory + else: + base, ext = os.path.splitext(fname) + if ext in [".py", ".pyw"]: + type_class = ShellFolderFile + type_name = "file" + else: + type_class = None + if type_class is not None: + pidls.append( [type_name + "\0" + fqn] ) + return NewEnum(pidls, iid=shell.IID_IEnumIDList, + useDispatcher=(debug>0)) + + # As per comments above, even though this manages a file, it is *not* a + # ShellFolderFileSystem, as the children are not on the file system. + class ShellFolderFile(ShellFolderBase): + def __init__(self, path): + self.path = os.path.abspath(path) + def EnumObjects(self, hwndOwner, flags): + objects = get_clbr_for_file(self.path) + pidls = [] + for name, ob in objects.items(): + pidls.append( ["object\0" + self.path + "\0" + name] ) + return NewEnum(pidls, iid=shell.IID_IEnumIDList, + useDispatcher=(debug>0)) + + def GetAttributesOf(self, pidls, attrFlags): + ret_flags = -1 + for pidl in pidls: + assert len(pidl)==1, "Expecting relative pidls" + pidl = pidl[0] + typ, filename, obname = pidl.split('\0') + obs = get_clbr_for_file(filename) + ob = obs[obname] + flags = shellcon.SFGAO_BROWSABLE | shellcon.SFGAO_FOLDER | \ + shellcon.SFGAO_FILESYSANCESTOR + if hasattr(ob, "methods"): + flags |= shellcon.SFGAO_HASSUBFOLDER + ret_flags &= flags + return ret_flags + + def GetDisplayNameOf(self, pidl, flags): + assert len(pidl)==1, "Expecting relative PIDL" + typ, fname, obname = pidl[0].split('\0') + return obname + + def CreateViewObject(self, hwnd, iid): + return wrap(ScintillaShellView(hwnd, self.path), useDispatcher=debug>0) + + # A ShellFolder for our Python objects + class ShellFolderObject(ShellFolderBase): + def __init__(self, details): + self.path, details = details.split('\0') + if details.find(".")>0: + self.class_name, self.method_name = details.split(".") + else: + self.class_name = details + self.method_name = None + def CreateViewObject(self, hwnd, iid): + mod_objects = get_clbr_for_file(self.path) + object = mod_objects[self.class_name] + if self.method_name is None: + lineno = object.lineno + else: + lineno = object.methods[self.method_name] + return wrap(ScintillaShellView(hwnd, self.path, lineno), + useDispatcher=debug>0) + def EnumObjects(self, hwndOwner, flags): + assert self.method_name is None, "Should not be enuming methods!" + mod_objects = get_clbr_for_file(self.path) + my_objects = mod_objects[self.class_name] + pidls = [] + for func_name, lineno in my_objects.methods.items(): + pidl = ["object\0" + self.path + "\0" + + self.class_name + "." + func_name] + pidls.append(pidl) + return NewEnum(pidls, iid=shell.IID_IEnumIDList, + useDispatcher=(debug>0)) + def GetDisplayNameOf(self, pidl, flags): + assert len(pidl)==1, "Expecting relative PIDL" + typ, fname, obname = pidl[0].split('\0') + class_name, method_name = obname.split('.') + return method_name + def GetAttributesOf(self, pidls, attrFlags): + ret_flags = -1 + for pidl in pidls: + assert len(pidl)==1, "Expecting relative pidls" + flags = shellcon.SFGAO_BROWSABLE | shellcon.SFGAO_FOLDER | \ + shellcon.SFGAO_FILESYSANCESTOR + ret_flags &= flags + return ret_flags + + # The "Root" folder of our namespace. As all children are directories, + # it is derived from ShellFolderFileSystem + class ShellFolderRoot(ShellFolderFileSystem): + _reg_progid_ = "Python.ShellExtension.Folder" + _reg_desc_ = "Python Path Shell Browser" + _reg_clsid_ = "{f6287035-3074-4cb5-a8a6-d3c80e206944}" def GetClassID(self): return self._reg_clsid_ def Initialize(self, pidl): ! #print "Initialize called with pidl", repr(pidl) ! pass def CreateViewObject(self, hwnd, iid): ! raise COMException(hresult=winerror.E_NOTIMPL) ! def EnumObjects(self, hwndOwner, flags): ! items = [ ["directory\0" + p] for p in sys.path if os.path.isdir(p)] ! return NewEnum(items, iid=shell.IID_IEnumIDList, ! useDispatcher=(debug>0)) ! ! # A Simple shell view implementation ! # Our shell extension. ! class ScintillaShellView: ! _public_methods_ = IShellView_Methods ! _com_interfaces_ = [pythoncom.IID_IOleWindow, ! shell.IID_IShellView, ! ] ! def __init__(self, hwnd, filename, lineno = None): ! self.filename = filename ! self.lineno = lineno ! self.hwnd_parent = hwnd ! self.hwnd = None ! def _SendSci(self, msg, wparam=0, lparam=0): ! return win32gui.SendMessage(self.hwnd, msg, wparam, lparam) ! ! # IShellView ! def CreateViewWindow(self, prev, settings, browser, rect): ! print "CreateViewWindow", prev, settings, browser, rect ! # Make sure scintilla.dll is loaded. If not, find it on sys.path ! # (which it generally is for Pythonwin) ! try: ! win32api.GetModuleHandle("Scintilla.dll") ! except win32api.error: ! for p in sys.path: ! fname = os.path.join(p, "Scintilla.dll") ! if not os.path.isfile(fname): ! fname = os.path.join(p, "Build", "Scintilla.dll") ! if os.path.isfile(fname): ! win32api.LoadLibrary(fname) ! break ! else: ! raise RuntimeError, "Can't find scintilla!" ! ! style = win32con.WS_CHILD | win32con.WS_VSCROLL | \ ! win32con.WS_HSCROLL | win32con.WS_CLIPCHILDREN | \ ! win32con.WS_VISIBLE ! self.hwnd = win32gui.CreateWindow("Scintilla", "Scintilla", style, ! rect[0], rect[1], rect[2]-rect[0], rect[3]-rect[1], ! self.hwnd_parent, 1000, 0, None) ! file_data = file(self.filename, "U").read() ! ! self._SetupLexer() ! self._SendSci(scintillacon.SCI_SETTEXT, 0, file_data) ! self._SendSci(scintillacon.SCI_COLOURISE, 0, -1) ! if self.lineno != None: ! self._SendSci(scintillacon.SCI_GOTOLINE, self.lineno) ! print "Made scintilla", self.hwnd ! ! def _SetupLexer(self): ! h = self.hwnd ! styles = [ ! ((0, 0, 200, 0, 0x808080), None, scintillacon.SCE_P_DEFAULT ), ! ((0, 2, 200, 0, 0x008000), None, scintillacon.SCE_P_COMMENTLINE ), ! ((0, 2, 200, 0, 0x808080), None, scintillacon.SCE_P_COMMENTBLOCK ), ! ((0, 0, 200, 0, 0x808000), None, scintillacon.SCE_P_NUMBER ), ! ((0, 0, 200, 0, 0x008080), None, scintillacon.SCE_P_STRING ), ! ((0, 0, 200, 0, 0x008080), None, scintillacon.SCE_P_CHARACTER ), ! ((0, 0, 200, 0, 0x008080), None, scintillacon.SCE_P_TRIPLE ), ! ((0, 0, 200, 0, 0x008080), None, scintillacon.SCE_P_TRIPLEDOUBLE), ! ((0, 0, 200, 0, 0x000000), 0x008080, scintillacon.SCE_P_STRINGEOL), ! ((0, 1, 200, 0, 0x800000), None, scintillacon.SCE_P_WORD), ! ((0, 1, 200, 0, 0xFF0000), None, scintillacon.SCE_P_CLASSNAME ), ! ((0, 1, 200, 0, 0x808000), None, scintillacon.SCE_P_DEFNAME), ! ((0, 0, 200, 0, 0x000000), None, scintillacon.SCE_P_OPERATOR), ! ((0, 0, 200, 0, 0x000000), None, scintillacon.SCE_P_IDENTIFIER ), ! ] ! self._SendSci(scintillacon.SCI_SETLEXER, scintillacon.SCLEX_PYTHON, 0) ! self._SendSci(scintillacon.SCI_SETSTYLEBITS, 5) ! print "Got back lexer", win32gui.SendMessage(self.hwnd, scintillacon.SCI_GETLEXER) ! baseFormat = (-402653169, 0, 200, 0, 0, 0, 49, 'Courier New') ! for f, bg, stylenum in styles: ! self._SendSci(scintillacon.SCI_STYLESETFORE, stylenum, f[4]) ! self._SendSci(scintillacon.SCI_STYLESETFONT, stylenum, baseFormat[7]) ! if f[1] & 1: self._SendSci(scintillacon.SCI_STYLESETBOLD, stylenum, 1) ! else: self._SendSci(scintillacon.SCI_STYLESETBOLD, stylenum, 0) ! if f[1] & 2: self._SendSci(scintillacon.SCI_STYLESETITALIC, stylenum, 1) ! else: self._SendSci(scintillacon.SCI_STYLESETITALIC, stylenum, 0) ! self._SendSci(scintillacon.SCI_STYLESETSIZE, stylenum, int(baseFormat[2]/20)) ! if bg is not None: ! self._SendSci(scintillacon.SCI_STYLESETBACK, stylenum, bg) ! self._SendSci(scintillacon.SCI_STYLESETEOLFILLED, stylenum, 1) # Only needed for unclosed strings. ! ! def DestroyViewWindow(self): ! win32gui.DestroyWindow(self.hwnd) ! self.hwnd = None ! print "Destroyed scintilla window" ! ! def TranslateAccelerator(self, msg): ! return winerror.S_FALSE ! def DllRegisterServer(): import _winreg *************** *** 89,104 **** "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \ "Explorer\\Desktop\\Namespace\\" + \ ! ShellFolder._reg_clsid_) ! _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellFolder._reg_desc_) # And special shell keys under our CLSID key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, ! "CLSID\\" + ShellFolder._reg_clsid_ + "\\ShellFolder") # 'Attributes' is an int stored as a binary! use struct attr = shellcon.SFGAO_FOLDER | shellcon.SFGAO_HASSUBFOLDER | \ shellcon.SFGAO_BROWSABLE import struct ! s = struct.pack("I", attr) _winreg.SetValueEx(key, "Attributes", 0, _winreg.REG_BINARY, s) ! print ShellFolder._reg_desc_, "registration complete." def DllUnregisterServer(): --- 370,385 ---- "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \ "Explorer\\Desktop\\Namespace\\" + \ ! ShellFolderRoot._reg_clsid_) ! _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ShellFolderRoot._reg_desc_) # And special shell keys under our CLSID key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, ! "CLSID\\" + ShellFolderRoot._reg_clsid_ + "\\ShellFolder") # 'Attributes' is an int stored as a binary! use struct attr = shellcon.SFGAO_FOLDER | shellcon.SFGAO_HASSUBFOLDER | \ shellcon.SFGAO_BROWSABLE import struct ! s = struct.pack("i", attr) _winreg.SetValueEx(key, "Attributes", 0, _winreg.REG_BINARY, s) ! print ShellFolderRoot._reg_desc_, "registration complete." def DllUnregisterServer(): *************** *** 108,121 **** "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \ "Explorer\\Desktop\\Namespace\\" + \ ! ShellFolder._reg_clsid_) except WindowsError, details: import errno if details.errno != errno.ENOENT: raise ! print ShellFolder._reg_desc_, "unregistration complete." if __name__=='__main__': from win32com.server import register ! register.UseCommandLine(ShellFolder, finalize_register = DllRegisterServer, finalize_unregister = DllUnregisterServer) --- 389,403 ---- "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\" \ "Explorer\\Desktop\\Namespace\\" + \ ! ShellFolderRoot._reg_clsid_) except WindowsError, details: import errno if details.errno != errno.ENOENT: raise ! print ShellFolderRoot._reg_desc_, "unregistration complete." if __name__=='__main__': from win32com.server import register ! register.UseCommandLine(ShellFolderRoot, ! debug = debug, finalize_register = DllRegisterServer, finalize_unregister = DllUnregisterServer) |
From: <mha...@us...> - 2003-11-24 09:23:50
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1:/tmp/cvs-serv10253 Modified Files: PyIShellFolder.cpp Log Message: Lots of bug fixes. Index: PyIShellFolder.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellFolder.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PyIShellFolder.cpp 2 Nov 2003 09:58:32 -0000 1.3 --- PyIShellFolder.cpp 24 Nov 2003 09:23:47 -0000 1.4 *************** *** 5,8 **** --- 5,10 ---- #include "PyIShellFolder.h" + extern void *PyShell_AllocMem(ULONG cb); + // @doc - This file contains autoduck documentation // --------------------------------------------------- *************** *** 279,295 **** // @pyparm <o PyIID>|riid||Description for riid // @pyparm int|rgfInOut||Description for rgfInOut PyObject *obpidl; PyObject *obriid; HWND hwndOwner; UINT cidl; LPCITEMIDLIST *pidl; ! IID riid; UINT rgfInOut; void * out; ! if ( !PyArg_ParseTuple(args, "lOOl:GetUIObjectOf", &hwndOwner, &obpidl, &obriid, &rgfInOut) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsPIDLArray(obpidl, &cidl, &pidl)) bPythonIsHappy = FALSE; if (!PyWinObject_AsIID(obriid, &riid)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; --- 281,303 ---- // @pyparm <o PyIID>|riid||Description for riid // @pyparm int|rgfInOut||Description for rgfInOut + // @pyparm <o PyIID>|iidout|None|The IID to wrap the result in. If not specified, riid is used. PyObject *obpidl; PyObject *obriid; + PyObject *obiidout = NULL; HWND hwndOwner; UINT cidl; LPCITEMIDLIST *pidl; ! IID riid, iidout; UINT rgfInOut; void * out; ! if ( !PyArg_ParseTuple(args, "lOOl|O:GetUIObjectOf", &hwndOwner, &obpidl, &obriid, &rgfInOut, &obiidout) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsPIDLArray(obpidl, &cidl, &pidl)) bPythonIsHappy = FALSE; if (!PyWinObject_AsIID(obriid, &riid)) bPythonIsHappy = FALSE; + if (obiidout==NULL) + iidout = riid; + else + if (!PyWinObject_AsIID(obiidout, &iidout)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; *************** *** 304,308 **** PyObject *obout; ! obout = PyCom_PyObjectFromIUnknown((IUnknown *)out, riid, FALSE); PyObject *pyretval = Py_BuildValue("lO", rgfInOut, obout); Py_XDECREF(obout); --- 312,316 ---- PyObject *obout; ! obout = PyCom_PyObjectFromIUnknown((IUnknown *)out, iidout, FALSE); PyObject *pyretval = Py_BuildValue("lO", rgfInOut, obout); Py_XDECREF(obout); *************** *** 424,431 **** // Process the Python results, and convert back to the real params PyObject *obppidl; ! if (!PyArg_ParseTuple(result, "lOl" , pchEaten, &obppidl, pdwAttributes)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsPIDL(obppidl, ppidl)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); Py_DECREF(result); return hr; --- 432,443 ---- // Process the Python results, and convert back to the real params PyObject *obppidl; ! ULONG chEaten, dwAttributes; ! if (!PyArg_ParseTuple(result, "lOl" , &chEaten, &obppidl, &dwAttributes)) ! return PyCom_SetAndLogCOMErrorFromPyException("ParseDisplayName", IID_IShellFolder); BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsPIDL(obppidl, ppidl)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) hr = PyCom_SetAndLogCOMErrorFromPyException("ParseDisplayName", IID_IShellFolder); ! if (pchEaten) *pchEaten = chEaten; ! if (pdwAttributes) *pdwAttributes = dwAttributes; Py_DECREF(result); return hr; *************** *** 442,451 **** if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! PyObject *obppeidl; ! if (!PyArg_Parse(result, "O" , &obppeidl)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obppeidl, IID_IEnumIDList, (void **)&ppeidl, FALSE /* bNoneOK */)) ! bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); Py_DECREF(result); return hr; --- 454,459 ---- if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! PyCom_InterfaceFromPyInstanceOrObject(result, IID_IEnumIDList, (void **)ppeidl, FALSE /* bNoneOK */); ! hr = PyCom_SetAndLogCOMErrorFromPyException("EnumObjects", IID_IShellFolder); Py_DECREF(result); return hr; *************** *** 458,461 **** --- 466,470 ---- /* [out] */ void ** out) { + static const char *szMethodName = "BindToObject"; PY_GATEWAY_METHOD; PyObject *obpidl; *************** *** 466,470 **** obriid = PyWinObject_FromIID(riid); PyObject *result; ! HRESULT hr=InvokeViaPolicy("BindToObject", &result, "OOO", obpidl, obpbcReserved, obriid); Py_XDECREF(obpidl); Py_XDECREF(obpbcReserved); --- 475,479 ---- obriid = PyWinObject_FromIID(riid); PyObject *result; ! HRESULT hr=InvokeViaPolicy(szMethodName, &result, "OOO", obpidl, obpbcReserved, obriid); Py_XDECREF(obpidl); Py_XDECREF(obpbcReserved); *************** *** 472,481 **** if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! PyObject *obout; ! if (!PyArg_Parse(result, "O" , &obout)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obout, IID_IUnknown, (void **)&out, FALSE /* bNoneOK */)) ! bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); Py_DECREF(result); return hr; --- 481,486 ---- if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! PyCom_InterfaceFromPyInstanceOrObject(result, riid, out, FALSE /* bNoneOK */); ! hr = PyCom_SetAndLogCOMErrorFromPyException(szMethodName, IID_IShellFolder); Py_DECREF(result); return hr; *************** *** 488,491 **** --- 493,497 ---- /* [out] */ void **ppRet) { + static const char *szMethodName = "BindToStorage"; PY_GATEWAY_METHOD; PyObject *obpidl; *************** *** 496,500 **** obriid = PyWinObject_FromIID(riid); PyObject *result; ! HRESULT hr=InvokeViaPolicy("BindToStorage", &result, "OOO", obpidl, obpbcReserved, obriid); Py_XDECREF(obpidl); Py_XDECREF(obpbcReserved); --- 502,506 ---- obriid = PyWinObject_FromIID(riid); PyObject *result; ! HRESULT hr=InvokeViaPolicy(szMethodName, &result, "OOO", obpidl, obpbcReserved, obriid); Py_XDECREF(obpidl); Py_XDECREF(obpbcReserved); *************** *** 502,511 **** if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! PyObject *obout; ! if (!PyArg_Parse(result, "O" , &obout)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obout, riid, ppRet, FALSE /* bNoneOK */)) ! bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); Py_DECREF(result); return hr; --- 508,513 ---- if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! PyCom_InterfaceFromPyInstanceOrObject(result, riid, ppRet, FALSE /* bNoneOK */); ! hr = PyCom_SetAndLogCOMErrorFromPyException(szMethodName, IID_IShellFolder); Py_DECREF(result); return hr; *************** *** 522,528 **** obpidl1 = PyObject_FromPIDL(pidl1, FALSE); obpidl2 = PyObject_FromPIDL(pidl2, FALSE); ! HRESULT hr=InvokeViaPolicy("CompareIDs", NULL, "lOO", lparam, obpidl1, obpidl2); Py_XDECREF(obpidl1); Py_XDECREF(obpidl2); return hr; } --- 524,535 ---- obpidl1 = PyObject_FromPIDL(pidl1, FALSE); obpidl2 = PyObject_FromPIDL(pidl2, FALSE); ! PyObject *result; ! HRESULT hr=InvokeViaPolicy("CompareIDs", &result, "lOO", lparam, obpidl1, obpidl2); Py_XDECREF(obpidl1); Py_XDECREF(obpidl2); + if (FAILED(hr)) return hr; + if (PyInt_Check(result)) + hr = MAKE_HRESULT(SEVERITY_SUCCESS, 0, PyInt_AsLong(result)); + Py_DECREF(result); return hr; } *************** *** 533,550 **** /* [out] */ void **ppRet) { PY_GATEWAY_METHOD; PyObject *obriid; obriid = PyWinObject_FromIID(riid); PyObject *result; ! HRESULT hr=InvokeViaPolicy("CreateViewObject", &result, "lO", hwndOwner, obriid); Py_XDECREF(obriid); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! PyObject *obout; ! if (!PyArg_Parse(result, "O" , &obout)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obout, riid, ppRet, FALSE /* bNoneOK */)) ! bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); Py_DECREF(result); return hr; --- 540,554 ---- /* [out] */ void **ppRet) { + static const char *szMethodName = "CreateViewObject"; PY_GATEWAY_METHOD; PyObject *obriid; obriid = PyWinObject_FromIID(riid); PyObject *result; ! HRESULT hr=InvokeViaPolicy(szMethodName, &result, "lO", hwndOwner, obriid); Py_XDECREF(obriid); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! PyCom_InterfaceFromPyInstanceOrObject(result, riid, ppRet, FALSE /* bNoneOK */); ! hr = PyCom_SetAndLogCOMErrorFromPyException(szMethodName, IID_IShellFolder); Py_DECREF(result); return hr; *************** *** 564,568 **** if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! if (!PyArg_Parse(result, "l" , rgfInOut)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); Py_DECREF(result); return hr; --- 568,573 ---- if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! if (!PyArg_Parse(result, "l" , rgfInOut)) ! hr = PyCom_SetAndLogCOMErrorFromPyException("GetAttributesOf", IID_IShellFolder); Py_DECREF(result); return hr; *************** *** 577,580 **** --- 582,586 ---- /* [out] */ void ** ppRet) { + static const char *szMethodName = "GetUIObjectOf"; PY_GATEWAY_METHOD; PyObject *obpidl; *************** *** 583,587 **** obriid = PyWinObject_FromIID(riid); PyObject *result; ! HRESULT hr=InvokeViaPolicy("GetUIObjectOf", &result, "lOOl", hwndOwner, obpidl, obriid, rgfInOut); Py_XDECREF(obpidl); Py_XDECREF(obriid); --- 589,593 ---- obriid = PyWinObject_FromIID(riid); PyObject *result; ! HRESULT hr=InvokeViaPolicy(szMethodName, &result, "lOOl", hwndOwner, obpidl, obriid, rgfInOut); Py_XDECREF(obpidl); Py_XDECREF(obriid); *************** *** 589,597 **** // Process the Python results, and convert back to the real params PyObject *obout; ! if (!PyArg_ParseTuple(result, "lO" , rgfInOut, &obout)) return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obout, IID_IUnknown, ppRet, FALSE/* bNoneOK */)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) hr = PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); Py_DECREF(result); return hr; --- 595,605 ---- // Process the Python results, and convert back to the real params PyObject *obout; ! UINT inout; ! if (!PyArg_ParseTuple(result, "lO" , &inout, &obout)) return PyCom_SetAndLogCOMErrorFromPyException(szMethodName, IID_IShellFolder); BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obout, riid, ppRet, FALSE/* bNoneOK */)) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) hr = PyCom_SetAndLogCOMErrorFromPyException(szMethodName, IID_IShellFolder); ! if (rgfInOut) *rgfInOut = inout; Py_DECREF(result); return hr; *************** *** 603,616 **** /* [out] */ STRRET __RPC_FAR * out) { PY_GATEWAY_METHOD; PyObject *obpidl; obpidl = PyObject_FromPIDL(pidl, FALSE); PyObject *result; ! HRESULT hr=InvokeViaPolicy("GetDisplayNameOf", &result, "Ol", obpidl, uFlags); Py_XDECREF(obpidl); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! // *** The output argument out of type "STRRET __RPC_FAR *" was not processed *** ! // The type 'STRRET' (out) is unknown. Py_DECREF(result); return hr; --- 611,628 ---- /* [out] */ STRRET __RPC_FAR * out) { + static const char *szMethodName = "GetDisplayNameOf"; + if (!out) + return E_POINTER; PY_GATEWAY_METHOD; PyObject *obpidl; obpidl = PyObject_FromPIDL(pidl, FALSE); PyObject *result; ! HRESULT hr=InvokeViaPolicy(szMethodName, &result, "Ol", obpidl, uFlags); Py_XDECREF(obpidl); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! out->uType = STRRET_WSTR; ! if (!PyWinObject_AsPfnAllocatedWCHAR(result, PyShell_AllocMem, &out->pOleStr)) ! hr = PyCom_SetAndLogCOMErrorFromPyException(szMethodName, IID_IShellFolder); Py_DECREF(result); return hr; *************** *** 624,627 **** --- 636,640 ---- /* [out] */ LPITEMIDLIST *ppidlOut) { + static const char *szMethodName = "SetNameOf"; PY_GATEWAY_METHOD; PyObject *obpidl; *************** *** 630,639 **** oblpszName = MakeOLECHARToObj(pszName); PyObject *result; ! HRESULT hr=InvokeViaPolicy("SetNameOf", &result, "lOOl", hwnd, obpidl, oblpszName, uFlags); Py_XDECREF(obpidl); Py_XDECREF(oblpszName); ! PyObject_AsPIDL(result, ppidlOut, FALSE); ! return PyCom_HandlePythonFailureToCOM(/*pexcepinfo*/); } --- 643,654 ---- oblpszName = MakeOLECHARToObj(pszName); PyObject *result; ! HRESULT hr=InvokeViaPolicy(szMethodName, &result, "lOOl", hwnd, obpidl, oblpszName, uFlags); Py_XDECREF(obpidl); Py_XDECREF(oblpszName); ! if (FAILED(hr)) return hr; PyObject_AsPIDL(result, ppidlOut, FALSE); ! hr = PyCom_SetAndLogCOMErrorFromPyException(szMethodName, IID_IShellFolder); ! Py_DECREF(result); ! return hr; } |
From: <mha...@us...> - 2003-11-24 09:23:30
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1:/tmp/cvs-serv9986 Modified Files: shell.cpp Log Message: PIDLs are now parsed by the module, and returned as a list of strings. This makes working inside PIDLs much simpler. Number of new shell global functions. Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** shell.cpp 6 Nov 2003 06:15:03 -0000 1.12 --- shell.cpp 24 Nov 2003 09:23:27 -0000 1.13 *************** *** 40,44 **** } ! void *PyShell_AllocMem(size_t cb) { IMalloc *pMalloc; --- 40,44 ---- } ! void *PyShell_AllocMem(ULONG cb) { IMalloc *pMalloc; *************** *** 72,81 **** PyObject *PyObject_FromPIDL(LPCITEMIDLIST pidl, BOOL bFreeSystemPIDL) { ! PyObject *ret = PyString_FromStringAndSize((char *)pidl, PyShell_ILGetSize(pidl) ); if (bFreeSystemPIDL) PyShell_FreeMem( (void *)pidl); return ret; } ! // @object PyIDL|A Python representation of an IDL. Implemented as a Python string. BOOL PyObject_AsPIDL(PyObject *ob, ITEMIDLIST **ppidl, BOOL bNoneOK /*= FALSE*/) { --- 72,92 ---- PyObject *PyObject_FromPIDL(LPCITEMIDLIST pidl, BOOL bFreeSystemPIDL) { ! PyObject *ret = PyList_New(0); ! if (ret) { ! while (pidl->mkid.cb) { ! // cb includes sizeof(cb) itself - so string len is cb-sizeof(cb) ! PyObject *sub = PyString_FromStringAndSize((char *)pidl->mkid.abID, pidl->mkid.cb-sizeof(pidl->mkid.cb)); ! if (sub) { ! PyList_Append(ret, sub); ! Py_DECREF(sub); ! } ! pidl = _ILNext(pidl); ! } ! } if (bFreeSystemPIDL) PyShell_FreeMem( (void *)pidl); return ret; } ! // @object PyIDL|A Python representation of an IDL. Implemented as list of Python strings. BOOL PyObject_AsPIDL(PyObject *ob, ITEMIDLIST **ppidl, BOOL bNoneOK /*= FALSE*/) { *************** *** 88,105 **** return TRUE; } ! if (!PyString_Check(ob)) { ! PyErr_SetString(PyExc_TypeError, "Only strings and None are valid ITEMIDLIST objects."); return FALSE; } ! size_t cb = PyString_Size(ob); ! void *buf = PyShell_AllocMem( cb ); ! if (buf==NULL) { ! PyErr_SetString(PyExc_MemoryError, "allocating memory for a PIDL"); return FALSE; } ! memcpy( buf, PyString_AsString(ob), cb); *ppidl = (LPITEMIDLIST)buf; return TRUE; } void PyObject_FreePIDL( LPCITEMIDLIST pidl ) { --- 99,147 ---- return TRUE; } ! if (!PySequence_Check(ob) || PyString_Check(ob)) { ! PyErr_Format(PyExc_TypeError, "Only sequences (but not strings) are valid ITEMIDLIST objects (got %s).", ob->ob_type->tp_name); return FALSE; } ! UINT num_items = (unsigned)PySequence_Length(ob); ! // first pass over the sequence to determine number of bytes. ! UINT cbTotal = sizeof((*ppidl)->mkid.cb); // Null terminator ! UINT i; ! for (i=0;i<num_items;i++) { ! PyObject *sub = PySequence_GetItem(ob, i); ! if (!sub) ! return FALSE; ! if (!PyString_Check(sub)) { ! PyErr_Format(PyExc_TypeError, "ITEMIDLIST sub-items must be strings (got %s)", sub->ob_type->tp_name); ! Py_DECREF(sub); ! return FALSE; ! } ! cbTotal += sizeof((*ppidl)->mkid.cb) + PyString_GET_SIZE(sub); ! Py_DECREF(sub); ! } ! // Now again, filling our buffer. ! void *buf = PyShell_AllocMem( cbTotal ); ! if (!buf) { ! PyErr_NoMemory(); return FALSE; } ! LPITEMIDLIST pidl = (LPITEMIDLIST)buf; ! for (i=0;i<num_items;i++) { ! PyObject *sub = PySequence_GetItem(ob, i); ! if (!sub) ! return FALSE; ! if (!PyString_Check(sub)) { ! PyErr_Format(PyExc_TypeError, "ITEMIDLIST sub-items must be strings (got %s)", sub->ob_type->tp_name); ! Py_DECREF(sub); ! return FALSE; ! } ! pidl->mkid.cb = PyString_GET_SIZE(sub) + sizeof(pidl->mkid.cb); ! memcpy(pidl->mkid.abID, PyString_AS_STRING(sub), PyString_GET_SIZE(sub)); ! pidl = _ILNext(pidl); ! } ! pidl->mkid.cb = 0; *ppidl = (LPITEMIDLIST)buf; return TRUE; } + void PyObject_FreePIDL( LPCITEMIDLIST pidl ) { *************** *** 388,391 **** --- 430,443 ---- } + // @object SHFILEINFO|A tuple representing a SHFILEINFO structure + // Represented as a tuple of (hIcon, iIcon, dwAttributes, displayName, typeName) + PyObject *PyObject_FromSHFILEINFO(SHFILEINFO *p) + { + PyObject *obDisplayName = PyWinObject_FromTCHAR(p->szDisplayName); + PyObject *obTypeName = PyWinObject_FromTCHAR(p->szTypeName); + return Py_BuildValue("iiiNN", p->hIcon, p->iIcon, p->dwAttributes, + obDisplayName, obTypeName); + } + ////////////////////////////////////////////////// // *************** *** 557,560 **** --- 609,666 ---- } + // @pymethod <o SHFILEINFO>|shell|SHGetFileInfo|Retrieves information about an object in the file system, such as a file, a folder, a directory, or a drive root. + static PyObject *PySHGetFileInfo(PyObject *self, PyObject *args) + { + PyObject *ret = NULL; + PyObject *obName; + TCHAR *name = NULL; + LPITEMIDLIST pidl = NULL; + TCHAR *pidl_or_name; + int attr, flags, info_attrs; + BOOL ok; + if (!PyArg_ParseTuple(args, "Oii|i", + &obName, // @pyparm string/<o PIDL>|name||The path and file name. Both absolute + // and relative paths are valid. + // <nl>If the uFlags parameter includes the SHGFI_PIDL flag, this parameter + // must be a valid <o PIDL> object that uniquely identifies the file within + // the shell's namespace. The PIDL must be a fully qualified PIDL. + // Relative PIDLs are not allowed. + // <nl>If the uFlags parameter includes the SHGFI_USEFILEATTRIBUTES flag, this parameter does not have to be a valid file name. + // The function will proceed as if the file exists with the specified name + // and with the file attributes passed in the dwFileAttributes parameter. + // This allows you to obtain information about a file type by passing + // just the extension for pszPath and passing FILE_ATTRIBUTE_NORMAL + // in dwFileAttributes. + // <nl>This string can use either short (the 8.3 form) or long file names. + &attr, // @pyparm int|dwFileAttributes||Combination of one or more file attribute flags (FILE_ATTRIBUTE_ values). If uFlags does not include the SHGFI_USEFILEATTRIBUTES flag, this parameter is ignored. + &flags, // @pyparm int|uFlags||Flags that specify the file information to retrieve. See MSDN for details + &info_attrs)) // @pyparm int|infoAttrs|0|Flags copued to the SHFILEINFO.dwAttributes member - useful when flags contains SHGFI_ATTR_SPECIFIED + return NULL; + if (flags & SHGFI_PIDL) { + ok = PyObject_AsPIDL(obName, &pidl, FALSE); + pidl_or_name = (TCHAR *)pidl; + } else { + ok = PyWinObject_AsTCHAR(obName, &name, FALSE); + pidl_or_name = name; + } + if (!ok) + return NULL; + SHFILEINFO info; + memset(&info, 0, sizeof(info)); + info.dwAttributes = info_attrs; + PY_INTERFACE_PRECALL; + HRESULT hr = SHGetFileInfo(name, attr, &info, sizeof(info), flags); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) { + OleSetOleError(hr); + goto done; + } + ret = PyObject_FromSHFILEINFO(&info); + done: + if (name) PyWinObject_FreeTCHAR(name); + if (pidl) PyObject_FreePIDL(pidl); + return ret; + } + // @pymethod string/<o PyUnicode>|shell|SHGetFolderPath|Retrieves the path of a folder. static PyObject *PySHGetFolderPath(PyObject *self, PyObject *args) *************** *** 819,822 **** --- 925,948 ---- } + // @pymethod <o PyIUnknown>|SHGetInstanceExplorer|Allows components that run in a Web browser (Iexplore.exe) or a nondefault Windows® Explorer (Explorer.exe) process to hold a reference to the process. The components can use the reference to prevent the process from closing prematurely. + static PyObject *PySHGetInstanceExplorer(PyObject *self, PyObject *args) + { + if (!PyArg_ParseTuple(args, ":SHGetInstanceExplorer")) + return NULL; + IUnknown *pUnk = NULL; + HRESULT hr = SHGetInstanceExplorer(&pUnk); + if (FAILED(hr)) + return OleSetOleError(hr); + return PyCom_PyObjectFromIUnknown(pUnk, IID_IUnknown, FALSE); + // @comm SHGetInstanceExplorer succeeds only if it is called from within + // an Explorer.exe or Iexplorer.exe process. It is typically used by + // components that run in the context of the Web browser (Iexplore.exe). + // However, it is also useful when Explorer.exe has been configured to + // run all folders in a second process. SHGetInstanceExplorer fails if + // the component is running in the default Explorer.exe process. There + // is no need to hold a reference to this process, as it is shut down + // only when the user logs out. + } + /* List of module functions */ // @module shell|A module, encapsulating the ActiveX Control interfaces *************** *** 827,830 **** --- 953,957 ---- { "SHGetPathFromIDList", PySHGetPathFromIDList, 1 }, // @pymeth SHGetPathFromIDList|Converts an <o PyIDL> to a path. { "SHBrowseForFolder", PySHBrowseForFolder, 1 }, // @pymeth SHBrowseForFolder|Displays a dialog box that enables the user to select a shell folder. + { "SHGetFileInfo", PySHGetFileInfo, 1}, // @pymeth SHGetFileInfo|Retrieves information about an object in the file system, such as a file, a folder, a directory, or a drive root. { "SHGetFolderPath", PySHGetFolderPath, 1 }, // @pymeth SHGetFolderPath|Retrieves the path of a folder. { "SHGetFolderLocation", PySHGetFolderLocation, 1 }, // @pymeth SHGetFolderLocation|Retrieves the <o PyIDL> of a folder. *************** *** 837,840 **** --- 964,968 ---- { "SHUpdateImage", PySHUpdateImage, 1}, // @pymeth SHUpdateImage|Notifies the shell that an image in the system image list has changed. { "SHChangeNotify", PySHChangeNotify, 1}, // @pymeth SHChangeNotify|Notifies the system of an event that an application has performed. + { "SHGetInstanceExplorer", PySHGetInstanceExplorer, 1}, // @pymeth SHGetInstanceExplorer|Allows components that run in a Web browser (Iexplore.exe) or a nondefault Windows® Explorer (Explorer.exe) process to hold a reference to the process. The components can use the reference to prevent the process from closing prematurely. { NULL, NULL }, }; |
From: <mha...@us...> - 2003-11-24 09:14:56
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src/include In directory sc8-pr-cvs1:/tmp/cvs-serv8434/include Modified Files: PythonCOM.h Log Message: New function PyCom_SetAndLogCOMErrorFromPyExceptio(), so gateway errors can better be seen. Index: PythonCOM.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/include/PythonCOM.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PythonCOM.h 2 Nov 2003 09:55:27 -0000 1.17 --- PythonCOM.h 24 Nov 2003 09:14:53 -0000 1.18 *************** *** 306,309 **** --- 306,312 ---- // information about the Python exception. + // Set a COM exception, logging the exception if not an explicitly raised 'server' exception + PYCOM_EXPORT HRESULT PyCom_SetAndLogCOMErrorFromPyException(const char *methodName, REFIID riid /* = IID_NULL */); + // Used in gateways to SetErrorInfo() with a simple HRESULT, then return it. // The description is generally only useful for debugging purposes, |
From: <mha...@us...> - 2003-11-24 09:14:56
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1:/tmp/cvs-serv8434 Modified Files: ErrorUtils.cpp Log Message: New function PyCom_SetAndLogCOMErrorFromPyExceptio(), so gateway errors can better be seen. Index: ErrorUtils.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/ErrorUtils.cpp,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** ErrorUtils.cpp 23 Oct 2003 06:17:49 -0000 1.19 --- ErrorUtils.cpp 24 Nov 2003 09:14:53 -0000 1.20 *************** *** 337,340 **** --- 337,349 ---- } + PYCOM_EXPORT HRESULT PyCom_SetAndLogCOMErrorFromPyException(const char *methodName, REFIID riid /* = IID_NULL */) + { + if (!PyErr_Occurred()) + // No error occurred + return S_OK; + PyCom_LogNonServerError("Unexpected exception in gateway method '%s'", methodName); + return PyCom_SetCOMErrorFromPyException(riid); + } + //////////////////////////////////////////////////////////////////////// // Some logging functions |
From: <mha...@us...> - 2003-11-24 09:13:14
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1:/tmp/cvs-serv8086 Modified Files: PyWinTypes.h PyUnicode.cpp Log Message: PyWinObject_AsTaskAllocatedWCHAR did not NULL terminate the strings. Abstract this function to take a function pointer to perform the allocation, so other allocators can be used (which the shell does) Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PyWinTypes.h 7 Nov 2003 03:58:17 -0000 1.17 --- PyWinTypes.h 24 Nov 2003 09:13:11 -0000 1.18 *************** *** 171,174 **** --- 171,181 ---- #ifndef MS_WINCE + // String support for buffers allocated via a function of your choice. + PYWINTYPES_EXPORT PyWinObject_AsPfnAllocatedWCHAR(PyObject *stringObject, + void *(*pfnAllocator)(ULONG), + WCHAR **ppResult, + BOOL bNoneOK = FALSE, + DWORD *pResultLen = NULL); + // String support for buffers allocated via CoTaskMemAlloc and CoTaskMemFree PYWINTYPES_EXPORT BOOL PyWinObject_AsTaskAllocatedWCHAR(PyObject *stringObject, WCHAR **ppResult, BOOL bNoneOK /*= FALSE*/,DWORD *pResultLen /*= NULL*/); Index: PyUnicode.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyUnicode.cpp,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** PyUnicode.cpp 8 Nov 2003 05:53:50 -0000 1.18 --- PyUnicode.cpp 24 Nov 2003 09:13:11 -0000 1.19 *************** *** 16,20 **** #ifndef MS_WINCE ! BOOL PyWinObject_AsTaskAllocatedWCHAR(PyObject *stringObject, WCHAR **ppResult, BOOL bNoneOK /*= FALSE*/,DWORD *pResultLen /*= NULL*/) { BOOL rc = TRUE; --- 16,20 ---- #ifndef MS_WINCE ! BOOL PyWinObject_AsPfnAllocatedWCHAR(PyObject *stringObject, void *(*pfnAllocator)(ULONG), WCHAR **ppResult, BOOL bNoneOK /*= FALSE*/,DWORD *pResultLen /*= NULL*/) { BOOL rc = TRUE; *************** *** 29,36 **** should never need more */ ! *ppResult = (LPWSTR)CoTaskMemAlloc(cch*sizeof(WCHAR)); if (*ppResult) /* convert and get the final character size */ ! cch = MultiByteToWideChar(CP_ACP, 0, buf, cch, *ppResult, cch); if (*ppResult && pResultLen) *pResultLen = cch; } else if (PyUnicode_Check(stringObject)) { --- 29,36 ---- should never need more */ ! *ppResult = (LPWSTR)(*pfnAllocator)((cch+1)*sizeof(WCHAR)); if (*ppResult) /* convert and get the final character size */ ! cch = MultiByteToWideChar(CP_ACP, 0, buf, cch+1, *ppResult, cch+1); if (*ppResult && pResultLen) *pResultLen = cch; } else if (PyUnicode_Check(stringObject)) { *************** *** 43,49 **** UINT cch = SysStringLen(v); #endif ! *ppResult = (WCHAR *)CoTaskMemAlloc(cch * sizeof(WCHAR)); if (*ppResult) ! memcpy(*ppResult, v, cch * sizeof(WCHAR)); if (*ppResult && pResultLen) *pResultLen = cch; --- 43,49 ---- UINT cch = SysStringLen(v); #endif ! *ppResult = (WCHAR *)pfnAllocator((cch+1) * sizeof(WCHAR)); if (*ppResult) ! memcpy(*ppResult, v, (cch+1) * sizeof(WCHAR)); if (*ppResult && pResultLen) *pResultLen = cch; *************** *** 61,68 **** } if (rc && !ppResult) { ! PyErr_SetString(PyExc_MemoryError, "Allocating WCHAR via CoTaskMemAlloc"); return FALSE; } return rc; } --- 61,79 ---- } if (rc && !ppResult) { ! PyErr_SetString(PyExc_MemoryError, "Allocating WCHAR"); return FALSE; } return rc; + } + + // Get around calling conversion issues. + void *AllocViaCoTaskMemAlloc(ULONG cb) + { + return CoTaskMemAlloc(cb); + } + + BOOL PyWinObject_AsTaskAllocatedWCHAR(PyObject *stringObject, WCHAR **ppResult, BOOL bNoneOK /*= FALSE*/,DWORD *pResultLen /*= NULL*/) + { + return PyWinObject_AsPfnAllocatedWCHAR(stringObject, AllocViaCoTaskMemAlloc, ppResult, bNoneOK, pResultLen); } |
From: <ru...@us...> - 2003-11-23 16:42:22
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1:/tmp/cvs-serv2578/win32/src Modified Files: win32security.i Log Message: Check if CryptEnumProviders exists (not supported on NT) Index: win32security.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32security.i,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** win32security.i 24 Oct 2003 05:32:33 -0000 1.13 --- win32security.i 23 Nov 2003 16:42:18 -0000 1.14 *************** *** 256,259 **** --- 256,261 ---- static long (WINAPI *lsarpcn)(POLICY_NOTIFICATION_INFORMATION_CLASS,HANDLE) = NULL; static long (WINAPI *lsaupcn)(POLICY_NOTIFICATION_INFORMATION_CLASS,HANDLE) = NULL; + static BOOL (WINAPI *cryptenumproviders)(DWORD, DWORD *, DWORD, DWORD *, LPTSTR, DWORD *) = NULL; + BOOL CheckIfSupported(char *funcname, WCHAR *dllname, FARPROC *fp) *************** *** 358,362 **** if (CheckIfSupported("LsaUnregisterPolicyChangeNotification",_T("Secur32.dll"),&fp)) lsaupcn=(NTSTATUS (NTAPI *)(POLICY_NOTIFICATION_INFORMATION_CLASS,HANDLE))(fp); ! %} --- 360,365 ---- if (CheckIfSupported("LsaUnregisterPolicyChangeNotification",_T("Secur32.dll"),&fp)) lsaupcn=(NTSTATUS (NTAPI *)(POLICY_NOTIFICATION_INFORMATION_CLASS,HANDLE))(fp); ! if (CheckIfSupported("CryptEnumProvidersW", _T("Advapi32.dll"),&fp)) ! cryptenumproviders=(BOOL (WINAPI *)(DWORD, DWORD *, DWORD, DWORD *, LPTSTR, DWORD *))(fp); %} *************** *** 2088,2091 **** --- 2091,2096 ---- static PyObject *PyCryptEnumProviders(PyObject *self, PyObject *args) { + if (cryptenumproviders==NULL) + return PyErr_Format(PyExc_NotImplementedError,"CryptEnumProviders not supported by this version of Windows"); if (!PyArg_ParseTuple(args, ":CryptEnumProviders")) return NULL; *************** *** 2099,2103 **** cbProvName=0; pszProvName=NULL; ! succeeded = CryptEnumProviders(dwIndex, NULL, dwFlags, &dwProvType, NULL, &cbProvName); if (!succeeded) break; --- 2104,2108 ---- cbProvName=0; pszProvName=NULL; ! succeeded = (*cryptenumproviders)(dwIndex, NULL, dwFlags, &dwProvType, NULL, &cbProvName); if (!succeeded) break; *************** *** 2111,2115 **** return NULL; } ! succeeded = CryptEnumProviders(dwIndex, NULL, dwFlags, &dwProvType, pszProvName, &cbProvName); if (!succeeded){ free(pszProvName); --- 2116,2120 ---- return NULL; } ! succeeded = (*cryptenumproviders)(dwIndex, NULL, dwFlags, &dwProvType, pszProvName, &cbProvName); if (!succeeded){ free(pszProvName); |
From: <ru...@us...> - 2003-11-16 07:00:34
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1:/tmp/cvs-serv26489/win32/src Modified Files: win32file.i Log Message: Add AddUsersToEncryptedFile and related functions Index: win32file.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32file.i,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** win32file.i 29 Oct 2003 02:06:14 -0000 1.33 --- win32file.i 16 Nov 2003 06:59:53 -0000 1.34 *************** *** 2341,2344 **** --- 2341,2351 ---- static BOOL (WINAPI *pfnDecryptFile)(WCHAR *)=NULL; static BOOL (WINAPI *pfnEncryptionDisable)(WCHAR *, BOOL)=NULL; + static BOOL (WINAPI *pfnFileEncryptionStatus)(WCHAR *, LPDWORD)=NULL; + static DWORD (WINAPI *pfnQueryUsersOnEncryptedFile)(WCHAR *, PENCRYPTION_CERTIFICATE_HASH_LIST *)=NULL; + static BOOL (WINAPI *pfnFreeEncryptionCertificateHashList)(PENCRYPTION_CERTIFICATE_HASH_LIST)=NULL; + static DWORD (WINAPI *pfnQueryRecoveryAgentsOnEncryptedFile)(WCHAR *, PENCRYPTION_CERTIFICATE_HASH_LIST *)=NULL; + static DWORD (WINAPI *pfnRemoveUsersFromEncryptedFile)(WCHAR *, PENCRYPTION_CERTIFICATE_HASH_LIST)=NULL; + static DWORD (WINAPI *pfnAddUsersToEncryptedFile)(WCHAR *, PENCRYPTION_CERTIFICATE_LIST)=NULL; + *************** *** 2522,2525 **** --- 2529,2533 ---- } + // @pyswig |EncryptFile|Encrypts specified file (requires Win2k or higher and NTFS) static PyObject* *************** *** 2591,2594 **** --- 2599,3017 ---- } + // @pyswig int|FileEncryptionStatus|Requires Windows 2000 or higher - Returns FILE_ENCRYPTABLE, FILE_IS_ENCRYPTED, FILE_SYSTEM_ATTR, FILE_ROOT_DIR, FILE_SYSTEM_DIR, FILE_UNKNOWN, FILE_SYSTEM_NOT_SUPPORT, FILE_USER_DISALLOWED, or FILE_READ_ONLY + static PyObject* + py_FileEncryptionStatus(PyObject *self, PyObject *args) + { + // @pyparm string/unicode|FileName||file to query + PyObject *ret=NULL, *obfname=NULL; + WCHAR *fname = NULL; + DWORD Status=0; + if (pfnFileEncryptionStatus==NULL) + return PyErr_Format(PyExc_NotImplementedError,"FileEncryptionStatus not supported by this version of Windows"); + if (!PyArg_ParseTuple(args,"O", &obfname)) + return NULL; + if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) + return NULL; + if (!(*pfnFileEncryptionStatus)(fname, &Status)) + PyWin_SetAPIError("FileEncryptionStatus"); + else + ret=Py_BuildValue("i",Status); + PyWinObject_FreeWCHAR(fname); + return ret; + } + + void PyWinObject_FreePENCRYPTION_CERTIFICATE_LIST(PENCRYPTION_CERTIFICATE_LIST pecl) + { + DWORD cert_ind=0; + PENCRYPTION_CERTIFICATE *ppec=NULL; + if (pecl->pUsers != NULL){ + ppec=pecl->pUsers; + for (cert_ind=0;cert_ind<pecl->nUsers;cert_ind++){ + if (*ppec != NULL){ + if ((*ppec)->pCertBlob != NULL) + free ((*ppec)->pCertBlob); + // don't free PENCRYPTION_CERTIFICATE->pCertBlob->pbData or PENCRYPTION_CERTIFICATE->pUserSid, + // both have internal pointers from Python string and Sid objects + free (*ppec); + } + ppec++; + } + free(pecl->pUsers); + } + } + + void PyWinObject_FreePENCRYPTION_CERTIFICATE_HASH_LIST(PENCRYPTION_CERTIFICATE_HASH_LIST pechl) + { + DWORD hash_ind=0; + PENCRYPTION_CERTIFICATE_HASH *ppech=NULL; + if (pechl->pUsers != NULL){ + ppech=pechl->pUsers; + for (hash_ind=0;hash_ind<pechl->nCert_Hash;hash_ind++){ + if (*ppech != NULL){ + // PENCRYPTION_CERTIFICATE_HASH->pHash->pbData and PENCRYPTION_CERTIFICATE_HASH->pUserSid + // will be freed when corresponding python objects are deallocated + if ((*ppech)->lpDisplayInformation != NULL) + PyWinObject_FreeWCHAR((*ppech)->lpDisplayInformation); + if ((*ppech)->pHash != NULL) + free ((*ppech)->pHash); + free (*ppech); + } + ppech++; + } + free(pechl->pUsers); + } + } + + PyObject *PyWinObject_FromPENCRYPTION_CERTIFICATE_LIST(PENCRYPTION_CERTIFICATE_LIST pecl) + { + DWORD user_cnt; + PENCRYPTION_CERTIFICATE *user_item=NULL; + PyObject *obsid=NULL, *ret_item=NULL; + PyObject *ret=PyTuple_New(pecl->nUsers); + if (!ret){ + PyErr_SetString(PyExc_MemoryError,"PyWinObject_FromPENCRYPTION_CERTIFICATE_LIST: unable to allocate return tuple"); + return NULL; + } + user_item=pecl->pUsers; + for (user_cnt=0; user_cnt < pecl->nUsers; user_cnt++){ + obsid=PyWinObject_FromSID((*user_item)->pUserSid); + ret_item=Py_BuildValue("Ns#", obsid, (*user_item)->pCertBlob->pbData,(*user_item)->pCertBlob->cbData); + if (!ret_item){ + PyErr_SetString(PyExc_MemoryError,"PyWinObject_FromPENCRYPTION_CERTIFICATE_LIST: unable to allocate tuple item"); + Py_DECREF(ret); + return NULL; + } + PyTuple_SetItem(ret, user_cnt, ret_item); + user_item++; + } + return ret; + } + + PyObject *PyWinObject_FromPENCRYPTION_CERTIFICATE_HASH_LIST(PENCRYPTION_CERTIFICATE_HASH_LIST pechl) + { + DWORD user_cnt; + PENCRYPTION_CERTIFICATE_HASH *user_item=NULL; + PyObject *obsid=NULL, *obDisplayInformation=NULL, *ret_item=NULL; + PyObject *ret=PyTuple_New(pechl->nCert_Hash); + if (!ret){ + PyErr_SetString(PyExc_MemoryError,"PyWinObject_FromPENCRYPTION_CERTIFICATE_HASH_LIST: unable to allocate return tuple"); + return NULL; + } + user_item=pechl->pUsers; + for (user_cnt=0; user_cnt < pechl->nCert_Hash; user_cnt++){ + obsid=PyWinObject_FromSID((*user_item)->pUserSid); + obDisplayInformation=PyWinObject_FromWCHAR((*user_item)->lpDisplayInformation); + if (!obDisplayInformation){ + Py_DECREF(ret); + return NULL; + } + ret_item=Py_BuildValue("Ns#N", obsid, (*user_item)->pHash->pbData,(*user_item)->pHash->cbData, obDisplayInformation); + if (!ret_item){ + PyErr_SetString(PyExc_MemoryError,"PyWinObject_FromPENCRYPTION_CERTIFICATE_HASH_LIST: unable to allocate tuple item"); + Py_DECREF(ret); + return NULL; + } + PyTuple_SetItem(ret, user_cnt, ret_item); + user_item++; + } + return ret; + } + + BOOL PyWinObject_AsPENCRYPTION_CERTIFICATE_LIST(PyObject *obcert_list, PENCRYPTION_CERTIFICATE_LIST pecl) + { + char *format_msg="ENCRYPTION_CERTIFICATE_LIST must be represented as a sequence of sequences of (PySID, str, int dwCertEncodingType )"; + BOOL bSuccess=TRUE; + DWORD cert_cnt=0, cert_ind=0; + PENCRYPTION_CERTIFICATE *ppec=NULL; + PyObject *obcert=NULL; + PyObject *obsid=NULL, *obcert_member=NULL; + + if (!PySequence_Check(obcert_list)){ + PyErr_SetString(PyExc_TypeError,format_msg); + return FALSE; + } + cert_cnt=PySequence_Length(obcert_list); + pecl->nUsers=cert_cnt; + ppec=(PENCRYPTION_CERTIFICATE *)malloc(cert_cnt*sizeof(PENCRYPTION_CERTIFICATE)); + if (ppec==NULL){ + PyErr_SetString(PyExc_MemoryError,"PyWinObject_AsENCRYPTION_CERTIFICATE_LIST: unable to allocate hash list"); + return NULL; + } + ZeroMemory(ppec,cert_cnt*sizeof(PENCRYPTION_CERTIFICATE)); + pecl->pUsers=ppec; + + for (cert_ind=0;cert_ind<cert_cnt;cert_ind++){ + obcert=PySequence_GetItem(obcert_list, cert_ind); + if (!PySequence_Check(obcert)){ + PyErr_SetString(PyExc_TypeError,format_msg); + bSuccess=FALSE; + } + if (bSuccess) + if (PySequence_Length(obcert)!=3){ + PyErr_SetString(PyExc_TypeError,format_msg); + bSuccess=FALSE; + } + if (bSuccess){ + *ppec=new(ENCRYPTION_CERTIFICATE); + if (*ppec==NULL){ + PyErr_SetString(PyExc_MemoryError,"PyWinObject_AsENCRYPTION_CERTIFICATE_LIST: unable to allocate ENCRYPTION_CERTIFICATE"); + bSuccess=FALSE; + } + } + if (bSuccess){ + ZeroMemory(*ppec,sizeof(ENCRYPTION_CERTIFICATE)); + (*ppec)->cbTotalLength=sizeof(ENCRYPTION_CERTIFICATE); + obcert_member=PySequence_GetItem(obcert,0); + bSuccess=PyWinObject_AsSID(obcert_member, (PSID *)&((*ppec)->pUserSid)); + Py_DECREF(obcert_member); + } + + if (bSuccess){ + (*ppec)->pCertBlob=new(EFS_CERTIFICATE_BLOB); + if ((*ppec)->pCertBlob==NULL){ + PyErr_SetString(PyExc_MemoryError,"PyWinObject_AsENCRYPTION_CERTIFICATE_LIST: unable to allocate EFS_CERTIFICATE_BLOB"); + bSuccess=FALSE; + } + } + if (bSuccess){ + ZeroMemory((*ppec)->pCertBlob,sizeof(EFS_CERTIFICATE_BLOB)); + obcert_member=PySequence_GetItem(obcert,1); + if (!PyInt_Check(obcert_member)){ + PyErr_SetString(PyExc_TypeError,"Second item (dwCertEncodingType) of ENCRYPTION_CERTIFICATE must be an integer"); + bSuccess=FALSE; + } + else + (*ppec)->pCertBlob->dwCertEncodingType=PyInt_AsLong(obcert_member); + Py_DECREF(obcert_member); + } + + if (bSuccess){ + obcert_member=PySequence_GetItem(obcert,2); + if (PyString_AsStringAndSize(obcert_member, + (char **)&((*ppec)->pCertBlob->pbData), + (int *) &((*ppec)->pCertBlob->cbData))==-1){ + PyErr_SetString(PyExc_TypeError,"Third item of ENCRYPTION_CERTIFICATE must be a string containing encoded certificate data"); + bSuccess=FALSE; + } + Py_DECREF(obcert_member); + } + Py_DECREF(obcert); + if (!bSuccess) + break; + ppec++; + } + return bSuccess; + } + + BOOL PyWinObject_AsPENCRYPTION_CERTIFICATE_HASH_LIST(PyObject *obhash_list, PENCRYPTION_CERTIFICATE_HASH_LIST pechl) + { + char *err_msg="ENCRYPTION_CERTIFICATE_HASH_LIST must be represented as a sequence of sequences of (PySID, string, unicode)"; + BOOL bSuccess=TRUE; + DWORD hash_cnt=0, hash_ind=0; + PENCRYPTION_CERTIFICATE_HASH *ppech=NULL; + PyObject *obsid=NULL, *obDisplayInformation=NULL, *obhash=NULL; + PyObject *obhash_item=NULL; + + if (!PySequence_Check(obhash_list)){ + PyErr_SetString(PyExc_TypeError,err_msg); + return FALSE; + } + hash_cnt=PySequence_Length(obhash_list); + pechl->nCert_Hash=hash_cnt; + ppech=(PENCRYPTION_CERTIFICATE_HASH *)malloc(hash_cnt*sizeof(PENCRYPTION_CERTIFICATE_HASH)); + if (ppech==NULL){ + PyErr_SetString(PyExc_MemoryError,"PyWinObject_AsENCRYPTION_CERTIFICATE_HASH_LIST: unable to allocate ENCRYPTION_CERTIFICATE_HASH_LIST"); + return FALSE; + } + ZeroMemory(ppech,hash_cnt*sizeof(PENCRYPTION_CERTIFICATE_HASH)); + pechl->pUsers=ppech; + + for (hash_ind=0;hash_ind<hash_cnt;hash_ind++){ + obhash=PySequence_GetItem(obhash_list, hash_ind); + if (!PySequence_Check(obhash)){ + PyErr_SetString(PyExc_TypeError,err_msg); + bSuccess=FALSE; + } + if (bSuccess) + if (PySequence_Length(obhash)!=3){ + PyErr_SetString(PyExc_TypeError,err_msg); + bSuccess=FALSE; + } + if (bSuccess){ + *ppech=new(ENCRYPTION_CERTIFICATE_HASH); + if (*ppech==NULL){ + PyErr_SetString(PyExc_MemoryError,"PyWinObject_AsPENCRYPTION_CERTIFICATE_HASH_LIST: unable to allocate EMCRYPTION_CERTIFICATE_HASH"); + bSuccess=FALSE; + } + } + if (bSuccess){ + ZeroMemory(*ppech,sizeof(ENCRYPTION_CERTIFICATE_HASH)); + (*ppech)->cbTotalLength=sizeof(ENCRYPTION_CERTIFICATE_HASH); + obhash_item=PySequence_GetItem(obhash,0); + bSuccess=PyWinObject_AsSID(obhash_item, (PSID *)&((*ppech)->pUserSid)); + Py_DECREF(obhash_item); + } + + if (bSuccess){ + (*ppech)->pHash=new(EFS_HASH_BLOB); + if ((*ppech)->pHash==NULL){ + PyErr_SetString(PyExc_MemoryError,"PyWinObject_AsPENCRYPTION_CERTIFICATE_HASH_LIST: unable to allocate EFS_HASH_BLOB"); + bSuccess=FALSE; + } + } + + if (bSuccess){ + ZeroMemory((*ppech)->pHash,sizeof(EFS_HASH_BLOB)); + obhash_item=PySequence_GetItem(obhash,1); + if (PyString_AsStringAndSize(obhash_item, + (char **)&((*ppech)->pHash->pbData), + (int *) &((*ppech)->pHash->cbData))==-1){ + PyErr_SetString(PyExc_TypeError,"Second item of ENCRYPTION_CERTIFICATE_HASH tuple must be a string containing encoded certificate data"); + bSuccess=FALSE; + } + Py_DECREF(obhash_item); + } + + if (bSuccess){ + obhash_item=PySequence_GetItem(obhash,2); + bSuccess=PyWinObject_AsWCHAR(obhash_item, &(*ppech)->lpDisplayInformation); + Py_DECREF(obhash_item); + } + Py_DECREF(obhash); + if (!bSuccess) + break; + ppech++; + } + return bSuccess; + } + + + // @pyswig (<o PySID>,string,unicode)|QueryUsersOnEncryptedFile|Returns list of users for an encrypted file as tuples of (SID, certificate hash blob, display info) + static PyObject* + py_QueryUsersOnEncryptedFile(PyObject *self, PyObject *args) + { + // @pyparm string/unicode|FileName||file to query + if ((pfnQueryUsersOnEncryptedFile==NULL)||(pfnFreeEncryptionCertificateHashList==NULL)) + return PyErr_Format(PyExc_NotImplementedError,"QueryUsersOnEncryptedFile not supported by this version of Windows"); + PyObject *ret=NULL, *obfname=NULL, *ret_item=NULL; + WCHAR *fname=NULL; + DWORD err=0; + PyObject *obsid=NULL, *obDisplayInformation=NULL; + PENCRYPTION_CERTIFICATE_HASH_LIST pechl=NULL; + + if (!PyArg_ParseTuple(args,"O:QueryUsersOnEncryptedFile", &obfname)) + return NULL; + if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) + return NULL; + + err=(*pfnQueryUsersOnEncryptedFile)(fname, &pechl); + if (err != ERROR_SUCCESS) + PyWin_SetAPIError("QueryUsersOnEncryptedFile",err); + else + ret=PyWinObject_FromPENCRYPTION_CERTIFICATE_HASH_LIST(pechl); + + if (fname!=NULL) + PyWinObject_FreeWCHAR(fname); + if (pechl!=NULL) + (*pfnFreeEncryptionCertificateHashList)(pechl); + return ret; + } + + // @pyswig (<o PySID>,string,unicode)|QueryRecoveryAgentsOnEncryptedFile|Lists recovery agents for file as a tuple of tuples - ((SID, certificate hash blob, display info),....) + static PyObject* + py_QueryRecoveryAgentsOnEncryptedFile(PyObject *self, PyObject *args) + { + // @pyparm string/unicode|FileName||file to query + if ((pfnQueryRecoveryAgentsOnEncryptedFile==NULL)||(pfnFreeEncryptionCertificateHashList==NULL)) + return PyErr_Format(PyExc_NotImplementedError,"QueryRecoveryAgentsOnEncryptedFile not supported by this version of Windows"); + PyObject *ret=NULL, *obfname=NULL, *ret_item=NULL; + WCHAR *fname=NULL; + DWORD user_cnt=0, err=0; + PyObject *obsid=NULL, *obDisplayInformation=NULL; + PENCRYPTION_CERTIFICATE_HASH_LIST pechl=NULL; + PENCRYPTION_CERTIFICATE_HASH *user_item=NULL; + if (!PyArg_ParseTuple(args,"O:QueryRecoveryAgentsOnEncryptedFile", &obfname)) + return NULL; + if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) + return NULL; + + err=(*pfnQueryRecoveryAgentsOnEncryptedFile)(fname, &pechl); + if (err != ERROR_SUCCESS) + PyWin_SetAPIError("QueryRecoveryAgentsOnEncryptedFile",err); + else + ret=PyWinObject_FromPENCRYPTION_CERTIFICATE_HASH_LIST(pechl); + + if (fname!=NULL) + PyWinObject_FreeWCHAR(fname); + if (pechl!=NULL) + (*pfnFreeEncryptionCertificateHashList)(pechl); + return ret; + } + + // @pyswig |RemoveUsersFromEncryptedFile|Removes specified certificates from file - if certificate is not found, it is ignored + static PyObject* + py_RemoveUsersFromEncryptedFile(PyObject *self, PyObject *args) + { + // @pyparm string/unicode|FileName||File from which to remove users + // @pyparm ((<o PySID>,string,unicode),...)|pHashes||Sequence representing an ENCRYPTION_CERTIFICATE_HASH_LIST structure, as returned by QueryUsersOnEncryptedFile + if (pfnRemoveUsersFromEncryptedFile==NULL) + return PyErr_Format(PyExc_NotImplementedError,"RemoveUsersFromEncryptedFile not supported by this version of Windows"); + PyObject *ret=NULL, *obfname=NULL, *obechl=NULL; + WCHAR *fname=NULL; + DWORD err=0; + ENCRYPTION_CERTIFICATE_HASH_LIST echl; + ZeroMemory(&echl,sizeof(ENCRYPTION_CERTIFICATE_HASH_LIST)); + if (!PyArg_ParseTuple(args,"OO:RemoveUsersFromEncryptedFile", &obfname, &obechl)) + return NULL; + if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) + return NULL; + if (!PyWinObject_AsPENCRYPTION_CERTIFICATE_HASH_LIST(obechl,&echl)) + goto done; + + err=(*pfnRemoveUsersFromEncryptedFile)(fname, &echl); + if (err != ERROR_SUCCESS) + PyWin_SetAPIError("RemoveUsersFromEncryptedFile",err); + else + ret=Py_None; + done: + PyWinObject_FreePENCRYPTION_CERTIFICATE_HASH_LIST(&echl); + if (fname!=NULL) + PyWinObject_FreeWCHAR(fname); + Py_XINCREF(ret); + return ret; + } + + // @pyswig |AddUsersToEncryptedFile|Allows user identified by SID and EFS certificate access to decrypt specified file + static PyObject* + py_AddUsersToEncryptedFile(PyObject *self, PyObject *args) + { + // @pyparm string/unicode|FileName||File that additional users will be allowed to decrypt + // @pyparm ((<o PySID>,string,int),...)|pUsers||Sequence representing ENCRYPTION_CERTIFICATE_LIST - elements are sequences consisting of users' Sid, encoded EFS certficate (user must export a .cer to obtain this data), and encoding type (usually 1 for X509_ASN_ENCODING) + if (pfnAddUsersToEncryptedFile==NULL) + return PyErr_Format(PyExc_NotImplementedError,"AddUsersToEncryptedFile not supported by this version of Windows"); + PyObject *ret=NULL, *obfname=NULL, *obecl=NULL; + WCHAR *fname=NULL; + DWORD err=0; + ENCRYPTION_CERTIFICATE_LIST ecl; + ZeroMemory(&ecl,sizeof(ENCRYPTION_CERTIFICATE_LIST)); + if (!PyArg_ParseTuple(args,"OO:AddUsersToEncryptedFile", &obfname, &obecl)) + return NULL; + if (!PyWinObject_AsWCHAR(obfname, &fname, FALSE)) + return NULL; + if (!PyWinObject_AsPENCRYPTION_CERTIFICATE_LIST(obecl,&ecl)) + return NULL; + + err=(*pfnAddUsersToEncryptedFile)(fname, &ecl); + if (err != ERROR_SUCCESS) + PyWin_SetAPIError("AddUsersToEncryptedFile",err); + else + ret=Py_None; + if (fname!=NULL) + PyWinObject_FreeWCHAR(fname); + PyWinObject_FreePENCRYPTION_CERTIFICATE_LIST(&ecl); + Py_XINCREF(ret); + return ret; + } + %} *************** *** 2602,2606 **** %native (DecryptFile) py_DecryptFile; %native (EncryptionDisable) py_EncryptionDisable; ! %init %{ --- 3025,3033 ---- %native (DecryptFile) py_DecryptFile; %native (EncryptionDisable) py_EncryptionDisable; ! %native (FileEncryptionStatus) py_FileEncryptionStatus; ! %native (QueryUsersOnEncryptedFile) py_QueryUsersOnEncryptedFile; ! %native (QueryRecoveryAgentsOnEncryptedFile) py_QueryRecoveryAgentsOnEncryptedFile; ! %native (RemoveUsersFromEncryptedFile) py_RemoveUsersFromEncryptedFile; ! %native (AddUsersToEncryptedFile) py_AddUsersToEncryptedFile; %init %{ *************** *** 2618,2623 **** --- 3045,3069 ---- fp=GetProcAddress(hmodule,"EncryptionDisable"); if (fp) pfnEncryptionDisable=(BOOL (WINAPI *)(WCHAR *, BOOL))(fp); + + fp=GetProcAddress(hmodule,"FileEncryptionStatusW"); + if (fp) pfnFileEncryptionStatus=(BOOL (WINAPI *)(WCHAR *, LPDWORD))(fp); + + fp=GetProcAddress(hmodule,"QueryUsersOnEncryptedFile"); + if (fp) pfnQueryUsersOnEncryptedFile=(DWORD (WINAPI *)(WCHAR *, PENCRYPTION_CERTIFICATE_HASH_LIST *))(fp); + + fp=GetProcAddress(hmodule,"FreeEncryptionCertificateHashList"); + if (fp) pfnFreeEncryptionCertificateHashList=(BOOL (WINAPI *)(PENCRYPTION_CERTIFICATE_HASH_LIST))(fp); + + fp=GetProcAddress(hmodule,"QueryRecoveryAgentsOnEncryptedFile"); + if (fp) pfnQueryRecoveryAgentsOnEncryptedFile=(DWORD (WINAPI *)(WCHAR *,PENCRYPTION_CERTIFICATE_HASH_LIST *))(fp); + + fp=GetProcAddress(hmodule,"RemoveUsersFromEncryptedFile"); + if (fp) pfnRemoveUsersFromEncryptedFile=(DWORD (WINAPI *)(WCHAR *,PENCRYPTION_CERTIFICATE_HASH_LIST))(fp); + + fp=GetProcAddress(hmodule,"AddUsersToEncryptedFile"); + if (fp) pfnAddUsersToEncryptedFile=(DWORD (WINAPI *)(WCHAR *,PENCRYPTION_CERTIFICATE_LIST))(fp); } + hmodule = GetModuleHandle("kernel32.dll"); if (hmodule){ *************** *** 2688,2690 **** #define PURGE_RXCLEAR PURGE_RXCLEAR // Clears the input buffer (if the device driver has one). ! --- 3134,3144 ---- #define PURGE_RXCLEAR PURGE_RXCLEAR // Clears the input buffer (if the device driver has one). ! #define FILE_ENCRYPTABLE FILE_ENCRYPTABLE ! #define FILE_IS_ENCRYPTED FILE_IS_ENCRYPTED ! #define FILE_SYSTEM_ATTR FILE_SYSTEM_ATTR ! #define FILE_ROOT_DIR FILE_ROOT_DIR ! #define FILE_SYSTEM_DIR FILE_SYSTEM_DIR ! #define FILE_UNKNOWN FILE_UNKNOWN ! #define FILE_SYSTEM_NOT_SUPPORT FILE_SYSTEM_NOT_SUPPORT ! #define FILE_USER_DISALLOWED FILE_USER_DISALLOWED ! #define FILE_READ_ONLY FILE_READ_ONLY |
From: <mha...@us...> - 2003-11-12 12:03:20
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1:/tmp/cvs-serv21926 Modified Files: setup_win32all_core.py Log Message: Start of getting non-py files installed. Index: setup_win32all_core.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup_win32all_core.py,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** setup_win32all_core.py 11 Nov 2003 11:14:40 -0000 1.18 --- setup_win32all_core.py 12 Nov 2003 12:02:56 -0000 1.19 *************** *** 1,6 **** ! # distutils setup-script for win32all core dlls, currently only ! # pywintypes and pythoncom. # # Thomas Heller, started in 2000 or so. from distutils.core import setup, Extension, Command --- 1,13 ---- ! # distutils setup-script for win32all # # Thomas Heller, started in 2000 or so. + # + # Things known to be missing: + # * Commented "data files" + # * Install of .exe/.dlls - most .exe files go next to python.exe + # * "dbi" was built as .dll, as odbc depends on it. does it work? + # * create win32com\gen_py directory post install. + # * Installing the 2 system DLLs to the system directory (just notice post- + # setup script does this - maybe do this on std "install" too? from distutils.core import setup, Extension, Command *************** *** 9,12 **** --- 16,21 ---- from distutils.dep_util import newer_group from distutils import log + from distutils.sysconfig import get_python_lib + from distutils.filelist import FileList import os, string, sys *************** *** 531,534 **** --- 540,573 ---- WinExt_pythonwin("Pythonwin", extra_link_args=["/SUBSYSTEM:WINDOWS"]), ] + + # XXX - incomplete, but checking in to avoid conflicts with Thomas ;) + # NOTE: somewhat counter-intuitively, a result list a-la: + # [('Lib/site-packages\\Pythonwin', ('Pythonwin/license.txt',)),] + # will 'do the right thing' in terms of installing licence.txt into + # 'Lib/site-packages/Pythonwin/licence.txt'. I intent exploiting this to + # get 'com/wincom/whatever' installed to 'win32com/whatever' + def convert_data_files(files): + ret = [] + for file in files: + if file.find("*") >= 0: + continue + flist = FileList(os.path.dirname(file)) + if not flist.include_pattern(os.path.basename(file)): + raise RuntimeError, "No files match '%s'" % file + found = flist.files + else: + if not os.path.isfile(file): + raise RuntimeError, "No file '%s'" % file + path = os.path.join("Lib/site-packages", os.path.dirname(file)) + ret.append( (path, (file,)) ) + continue + # xxx - incomplete, but semi-working, and going to bed :) + # found = [file] + ret.append( ("Lib/site-packages", found) ) + + print ret + return ret + + ################################################################ *************** *** 555,558 **** --- 594,612 ---- "Pythonwin": "Pythonwin"}, + data_files=convert_data_files([ + 'Pythonwin/pywin/*.cfg', + 'pywin32.chm', + 'Pythonwin/license.txt', + 'win32/license.txt', + # win32com readme (doesn't work for cvt_data_files) + # win32com/license + # win32com test - *.txt, *.py, *.vbs, *.js, *.sct, *.xsl + # win32com HTML\* + # win32com HTML\image\* + # win32comext\axscript\test - *.py, *.vbs, *.pys + # win32comext\axscript\demos\ie\*.* + # win32comext\axscript\demos\wsh\*.* + # win32comext\axscript\demos\asp\*.* + ]), packages=['win32', 'win32com', *************** *** 600,609 **** # If we did any extension building... if dist.command_obj.has_key('build_ext'): # Print the list of extension modules we skipped building. excluded_extensions = dist.command_obj['build_ext'].excluded_extensions if excluded_extensions: ! print "*** NOTE: The following extensions were NOT built:" for ext, why in excluded_extensions: print " %s: %s" % (ext.name, why) else: ! print "All extension modules built OK" --- 654,666 ---- # If we did any extension building... if dist.command_obj.has_key('build_ext'): + what_string = "built" + if dist.command_obj.has_key('install'): # just to be purdy + what_string += "/installed" # Print the list of extension modules we skipped building. excluded_extensions = dist.command_obj['build_ext'].excluded_extensions if excluded_extensions: ! print "*** NOTE: The following extensions were NOT %s:" % what_string for ext, why in excluded_extensions: print " %s: %s" % (ext.name, why) else: ! print "All extension modules %s OK" % (what_string,) |
From: <mha...@us...> - 2003-11-12 10:03:27
|
Update of /cvsroot/pywin32/pywin32/com/win32com/test In directory sc8-pr-cvs1:/tmp/cvs-serv2371/com/win32com/test Modified Files: __init__.py Log Message: Add a comment - empty __init__.py files are (Semi) evil. Index: __init__.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/test/__init__.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** __init__.py 1 Sep 1999 23:04:51 -0000 1.1 --- __init__.py 12 Nov 2003 10:03:05 -0000 1.2 *************** *** 0 **** --- 1 ---- + # Empty file to designate a Python package |
From: <mha...@us...> - 2003-11-12 00:12:34
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1:/tmp/cvs-serv7985 Modified Files: win32uiole.cpp Log Message: Magically fix build errors when using standard MSVC6 headers. Index: win32uiole.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uiole.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32uiole.cpp 9 Feb 2001 07:35:52 -0000 1.2 --- win32uiole.cpp 12 Nov 2003 00:12:31 -0000 1.3 *************** *** 6,14 **** #include "win32template.h" #include "PythonCOM.h" #include "afxdao.h" // Sorry about this - OLE support needs MFC private header. ! // Adding MFC source path to include path causes grief! ! //#include "c:\program files\DevStudio\VC\mfc\src\occimpl.h" #include "..\src\occimpl.h" --- 6,20 ---- #include "win32template.h" #include "PythonCOM.h" + // not including this here causes compile errors when it *is* + // included by later headers, using MSVC6 standard headers + // (although replacing transact.h with a later Platform SDK + // version does *not* give the error. Whatever. + #include "transact.h" #include "afxdao.h" // Sorry about this - OLE support needs MFC private header. ! // You MUST install MFC with source-code to build this extension. ! // (and this source must be in "../src" relative to the MFC ! // includes, which it is by default) #include "..\src\occimpl.h" |
From: <mha...@us...> - 2003-11-11 23:57:35
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1:/tmp/cvs-serv4153 Modified Files: PythonService.cpp Log Message: PythonService.exe -register would crash with a thread-state error. Update usage to indicate that '-register' shouldn't be necessary any more (as win32serviceutil can generally find it fine - registration is only a fallback when the .EXE isn't in a place win32serviceutil can find. One day I will drop PythonService.exe completely, and with it will go this entire concept. Index: PythonService.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PythonService.cpp,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PythonService.cpp 8 Nov 2003 12:34:45 -0000 1.11 --- PythonService.cpp 11 Nov 2003 23:57:31 -0000 1.12 *************** *** 972,976 **** printf("Options:\n"); #ifndef BUILD_FREEZE ! printf(" -register - register the EXE - this must be done at least once.\n"); #endif printf(" -debug servicename [parms] - debug the Python service.\n"); --- 972,976 ---- printf("Options:\n"); #ifndef BUILD_FREEZE ! printf(" -register - register the EXE - this should generally not be necessary.\n"); #endif printf(" -debug servicename [parms] - debug the Python service.\n"); *************** *** 1140,1145 **** return FALSE; } ! if (!Py_IsInitialized()) ! Py_Initialize(); // Register this specific EXE against this specific DLL version PyObject *obVerString = PySys_GetObject("winver"); --- 1140,1145 ---- return FALSE; } ! assert (Py_IsInitialized()); ! CEnterLeavePython _celp; // Register this specific EXE against this specific DLL version PyObject *obVerString = PySys_GetObject("winver"); |
From: <mha...@us...> - 2003-11-11 23:46:08
|
Update of /cvsroot/pywin32/pywin32/com/win32com/src In directory sc8-pr-cvs1:/tmp/cvs-serv1930 Modified Files: PythonCOM.cpp Log Message: Remove RecoverFromID, which was an old debugging hack used by Greg Stein allowing you to (try to) reference any memory address you like, and has not been used in many years. Index: PythonCOM.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32com/src/PythonCOM.cpp,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** PythonCOM.cpp 8 Nov 2003 02:01:55 -0000 1.26 --- PythonCOM.cpp 11 Nov 2003 23:46:01 -0000 1.27 *************** *** 617,636 **** } - static PyObject *pythoncom_RecoverFromID(PyObject *self, PyObject *args) - { - int p = 0; - - if ( !PyArg_ParseTuple(args, "i", &p) ) - return NULL; - - if ( !p ) - { - Py_INCREF(Py_None); - return Py_None; - } - - return (PyObject *)p; - } - // @pymethod <o PyIDispatch>|pythoncom|UnwrapObject|Unwraps a Python instance in a gateway object. static PyObject *pythoncom_UnwrapObject(PyObject *self, PyObject *args) --- 617,620 ---- *************** *** 1455,1459 **** #endif // MS_WINCE { "ReadClassStg", pythoncom_ReadClassStg, 1}, // @pymeth ReadClassStg|Reads a CLSID from a storage object - { "RecoverFromID", pythoncom_RecoverFromID, 1 }, { "RegisterTypeLib", pythoncom_registertypelib, 1}, // @pymeth RegisterTypeLib|Adds information about a type library to the system registry. { "UnRegisterTypeLib", pythoncom_unregistertypelib, 1}, // @pymeth UnRegisterTypeLib|Removes a type library from the system registry. --- 1439,1442 ---- |
From: <mha...@us...> - 2003-11-11 11:14:52
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1:/tmp/cvs-serv1164 Modified Files: setup_win32all_core.py Log Message: Fix a few package paths, and a couple of extra PCH Index: setup_win32all_core.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup_win32all_core.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** setup_win32all_core.py 11 Nov 2003 08:29:02 -0000 1.17 --- setup_win32all_core.py 11 Nov 2003 11:14:40 -0000 1.18 *************** *** 106,109 **** --- 106,111 ---- return "win32" + # Note this is used only for "win32com extensions", not pythoncom + # itself - thus, output is "win32comext" class WinExt_win32com(WinExt): def __init__ (self, name, **kw): *************** *** 113,117 **** WinExt.__init__(self, name, **kw) def get_pywin32_dir(self): ! return "win32com/" + self.name # 'win32com.mapi.exchange' and 'win32com.mapi.exchdapi' currently only --- 115,119 ---- WinExt.__init__(self, name, **kw) def get_pywin32_dir(self): ! return "win32comext/" + self.name # 'win32com.mapi.exchange' and 'win32com.mapi.exchdapi' currently only *************** *** 519,524 **** pythonwin_extensions = [ WinExt_pythonwin("win32ui", extra_compile_args = ['-DBUILD_PYW'], ! pch_header = "stdafx.h"), ! WinExt_pythonwin("win32uiole"), WinExt_pythonwin("dde", pch_header="stdafxdde.h"), ] --- 521,526 ---- pythonwin_extensions = [ WinExt_pythonwin("win32ui", extra_compile_args = ['-DBUILD_PYW'], ! pch_header="stdafx.h"), ! WinExt_pythonwin("win32uiole", pch_header="stdafxole.h"), WinExt_pythonwin("dde", pch_header="stdafxdde.h"), ] *************** *** 548,555 **** ext_modules = win32_extensions + com_extensions + pythonwin_extensions, ! package_dir = {"win32": "win32/lib", "win32com": "com/win32com", "win32comext": "com/win32comext", ! "Pythonwin": "Pythonwin/pywin"}, packages=['win32', --- 550,557 ---- ext_modules = win32_extensions + com_extensions + pythonwin_extensions, ! package_dir = {"win32": "win32", "win32com": "com/win32com", "win32comext": "com/win32comext", ! "Pythonwin": "Pythonwin"}, packages=['win32', *************** *** 577,591 **** 'win32comext.axscript.server', 'Pythonwin', ! 'Pythonwin.debugger', ! 'Pythonwin.dialogs', ! 'Pythonwin.docking', ! 'Pythonwin.framework', ! 'Pythonwin.framework.editor', ! 'Pythonwin.framework.editor.color', ! 'Pythonwin.idle', ! 'Pythonwin.mfc', ! 'Pythonwin.scintilla', ! 'Pythonwin.tools', ], ) --- 579,599 ---- 'win32comext.axscript.server', + 'win32comext.shell', + 'win32comext.mapi', + 'win32comext.internet', + 'win32comext.axcontrol', + 'Pythonwin', ! 'Pythonwin.pywin', ! 'Pythonwin.pywin.debugger', ! 'Pythonwin.pywin.dialogs', ! 'Pythonwin.pywin.docking', ! 'Pythonwin.pywin.framework', ! 'Pythonwin.pywin.framework.editor', ! 'Pythonwin.pywin.framework.editor.color', ! 'Pythonwin.pywin.idle', ! 'Pythonwin.pywin.mfc', ! 'Pythonwin.pywin.scintilla', ! 'Pythonwin.pywin.tools', ], ) |
From: <mha...@us...> - 2003-11-11 08:29:05
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1:/tmp/cvs-serv3964 Modified Files: setup_win32all_core.py Log Message: * Reinstate environ["LIB"] check - I'm not sure what I saw, but not what I thought I saw. * Pass /SUBSYSTEM when linking pythonwin. * Enable PCH for certain projects - this halves the build time when starting from scratch! Index: setup_win32all_core.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup_win32all_core.py,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** setup_win32all_core.py 11 Nov 2003 07:38:25 -0000 1.16 --- setup_win32all_core.py 11 Nov 2003 08:29:02 -0000 1.17 *************** *** 36,39 **** --- 36,40 ---- export_symbol_file=None, dsp_file=None, + pch_header=None ): assert dsp_file or sources, "Either dsp_file or sources must be specified" *************** *** 51,54 **** --- 52,56 ---- sources.extend(self.get_source_files(dsp_file)) + self.pch_header = pch_header Extension.__init__ (self, name, sources, include_dirs, *************** *** 148,155 **** def _why_cant_build_extension(self, ext): # Return None, or a reason it can't be built. for lib in ext.libraries: if self.found_libraries.has_key(lib.lower()): continue ! for dir in self.compiler.library_dirs + ext.library_dirs: if os.path.isfile(os.path.join(dir, lib + ".lib")): self.found_libraries[lib.lower()] = True --- 150,159 ---- def _why_cant_build_extension(self, ext): # Return None, or a reason it can't be built. + common_dirs = self.compiler.library_dirs + common_dirs += os.environ.get("LIB").split(os.pathsep) for lib in ext.libraries: if self.found_libraries.has_key(lib.lower()): continue ! for dir in common_dirs + ext.library_dirs: if os.path.isfile(os.path.join(dir, lib + ".lib")): self.found_libraries[lib.lower()] = True *************** *** 305,308 **** --- 309,316 ---- return + if not self.mingw32 and ext.pch_header: + ext.extra_compile_args = ext.extra_compile_args or [] + ext.extra_compile_args.append("/YX"+ext.pch_header) + # some source files are compiled for different extensions # with special defines. So we cannot use a shared *************** *** 411,414 **** --- 419,423 ---- extra_compile_args = ['-DBUILD_PYWINTYPES'], libraries = "advapi32 user32 ole32 oleaut32", + pch_header = "PyWinTypes.h", ) *************** *** 478,496 **** export_symbol_file = 'com/win32com/src/PythonCOM.def', extra_compile_args = ['-DBUILD_PYTHONCOM'], ) com_extensions = [pythoncom] com_extensions += [ WinExt_win32com('adsi', libraries="ACTIVEDS ADSIID"), ! WinExt_win32com('axcontrol'), WinExt_win32com('axscript', dsp_file=r"com\Active Scripting.dsp", extra_compile_args = ['-DPY_BUILD_AXSCRIPT'], ), WinExt_win32com('axdebug', dsp_file=r"com\Active Debugging.dsp", libraries="axscript msdbg", ), WinExt_win32com('internet'), ! WinExt_win32com('mapi', libraries="mapi32"), WinExt_win32com_mapi('exchange', libraries="""MBLOGON ADDRLKUP mapi32 exchinst --- 487,508 ---- export_symbol_file = 'com/win32com/src/PythonCOM.def', extra_compile_args = ['-DBUILD_PYTHONCOM'], + pch_header = "stdafx.h", ) com_extensions = [pythoncom] com_extensions += [ WinExt_win32com('adsi', libraries="ACTIVEDS ADSIID"), ! WinExt_win32com('axcontrol', pch_header="axcontrol_pch.h"), WinExt_win32com('axscript', dsp_file=r"com\Active Scripting.dsp", extra_compile_args = ['-DPY_BUILD_AXSCRIPT'], + pch_header = "stdafx.h" ), WinExt_win32com('axdebug', dsp_file=r"com\Active Debugging.dsp", libraries="axscript msdbg", + pch_header = "stdafx.h", ), WinExt_win32com('internet'), ! WinExt_win32com('mapi', libraries="mapi32", pch_header="PythonCOM.h"), WinExt_win32com_mapi('exchange', libraries="""MBLOGON ADDRLKUP mapi32 exchinst *************** *** 502,514 **** EDKMAPI mapi32 version""", extra_link_args=["/nodefaultlib:libc"]), ! WinExt_win32com('shell', libraries='shell32') ] pythonwin_extensions = [ ! WinExt_pythonwin("win32ui", ! extra_compile_args = ! ['-DBUILD_PYW']), WinExt_pythonwin("win32uiole"), ! WinExt_pythonwin("dde"), ] --- 514,525 ---- EDKMAPI mapi32 version""", extra_link_args=["/nodefaultlib:libc"]), ! WinExt_win32com('shell', libraries='shell32', pch_header="shell_pch.h") ] pythonwin_extensions = [ ! WinExt_pythonwin("win32ui", extra_compile_args = ['-DBUILD_PYW'], ! pch_header = "stdafx.h"), WinExt_pythonwin("win32uiole"), ! WinExt_pythonwin("dde", pch_header="stdafxdde.h"), ] *************** *** 516,521 **** WinExt_win32("win32popenWin9x", libraries = "user32"), ! WinExt_pythonwin("Pythonwin"), ! ## extra_compile_args = ['-D_WINDOWS', '-D_AFXDLL', '-D_MBCS']), ] ################################################################ --- 527,531 ---- WinExt_win32("win32popenWin9x", libraries = "user32"), ! WinExt_pythonwin("Pythonwin", extra_link_args=["/SUBSYSTEM:WINDOWS"]), ] ################################################################ |
From: <mha...@us...> - 2003-11-11 07:38:28
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1:/tmp/cvs-serv28037 Modified Files: setup_win32all_core.py Log Message: Now this code is run as each extension is build, the compiler has already found all its dirs - so no need to look in environ["LIB"] Index: setup_win32all_core.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup_win32all_core.py,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** setup_win32all_core.py 11 Nov 2003 07:32:05 -0000 1.15 --- setup_win32all_core.py 11 Nov 2003 07:38:25 -0000 1.16 *************** *** 148,157 **** def _why_cant_build_extension(self, ext): # Return None, or a reason it can't be built. - common_dirs = self.compiler.library_dirs - common_dirs += os.environ.get("LIB").split(os.pathsep) for lib in ext.libraries: if self.found_libraries.has_key(lib.lower()): continue ! for dir in common_dirs + ext.library_dirs: if os.path.isfile(os.path.join(dir, lib + ".lib")): self.found_libraries[lib.lower()] = True --- 148,155 ---- def _why_cant_build_extension(self, ext): # Return None, or a reason it can't be built. for lib in ext.libraries: if self.found_libraries.has_key(lib.lower()): continue ! for dir in self.compiler.library_dirs + ext.library_dirs: if os.path.isfile(os.path.join(dir, lib + ".lib")): self.found_libraries[lib.lower()] = True |