pywin32-checkins Mailing List for Python for Windows Extensions (Page 82)
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: Mark H. <mha...@us...> - 2008-02-07 05:41:59
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21396/demos/servers Added Files: folder_view.propdesc folder_view.py Log Message: * Many new vista shell interfaces (ICategorizer, ICategoryProvider, IDefaultExtractIconInit, IEnumExplorerCommand, IExplorerCommandProvider) and a couple other older ones we were missing (IShellFolder2, IPersistFolder2) * New vista shell functions (AssocCreateForClasses, SHCreateDataObject, SHCreateDefaultContextMenu, SHCreateDefaultExtractIcon, SHCreateShellFolderView, SHCreateShellItemArray, SHCreateShellItemArrayFromDataObject, SHCreateShellItemArrayFromIDLists, SHCreateShellItemArrayFromShellItem, SHGetNameFromIDList * Remove hacks now we can build with Vista SDK * New demo using a default shell view and Vista explorer interfaces (but it doesn't quite work!) --- NEW FILE: folder_view.propdesc --- <schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/windows/2006/propertydescription" schemaVersion="1.0" > <propertyDescriptionList> <propertyDescription name="Sample.AreaSize" formatID="{d6f5e341-c65c-11dc-ba21-005056c00008}" propID="3"> <description>The Size of the area of the shape.</description> <searchInfo inInvertedIndex="false" isColumn="false" /> <typeInfo canStackBy="true" type="String"/> <labelInfo label="Area"/> </propertyDescription> <propertyDescription name="Sample.NumberOfSides" formatID="{d6f5e342-c65c-11dc-ba21-005056c00008}" propID="3"> <description>Number of sides is the shape.</description> <searchInfo inInvertedIndex="false" isColumn="false" /> <typeInfo canStackBy="true" type="Int32"/> <labelInfo label="Number of Sides."/> </propertyDescription> <propertyDescription name="Sample.DirectoryLevel" formatID="{d6f5e343-c65c-11dc-ba21-005056c00008}" propID="3"> <description>Number of directory levels to this item.</description> <searchInfo inInvertedIndex="false" isColumn="false" /> <typeInfo canStackBy="false" type="Int32"/> <labelInfo label="Directory Level."/> </propertyDescription> </propertyDescriptionList> </schema> --- NEW FILE: folder_view.py --- # This is a port of the Vista SDK "FolderView" sample, and associated # notes at http://shellrevealed.com/blogs/shellblog/archive/2007/03/15/Shell-Namespace-Extension_3A00_-Creating-and-Using-the-System-Folder-View-Object.aspx # A key difference to shell_view.py is that this version uses the default # IShellView provided by the shell (via SHCreateShellFolderView) rather # than our own. # XXX - sadly, it doesn't work quite like the original sample. Oh well, # another day... import sys import os import pickle import random import win32api import winxpgui as win32gui # the needs vista, let alone xp! import win32con import winerror import commctrl import pythoncom from win32com.util import IIDToInterfaceName from win32com.server.exception import COMException from win32com.server.util import wrap as _wrap from win32com.server.util import NewEnum as _NewEnum from win32com.shell import shell, shellcon from win32com.axcontrol import axcontrol # IObjectWithSite from win32com.propsys import propsys GUID=pythoncom.MakeIID # If set, output spews to the win32traceutil collector... debug=0 # wrap a python object in a COM pointer def wrap(ob, iid=None): return _wrap(ob, iid, useDispatcher=(debug>0)) def NewEnum(seq, iid): return _NewEnum(seq, iid=iid, useDispatcher=(debug>0)) # The sample makes heavy use of "string ids" (ie, integer IDs defined in .h # files, loaded at runtime from a (presumably localized) DLL. We cheat. _sids = {} # strings, indexed bystring_id, def LoadString(sid): return _sids[sid] # fn to create a unique string ID _last_ids = 0 def _make_ids(s): global _last_ids _last_ids += 1 _sids[_last_ids] = s return _last_ids # These strings are what the user sees and would be localized. # XXX - its possible that the shell might persist these values, so # this scheme wouldn't really be suitable in a real ap. IDS_UNSPECIFIED = _make_ids("unspecified") IDS_SMALL = _make_ids("small") IDS_MEDIUM = _make_ids("medium") IDS_LARGE = _make_ids("large") IDS_CIRCLE = _make_ids("circle") IDS_TRIANGLE = _make_ids("triangle") IDS_RECTANGLE = _make_ids("rectangle") IDS_POLYGON = _make_ids("polygon") IDS_DISPLAY = _make_ids("Display") IDS_DISPLAY_TT = _make_ids("Display the item.") IDS_SETTINGS = _make_ids("Settings") IDS_SETTING1 = _make_ids("Setting 1") IDS_SETTING2 = _make_ids("Setting 2") IDS_SETTING3 = _make_ids("Setting 3") IDS_SETTINGS_TT = _make_ids("Modify settings.") IDS_SETTING1_TT = _make_ids("Modify setting 1.") IDS_SETTING2_TT = _make_ids("Modify setting 2.") IDS_SETTING3_TT = _make_ids("Modify setting 3.") IDS_LESSTHAN5 = _make_ids("Less Than 5") IDS_5ORGREATER = _make_ids("Five or Greater") del _make_ids, _last_ids # Other misc resource stuff IDI_ICON1 = 100 IDI_SETTINGS = 101 # The sample defines a number of "category ids". Each one gets # its own GUID. CAT_GUID_NAME=GUID("{de094c9d-c65a-11dc-ba21-005056c00008}") CAT_GUID_SIZE=GUID("{de094c9e-c65a-11dc-ba21-005056c00008}") CAT_GUID_SIDES=GUID("{de094c9f-c65a-11dc-ba21-005056c00008}") CAT_GUID_LEVEL=GUID("{de094ca0-c65a-11dc-ba21-005056c00008}") # The next category guid is NOT based on a column (see # ViewCategoryProvider::EnumCategories()...) CAT_GUID_VALUE="{de094ca1-c65a-11dc-ba21-005056c00008}" GUID_Display=GUID("{4d6c2fdd-c689-11dc-ba21-005056c00008}") GUID_Settings=GUID("{4d6c2fde-c689-11dc-ba21-005056c00008}") GUID_Setting1=GUID("{4d6c2fdf-c689-11dc-ba21-005056c00008}") GUID_Setting2=GUID("{4d6c2fe0-c689-11dc-ba21-005056c00008}") GUID_Setting3=GUID("{4d6c2fe1-c689-11dc-ba21-005056c00008}") # Hrm - not sure what to do about the std keys. # Probably need a simple parser for propkey.h PKEY_ItemNameDisplay = ("{B725F130-47EF-101A-A5F1-02608C9EEBAC}", 10) PKEY_PropList_PreviewDetails = ("{C9944A21-A406-48FE-8225-AEC7E24C211B}", 8) # Not sure what the "3" here refers to - docs say PID_FIRST_USABLE (2) be # used. Presumably it is the 'propID' value in the .propdesc file! # note that the following GUIDs are also references in the .propdesc file PID_SOMETHING=3 # These are our 'private' PKEYs # Col 2, name="Sample.AreaSize" PKEY_Sample_AreaSize=("{d6f5e341-c65c-11dc-ba21-005056c00008}", PID_SOMETHING) # Col 3, name="Sample.NumberOfSides" PKEY_Sample_NumberOfSides = ("{d6f5e342-c65c-11dc-ba21-005056c00008}", PID_SOMETHING) # Col 4, name="Sample.DirectoryLevel" PKEY_Sample_DirectoryLevel = ("{d6f5e343-c65c-11dc-ba21-005056c00008}", PID_SOMETHING) # We construct a PIDL from a pickle of a dict - turn it back into a # dict (we should *never* be called with a PIDL that the last elt is not # ours, so it is safe to assume we created it (assume->"ass" = "u" + "me" :) def pidl_to_item(pidl): # Note that only the *last* elt in the PIDL is certainly ours, # but it contains everything we need encoded as a dict. return pickle.loads(pidl[-1]) # Start of msdn sample port... # make_item_enum replaces the sample's entire EnumIDList.cpp :) def make_item_enum(level, flags): pidls = [] nums = """zero one two three four five size seven eight nine ten""".split() for i, name in enumerate(nums): size = random.randint(0,255) sides = 1 while sides in [1,2]: sides = random.randint(0,5) is_folder = (i % 2) != 0 # check the flags say to include it. # (This seems strange; if you ask the same folder for, but appear skip = False if not (flags & shellcon.SHCONTF_STORAGE): if is_folder: skip = not (flags & shellcon.SHCONTF_FOLDERS) else: skip = not (flags & shellcon.SHCONTF_NONFOLDERS) if not skip: data = dict(name=name, size=size, sides=sides, level=level, is_folder=is_folder) pidls.append([pickle.dumps(data)]) return NewEnum(pidls, shell.IID_IEnumIDList) # start of Utils.cpp port def DisplayItem(shell_item_array, hwnd_parent=0): # Get the first ShellItem and display its name if shell_item_array is None: msg = "You must select something!" else: si = shell_item_array.GetItemAt(0) name = si.GetDisplayName(shellcon.SIGDN_NORMALDISPLAY) msg = "%d items selected, first is %r" % (shell_item_array.GetCount(), name) win32gui.MessageBox(hwnd_parent, msg, "Hello", win32con.MB_OK) # end of Utils.cpp port # start of sample's FVCommands.cpp port class Command: def __init__(self, guid, ids, ids_tt, idi, flags, callback, children): self.guid = guid; self.ids = ids; self.ids_tt = ids_tt self.idi = idi; self.flags = flags; self.callback = callback; self.children = children assert not children or isinstance(children[0], Command) def tuple(self): return self.guid, self.ids, self.ids_tt, self.idi, self.flags, self.callback, self.children # command callbacks - called back directly by us - see ExplorerCommand.Invoke def onDisplay(items, bindctx): DisplayItem(items) def onSetting1(items, bindctx): win32gui.MessageBox(0, LoadString(IDS_SETTING1), "Hello", win32con.MB_OK) def onSetting2(items, bindctx): win32gui.MessageBox(0, LoadString(IDS_SETTING2), "Hello", win32con.MB_OK) def onSetting3(items, bindctx): win32gui.MessageBox(0, LoadString(IDS_SETTING3), "Hello", win32con.MB_OK) taskSettings = [ Command(GUID_Setting1, IDS_SETTING1, IDS_SETTING1_TT, IDI_SETTINGS, 0, onSetting1, None), Command(GUID_Setting2, IDS_SETTING2, IDS_SETTING2_TT, IDI_SETTINGS, 0, onSetting2, None), Command(GUID_Setting3, IDS_SETTING3, IDS_SETTING3_TT, IDI_SETTINGS, 0, onSetting3, None), ] tasks = [ Command(GUID_Display, IDS_DISPLAY, IDS_DISPLAY_TT, IDI_ICON1, 0, onDisplay, None ), Command(GUID_Settings, IDS_SETTINGS, IDS_SETTINGS_TT, IDI_SETTINGS, shellcon.ECF_HASSUBCOMMANDS, None, taskSettings), ] class ExplorerCommandProvider: _com_interfaces_ = [shell.IID_IExplorerCommandProvider] _public_methods_ = shellcon.IExplorerCommandProvider_Methods def GetCommands(self, site, iid): items = [wrap(ExplorerCommand(t)) for t in tasks] return NewEnum(items, shell.IID_IEnumExplorerCommand) class ExplorerCommand: _com_interfaces_ = [shell.IID_IExplorerCommand] _public_methods_ = shellcon.IExplorerCommand_Methods def __init__(self, cmd): self.cmd = cmd # The sample also appears to ignore the pidl args!? def GetTitle(self, pidl): return LoadString(self.cmd.ids) def GetToolTip(self, pidl): return LoadString(self.cmd.ids_tt) def GetIcon(self, pidl): # Return a string of the usual "dll,resource_id" format # todo - just return any ".ico that comes with python" + ",0" :) raise COMException(hresult=winerror.E_NOTIMPL) def GetState(self, shell_items, slow_ok): return shellcon.ECS_ENABLED def GetFlags(self): return self.cmd.flags def GetCanonicalName(self): return self.cmd.guid def Invoke(self, items, bind_ctx): # If no function defined - just return S_OK if self.cmd.callback: self.cmd.callback(items, bind_ctx) else: print "No callback for command ", LoadString(self.cmd.ids) def EnumSubCommands(self): if not self.cmd.children: return None items = [wrap(ExplorerCommand(c)) for c in self.cmd.children] return NewEnum(items, shell.IID_IEnumExplorerCommand) # end of sample's FVCommands.cpp port # start of sample's Category.cpp port class FolderViewCategorizer: _com_interfaces_ = [shell.IID_ICategorizer] _public_methods_ = shellcon.ICategorizer_Methods description = None # subclasses should set their own def __init__(self, shell_folder): self.sf = shell_folder # Determines the relative order of two items in their item identifier lists. def CompareCategory(self, flags, cat1, cat2): return cat1-cat2 # Retrieves the name of a categorizer, such as "Group By Device # Type", that can be displayed in the user interface. def GetDescription(self, cch): return self.description # Retrieves information about a category, such as the default # display and the text to display in the user interface. def GetCategoryInfo(self, catid): # Note: this isn't always appropriate! See overrides below return 0, str(catid) # ???? class FolderViewCategorizer_Name(FolderViewCategorizer): description = "Alphabetical" def GetCategory(self, pidls): ret = [] for pidl in pidls: val = self.sf.GetDetailsEx(pidl, PKEY_ItemNameDisplay) ret.append(val) return ret class FolderViewCategorizer_Size(FolderViewCategorizer): description = "Group By Size" def GetCategory(self, pidls): ret = [] for pidl in pidls: # Why don't we just get the size of the PIDL? val = self.sf.GetDetailsEx(pidl, PKEY_Sample_AreaSize) val = int(val) # it probably came in a VT_BSTR variant if val < 255//3: cid = IDS_SMALL elif val < 2 * 255 // 3: cid = IDS_MEDIUM else: cid = IDS_LARGE ret.append(cid) return ret def GetCategoryInfo(self, catid): return 0, LoadString(catid) class FolderViewCategorizer_Sides(FolderViewCategorizer): description = "Group By Sides" def GetCategory(self, pidls): ret = [] for pidl in pidls: val = self.sf.GetDetailsEx(pidl, PKEY_ItemNameDisplay) if val==0: cid = IDS_CIRCLE elif val==3: cid = IDS_TRIANGLE elif val==4: cid = IDS_RECTANGLE elif val==5: cid = IDS_POLYGON else: cid = IDS_UNSPECIFIED ret.append(cid) return ret def GetCategoryInfo(self, catid): return 0, LoadString(catid) class FolderViewCategorizer_Value(FolderViewCategorizer): description = "Group By Value" def GetCategory(self, pidls): ret = [] for pidl in pidls: val = self.sf.GetDetailsEx(pidl, PKEY_ItemNameDisplay) if val in "one two three four".split(): ret.append(IDS_LESSTHAN5) else: ret.append(IDS_5ORGREATER) return ret def GetCategoryInfo(self, catid): return 0, LoadString(catid) class FolderViewCategorizer_Level(FolderViewCategorizer): description = "Group By Value" def GetCategory(self, pidls): return [self.sf.GetDetailsEx(pidl, PKEY_Sample_DirectoryLevel) for pidl in pidls] class ViewCategoryProvider: _com_interfaces_ = [shell.IID_ICategoryProvider] _public_methods_ = shellcon.ICategoryProvider_Methods def __init__(self, shell_folder): self.shell_folder = shell_folder def CanCategorizeOnSCID(self, pkey): return pkey in [PKEY_ItemNameDisplay, PKEY_Sample_AreaSize, PKEY_Sample_NumberOfSides, PKEY_Sample_DirectoryLevel] # Creates a category object. def CreateCategory(self, guid, iid): if iid == shell.IID_ICategorizer: if guid == CAT_GUID_NAME: klass = FolderViewCategorizer_Name elif guid == CAT_GUID_SIDES: klass = FolderViewCategorizer_Sides elif guid == CAT_GUID_SIZE: klass = FolderViewCategorizer_Size elif guid == CAT_GUID_VALUE: klass = FolderViewCategorizer_Value elif guid == CAT_GUID_LEVEL: klass = FolderViewCategorizer_Level else: raise COMException(hresult=winerror.E_INVALIDARG) return wrap(klass(self.shell_folder)) raise COMException(hresult=winerror.E_NOINTERFACE) # Retrieves the enumerator for the categories. def EnumCategories(self): # These are additional categories beyond the columns seq = [CAT_GUID_VALUE] return NewEnum(seq, pythoncom.IID_IEnumGUID) # Retrieves a globally unique identifier (GUID) that represents # the categorizer to use for the specified Shell column. def GetCategoryForSCID(self, scid): if scid==PKEY_ItemNameDisplay: guid = CAT_GUID_NAME elif scid == PKEY_Sample_AreaSize: guid = CAT_GUID_SIZE elif scid == PKEY_Sample_NumberOfSides: guid = CAT_GUID_SIDES elif scid == PKEY_Sample_DirectoryLevel: guid = CAT_GUID_LEVEL elif scid == pythoncom.IID_NULL: # This can be called with a NULL # format ID. This will happen if you have a category, # not based on a column, that gets stored in the # property bag. When a return is made to this item, # it will call this function with a NULL format id. guid = CAT_GUID_VALUE else: raise COMException(hresult=winerror.E_INVALIDARG) return guid # Retrieves the name of the specified category. This is where # additional categories that appear under the column # related categories in the UI, get their display names. def GetCategoryName(self, guid, cch): if guid == CAT_GUID_VALUE: return "Value" raise COMException(hresult=winerror.E_FAIL) # Enables the folder to override the default grouping. def GetDefaultCategory(self): return CAT_GUID_LEVEL, (pythoncom.IID_NULL, 0) # end of sample's Category.cpp port # start of sample's ContextMenu.cpp port MENUVERB_DISPLAY = 0 folderViewImplContextMenuIDs = [ ("display", MENUVERB_DISPLAY, 0, ), ] class ContextMenu: _reg_progid_ = "Python.ShellFolderSample.ContextMenu" _reg_desc_ = "Python FolderView Context Menu" _reg_clsid_ = "{fed40039-021f-4011-87c5-6188b9979764}" _com_interfaces_ = [shell.IID_IShellExtInit, shell.IID_IContextMenu, axcontrol.IID_IObjectWithSite] _public_methods_ = shellcon.IContextMenu_Methods + shellcon.IShellExtInit_Methods + ["GetSite", "SetSite"] _context_menu_type_ = "PythonFolderViewSampleType" def __init__(self): self.site = None self.dataobj = None def Initialize(self, folder, dataobj, hkey): self.dataobj = dataobj def QueryContextMenu(self, hMenu, indexMenu, idCmdFirst, idCmdLast, uFlags): s = LoadString(IDS_DISPLAY); win32gui.InsertMenu(hMenu, indexMenu, win32con.MF_BYPOSITION, idCmdFirst + MENUVERB_DISPLAY, s); indexMenu += 1 # other verbs could go here... # indicate that we added one verb. return 1 def InvokeCommand(self, ci): mask, hwnd, verb, params, dir, nShow, hotkey, hicon = ci # this seems very convuluted, but its what the sample does :) for verb_name, verb_id, flag in folderViewImplContextMenuIDs: if isinstance(verb, int): matches = verb==verb_id else: matches = verb==verb_name if matches: break else: assert False, ci # failed to find our ID if verb_id == MENUVERB_DISPLAY: sia = shell.SHCreateShellItemArrayFromDataObject(self.dataobj) DisplayItem(hwnd, sia) else: assert False, ci # Got some verb we weren't expecting? def GetCommandString(self, cmd, typ): raise COMException(hresult=winerror.E_NOTIMPL) def SetSite(self, site): self.site = site def GetSite(self, iid): return self.site # end of sample's ContextMenu.cpp port # start of sample's ShellFolder.cpp port class ShellFolder: _com_interfaces_ = [shell.IID_IBrowserFrameOptions, pythoncom.IID_IPersist, shell.IID_IPersistFolder, shell.IID_IPersistFolder2, shell.IID_IShellFolder, shell.IID_IShellFolder2, ] _public_methods_ = shellcon.IBrowserFrame_Methods + \ shellcon.IPersistFolder2_Methods + \ shellcon.IShellFolder2_Methods _reg_progid_ = "Python.ShellFolderSample.Folder2" _reg_desc_ = "Python FolderView sample" _reg_clsid_ = "{bb8c24ad-6aaa-4cec-ac5e-c429d5f57627}" max_levels = 5 def __init__(self, level=0): self.current_level = level self.pidl = None # set when Initialize is called def ParseDisplayName(self, hwnd, reserved, displayName, attr): #print "ParseDisplayName", displayName raise COMException(hresult=winerror.E_NOTIMPL) def EnumObjects(self, hwndOwner, flags): if self.current_level >= self.max_levels: return None return make_item_enum(self.current_level+1, flags) def BindToObject(self, pidl, bc, iid): tail = pidl_to_item(pidl) # assert tail['is_folder'], "BindToObject should only be called on folders?" # *sob* # No point creating object just to have QI fail. if iid not in ShellFolder._com_interfaces_: raise COMException(hresult=winerror.E_NOTIMPL) child = ShellFolder(self.current_level+1) # hrmph - not sure what multiple PIDLs here mean? # assert len(pidl)==1, pidl # expecting just relative child PIDL child.Initialize(self.pidl + pidl) return wrap(child, iid) def BindToStorage(self, pidl, bc, iid): return self.BindToObject(pidl, bc, iid) def CompareIDs(self, param, id1, id2): return 0 # XXX - todo - implement this! def CreateViewObject(self, hwnd, iid): if iid == shell.IID_IShellView: com_folder = wrap(self) return shell.SHCreateShellFolderView(com_folder) elif iid == shell.IID_ICategoryProvider: return wrap(ViewCategoryProvider(self)) elif iid == shell.IID_IContextMenu: ws = wrap(self) dcm = (hwnd, None, self.pidl, ws, None) return shell.SHCreateDefaultContextMenu(dcm, iid) elif iid == shell.IID_IExplorerCommandProvider: return wrap(ExplorerCommandProvider()) else: raise COMException(hresult=winerror.E_NOINTERFACE) def GetAttributesOf(self, pidls, attrFlags): assert len(pidls)==1, "sample only expects 1 too!" assert len(pidls[0])==1, "expect relative pidls!" item = pidl_to_item(pidls[0]) flags = 0 if item['is_folder']: flags |= shellcon.SFGAO_FOLDER if item['level'] < self.max_levels: flags |= shellcon.SFGAO_HASSUBFOLDER return flags # Retrieves an OLE interface that can be used to carry out # actions on the specified file objects or folders. def GetUIObjectOf(self, hwndOwner, pidls, iid, inout): assert len(pidls)==1, "oops - arent expecting more than one!" assert len(pidls[0])==1, "assuming relative pidls!" item = pidl_to_item(pidls[0]) if iid == shell.IID_IContextMenu: ws = wrap(self) dcm = (hwndOwner, None, self.pidl, ws, pidls) return shell.SHCreateDefaultContextMenu(dcm, iid) elif iid == shell.IID_IExtractIconW: dxi = shell.SHCreateDefaultExtractIcon() # dxi is IDefaultExtractIconInit if item['is_folder']: dxi.SetNormalIcon("shell32.dll", 4) else: dxi.SetNormalIcon("shell32.dll", 1) # just return the dxi - let Python QI for IID_IExtractIconW return dxi elif iid == pythoncom.IID_IDataObject: return shell.SHCreateDataObject(self.pidl, pidls, None, iid); elif iid == shell.IID_IQueryAssociations: elts = [] if item['is_folder']: elts.append((shellcon.ASSOCCLASS_FOLDER, None, None)) elts.append((shellcon.ASSOCCLASS_PROGID_STR, None, ContextMenu._context_menu_type_)) return shell.AssocCreateForClasses(elts, iid) raise COMException(hresult=winerror.E_NOINTERFACE) # Retrieves the display name for the specified file object or subfolder. def GetDisplayNameOf(self, pidl, flags): item = pidl_to_item(pidl) if flags & shellcon.SHGDN_FORPARSING: if flags & shellcon.SHGDN_INFOLDER: return item['name'] else: if flags & shellcon.SHGDN_FORADDRESSBAR: sigdn = shellcon.SIGDN_DESKTOPABSOLUTEEDITING else: sigdn = shellcon.SIGDN_DESKTOPABSOLUTEPARSING parent = shell.SHGetNameFromIDList(self.pidl, sigdn) return parent + "\\" + item['name'] else: return item['name'] def SetNameOf(self, hwndOwner, pidl, new_name, flags): raise COMException(hresult=winerror.E_NOTIMPL) def GetClassID(self): return self._reg_clsid_ # IPersistFolder method def Initialize(self, pidl): self.pidl = pidl # IShellFolder2 methods def EnumSearches(self): raise COMException(hresult=winerror.E_NOINTERFACE) # Retrieves the default sorting and display columns. def GetDefaultColumn(self, dwres): # result is (sort, display) return 0, 0 # Retrieves the default state for a specified column. def GetDefaultColumnState(self, iCol): if iCol < 3: return shellcon.SHCOLSTATE_ONBYDEFAULT | shellcon.SHCOLSTATE_TYPE_STR raise COMException(hresult=winerror.E_INVALIDARG) # Requests the GUID of the default search object for the folder. def GetDefaultSearchGUID(self): raise COMException(hresult=winerror.E_NOTIMPL) # Helper function for getting the display name for a column. def _GetColumnDisplayName(self, pidl, pkey): item = pidl_to_item(pidl) is_folder = item['is_folder'] if pkey == PKEY_ItemNameDisplay: val = item['name'] elif pkey == PKEY_Sample_AreaSize and not is_folder: val = "%d Sq. Ft." % item['size'] elif pkey == PKEY_Sample_NumberOfSides and not is_folder: val = str(item['sides']) # not sure why str() elif pkey == PKEY_Sample_DirectoryLevel: val = str(item['level']) else: val = '' return val # Retrieves detailed information, identified by a # property set ID (FMTID) and property ID (PID), # on an item in a Shell folder. def GetDetailsEx(self, pidl, pkey): item = pidl_to_item(pidl) is_folder = item['is_folder'] if not is_folder and pkey == PKEY_PropList_PreviewDetails: return "prop:Sample.AreaSize;Sample.NumberOfSides;Sample.DirectoryLevel" return self._GetColumnDisplayName(pidl, pkey) # Retrieves detailed information, identified by a # column index, on an item in a Shell folder. def GetDetailsOf(self, pidl, iCol): key = self.MapColumnToSCID(iCol); if pidl is None: data = [(commctrl.LVCFMT_LEFT, "Name"), (commctrl.LVCFMT_CENTER, "Size"), (commctrl.LVCFMT_CENTER, "Sides"), (commctrl.LVCFMT_CENTER, "Level"),] if iCol >= len(data): raise COMException(hresult=winerror.E_FAIL) fmt, val = data[iCol] else: fmt = 0 # ? val = self._GetColumnDisplayName(pidl, key) cxChar = 24 return fmt, cxChar, val # Converts a column name to the appropriate # property set ID (FMTID) and property ID (PID). def MapColumnToSCID(self, iCol): data = [PKEY_ItemNameDisplay, PKEY_Sample_AreaSize, PKEY_Sample_NumberOfSides, PKEY_Sample_DirectoryLevel] if iCol >= len(data): raise COMException(hresult=winerror.E_FAIL) return data[iCol] # IPersistFolder2 methods # Retrieves the PIDLIST_ABSOLUTE for the folder object. def GetCurFolder(self): # The docs say this is OK, but I suspect its a problem in this case :) #assert self.pidl, "haven't been initialized?" return self.pidl # end of sample's ShellFolder.cpp port def get_schema_fname(): me = win32api.GetFullPathName(__file__) sc = os.path.splitext(me)[0] + ".propdesc" assert os.path.isfile(sc), sc return sc def DllRegisterServer(): import _winreg if sys.getwindowsversion()[0] < 6: print "This sample only works on Vista" sys.exit(1) key = _winreg.CreateKey(_winreg.HKEY_LOCAL_MACHINE, "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) # register the context menu handler under the FolderViewSampleType type. keypath = "%s\\shellex\\ContextMenuHandlers\\%s" % (ContextMenu._context_menu_type_, ContextMenu._reg_desc_) key = _winreg.CreateKey(_winreg.HKEY_CLASSES_ROOT, keypath) _winreg.SetValueEx(key, None, 0, _winreg.REG_SZ, ContextMenu._reg_clsid_) propsys.PSRegisterPropertySchema(get_schema_fname()) print ShellFolder._reg_desc_, "registration complete." def DllUnregisterServer(): import _winreg paths = [ "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Desktop\\Namespace\\" + ShellFolder._reg_clsid_, "%s\\shellex\\ContextMenuHandlers\\%s" % (ContextMenu._context_menu_type_, ContextMenu._reg_desc_), ] for path in paths: try: _winreg.DeleteKey(_winreg.HKEY_LOCAL_MACHINE, path) except WindowsError, details: import errno if details.errno != errno.ENOENT: print "FAILED to remove %s: %s" % (path, details) propsys.PSUnregisterPropertySchema(get_schema_fname()) print ShellFolder._reg_desc_, "unregistration complete." if __name__=='__main__': from win32com.server import register register.UseCommandLine(ShellFolder, ContextMenu, debug = debug, finalize_register = DllRegisterServer, finalize_unregister = DllUnregisterServer) |
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21396/src Modified Files: PyIColumnProvider.cpp PyIPersistFolder.h PyIShellItemArray.cpp shell.cpp shell_pch.h Added Files: PyICategorizer.cpp PyICategorizer.h PyICategoryProvider.cpp PyICategoryProvider.h PyIDefaultExtractIconInit.cpp PyIDefaultExtractIconInit.h PyIEnumExplorerCommand.cpp PyIEnumExplorerCommand.h PyIExplorerCommandProvider.cpp PyIExplorerCommandProvider.h PyIPersistFolder2.cpp PyIShellFolder2.cpp PyIShellFolder2.h Removed Files: PyIExplorerInterfaces.h Log Message: * Many new vista shell interfaces (ICategorizer, ICategoryProvider, IDefaultExtractIconInit, IEnumExplorerCommand, IExplorerCommandProvider) and a couple other older ones we were missing (IShellFolder2, IPersistFolder2) * New vista shell functions (AssocCreateForClasses, SHCreateDataObject, SHCreateDefaultContextMenu, SHCreateDefaultExtractIcon, SHCreateShellFolderView, SHCreateShellItemArray, SHCreateShellItemArrayFromDataObject, SHCreateShellItemArrayFromIDLists, SHCreateShellItemArrayFromShellItem, SHGetNameFromIDList * Remove hacks now we can build with Vista SDK * New demo using a default shell view and Vista explorer interfaces (but it doesn't quite work!) Index: PyIShellItemArray.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellItemArray.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIShellItemArray.cpp 8 Jan 2008 00:41:03 -0000 1.1 --- PyIShellItemArray.cpp 7 Feb 2008 05:42:01 -0000 1.2 *************** *** 9,15 **** // // Interface Implementation - extern BOOL PyObject_AsSHCOLUMNID(PyObject *ob, SHCOLUMNID *p); - extern PyObject *PyObject_FromSHCOLUMNID(LPCSHCOLUMNID p); - PyIShellItemArray::PyIShellItemArray(IUnknown *pdisp): --- 9,12 ---- *************** *** 110,114 **** HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pISIA->GetPropertyDescriptionList( &keyType, riid, &pv ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) --- 107,111 ---- HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pISIA->GetPropertyDescriptionList( keyType, riid, &pv ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) *************** *** 281,288 **** { PY_GATEWAY_METHOD; ! // *** The input argument keyType of type "REFPROPERTYKEY" was not processed *** ! // - Please ensure this conversion function exists, and is appropriate ! // - The type 'REFPROPERTYKEY' (keyType) is unknown. ! PyObject *obkeyType = PyObject_FromSHCOLUMNID(keyType); if (obkeyType==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetPropertyDescriptionList"); PyObject *obriid; --- 278,282 ---- { PY_GATEWAY_METHOD; ! PyObject *obkeyType = PyObject_FromSHCOLUMNID(&keyType); if (obkeyType==NULL) return MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetPropertyDescriptionList"); PyObject *obriid; Index: PyIPersistFolder.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIPersistFolder.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyIPersistFolder.h 8 Oct 2003 23:34:41 -0000 1.1 --- PyIPersistFolder.h 7 Feb 2008 05:42:01 -0000 1.2 *************** *** 38,39 **** --- 38,81 ---- }; + + // IPersistFolder2 + // + // Interface Declaration + + class PyIPersistFolder2 : public PyIPersistFolder + { + public: + MAKE_PYCOM_CTOR(PyIPersistFolder2); + static IPersistFolder2 *GetI(PyObject *self); + static PyComTypeObject type; + + // The Python methods + static PyObject *GetCurFolder(PyObject *self, PyObject *args); + + protected: + PyIPersistFolder2(IUnknown *pdisp); + ~PyIPersistFolder2(); + }; + // --------------------------------------------------- + // + // Gateway Declaration + + class PyGPersistFolder2 : public PyGPersistFolder, public IPersistFolder2 + { + protected: + PyGPersistFolder2(PyObject *instance) : PyGPersistFolder(instance) { ; } + PYGATEWAY_MAKE_SUPPORT2(PyGPersistFolder2, IPersistFolder2, IID_IPersistFolder2, PyGPersistFolder) + + // IPersist + STDMETHOD(GetClassID)( + /* [out] */ CLSID __RPC_FAR *pClassID); + + // IPersistFolder + STDMETHOD(Initialize)( + LPCITEMIDLIST pidl); + + // IPersistFolder2 + STDMETHOD(GetCurFolder)( + PIDLIST_ABSOLUTE * ppidl); + + }; Index: shell_pch.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell_pch.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** shell_pch.h 8 Jan 2008 00:41:03 -0000 1.8 --- shell_pch.h 7 Feb 2008 05:42:01 -0000 1.9 *************** *** 1,5 **** // shell_pch.h : header file for PCH generation for the shell COM extension ! #define _WIN32_IE 0x0601 #include <windows.h> #include <oleauto.h> --- 1,5 ---- // shell_pch.h : header file for PCH generation for the shell COM extension ! #define _WIN32_IE _WIN32_IE_IE70 #include <windows.h> #include <oleauto.h> *************** *** 36,42 **** PyObject *PyObject_FromRECT(const RECT *r); - // For the Vista IExplorer* interfaces - #include "PyIExplorerInterfaces.h" - BOOL PyObject_AsEXPLORER_BROWSER_OPTIONS(PyObject *, EXPLORER_BROWSER_OPTIONS *); PyObject *PyObject_FromEXPLORER_BROWSER_OPTIONS(EXPLORER_BROWSER_OPTIONS); --- 36,39 ---- *************** *** 45,48 **** --- 42,61 ---- PyObject *PyObject_FromEXPLORER_BROWSER_FILL_FLAGS(EXPLORER_BROWSER_FILL_FLAGS); + BOOL PyObject_AsSHCOLUMNID(PyObject *ob, SHCOLUMNID *p); + PyObject *PyObject_FromSHCOLUMNID(LPCSHCOLUMNID p); + + BOOL PyObject_AsSHCOLUMNINIT(PyObject *, SHCOLUMNINIT *); + PyObject *PyObject_FromSHCOLUMNINIT(LPCSHCOLUMNINIT); + + BOOL PyObject_AsSHCOLUMNINFO(PyObject *, SHCOLUMNINFO *); + PyObject *PyObject_FromSHCOLUMNINFO(LPCSHCOLUMNINFO); + + BOOL PyObject_AsSHCOLUMNDATA(PyObject *, SHCOLUMNDATA *); + void PyObject_FreeSHCOLUMNDATA(SHCOLUMNDATA *p); + PyObject *PyObject_FromSHCOLUMNDATA(LPCSHCOLUMNDATA); + + PyObject *PyObject_FromFOLDERSETTINGS( const FOLDERSETTINGS *pf); + BOOL PyObject_AsFOLDERSETTINGS( PyObject *ob, FOLDERSETTINGS *pf); + extern void *PyShell_AllocMem(ULONG cb); --- NEW FILE: PyIEnumExplorerCommand.cpp --- // This file implements the IEnumExplorerCommand Interface and Gateway for Python. // Generated by makegw.py #include "shell_pch.h" #include "PyIEnumExplorerCommand.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIEnumExplorerCommand::PyIEnumExplorerCommand(IUnknown *pdisp): PyIUnknown(pdisp) { ob_type = &type; } PyIEnumExplorerCommand::~PyIEnumExplorerCommand() { } /* static */ IEnumExplorerCommand *PyIEnumExplorerCommand::GetI(PyObject *self) { return (IEnumExplorerCommand *)PyIUnknown::GetI(self); } // @pymethod object|PyIEnumExplorerCommand|Next|Retrieves a specified number of items in the enumeration sequence. PyObject *PyIEnumExplorerCommand::Next(PyObject *self, PyObject *args) { long celt = 1; // @pyparm int|num|1|Number of items to retrieve. if ( !PyArg_ParseTuple(args, "|l:Next", &celt) ) return NULL; IEnumExplorerCommand *pIEExplorerCommand = GetI(self); if ( pIEExplorerCommand == NULL ) return NULL; IExplorerCommand **rgVar = new IExplorerCommand *[celt]; if ( rgVar == NULL ) { PyErr_SetString(PyExc_MemoryError, "allocating result ExplorerCommands"); return NULL; } int i; /* for ( i = celt; i--; ) // *** possibly init each structure element??? */ ULONG celtFetched = 0; PY_INTERFACE_PRECALL; HRESULT hr = pIEExplorerCommand->Next(celt, rgVar, &celtFetched); PY_INTERFACE_POSTCALL; if ( HRESULT_CODE(hr) != ERROR_NO_MORE_ITEMS && FAILED(hr) ) { delete [] rgVar; return PyCom_BuildPyException(hr, pIEExplorerCommand, IID_IEnumExplorerCommand); } PyObject *result = PyTuple_New(celtFetched); if ( result != NULL ) { for ( i = celtFetched; i--; ) { PyObject *ob = PyCom_PyObjectFromIUnknown(rgVar[i], IID_IExplorerCommand, FALSE); if ( ob == NULL ) { Py_DECREF(result); result = NULL; break; } PyTuple_SET_ITEM(result, i, ob); } } /* for ( i = celtFetched; i--; ) // *** possibly cleanup each structure element??? */ delete [] rgVar; return result; } // @pymethod |PyIEnumExplorerCommand|Skip|Skips over the next specified elementes. PyObject *PyIEnumExplorerCommand::Skip(PyObject *self, PyObject *args) { long celt; if ( !PyArg_ParseTuple(args, "l:Skip", &celt) ) return NULL; IEnumExplorerCommand *pIEExplorerCommand = GetI(self); if ( pIEExplorerCommand == NULL ) return NULL; PY_INTERFACE_PRECALL; HRESULT hr = pIEExplorerCommand->Skip(celt); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIEExplorerCommand, IID_IEnumExplorerCommand); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIEnumExplorerCommand|Reset|Resets the enumeration sequence to the beginning. PyObject *PyIEnumExplorerCommand::Reset(PyObject *self, PyObject *args) { if ( !PyArg_ParseTuple(args, ":Reset") ) return NULL; IEnumExplorerCommand *pIEExplorerCommand = GetI(self); if ( pIEExplorerCommand == NULL ) return NULL; PY_INTERFACE_PRECALL; HRESULT hr = pIEExplorerCommand->Reset(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIEExplorerCommand, IID_IEnumExplorerCommand); Py_INCREF(Py_None); return Py_None; } // @pymethod <o PyIEnumExplorerCommand>|PyIEnumExplorerCommand|Clone|Creates another enumerator that contains the same enumeration state as the current one PyObject *PyIEnumExplorerCommand::Clone(PyObject *self, PyObject *args) { if ( !PyArg_ParseTuple(args, ":Clone") ) return NULL; IEnumExplorerCommand *pIEExplorerCommand = GetI(self); if ( pIEExplorerCommand == NULL ) return NULL; IEnumExplorerCommand *pClone; PY_INTERFACE_PRECALL; HRESULT hr = pIEExplorerCommand->Clone(&pClone); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIEExplorerCommand, IID_IEnumExplorerCommand); return PyCom_PyObjectFromIUnknown(pClone, IID_IEnumExplorerCommand, FALSE); } // @object PyIEnumExplorerCommand|A Python interface to IEnumExplorerCommand static struct PyMethodDef PyIEnumExplorerCommand_methods[] = { { "Next", PyIEnumExplorerCommand::Next, 1 }, // @pymeth Next|Retrieves a specified number of items in the enumeration sequence. { "Skip", PyIEnumExplorerCommand::Skip, 1 }, // @pymeth Skip|Skips over the next specified elementes. { "Reset", PyIEnumExplorerCommand::Reset, 1 }, // @pymeth Reset|Resets the enumeration sequence to the beginning. { "Clone", PyIEnumExplorerCommand::Clone, 1 }, // @pymeth Clone|Creates another enumerator that contains the same enumeration state as the current one. { NULL } }; PyComTypeObject PyIEnumExplorerCommand::type("PyIEnumExplorerCommand", &PyIUnknown::type, sizeof(PyIEnumExplorerCommand), PyIEnumExplorerCommand_methods, GET_PYCOM_CTOR(PyIEnumExplorerCommand)); // --------------------------------------------------- // // Gateway Implementation // Std delegation /* STDMETHODIMP_(ULONG) PyGEnumExplorerCommand::AddRef(void) {return PyGatewayBase::AddRef();} STDMETHODIMP_(ULONG) PyGEnumExplorerCommand::Release(void) {return PyGatewayBase::Release();} STDMETHODIMP PyGEnumExplorerCommand::QueryInterface(REFIID iid, void ** obj) {return PyGatewayBase::QueryInterface(iid, obj);} STDMETHODIMP PyGEnumExplorerCommand::GetTypeInfoCount(UINT FAR* pctInfo) {return PyGatewayBase::GetTypeInfoCount(pctInfo);} STDMETHODIMP PyGEnumExplorerCommand::GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo FAR* FAR* pptInfo) {return PyGatewayBase::GetTypeInfo(itinfo, lcid, pptInfo);} STDMETHODIMP PyGEnumExplorerCommand::GetIDsOfNames(REFIID refiid, OLECHAR FAR* FAR* rgszNames, UINT cNames, LCID lcid, DISPID FAR* rgdispid) {return PyGatewayBase::GetIDsOfNames( refiid, rgszNames, cNames, lcid, rgdispid);} STDMETHODIMP PyGEnumExplorerCommand::Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* params, VARIANT FAR* pVarResult, EXCEPINFO FAR* pexcepinfo, UINT FAR* puArgErr) {return PyGatewayBase::Invoke( dispid, riid, lcid, wFlags, params, pVarResult, pexcepinfo, puArgErr);} */ STDMETHODIMP PyGEnumExplorerCommand::Next( /* [in] */ ULONG celt, /* [length_is][size_is][out] */ IExplorerCommand __RPC_FAR * __RPC_FAR *rgVar, /* [out] */ ULONG __RPC_FAR *pCeltFetched) { PY_GATEWAY_METHOD; PyObject *result; HRESULT hr = InvokeViaPolicy("Next", &result, "i", celt); if ( FAILED(hr) ) return hr; if ( !PySequence_Check(result) ) goto error; Py_ssize_t len = PyObject_Length(result); if ( len == -1 ) goto error; if ( len > (int)celt) len = celt; if ( pCeltFetched ) *pCeltFetched = (ULONG)len; int i; for ( i = 0; i < len; ++i ) { PyObject *ob = PySequence_GetItem(result, i); if ( ob == NULL ) goto error; if ( !PyCom_InterfaceFromPyObject(ob, IID_IExplorerCommand, (void **)&rgVar[i], FALSE) ) { Py_DECREF(result); return MAKE_PYCOM_GATEWAY_FAILURE_CODE("Next"); } } Py_DECREF(result); return len < (int)celt ? S_FALSE : S_OK; error: PyErr_Clear(); // just in case Py_DECREF(result); return PyCom_SetCOMErrorFromSimple(E_FAIL, IID_IEnumExplorerCommand, "Next() did not return a sequence of objects"); } STDMETHODIMP PyGEnumExplorerCommand::Skip( /* [in] */ ULONG celt) { PY_GATEWAY_METHOD; return InvokeViaPolicy("Skip", NULL, "i", celt); } STDMETHODIMP PyGEnumExplorerCommand::Reset(void) { PY_GATEWAY_METHOD; return InvokeViaPolicy("Reset"); } STDMETHODIMP PyGEnumExplorerCommand::Clone( /* [out] */ IEnumExplorerCommand __RPC_FAR *__RPC_FAR *ppEnum) { PY_GATEWAY_METHOD; PyObject * result; HRESULT hr = InvokeViaPolicy("Clone", &result); if ( FAILED(hr) ) return hr; /* ** Make sure we have the right kind of object: we should have some kind ** of IUnknown subclass wrapped into a PyIUnknown instance. */ if ( !PyIBase::is_object(result, &PyIUnknown::type) ) { /* the wrong kind of object was returned to us */ Py_DECREF(result); return PyCom_SetCOMErrorFromSimple(E_FAIL, IID_IEnumExplorerCommand); } /* ** Get the IUnknown out of the thing. note that the Python ob maintains ** a reference, so we don't have to explicitly AddRef() here. */ IUnknown *punk = ((PyIUnknown *)result)->m_obj; if ( !punk ) { /* damn. the object was released. */ Py_DECREF(result); return PyCom_SetCOMErrorFromSimple(E_FAIL, IID_IEnumExplorerCommand); } /* ** Get the interface we want. note it is returned with a refcount. ** This QI is actually going to instantiate a PyGEnumExplorerCommand. */ hr = punk->QueryInterface(IID_IEnumExplorerCommand, (LPVOID *)ppEnum); /* done with the result; this DECREF is also for <punk> */ Py_DECREF(result); return PyCom_SetCOMErrorFromSimple(hr, IID_IEnumExplorerCommand, "Python could not convert the result from Next() into the required COM interface"); } --- NEW FILE: PyIDefaultExtractIconInit.cpp --- // This file implements the IDefaultExtractIconInit Interface and Gateway for Python. // Generated by makegw.py #include "shell_pch.h" #include "PyIDefaultExtractIconInit.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIDefaultExtractIconInit::PyIDefaultExtractIconInit(IUnknown *pdisp): PyIUnknown(pdisp) { ob_type = &type; } PyIDefaultExtractIconInit::~PyIDefaultExtractIconInit() { } /* static */ IDefaultExtractIconInit *PyIDefaultExtractIconInit::GetI(PyObject *self) { return (IDefaultExtractIconInit *)PyIUnknown::GetI(self); } // @pymethod |PyIDefaultExtractIconInit|SetFlags|Description of SetFlags. PyObject *PyIDefaultExtractIconInit::SetFlags(PyObject *self, PyObject *args) { IDefaultExtractIconInit *pIDEII = GetI(self); if ( pIDEII == NULL ) return NULL; // @pyparm int|uFlags||Description for uFlags UINT uFlags; if ( !PyArg_ParseTuple(args, "i:SetFlags", &uFlags) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDEII->SetFlags( uFlags ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIDEII, IID_IDefaultExtractIconInit ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDefaultExtractIconInit|SetKey|Description of SetKey. PyObject *PyIDefaultExtractIconInit::SetKey(PyObject *self, PyObject *args) { IDefaultExtractIconInit *pIDEII = GetI(self); if ( pIDEII == NULL ) return NULL; HKEY hkey; PyObject *obhkey; // @pyparm <o PyHKEY>|hkey||Description for hkey if ( !PyArg_ParseTuple(args, "O:SetKey", &obhkey) ) return NULL; if (!PyWinObject_AsHKEY(obhkey, &hkey)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDEII->SetKey( hkey ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIDEII, IID_IDefaultExtractIconInit ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDefaultExtractIconInit|SetNormalIcon|Description of SetNormalIcon. PyObject *PyIDefaultExtractIconInit::SetNormalIcon(PyObject *self, PyObject *args) { IDefaultExtractIconInit *pIDEII = GetI(self); if ( pIDEII == NULL ) return NULL; // @pyparm <o unicode>|pszFile||Description for pszFile // @pyparm int|iIcon||Description for iIcon PyObject *obpszFile; LPWSTR pszFile; int iIcon; if ( !PyArg_ParseTuple(args, "Oi:SetNormalIcon", &obpszFile, &iIcon) ) return NULL; if (!PyWinObject_AsBstr(obpszFile, &pszFile)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDEII->SetNormalIcon( pszFile, iIcon ); SysFreeString(pszFile); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIDEII, IID_IDefaultExtractIconInit ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDefaultExtractIconInit|SetOpenIcon|Description of SetOpenIcon. PyObject *PyIDefaultExtractIconInit::SetOpenIcon(PyObject *self, PyObject *args) { IDefaultExtractIconInit *pIDEII = GetI(self); if ( pIDEII == NULL ) return NULL; // @pyparm <o unicode>|pszFile||Description for pszFile // @pyparm int|iIcon||Description for iIcon PyObject *obpszFile; LPWSTR pszFile; int iIcon; if ( !PyArg_ParseTuple(args, "Oi:SetOpenIcon", &obpszFile, &iIcon) ) return NULL; if (!PyWinObject_AsBstr(obpszFile, &pszFile)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDEII->SetOpenIcon( pszFile, iIcon ); SysFreeString(pszFile); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIDEII, IID_IDefaultExtractIconInit ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDefaultExtractIconInit|SetShortcutIcon|Description of SetShortcutIcon. PyObject *PyIDefaultExtractIconInit::SetShortcutIcon(PyObject *self, PyObject *args) { IDefaultExtractIconInit *pIDEII = GetI(self); if ( pIDEII == NULL ) return NULL; // @pyparm <o unicode>|pszFile||Description for pszFile // @pyparm int|iIcon||Description for iIcon PyObject *obpszFile; LPWSTR pszFile; int iIcon; if ( !PyArg_ParseTuple(args, "Oi:SetShortcutIcon", &obpszFile, &iIcon) ) return NULL; if (!PyWinObject_AsBstr(obpszFile, &pszFile)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDEII->SetShortcutIcon( pszFile, iIcon ); SysFreeString(pszFile); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIDEII, IID_IDefaultExtractIconInit ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIDefaultExtractIconInit|SetDefaultIcon|Description of SetDefaultIcon. PyObject *PyIDefaultExtractIconInit::SetDefaultIcon(PyObject *self, PyObject *args) { IDefaultExtractIconInit *pIDEII = GetI(self); if ( pIDEII == NULL ) return NULL; // @pyparm <o unicode>|pszFile||Description for pszFile // @pyparm int|iIcon||Description for iIcon PyObject *obpszFile; LPWSTR pszFile; int iIcon; if ( !PyArg_ParseTuple(args, "Oi:SetDefaultIcon", &obpszFile, &iIcon) ) return NULL; if (!PyWinObject_AsBstr(obpszFile, &pszFile)) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIDEII->SetDefaultIcon( pszFile, iIcon ); SysFreeString(pszFile); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIDEII, IID_IDefaultExtractIconInit ); Py_INCREF(Py_None); return Py_None; } // @object PyIDefaultExtractIconInit|Description of the interface static struct PyMethodDef PyIDefaultExtractIconInit_methods[] = { { "SetFlags", PyIDefaultExtractIconInit::SetFlags, 1 }, // @pymeth SetFlags|Description of SetFlags { "SetKey", PyIDefaultExtractIconInit::SetKey, 1 }, // @pymeth SetKey|Description of SetKey { "SetNormalIcon", PyIDefaultExtractIconInit::SetNormalIcon, 1 }, // @pymeth SetNormalIcon|Description of SetNormalIcon { "SetOpenIcon", PyIDefaultExtractIconInit::SetOpenIcon, 1 }, // @pymeth SetOpenIcon|Description of SetOpenIcon { "SetShortcutIcon", PyIDefaultExtractIconInit::SetShortcutIcon, 1 }, // @pymeth SetShortcutIcon|Description of SetShortcutIcon { "SetDefaultIcon", PyIDefaultExtractIconInit::SetDefaultIcon, 1 }, // @pymeth SetDefaultIcon|Description of SetDefaultIcon { NULL } }; PyComTypeObject PyIDefaultExtractIconInit::type("PyIDefaultExtractIconInit", &PyIUnknown::type, sizeof(PyIDefaultExtractIconInit), PyIDefaultExtractIconInit_methods, GET_PYCOM_CTOR(PyIDefaultExtractIconInit)); Index: shell.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/shell.cpp,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** shell.cpp 8 Jan 2008 00:41:03 -0000 1.60 --- shell.cpp 7 Feb 2008 05:42:01 -0000 1.61 *************** *** 19,29 **** --- 19,34 ---- #include "EmptyVC.h" #include "PyIShellLink.h" + #include "PyICategorizer.h" + #include "PyICategoryProvider.h" #include "PyIContextMenu.h" + #include "PyIDefaultExtractIconInit.h" #include "PyIExtractIcon.h" #include "PyIExtractIconW.h" #include "PyIShellExtInit.h" #include "PyIShellFolder.h" + #include "PyIShellFolder2.h" #include "PyIEmptyVolumeCache.h" #include "PyIEmptyVolumeCacheCallBack.h" + #include "PyIEnumExplorerCommand.h" #include "PyIEnumIDList.h" #include "PyICopyHook.h" *************** *** 51,54 **** --- 56,60 ---- #include "PyIExplorerBrowserEvents.h" #include "PyIExplorerCommand.h" + #include "PyIExplorerCommandProvider.h" #include "PyIShellItem.h" #include "PyIShellItemArray.h" *************** *** 59,71 **** #define OleSetOleError PyCom_BuildPyException - #if (WINVER < 0x600) - const IID IID_IExplorerBrowser = __uuidof(IExplorerBrowser); - const IID IID_IExplorerBrowserEvents = __uuidof(IExplorerBrowserEvents); - const IID IID_IExplorerCommand = __uuidof(IExplorerCommand); - const IID IID_IShellItemArray = __uuidof(IShellItemArray); - const IID IID_IEnumExplorerCommand = __uuidof(IEnumExplorerCommand); - const IID IID_IEnumShellItems = __uuidof(IEnumShellItems); - #endif - static HMODULE shell32 = NULL; static HMODULE shfolder = NULL; --- 65,68 ---- *************** *** 102,105 **** --- 99,105 ---- static PFNAssocCreate pfnAssocCreate = NULL; + typedef HRESULT (WINAPI * PFNAssocCreateForClasses)(const ASSOCIATIONELEMENT *, ULONG cClasses, REFIID riid, void **ppv); + static PFNAssocCreateForClasses pfnAssocCreateForClasses = NULL; + typedef LRESULT (WINAPI *PFNSHShellFolderView_Message)(HWND, UINT, LPARAM); static PFNSHShellFolderView_Message pfnSHShellFolderView_Message = NULL; *************** *** 108,115 **** static PFNIsUserAnAdmin pfnIsUserAnAdmin = NULL; void PyShell_FreeMem(void *p) { ! if (p!=NULL) ! CoTaskMemFree(p); } --- 108,144 ---- static PFNIsUserAnAdmin pfnIsUserAnAdmin = NULL; + typedef BOOL (WINAPI *PFNSHGetNameFromIDList)(PCIDLIST_ABSOLUTE, SIGDN, PWSTR *); + static PFNSHGetNameFromIDList pfnSHGetNameFromIDList = NULL; + + typedef BOOL (WINAPI *PFNSHCreateShellFolderView)(const SFV_CREATE *, IShellView **ppsv); + static PFNSHCreateShellFolderView pfnSHCreateShellFolderView = NULL; + + typedef BOOL (WINAPI *PFNSHCreateDefaultExtractIcon)(REFIID riid, void **ppv); + static PFNSHCreateDefaultExtractIcon pfnSHCreateDefaultExtractIcon = NULL; + + typedef BOOL (WINAPI *PFNSHCreateDataObject)(PCIDLIST_ABSOLUTE, UINT, PCUITEMID_CHILD_ARRAY, IDataObject *, REFIID, void **); + static PFNSHCreateDataObject pfnSHCreateDataObject = NULL; + + typedef BOOL (WINAPI *PFNSHCreateShellItemArray)(PCIDLIST_ABSOLUTE, IShellFolder *, UINT, PCUITEMID_CHILD_ARRAY, IShellItemArray **); + static PFNSHCreateShellItemArray pfnSHCreateShellItemArray = NULL; + + typedef BOOL (WINAPI *PFNSHCreateShellItemArrayFromDataObject)(IDataObject *pdo, REFIID, void **); + static PFNSHCreateShellItemArrayFromDataObject pfnSHCreateShellItemArrayFromDataObject = NULL; + + typedef BOOL (WINAPI *PFNSHCreateShellItemArrayFromIDLists)(UINT, PCIDLIST_ABSOLUTE_ARRAY, IShellItemArray **); + static PFNSHCreateShellItemArrayFromIDLists pfnSHCreateShellItemArrayFromIDLists = NULL; + + typedef BOOL (WINAPI *PFNSHCreateShellItemArrayFromShellItem)(IShellItem *, REFIID riid, void **); + static PFNSHCreateShellItemArrayFromShellItem pfnSHCreateShellItemArrayFromShellItem = NULL; + + typedef BOOL (WINAPI *PFNSHCreateDefaultContextMenu)(const DEFCONTEXTMENU *, REFIID, void **); + static PFNSHCreateDefaultContextMenu pfnSHCreateDefaultContextMenu = NULL; + void PyShell_FreeMem(void *p) { ! // NOTE: CoTaskMemFree documents NULL is an OK param - so we no ! // longer check for that - and given the new 'propsys' module, these ! // are screaming to become macros (and/or die!) ! CoTaskMemFree(p); } *************** *** 785,788 **** --- 814,872 ---- } + // Note - 'cleanup' as we don't free the object itself, just a couple of + // pointers inside it. + void PyObject_CleanupDEFCONTEXTMENU(DEFCONTEXTMENU *dcm) + { + PY_INTERFACE_PRECALL; // so all ->Releases() happen with GIL released. + if (dcm->pcmcb) + dcm->pcmcb->Release(); + if (dcm->psf) + dcm->psf->Release(); + if (dcm->punkAssociationInfo) + dcm->punkAssociationInfo->Release(); + if (dcm->pidlFolder) + PyObject_FreePIDL(dcm->pidlFolder); + if (dcm->apidl) + PyObject_FreePIDLArray(dcm->cidl, dcm->apidl); + PY_INTERFACE_POSTCALL + } + + // @object DEFCONTENTMENU|A tuple representing a DEFCONTEXTMENU structure. + BOOL PyObject_AsDEFCONTEXTMENU(PyObject *ob, DEFCONTEXTMENU *dcm) + { + BOOL ok = FALSE; + memset(dcm, 0, sizeof(*dcm)); + PyObject *obhwnd, *obcb, *obpidlFolder, *obsf, *obpidlChildren, *obai=Py_None, *obkeys=Py_None; + if (!PyArg_ParseTuple(ob, "OOOOO|OO", &obhwnd, &obcb, &obpidlFolder, &obsf, &obpidlChildren, &obai, &obkeys)) + return NULL; + // @pyparm <o PyHANDLE>|hwnd|| + if (!PyWinObject_AsHANDLE(obhwnd, (HANDLE *)&dcm->hwnd)) + goto done; + // @pyparm <o PyIContextMenuCB>|callback||May be None + if (!PyCom_InterfaceFromPyInstanceOrObject(obcb, IID_IContextMenuCB, (void **)&dcm->pcmcb, TRUE/* bNoneOK */)) + goto done; + // @pyparm <o PIDL>|pidlFolder||May be None + if (!PyObject_AsPIDL(obpidlFolder, (LPITEMIDLIST *)&dcm->pidlFolder, TRUE)) + goto done; + // @pyparm <o PyIShellFolder>|sf||The Shell data source object that is the parent of the child items specified in children. If parent is specified, this parameter can be NULL. + if (!PyCom_InterfaceFromPyInstanceOrObject(obsf, IID_IShellFolder, (void **)&dcm->psf, TRUE/* bNoneOK */)) + goto done; + // @pyparm [<o PIDL>, ...]|children|| + if (!PyObject_AsPIDLArray(obpidlChildren, &dcm->cidl, &dcm->apidl)) + goto done; + // @pyparm <o PyIUnknown>|unkAssocInfo||May be None + if (!PyCom_InterfaceFromPyInstanceOrObject(obsf, IID_IUnknown, (void **)&dcm->punkAssociationInfo, TRUE/* bNoneOK */)) + goto done; + if (obkeys != Py_None) { + PyErr_SetString(PyExc_ValueError, "Only None is supported for obKeys"); + goto done; + } + ok = TRUE; + done: + if (!ok) + PyObject_CleanupDEFCONTEXTMENU(dcm); + return ok; + } + // @object PyLPOLEMENUGROUPWIDTHS|Tuple containing 6 ints indicating nbr of options in each menu group BOOL PyObject_AsOLEMENUGROUPWIDTHS( PyObject *oblpMenuWidths, OLEMENUGROUPWIDTHS *pWidths) *************** *** 898,901 **** --- 982,1033 ---- } + void PyObject_FreeASSOCIATIONELEMENTs(ULONG celems, ASSOCIATIONELEMENT *a) + { + for(ULONG i=0;i<celems;i++) + if (a[i].pszClass) + PyWinObject_FreeWCHAR((PWSTR)a[i].pszClass); + free(a); + } + + BOOL PyObject_AsASSOCIATIONELEMENTs(PyObject *ob, ULONG *num, ASSOCIATIONELEMENT **ret) + { + BOOL ok = FALSE; + if (!PySequence_Check(ob)) { + PyErr_Format(PyExc_TypeError, "ASSOCIATIONELEMENTs arg must be a sequence of tuples"); + return FALSE; + } + *num = (ULONG)PySequence_Length(ob); + ASSOCIATIONELEMENT *elts; + elts = *ret = (ASSOCIATIONELEMENT *)malloc(*num * sizeof(ASSOCIATIONELEMENT)); + if (!elts) { + PyErr_NoMemory(); + return FALSE; + } + memset(elts, 0, *num * sizeof(ASSOCIATIONELEMENT)); + PyObject *klass = NULL; + for (ULONG i=0;i<*num;i++) { + Py_XDECREF(klass); // for prev time around the loop + klass = PySequence_GetItem(ob, i); + PyObject *obname, *obhk; + if (!klass) + goto done; + if (!PyArg_ParseTuple(klass, "kOO", &elts[i].ac, &obhk, &obname)) + goto done; + if (!PyWinObject_AsHKEY(obhk, &elts[i].hkClass)) + goto done; + if (!PyWinObject_AsWCHAR(obname, (PWSTR *)&elts[i].pszClass, TRUE)) + goto done; + } + ok = TRUE; + done: + Py_XDECREF(klass); + if (!ok && elts) { + PyObject_FreeASSOCIATIONELEMENTs(*num, elts); + *ret = NULL; + *num = 0; + } + return ok; + } + #if (PY_VERSION_HEX >= 0x02030000) // PyGILState only in 2.3+ *************** *** 2131,2135 **** &obVerb, // @pyparm string|lpVerb|| &obFile, // @pyparm string|lpFile|| ! &obParams, // @pyparm string|lpParams|| &obDirectory, // @pyparm string|lpDirectory|| &info.nShow, // @pyparm int|nShow|0| --- 2263,2267 ---- &obVerb, // @pyparm string|lpVerb|| &obFile, // @pyparm string|lpFile|| ! &obParams, // @pyparm string|lpParameters|| &obDirectory, // @pyparm string|lpDirectory|| &info.nShow, // @pyparm int|nShow|0| *************** *** 2231,2234 **** --- 2363,2401 ---- } + // @pymethod <o PyIUnknown>|shell|AssocCreateForClasses|Retrieves an object that implements an IQueryAssociations interface. + static PyObject *PyAssocCreateForClasses(PyObject *self, PyObject *args) + { + // @comm This function is only available on Vista and later; a + // COM exception with E_NOTIMPL will be thrown if the function can't be located. + if (pfnAssocCreateForClasses==NULL) + return PyCom_BuildPyException(E_NOTIMPL); + + PyObject *ret = NULL; + PyObject *obClasses, *obiid; + if (!PyArg_ParseTuple(args, "OO:AssocCreateForClasses", &obClasses, &obiid)) + return NULL; + ASSOCIATIONELEMENT *elts = NULL; + ULONG nclasses = 0; + IID iid; + if (!PyWinObject_AsIID(obiid, &iid)) + goto done; + if (!PyObject_AsASSOCIATIONELEMENTs(obClasses, &nclasses, &elts)) + goto done; + HRESULT hr; + void *v; + PY_INTERFACE_PRECALL; + hr = (*pfnAssocCreateForClasses)(elts, nclasses, iid, &v); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) { + PyCom_BuildPyException(hr); + goto done; + } + ret = PyCom_PyObjectFromIUnknown((IUnknown *)v, iid, FALSE); + done: + if (elts) + PyObject_FreeASSOCIATIONELEMENTs(nclasses, elts); + return ret; + } + // @pymethod <o PyIPropertyBag>|shell|SHGetViewStatePropertyBag|Retrieves an interface for the view state of a folder // @comm This function will also return IPropertyBag2, but we don't have a python implementation of this interface yet *************** *** 2314,2317 **** --- 2481,2846 ---- } + // @pymethod (o PyIShellView|shell|SHCreateShellFolderView| + static PyObject *PySHCreateShellFolderView(PyObject *self, PyObject *args) + { + if (pfnSHCreateShellFolderView==NULL) + return PyCom_BuildPyException(E_NOTIMPL); + + PyObject *ret = NULL; + PyObject *obsf; + PyObject *obouter = Py_None; + PyObject *obevents = Py_None; + // @pyparm <o PyIShellFolder>|sf|| + // @pyparm <o PyIShellView>|viewOuter|None| + // @pyparm <o PyIShellFolderViewCB>|callbacks|None| + if(!PyArg_ParseTuple(args, "O|OO:SHCreateShellFolderView", &obsf, &obouter, &obevents)) + return NULL; + SFV_CREATE create; + memset(&create, 0, sizeof(create)); + create.cbSize = sizeof(create); + if (!PyCom_InterfaceFromPyInstanceOrObject(obsf, IID_IShellFolder, (void **)&create.pshf, FALSE/* bNoneOK */)) + goto done; + if (!PyCom_InterfaceFromPyInstanceOrObject(obouter, IID_IShellView, (void **)&create.psvOuter, TRUE/* bNoneOK */)) + goto done; + if (!PyCom_InterfaceFromPyInstanceOrObject(obevents, IID_IShellFolderViewCB, (void **)&create.psfvcb, TRUE/* bNoneOK */)) + goto done; + IShellView *view = NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = (*pfnSHCreateShellFolderView)(&create, &view); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) + PyCom_BuildPyException(hr); + else + ret = PyCom_PyObjectFromIUnknown(view, IID_IShellView, FALSE); + // ref on view consumed by ret object. + done: + { + PY_INTERFACE_PRECALL; + if (create.pshf) create.pshf->Release(); + if (create.psvOuter) create.psvOuter->Release(); + if (create.psfvcb) create.psfvcb->Release(); + PY_INTERFACE_POSTCALL; + } + return ret; + } + + // @pymethod <o PyIDefaultExtractIconInit>|shell|SHCreateDefaultExtractIcon|Creates a standard icon extractor, whose defaults can be further configured via the IDefaultExtractIconInit interface. + static PyObject *PySHCreateDefaultExtractIcon(PyObject *self, PyObject *args) + { + // @comm This function is only available on Vista and later; a + // COM exception with E_NOTIMPL will be thrown if the function can't be located. + if (pfnSHCreateDefaultExtractIcon==NULL) + return PyCom_BuildPyException(E_NOTIMPL); + + // be lazy - don't take IID as a param! + if(!PyArg_ParseTuple(args, ":SHCreateDefaultExtractIcon")) + return NULL; + IDefaultExtractIconInit *ret = NULL; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = (*pfnSHCreateDefaultExtractIcon)(IID_IDefaultExtractIconInit, (void **)&ret); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) + return PyCom_BuildPyException(hr); + // ref on view consumed by ret object. + return PyCom_PyObjectFromIUnknown(ret, IID_IDefaultExtractIconInit, FALSE); + } + + // @pymethod <o PyIUnknown>|shell|SHCreateDataObject| + static PyObject *PySHCreateDataObject(PyObject *self, PyObject *args) + { + // @comm This function is only available on Vista and later; a + // COM exception with E_NOTIMPL will be thrown if the function can't be located. + if (pfnSHCreateDataObject==NULL) + return PyCom_BuildPyException(E_NOTIMPL); + + PyObject *ret = NULL; + PyObject *obParent; + PyObject *obChildren; + PyObject *obdo; + PyObject *obiid = Py_None; + PIDLIST_ABSOLUTE parent = NULL; + PCUITEMID_CHILD_ARRAY children = NULL; + IDataObject *do_inner = NULL; + void *do_ret = NULL; + IID iid = IID_IDataObject; + UINT nchildren; + if(!PyArg_ParseTuple(args, "OOO|O:SHCreateDataObject", &obParent, &obChildren, &obdo, &obiid)) + return NULL; + // @pyparm PIDL|parent|| + if (!PyObject_AsPIDL(obParent, &parent)) + goto done; + // @pyparm [PIDL, ...]|children|| + if (!PyObject_AsPIDLArray(obChildren, &nchildren, &children)) + goto done; + // @pyparm <o PyIDataObject>|do_inner||The inner data object, or None + if (!PyCom_InterfaceFromPyInstanceOrObject(obdo, IID_IDataObject, (void **)&do_inner, TRUE/* bNoneOK */)) + goto done; + // @pyparm <o PyIID>|iid|IID_IDataObject|The IID to query for + if (obiid != Py_None && !PyWinObject_AsIID(obiid, &iid)) + goto done; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = (*pfnSHCreateDataObject)(parent, nchildren, children, do_inner, iid, &do_ret); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) { + PyCom_BuildPyException(hr); + goto done; + } + // ref on view consumed by ret object. + ret = PyCom_PyObjectFromIUnknown((IUnknown *)do_ret, iid, FALSE); + done: + if (parent) + PyObject_FreePIDL(parent); + if (children) + PyObject_FreePIDLArray(nchildren, children); + if (do_inner) { + PY_INTERFACE_PRECALL; + do_inner->Release(); + PY_INTERFACE_POSTCALL; + } + return ret; + } + + // @pymethod <o PyIUnknown>|shell|SHCreateDefaultContextMenu| + static PyObject *PySHCreateDefaultContextMenu(PyObject *self, PyObject *args) + { + // @comm This function is only available on Vista and later; a + // COM exception with E_NOTIMPL will be thrown if the function can't be located. + if (pfnSHCreateDefaultContextMenu==NULL) + return PyCom_BuildPyException(E_NOTIMPL); + + PyObject *ret = NULL; + PyObject *obdcm, *obiid; + IID iid = IID_IContextMenu; + if(!PyArg_ParseTuple(args, "O|O:SHCreateDefaultContextMenu", &obdcm, &obiid)) + return NULL; + void *iret = NULL; + DEFCONTEXTMENU dcm; + // @pyparm <o DEFAULTCONTEXTMENU>|dcm|| + if (!PyObject_AsDEFCONTEXTMENU(obdcm, &dcm)) + goto done; + // @pyparm <o PyIID>|iid|IID_IContextMenu|The IID to query for + if (obiid != Py_None && !PyWinObject_AsIID(obiid, &iid)) + goto done; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = (*pfnSHCreateDefaultContextMenu)(&dcm, iid, &iret); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) { + PyCom_BuildPyException(hr); + goto done; + } + // ref on view consumed by ret object. + ret = PyCom_PyObjectFromIUnknown((IUnknown *)iret, iid, FALSE); + done: + PyObject_CleanupDEFCONTEXTMENU(&dcm); + return ret; + } + + // @pymethod unicode|shell|SHGetNameFromIDList|Retrieves the display name of an item from an ID list. + static PyObject *PySHGetNameFromIDList(PyObject *self, PyObject *args) + { + // @comm This function is only available on Vista and later; a + // COM exception with E_NOTIMPL will be thrown if the function can't be located. + if (pfnSHGetNameFromIDList==NULL) + return PyCom_BuildPyException(E_NOTIMPL); + PyObject *ret = NULL; + PyObject *obpidl; + SIGDN flags; + WCHAR *strret = NULL; + PIDLIST_ABSOLUTE pidl = NULL; + if(!PyArg_ParseTuple(args, "Ok:SHGetNameFromIDList", &obpidl, &flags)) + return NULL; + // @pyparm PIDL|parent|| + // @pyparm int|flags|| + if (!PyObject_AsPIDL(obpidl, &pidl)) + goto done; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = (*pfnSHGetNameFromIDList)(pidl, flags, &strret); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) { + PyCom_BuildPyException(hr); + goto done; + } + // ref on view consumed by ret object. + ret = PyWinObject_FromWCHAR(strret); + done: + if (pidl) + PyObject_FreePIDL(pidl); + if (strret) + CoTaskMemFree(strret); + return ret; + } + + // @pymethod <o PyIShellItemArray>|shell|SHCreateShellItemArray| + static PyObject *PySHCreateShellItemArray(PyObject *self, PyObject *args) + { + // @comm This function is only available on Vista and later; a + // COM exception with E_NOTIMPL will be thrown if the function can't be located. + if (pfnSHCreateShellItemArray==NULL) + return PyCom_BuildPyException(E_NOTIMPL); + + PyObject *ret = NULL; + PyObject *obParent; + PyObject *obChildren; + PyObject *obsf; + PIDLIST_ABSOLUTE parent = NULL; + PCUITEMID_CHILD_ARRAY children = NULL; + UINT nchildren; + IShellFolder *sf = NULL; + IShellItemArray *sia_ret = NULL; + if(!PyArg_ParseTuple(args, "OOO:SHCreateShellItemArray", &obParent, &obsf, &obChildren)) + return NULL; + // @pyparm PIDL|parent|| + if (!PyObject_AsPIDL(obParent, &parent, TRUE)) + goto done; + // @pyparm <o PyIShellFolder>|sf||The Shell data source object that is the parent of the child items specified in children. If parent is specified, this parameter can be NULL. + if (!PyCom_InterfaceFromPyInstanceOrObject(obsf, IID_IShellFolder, (void **)&sf, TRUE/* bNoneOK */)) + goto done; + // @pyparm [PIDL, ...]|children|| + if (!PyObject_AsPIDLArray(obChildren, &nchildren, &children)) + goto done; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = (*pfnSHCreateShellItemArray)(parent, sf, nchildren, children, &sia_ret); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) { + PyCom_BuildPyException(hr); + goto done; + } + // ref on view consumed by ret object. + ret = PyCom_PyObjectFromIUnknown(sia_ret, IID_IShellItemArray, FALSE); + done: + if (parent) + PyObject_FreePIDL(parent); + if (children) + PyObject_FreePIDLArray(nchildren, children); + if (sf) { + PY_INTERFACE_PRECALL; + sf->Release(); + PY_INTERFACE_POSTCALL; + } + return ret; + } + + // @pymethod <o PyIUnknown>|shell|SHCreateShellItemArray| + static PyObject *PySHCreateShellItemArrayFromDataObject(PyObject *self, PyObject *args) + { + // @comm This function is only available on Vista and later; a + // COM exception with E_NOTIMPL will be thrown if the function can't be located. + if (pfnSHCreateShellItemArrayFromDataObject==NULL) + return PyCom_BuildPyException(E_NOTIMPL); + + PyObject *ret = NULL; + PyObject *obdo; + PyObject *obiid = Py_None; + IID iid = IID_IShellItemArray; + IDataObject *ido = NULL; + void *iret = NULL; + if(!PyArg_ParseTuple(args, "O|O:SHCreateShellItemArrayFromDataObject", &obdo, &obiid)) + return NULL; + // @pyparm <o PyIDataObject>|do|| + if (!PyCom_InterfaceFromPyInstanceOrObject(obdo, IID_IDataObject, (void **)&ido, FALSE/* bNoneOK */)) + goto done; + // @pyparm <o PyIID>|iid|IID_IDataObject|The IID to query for + if (obiid != Py_None && !PyWinObject_AsIID(obiid, &iid)) + goto done; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = (*pfnSHCreateShellItemArrayFromDataObject)(ido, iid, &iret); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) { + PyCom_BuildPyException(hr); + goto done; + } + // ref on view consumed by ret object. + ret = PyCom_PyObjectFromIUnknown((IUnknown *)iret, iid, FALSE); + done: + if (ido) { + PY_INTERFACE_PRECALL; + ido->Release(); + PY_INTERFACE_POSTCALL; + } + return ret; + } + + // @pymethod <o PyIShellItemArray>|shell|SHCreateShellItemArrayFromIDLists| + static PyObject *PySHCreateShellItemArrayFromIDLists(PyObject *self, PyObject *args) + { + // @comm This function is only available on Vista and later; a + // COM exception with E_NOTIMPL will be thrown if the function can't be located. + if (pfnSHCreateShellItemArrayFromIDLists==NULL) + return PyCom_BuildPyException(E_NOTIMPL); + + PyObject *ret = NULL; + PyObject *obpidls; + PCIDLIST_ABSOLUTE_ARRAY pidls = NULL; + UINT npidls; + if(!PyArg_ParseTuple(args, "O:SHCreateShellItemArray", &obpidls)) + return NULL; + // @pyparm [PIDL, ...]|pidls|| + if (!PyObject_AsPIDLArray(obpidls, &npidls, &pidls)) + goto done; + HRESULT hr; + IShellItemArray *iret = NULL; + PY_INTERFACE_PRECALL; + hr = (*pfnSHCreateShellItemArrayFromIDLists)(npidls, pidls, &iret); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) { + PyCom_BuildPyException(hr); + goto done; + } + // ref on view consumed by ret object. + ret = PyCom_PyObjectFromIUnknown(iret, IID_IShellItemArray, FALSE); + done: + if (pidls) + PyObject_FreePIDLArray(npidls, pidls); + return ret; + } + + // @pymethod <o PyIUnknown>|shell|SHCreateShellItemArrayFromShellItem| + static PyObject *PySHCreateShellItemArrayFromShellItem(PyObject *self, PyObject *args) + { + // @comm This function is only available on Vista and later; a + // COM exception with E_NOTIMPL will be thrown if the function can't be located. + if (pfnSHCreateShellItemArrayFromShellItem==NULL) + return PyCom_BuildPyException(E_NOTIMPL); + + PyObject *ret = NULL; + PyObject *obsi; + PyObject *obiid = Py_None; + IShellItem *isi = NULL; + IID iid = IID_IShellItemArray; + void *iret = NULL; + if(!PyArg_ParseTuple(args, "O|O:SHCreateShellItemArrayFromShellItem", &obsi, &obiid)) + return NULL; + // @pyparm <o PyIDataObject>|do|| + if (!PyCom_InterfaceFromPyInstanceOrObject(obsi, IID_IShellItem, (void **)&isi, FALSE/* bNoneOK */)) + goto done; + // @pyparm <o PyIID>|iid|IID_IShellItem|The IID to query for + if (obiid != Py_None && !PyWinObject_AsIID(obiid, &iid)) + goto done; + HRESULT hr; + PY_INTERFACE_PRECALL; + hr = (*pfnSHCreateShellItemArrayFromShellItem)(isi, iid, &iret); + PY_INTERFACE_POSTCALL; + if (FAILED(hr)) { + PyCom_BuildPyException(hr); + goto done; + } + // ref on view consumed by ret object. + ret = PyCom_PyObjectFromIUnknown((IUnknown *)iret, iid, FALSE); + done: + if (isi) { + PY_INTERFACE_PRECALL; + isi->Release(); + PY_INTERFACE_POSTCALL; + } + return ret; + } + /* List of module functions */ *************** *** 2320,2327 **** --- 2849,2865 ---- { { "AssocCreate", PyAssocCreate, 1 }, // @pymeth AssocCreate|Creates a <o PyIQueryAssociations> object + { "AssocCreateForClasses", PyAssocCreateForClasses, 1}, // @pymeth AssocCreateForClasses|Retrieves an object that implements an IQueryAssociations interface."} { "DragQueryFile", PyDragQueryFile, 1 }, // @pymeth DragQueryFile|Retrieves the file names of dropped files that have resulted from a successful drag-and-drop operation. { "DragQueryFileW", PyDragQueryFileW, 1 }, // @pymeth DragQueryFileW|Retrieves the file names of dropped files that have resulted from a successful drag-and-drop operation. { "DragQueryPoint", PyDragQueryPoint, 1}, // @pymeth DragQueryPoint|Retrieves the position of the mouse pointer at the time a file was dropped during a drag-and-drop operation. { "IsUserAnAdmin", PyIsUserAnAdmin, METH_VARARGS}, // @pymeth IsUserAnAdmin|Tests whether the current user is a member of the Administrator's group. + { "SHCreateDataObject", PySHCreateDataObject, 1}, // @pymeth SHCreateDataObject|Creates a data object in a parent folder. + { "SHCreateDefaultContextMenu", PySHCreateDefaultContextMenu, 1}, // @pymeth SHCreateDefaultContextMenu| + { "SHCreateDefaultExtractIcon", PySHCreateDefaultExtractIcon, 1}, // @pymeth SHCreateDefaultExtractIcon|Creates a standard icon extractor, whose defaults can be further configured via the IDefaultExtractIconInit interface. + { "SHCreateShellFolderView", PySHCreateShellFolderView, 1}, // @pymeth SHCreateShellFolderView| + { "SHCreateShellItemArray", PySHCreateShellItemArray, 1}, // @pymeth SHCreateShellItemArray| + { "SHCreateShellItemArrayFromDataObject", PySHCreateShellItemArrayFromDataObject, 1}, // @pymeth SHCreateShellItemArrayFromDataObject| + { "SHCreateShellItemArrayFromIDLists", PySHCreateShellItemArrayFromIDLists, 1}, // @pymeth SHCreateShellItemArrayFromIDLists| + { "SHCreateShellItemArrayFromShellItem", PySHCreateShellItemArrayFromIDLists, 1}, // @pymeth SHCreateShellItemArrayFromIDLists| { "SHGetPathFromIDList", PySHGetPathFromIDList, 1 }, // @pymeth SHGetPathFromIDList|Converts an <o PyIDL> to a path. { "SHGetPathFromIDListW", PySHGetPathFromIDListW, 1 }, // @pymeth SHGetPathFromIDListW|Converts an <o PyIDL> to a unicode path. *************** *** 2331,2334 **** --- 2869,2873 ---- { "SHSetFolderPath", PySHSetFolderPath, 1 }, // @pymeth SHSetFolderPath|Sets the location of a special folder { "SHGetFolderLocation", PySHGetFolderLocation, 1 }, // @pymeth SHGetFolderLocation|Retrieves the <o PyIDL> of a folder. + { "SHGetNameFromIDList", PySHGetNameFromIDList, 1}, // @pymeth SHGetNameFromIDList|Retrieves the display name of an item from an ID list. { "SHGetSpecialFolderPath", PySHGetSpecialFolderPath, 1 }, // @pymeth SHGetSpecialFolderPath|Retrieves the path of a special folder. { "SHGetSpecialFolderLocation", PySHGetSpecialFolderLocation, 1 }, // @pymeth SHGetSpecialFolderLocation|Retrieves the <o PyIDL> of a special folder. *************** *** 2372,2375 **** --- 2911,2915 ---- PYCOM_INTERFACE_FULL(ShellExtInit), PYCOM_INTERFACE_FULL(ShellFolder), + PYCOM_INTERFACE_FULL(ShellFolder2), PYCOM_INTERFACE_FULL(ShellIcon), PYCOM_INTERFACE_FULL(ShellIconOverlay), *************** *** 2379,2385 **** --- 2919,2930 ---- PYCOM_INTERFACE_FULL(ShellBrowser), PYCOM_INTERFACE_FULL(EnumIDList), + PYCOM_INTERFACE_FULL(EnumExplorerCommand), PYCOM_INTERFACE_FULL(BrowserFrameOptions), PYCOM_INTERFACE_FULL(PersistFolder), + PYCOM_INTERFACE_FULL(PersistFolder2), + PYCOM_INTERFACE_SERVER_ONLY(Categorizer), + PYCOM_INTERFACE_FULL(CategoryProvider), PYCOM_INTERFACE_FULL(ColumnProvider), + PYCOM_INTERFACE_CLIENT_ONLY(DefaultExtractIconInit), PYCOM_INTERFACE_FULL(DropTargetHelper), PYCOM_INTERFACE_CLIENT_ONLY(EmptyVolumeCacheCallBack), *************** *** 2392,2395 **** --- 2937,2941 ---- PYCOM_INTERFACE_FULL(ExplorerBrowserEvents), PYCOM_INTERFACE_FULL(ExplorerCommand), + PYCOM_INTERFACE_SERVER_ONLY(ExplorerCommandProvider), // IID_ICopyHook doesn't exist - hack it up { &IID_IShellCopyHook, "IShellCopyHook", "IID_IShellCopyHook", &PyICopyHook::type, GET_PYGATEWAY_CTOR(PyGCopyHook) }, *************** *** 2459,2462 **** --- 3005,3018 ---- pfnSHShellFolderView_Message=(PFNSHShellFolderView_Message)GetProcAddress(shell32, "SHShellFolderView_Message"); pfnIsUserAnAdmin=(PFNIsUserAnAdmin)GetProcAddress(shell32, "IsUserAnAdmin"); + pfnSHCreateShellFolderView=(PFNSHCreateShellFolderView)GetProcAddress(shell32, "SHCreateShellFolderView"); + pfnSHCreateDefaultExtractIcon=(PFNSHCreateDefaultExtractIcon)GetProcAddress(shell32, "SHCreateDefaultExtractIcon"); + pfnSHGetNameFromIDList=(PFNSHGetNameFromIDList)GetProcAddress(shell32, "SHGetNameFromIDList"); + pfnAssocCreateForClasses=(PFNAssocCreateForClasses)GetProcAddress(shell32, "AssocCreateForClasses"); + pfnSHCreateShellItemArray=(PFNSHCreateShellItemArray)GetProcAddress(shell32, "SHCreateShellItemArray"); + pfnSHCreateShellItemArrayFromDataObject=(PFNSHCreateShellItemArrayFromDataObject)GetProcAddress(shell32, "SHCreateShellItemArrayFromDataObject"); + pfnSHCreateShellItemArrayFromIDLists=(PFNSHCreateShellItemArrayFromIDLists)GetProcAddress(shell32, "SHCreateShellItemArrayFromIDLists"); + pfnSHCreateShellItemArrayFromShellItem=(PFNSHCreateShellItemArrayFromShellItem)GetProcAddress(shell32, "SHCreateShellItemArrayFromShellItem"); + pfnSHCreateDefaultContextMenu=(PFNSHCreateDefaultContextMenu)GetProcAddress(shell32, "SHCreateDefaultContextMenu"); + pfnSHCreateDataObject=(PFNSHCreateDataObject)GetProcAddress(shell32, "SHCreateDataObject"); } // SHGetFolderPath comes from shfolder.dll on older systems --- NEW FILE: PyICategorizer.h --- // This file declares the ICategorizer Interface and Gateway for Python. // Generated by makegw.py // --------------------------------------------------- // // Gateway Declaration class PyGCategorizer : public PyGatewayBase, public ICategorizer { protected: PyGCategorizer(PyObject *instance) : PyGatewayBase(instance) { ; } PYGATEWAY_MAKE_SUPPORT2(PyGCategorizer, ICategorizer, IID_ICategorizer, PyGatewayBase) // ICategorizer STDMETHOD(GetDescription)( __RPC__out_ecount_full_string(cch) LPWSTR pszDesc, UINT cch); STDMETHOD(GetCategory)( UINT cidl, __RPC__in_ecount_full(cidl) PCUITEMID_CHILD_ARRAY apidl, __RPC__out_ecount_full(cidl) DWORD * rgCategoryIds); STDMETHOD(GetCategoryInfo)( DWORD dwCategoryId, __RPC__out CATEGORY_INFO * pci); STDMETHOD(CompareCategory)( CATSORT_FLAGS csfFlags, DWORD dwCategoryId1, DWORD dwCategoryId2); }; --- NEW FILE: PyIPersistFolder2.cpp --- // This file implements the IPersistFolder2 Interface and Gateway for Python. // Generated by makegw.py #include "shell_pch.h" #include "PyIPersist.h" #include "PyIPersistFolder.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIPersistFolder2::PyIPersistFolder2(IUnknown *pdisp): PyIPersistFolder(pdisp) { ob_type = &type; } PyIPersistFolder2::~PyIPersistFolder2() { } /* static */ IPersistFolder2 *PyIPersistFolder2::GetI(PyObject *self) { return (IPersistFolder2 *)PyIPersistFolder::GetI(self); } // @pymethod |PyIPersistFolder2|GetCurFolder|Description of GetCurFolder. PyObject *PyIPersistFolder2::GetCurFolder(PyObject *self, PyObject *args) { IPersistFolder2 *pIPF2 = GetI(self); if ( pIPF2 == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetCurFolder") ) return NULL; HRESULT hr; PIDLIST_ABSOLUTE pidl; PY_INTERFACE_PRECALL; hr = pIPF2->GetCurFolder( &pidl ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIPF2, IID_IPersistFolder2 ); return PyObject_FromPIDL(pidl, TRUE); } // @object PyIPersistFolder2|Description of the interface static struct PyMethodDef PyIPersistFolder2_methods[] = { { "GetCurFolder", PyIPersistFolder2::GetCurFolder, 1 }, // @pymeth GetCurFolder|Description of GetCurFolder { NULL } }; PyComTypeObject PyIPersistFolder2::type("PyIPersistFolder2", &PyIPersistFolder::type, sizeof(PyIPersistFolder2), PyIPersistFolder2_methods, GET_PYCOM_CTOR(PyIPersistFolder2)); // --------------------------------------------------- // // Gateway Implementation STDMETHODIMP PyGPersistFolder2::GetClassID(CLSID __RPC_FAR *pClassID) {return PyGPersistFolder::GetClassID(pClassID);} STDMETHODIMP PyGPersistFolder2::Initialize(LPCITEMIDLIST pidl) {return PyGPersistFolder::Initialize(pidl);} STDMETHODIMP PyGPersistFolder2::GetCurFolder( /* [out] */ PIDLIST_ABSOLUTE * ppidl) { PY_GATEWAY_METHOD; PyObject *result; HRESULT hr=InvokeViaPolicy("GetCurFolder", &result); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params if (!PyObject_AsPIDL(result, ppidl, TRUE)) hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetCurFolder"); else hr = *ppidl ? S_OK : S_FALSE; // this is what the docs say! Py_DECREF(result); return hr; } --- NEW FILE: PyIExplorerCommandProvider.h --- // This file declares the IExplorerCommandProvider Interface and Gateway for Python. // Generated by makegw.py // --------------------------------------------------- // // Gateway Declaration class PyGExplorerCommandProvider : public PyGatewayBase, public IExplorerCommandProvider { protected: PyGExplorerCommandProvider(PyObject *instance) : PyGatewayBase(instance) { ; } PYGATEWAY_MAKE_SUPPORT2(PyGExplorerCommandProvider, IExplorerCommandProvider, IID_IExplorerCommandProvider, PyGatewayBase) // IExplorerCommandProvider STDMETHOD(GetCommands)( __RPC__in_opt IUnknown * punkSite, __RPC__in REFIID riid, __RPC__deref_out_opt void ** ppv); STDMETHOD(GetCommand)( __RPC__in REFGUID rguidCommandId, __RPC__in REFIID riid, __RPC__deref_out_opt void ** ppv); }; --- NEW FILE: PyIExplorerCommandProvider.cpp --- // This file implements the IExplorerCommandProvider Interface and Gateway for Python. // Generated by makegw.py #include "shell_pch.h" #include "PyIExplorerCommandProvider.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Gateway Implementation STDMETHODIMP PyGExplorerCommandProvider::GetCommands( /* [in] */ __RPC__in_opt IUnknown * punkSite, /* [in] */ __RPC__in REFIID riid, /* [iid_is][out] */ __RPC__deref_out_opt void ** ppv) { PY_GATEWAY_METHOD; PyObject *result; HRESULT hr=InvokeViaPolicy("GetCommands", &result, "NN", PyCom_PyObjectFromIUnknown(punkSite, IID_IUnknown, TRUE), PyWinObject_FromIID(riid)); if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params if (!PyCom_InterfaceFromPyInstanceOrObject(result, riid, ppv, FALSE /* bNoneOK */)) hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetCommands"); Py_DECREF(result); return hr; } STDMETHODIMP PyGExplorerCommandProvider::GetCommand( /* [in] */ __RPC__in REFGUID rguidCommandId, /* [in] */ __RPC__in REFIID riid, /* [iid_is][out] */ __RPC__deref_out_opt void ** ppv) { PY_GATEWAY_METHOD; PyObject *result; HRESULT hr=InvokeViaPolicy("GetCommand", &result, "NN", PyWinObject_FromIID(rguidCommandId), PyWinObject_FromIID(riid)); if (FAILED(hr)) return hr; if (!PyCom_InterfaceFromPyInstanceOrObject(result, riid, ppv, FALSE /* bNoneOK */)) hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetCommand"); Py_DECREF(result); return hr; } --- NEW FILE: PyICategorizer.cpp --- // This file implements the ICategorizer Interface and Gateway for Python. // Generated by makegw.py #include "shell_pch.h" #include "PyICategorizer.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation // --------------------------------------------------- // // Gateway Implementation STDMETHODIMP PyGCategorizer::GetDescription( /* [size_is][string][out] */ __RPC__out_ecount_full_string(cch) LPWSTR pszDesc, /* [in] */ UINT cch) { PY_GATEWAY_METHOD; PyObject *result; HRESULT hr=InvokeViaPolicy("GetDescription", &result, "i", cch); if (FAILED(hr)) return hr; // ack - should be a function to convert directly into a buffer. WCHAR *allocd_result; if (!PyWinObject_AsWCHAR(result, &allocd_result, FALSE)) { hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetDescription"); } else { wcsncpy(pszDesc, allocd_result, cch); PyWinObject_FreeWCHAR(allocd_result); } Py_DECREF(result); return hr; } STDMETHODIMP PyGCategorizer::GetCategory( /* [in] */ UINT cidl, /* [size_is][in] */ __RPC__in_ecount_full(cidl) PCUITEMID_CHILD_ARRAY apidl, /* [size_is][out] */ __RPC__out_ecount_full(cidl) DWORD * rgCategoryIds) { static const char *method_name = "GetCategory"; PY_GATEWAY_METHOD; PyObject *obapidl = PyList_New(cidl); if (!obapidl) return MAKE_PYCOM_GATEWAY_FAILURE_CODE(method_name); for (UINT i=0;i<cidl;i++) { PyObject *obpidl = PyObject_FromPIDL(apidl[i], FALSE); if (obpidl) { Py_DECREF(obapidl); return MAKE_PYCOM_GATEWAY_FAILURE_CODE(method_name); } PyList_SET_ITEM(obapidl, i, obpidl); } PyObject *result; HRESULT hr=InvokeViaPolicy("GetCategory", &result, "O", obapidl); Py_DECREF(obapidl); if (FAILED(hr)) return hr; PyObject *dwords_tuple; DWORD ret_cnt; if ((dwords_tuple=PyWinSequence_Tuple(result, &ret_cnt))==NULL) hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE(method_name); else { if (ret_cnt != cidl) { PyErr_Format(PyExc_ValueError, "expecting sequence of length %d, got %d", cidl, ret_cnt); hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE(method_name); } else { for (DWORD tuple_index=0; tuple_index<cidl; tuple_index++){ PyObject *tuple_item=PyTuple_GET_ITEM(dwords_tuple,tuple_index); rgCategoryIds[tuple_index]=PyInt_AsLong(tuple_item); if ((rgCategoryIds[tuple_index]==-1) && PyErr_Occurred()){ hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE(method_name); break; } } } } Py_DECREF(result); return hr; } STDMETHODIMP PyGCategorizer::GetCategoryInfo( /* [in] */ DWORD dwCategoryId, /* [out] */ __RPC__out CATEGORY_INFO * pci) { PY_GATEWAY_METHOD; PyObject *result; HRESULT hr=InvokeViaPolicy("GetCategoryInfo", &result, "l", dwCategoryId); if (FAILED(hr)) return hr; PyObject *obName; if (!PyArg_ParseTuple(result, "iO", &pci->cif, &obName)) hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetCategory"); else { WCHAR *allocd_result; if (!PyWinObject_AsWCHAR(obName, &allocd_result, FALSE)) { hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetCategoryInfo"); } else { wcsncpy(pci->wszName, allocd_result, sizeof(pci->wszName)/sizeof(pci->wszName[0])); PyWinObject_FreeWCHAR(allocd_result); } } // Process the Python results, and convert back to the real params Py_DECREF(result); return hr; } STDMETHODIMP PyGCategorizer::CompareCategory( /* [in] */ CATSORT_FLAGS csfFlags, /* [in] */ DWORD dwCategoryId1, /* [in] */ DWORD dwCategoryId2) { PY_GATEWAY_METHOD; PyObject *result; HRESULT hr=InvokeViaPolicy("CompareCategory", &result, "lll", csfFlags, dwCategoryId1, dwCategoryId2); if (FAILED(hr)) return hr; if (!PyInt_Check(result)) { PyErr_Format(PyExc_TypeError, "CompareCategory expects an int, got a %s", result->ob_type->tp_name); hr = MAKE_PYCOM_GATEWAY_FAILURE_CODE("GetCategory"); } else { hr = MAKE_HRESULT(SEVERITY_SUCCESS, 0, (USHORT)PyInt_AsLong(result)); } Py_DECREF(result); return hr; } --- NEW FILE: PyIDefaultExtractIconInit.h --- // This file declares the IDefaultExtractIconInit Interface and Gateway for Python. // Generated by makegw.py // --------------------------------------------------- // // Interface Declaration class PyIDefaultExtractIconInit : public PyIUnknown { public: MAKE_PYCOM_CTOR(PyIDefaultExtractIconInit); static IDefaultExtractIconInit *GetI(PyObject *self); static PyComTypeObject type; // The Python methods static PyObject *SetFlags(PyObject *self, PyObject *args); static PyObject *SetKey(PyObject *self, PyObject *args); static PyObject *Se... [truncated message content] |
From: Mark H. <mha...@us...> - 2008-02-07 05:28:45
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16241/src Modified Files: PyIShellFolder.cpp Log Message: Allow None for EnumObjects, which will cause S_FALSE to be returned and allow GetUIObject to just return the interface and not the other unused inout param Index: PyIShellFolder.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/src/PyIShellFolder.cpp,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** PyIShellFolder.cpp 17 Oct 2007 03:49:55 -0000 1.17 --- PyIShellFolder.cpp 7 Feb 2008 05:28:46 -0000 1.18 *************** *** 490,495 **** 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; --- 490,500 ---- if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! if (result==Py_None) { ! hr = S_FALSE; ! *ppeidl = NULL; ! } else { ! PyCom_InterfaceFromPyInstanceOrObject(result, IID_IEnumIDList, (void **)ppeidl, FALSE /* bNoneOK */); ! hr = PyCom_SetAndLogCOMErrorFromPyException("EnumObjects", IID_IShellFolder); ! } Py_DECREF(result); return hr; *************** *** 628,639 **** if (FAILED(hr)) return hr; // 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; --- 633,651 ---- if (FAILED(hr)) return hr; // Process the Python results, and convert back to the real params ! // the 'inout' param appears unused - allow either. ! if (PyTuple_Check(result)) { ! PyObject *obout; ! UINT inout; ! if (!PyArg_ParseTuple(result, "lO" , &inout, &obout)) ! hr = PyCom_SetAndLogCOMErrorFromPyException(szMethodName, IID_IShellFolder); ! else { ! if (rgfInOut) *rgfInOut = inout; ! if (!PyCom_InterfaceFromPyInstanceOrObject(obout, riid, ppRet, FALSE/* bNoneOK */)) ! hr = PyCom_SetAndLogCOMErrorFromPyException(szMethodName, IID_IShellFolder); ! } ! } else { ! if (!PyCom_InterfaceFromPyInstanceOrObject(result, riid, ppRet, FALSE/* bNoneOK */)) ! hr = PyCom_SetAndLogCOMErrorFromPyException(szMethodName, IID_IShellFolder); ! } Py_DECREF(result); return hr; |
From: Mark H. <mha...@us...> - 2008-02-07 05:24:17
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15141/demos/servers Modified Files: context_menu.py shell_view.py Log Message: The list of interface methods are now stored in shellcon. Index: shell_view.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers/shell_view.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** shell_view.py 7 Jan 2008 22:56:38 -0000 1.10 --- shell_view.py 7 Feb 2008 05:24:20 -0000 1.11 *************** *** 97,116 **** # Our COM interfaces. - IOleWindow_Methods = "GetWindow ContextSensitiveHelp".split() - IShellView_Methods = IOleWindow_Methods + \ - """TranslateAccelerator EnableModeless UIActivate - Refresh CreateViewWindow DestroyViewWindow - GetCurrentInfo AddPropertySheetPages SaveViewState - SelectItem GetItemObject""".split() - - IShellFolder_Methods = """ParseDisplayName EnumObjects BindToObject - BindToStorage CompareIDs CreateViewObject - GetAttributesOf GetUIObjectOf GetDisplayNameOf - SetNameOf""".split() - - IBrowserFrame_Methods = ["GetFrameOptions"] - - IPersist_Methods = ["GetClassID"] - IPersistFolder_Methods = IPersist_Methods + ["Initialize"] # Base class for a shell folder. --- 97,100 ---- *************** *** 124,130 **** ] ! _public_methods_ = IBrowserFrame_Methods + \ ! IPersistFolder_Methods + \ ! IShellFolder_Methods def GetFrameOptions(self, mask): --- 108,114 ---- ] ! _public_methods_ = shellcon.IBrowserFrame_Methods + \ ! shellcon.IPersistFolder_Methods + \ ! shellcon.IShellFolder_Methods def GetFrameOptions(self, mask): *************** *** 167,171 **** 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) --- 151,155 ---- 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) *************** *** 356,360 **** # or filenames. class FileSystemView: ! _public_methods_ = IShellView_Methods _com_interfaces_ = [pythoncom.IID_IOleWindow, shell.IID_IShellView, --- 340,344 ---- # or filenames. class FileSystemView: ! _public_methods_ = shellcon.IShellView_Methods _com_interfaces_ = [pythoncom.IID_IOleWindow, shell.IID_IShellView, *************** *** 714,718 **** # number. class ScintillaShellView: ! _public_methods_ = IShellView_Methods _com_interfaces_ = [pythoncom.IID_IOleWindow, shell.IID_IShellView, --- 698,702 ---- # number. class ScintillaShellView: ! _public_methods_ = shellcon.IShellView_Methods _com_interfaces_ = [pythoncom.IID_IOleWindow, shell.IID_IShellView, Index: context_menu.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/demos/servers/context_menu.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** context_menu.py 9 Oct 2003 12:34:35 -0000 1.3 --- context_menu.py 7 Feb 2008 05:24:20 -0000 1.4 *************** *** 14,20 **** import win32con - IContextMenu_Methods = ["QueryContextMenu", "InvokeCommand", "GetCommandString"] - IShellExtInit_Methods = ["Initialize"] - class ShellExtension: _reg_progid_ = "Python.ShellExtension.ContextMenu" --- 14,17 ---- *************** *** 22,26 **** _reg_clsid_ = "{CED0336C-C9EE-4a7f-8D7F-C660393C381F}" _com_interfaces_ = [shell.IID_IShellExtInit, shell.IID_IContextMenu] ! _public_methods_ = IContextMenu_Methods + IShellExtInit_Methods def Initialize(self, folder, dataobj, hkey): --- 19,23 ---- _reg_clsid_ = "{CED0336C-C9EE-4a7f-8D7F-C660393C381F}" _com_interfaces_ = [shell.IID_IShellExtInit, shell.IID_IContextMenu] ! _public_methods_ = shellcon.IContextMenu_Methods + shellcon.IShellExtInit_Methods def Initialize(self, folder, dataobj, hkey): |
From: Mark H. <mha...@us...> - 2008-02-07 05:17:03
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/shell In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12328 Modified Files: shellcon.py Log Message: Many more IExplorer* related constants and interface method name constants are now shared here. Index: shellcon.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/shell/shellcon.py,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** shellcon.py 15 Feb 2007 13:11:02 -0000 1.17 --- shellcon.py 7 Feb 2008 05:17:05 -0000 1.18 *************** *** 1086,1087 **** --- 1086,1174 ---- EVCF_OUTOFDISKSPACE = 0x0040 EVCCBF_LASTNOTIFICATION = 0x0001 + + # ShObjIdl.h IExplorer* related + EBO_NONE = 0 + EBO_NAVIGATEONCE = 0x1 + EBO_SHOWFRAMES = 0x2 + EBO_ALWAYSNAVIGATE = 0x4 + EBO_NOTRAVELLOG = 0x8 + EBO_NOWRAPPERWINDOW = 0x10 + EBF_NONE = 0 + EBF_SELECTFROMDATAOBJECT = 0x100 + EBF_NODROPTARGET = 0x200 + ECS_ENABLED = 0 + ECS_DISABLED = 0x1 + ECS_HIDDEN = 0x2 + ECS_CHECKBOX = 0x4 + ECS_CHECKED = 0x8 + + ECF_HASSUBCOMMANDS = 0x1 + ECF_HASSPLITBUTTON = 0x2 + ECF_HIDELABEL = 0x4 + ECF_ISSEPARATOR = 0x8 + ECF_HASLUASHIELD = 0x10 + + SIATTRIBFLAGS_AND = 0x1 + SIATTRIBFLAGS_OR = 0x2 + SIATTRIBFLAGS_APPCOMPAT = 0x3 + SIATTRIBFLAGS_MASK = 0x3 + + SIGDN_NORMALDISPLAY = 0 + SIGDN_PARENTRELATIVEPARSING = -2147385343 ## 0x80018001 + SIGDN_DESKTOPABSOLUTEPARSING = -2147319808 ## 0x80028000 + SIGDN_PARENTRELATIVEEDITING = -2147282943 ## 0x80031001 + SIGDN_DESKTOPABSOLUTEEDITING = -2147172352 ## 0x8004c000 + SIGDN_FILESYSPATH = -2147123200 ## 0x80058000 + SIGDN_URL = -2147057664 ## 0x80068000 + SIGDN_PARENTRELATIVEFORADDRESSBAR = -2146975743 ## 0x8007c001, + SIGDN_PARENTRELATIVE = -2146959359 ## 0x80080001 + + SICHINT_DISPLAY = 0, + SICHINT_ALLFIELDS = -2147483648 ## 0x80000000 + SICHINT_CANONICAL = 0x10000000 + + ASSOCCLASS_SHELL_KEY = 0 + ASSOCCLASS_PROGID_KEY = 1 # hkeyClass + ASSOCCLASS_PROGID_STR = 2 # pszClass (HKCR\pszClass) + ASSOCCLASS_CLSID_KEY = 3 # hkeyClass + ASSOCCLASS_CLSID_STR = 4 # pszClass (HKCR\CLSID\pszClass) + ASSOCCLASS_APP_KEY = 5 # hkeyClass + ASSOCCLASS_APP_STR = 6 # pszClass (HKCR\Applications\PathFindFileName(pszClass)) + ASSOCCLASS_SYSTEM_STR = 7 # pszClass + ASSOCCLASS_FOLDER = 8 # none + ASSOCCLASS_STAR = 9 # none + + CLSID_ExplorerBrowser = "{71f96385-ddd6-48d3-a0c1-ae06e8b055fb}" + + # Names of the methods of many shell interfaces; used by implementation of + # the interfaces. + IBrowserFrame_Methods = ["GetFrameOptions"] + ICategorizer_Methods = ["GetDescription", "GetCategory", + "GetCategoryInfo", "CompareCategory"] + ICategoryProvider_Methods = ["CanCategorizeOnSCID", "GetDefaultCategory", + "GetCategoryForSCID", "EnumCategories", + "GetCategoryName", "CreateCategory"] + IContextMenu_Methods = ["QueryContextMenu", "InvokeCommand", "GetCommandString"] + IExplorerCommand_Methods = ["GetTitle", "GetIcon", "GetToolTip", + "GetCanonicalName", "GetState", "Invoke", + "GetFlags", "EnumSubCommands"] + IExplorerCommandProvider_Methods = ["GetCommand", "GetCommands"] + IOleWindow_Methods = ["GetWindow", "ContextSensitiveHelp"] # XXX - this should be somewhere in win32com + IPersist_Methods = ["GetClassID"] + IPersistFolder_Methods = IPersist_Methods + ["Initialize"] + IPersistFolder2_Methods = IPersistFolder_Methods + ["GetCurFolder"] + IShellExtInit_Methods = ["Initialize"] + IShellView_Methods = IOleWindow_Methods + \ + ["TranslateAccelerator", "EnableModeless", "UIActivate", + "Refresh", "CreateViewWindow", "DestroyViewWindow", + "GetCurrentInfo", "AddPropertySheetPages", + "SaveViewState", "SelectItem", "GetItemObject"] + + IShellFolder_Methods = ["ParseDisplayName", "EnumObjects", "BindToObject", + "BindToStorage", "CompareIDs", "CreateViewObject", + "GetAttributesOf", "GetUIObjectOf", + "GetDisplayNameOf", "SetNameOf"] + IShellFolder2_Methods = IShellFolder_Methods + \ + ["GetDefaultSearchGUID", "EnumSearches", + "GetDefaultColumn", "GetDefaultColumnState", + "GetDetailsEx", "GetDetailsOf", "MapColumnToSCID"] |
From: Mark H. <mha...@us...> - 2008-02-07 03:33:15
|
Update of /cvsroot/pywin32/pywin32/win32/Lib In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8131/lib Modified Files: win32serviceutil.py Log Message: Take advantage of all RegisterServiceCtrlHandler() functionality in a backwards compatible way, including a demo. Index: win32serviceutil.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/Lib/win32serviceutil.py,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** win32serviceutil.py 30 Jun 2007 04:37:52 -0000 1.25 --- win32serviceutil.py 7 Feb 2008 03:33:15 -0000 1.26 *************** *** 589,593 **** # -debug option svcArgs = string.join(args[1:]) ! exeName = LocateSpecificServiceExe(serviceName) try: os.system("%s -debug %s %s" % (exeName, serviceName, svcArgs)) --- 589,600 ---- # -debug option svcArgs = string.join(args[1:]) ! try: ! exeName = LocateSpecificServiceExe(serviceName) ! except win32api.error, exc: ! if exc[0] == winerror.ERROR_FILE_NOT_FOUND: ! print "The service does not appear to be installed." ! print "Please install the service before debugging it." ! sys.exit(1) ! raise try: os.system("%s -debug %s %s" % (exeName, serviceName, svcArgs)) *************** *** 721,730 **** def __init__(self, args): import servicemanager ! self.ssh = servicemanager.RegisterServiceCtrlHandler(args[0], self.ServiceCtrlHandler) servicemanager.SetEventSourceName(self._svc_name_) self.checkPoint = 0 def GetAcceptedControls(self): ! # Setup the service controls we accept based on our attributes accepted = 0 if hasattr(self, "SvcStop"): accepted = accepted | win32service.SERVICE_ACCEPT_STOP --- 728,739 ---- def __init__(self, args): import servicemanager ! self.ssh = servicemanager.RegisterServiceCtrlHandler(args[0], self.ServiceCtrlHandlerEx, True) servicemanager.SetEventSourceName(self._svc_name_) self.checkPoint = 0 def GetAcceptedControls(self): ! # Setup the service controls we accept based on our attributes. Note ! # that if you need to handle controls via SvcOther[Ex](), you must ! # override this. accepted = 0 if hasattr(self, "SvcStop"): accepted = accepted | win32service.SERVICE_ACCEPT_STOP *************** *** 763,769 **** def SvcOther(self, control): ! print "Unknown control status - %d" % control def ServiceCtrlHandler(self, control): if control==win32service.SERVICE_CONTROL_STOP: self.SvcStop() --- 772,791 ---- def SvcOther(self, control): ! try: ! print "Unknown control status - %d" % control ! except IOError: ! # services may not have a valid stdout! ! pass def ServiceCtrlHandler(self, control): + self.ServiceCtrlHandlerEx(control, 0, None) + + # The 'Ex' functions, which take additional params + def SvcOtherEx(self, control, event_type, data): + # The default here is to call self.SvcOther as that is the old behaviour. + # If you want to take advantage of the extra data, override this method + self.SvcOther(control) + + def ServiceCtrlHandlerEx(self, control, event_type, data): if control==win32service.SERVICE_CONTROL_STOP: self.SvcStop() *************** *** 777,781 **** self.SvcShutdown() else: ! self.SvcOther(control) def SvcRun(self): --- 799,803 ---- self.SvcShutdown() else: ! self.SvcOtherEx(control, event_type, data) def SvcRun(self): |
From: Mark H. <mha...@us...> - 2008-02-07 03:33:15
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8131/src Modified Files: PythonService.cpp Log Message: Take advantage of all RegisterServiceCtrlHandler() functionality in a backwards compatible way, including a demo. Index: PythonService.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PythonService.cpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** PythonService.cpp 22 Jan 2008 11:58:01 -0000 1.22 --- PythonService.cpp 7 Feb 2008 03:33:15 -0000 1.23 *************** *** 93,96 **** --- 93,97 ---- SERVICE_STATUS_HANDLE sshStatusHandle; // the handle for this service. PyObject *obServiceCtrlHandler; // The Python control handler for the service. + BOOL bUseEx; // does this handler expect the extra args? } PY_SERVICE_TABLE_ENTRY; *************** *** 317,323 **** { PyObject *nameOb, *obCallback; // @pyparm <o PyUnicode>|serviceName||The name of the service. This is provided in args[0] of the service class __init__ method. // @pyparm object|callback||The Python function that performs as the control function. This will be called with an integer status argument. ! if (!PyArg_ParseTuple(args, "OO", &nameOb, &obCallback)) return NULL; if (!PyCallable_Check(obCallback)) { --- 318,326 ---- { PyObject *nameOb, *obCallback; + BOOL bUseEx = FALSE; // @pyparm <o PyUnicode>|serviceName||The name of the service. This is provided in args[0] of the service class __init__ method. // @pyparm object|callback||The Python function that performs as the control function. This will be called with an integer status argument. ! // @pyparm bool|extra_args|False|Is this callback expecting the additional 2 args passed by HandlerEx? ! if (!PyArg_ParseTuple(args, "OO|i", &nameOb, &obCallback, &bUseEx)) return NULL; if (!PyCallable_Check(obCallback)) { *************** *** 336,339 **** --- 339,343 ---- Py_XDECREF(pe->obServiceCtrlHandler); pe->obServiceCtrlHandler = obCallback; + pe->bUseEx = bUseEx; Py_INCREF(obCallback); if (bServiceDebug) { // If debugging, get out now, and give None back. *************** *** 341,351 **** return Py_None; } ! if (g_RegisterServiceCtrlHandlerEx) { ! // Use 2K/XP extended registration if available ! pe->sshStatusHandle = g_RegisterServiceCtrlHandlerEx(szName, service_ctrl_ex, pe); ! } else { ! // Otherwise fall back to NT ! pe->sshStatusHandle = RegisterServiceCtrlHandler(szName, service_ctrl); ! } PyWinObject_FreeWCHAR(szName); PyObject *rc; --- 345,355 ---- return Py_None; } ! if (g_RegisterServiceCtrlHandlerEx) { ! // Use 2K/XP extended registration if available ! pe->sshStatusHandle = g_RegisterServiceCtrlHandlerEx(szName, service_ctrl_ex, pe); ! } else { ! // Otherwise fall back to NT ! pe->sshStatusHandle = RegisterServiceCtrlHandler(szName, service_ctrl); ! } PyWinObject_FreeWCHAR(szName); PyObject *rc; *************** *** 706,709 **** --- 710,714 ---- PythonServiceTable[0].sshStatusHandle = 0; PythonServiceTable[0].obServiceCtrlHandler = NULL; + PythonServiceTable[0].bUseEx = 0; return TRUE; } *************** *** 750,753 **** --- 755,759 ---- PythonServiceTable[i].sshStatusHandle = 0; PythonServiceTable[i].obServiceCtrlHandler = NULL; + PythonServiceTable[i].bUseEx = 0; return TRUE; } *************** *** 910,914 **** // we are running on NT or 2K/XP. ! DWORD WINAPI dispatchServiceCtrl(DWORD dwCtrlCode, PY_SERVICE_TABLE_ENTRY *pse) { --- 916,921 ---- // we are running on NT or 2K/XP. ! DWORD WINAPI dispatchServiceCtrl(DWORD dwCtrlCode, DWORD dwEventType, ! LPVOID eventData, PY_SERVICE_TABLE_ENTRY *pse) { *************** *** 921,925 **** DWORD dwResult; CEnterLeavePython celp; ! PyObject *args = Py_BuildValue("(l)", dwCtrlCode); PyObject *result = PyObject_CallObject(pse->obServiceCtrlHandler, args); Py_XDECREF(args); --- 928,959 ---- DWORD dwResult; CEnterLeavePython celp; ! PyObject *args; ! if (pse->bUseEx) { ! PyObject *sub; ! switch (dwEventType) { ! case SERVICE_CONTROL_DEVICEEVENT: ! sub = PyWinObject_FromPARAM((LPARAM)eventData); ! break; ! case SERVICE_CONTROL_POWEREVENT: { ! POWERBROADCAST_SETTING *pbs = (POWERBROADCAST_SETTING *)eventData; ! sub = Py_BuildValue("NN", ! PyWinObject_FromIID(pbs->PowerSetting), ! PyString_FromStringAndSize((char *)pbs->Data, pbs->DataLength)); ! break; ! } ! case SERVICE_CONTROL_SESSIONCHANGE: { ! WTSSESSION_NOTIFICATION *sn = (WTSSESSION_NOTIFICATION *)eventData; ! sub = Py_BuildValue("(i)", sn->dwSessionId); ! break; ! } ! default: ! sub = Py_None; ! Py_INCREF(sub); ! break; ! } ! args = Py_BuildValue("(llN)", dwCtrlCode, dwEventType, sub); ! } else { ! args = Py_BuildValue("(l)", dwCtrlCode); ! } PyObject *result = PyObject_CallObject(pse->obServiceCtrlHandler, args); Py_XDECREF(args); *************** *** 944,948 **** { PY_SERVICE_TABLE_ENTRY *pse = (PY_SERVICE_TABLE_ENTRY *)lpContext; ! return dispatchServiceCtrl(dwCtrlCode, pse); } --- 978,982 ---- { PY_SERVICE_TABLE_ENTRY *pse = (PY_SERVICE_TABLE_ENTRY *)lpContext; ! return dispatchServiceCtrl(dwCtrlCode, dwEventType, lpEventData, pse); } *************** *** 951,955 **** ) { ! dispatchServiceCtrl(dwCtrlCode, &PythonServiceTable[0]); } --- 985,989 ---- ) { ! dispatchServiceCtrl(dwCtrlCode, 0, NULL, &PythonServiceTable[0]); } |
From: Mark H. <mha...@us...> - 2008-02-07 03:33:15
|
Update of /cvsroot/pywin32/pywin32/win32/Demos/service In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8131/Demos/service Added Files: serviceEvents.py Log Message: Take advantage of all RegisterServiceCtrlHandler() functionality in a backwards compatible way, including a demo. --- NEW FILE: serviceEvents.py --- # A Demo of a service that takes advantage of the additional notifications # available in later Windows versions. import win32serviceutil, win32service import win32event import servicemanager class EventDemoService(win32serviceutil.ServiceFramework): _svc_name_ = "PyServiceEventDemo" _svc_display_name_ = "Python Service Event Demo" _svc_description_ = "Demonstrates a Python service which takes advantage of the extra notifications" def __init__(self, args): win32serviceutil.ServiceFramework.__init__(self, args) self.hWaitStop = win32event.CreateEvent(None, 0, 0, None) # Override the base class so we can accept additional events. def GetAcceptedControls(self): # say we accept them all. rc = win32serviceutil.ServiceFramework.GetAcceptedControls(self) rc |= win32service.SERVICE_ACCEPT_PARAMCHANGE \ | win32service.SERVICE_ACCEPT_NETBINDCHANGE \ | win32service.SERVICE_ACCEPT_HARDWAREPROFILECHANGE \ | win32service.SERVICE_ACCEPT_POWEREVENT \ | win32service.SERVICE_ACCEPT_SESSIONCHANGE return rc # All extra events are sent via SvcOtherEx (SvcOther remains as a # function taking only the first args for backwards compat) def SvcOtherEx(self, control, event_type, data): # This is only showing a few of the extra events - see the MSDN # docs for "HandlerEx callback" for more info. # XXX can't do SERVICE_CONTROL_DEVICEEVENT until we wrap RegisterDeviceNotification. if control == win32service.SERVICE_CONTROL_HARDWAREPROFILECHANGE: msg = "A hardware profile changed: change type %d" % (event_type,) elif control == win32service.SERVICE_CONTROL_POWEREVENT: msg = "A power event: setting guid=%d, raw_data=%s" % data elif control == win32service.SERVICE_CONTROL_SESSIONCHANGE: # data is a single elt tuple, but this could potentially grow # in the future if the win32 struct does msg = "Session event: session ID=%d" % data[:1] else: msg = "Other event: code=%d, event_type=%d, data=%s" \ % (control, event_type, data) servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, 0xF000, # generic message (msg, '') ) def SvcStop(self): self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING) win32event.SetEvent(self.hWaitStop) def SvcDoRun(self): # do nothing at all - just wait to be stopped win32event.WaitForSingleObject(self.hWaitStop, win32event.INFINITE) # Write a stop message. servicemanager.LogMsg( servicemanager.EVENTLOG_INFORMATION_TYPE, servicemanager.PYS_SERVICE_STOPPED, (self._svc_name_, '') ) if __name__=='__main__': win32serviceutil.HandleCommandLine(EventDemoService) |
From: Roger U. <ru...@us...> - 2008-02-07 03:27:32
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5942 Modified Files: win32apimodule.cpp Log Message: Add RegDeleteKeyEx (combined with RegDeleteKeyTransacted) Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** win32apimodule.cpp 7 Feb 2008 00:05:34 -0000 1.81 --- win32apimodule.cpp 7 Feb 2008 03:27:36 -0000 1.82 *************** *** 71,74 **** --- 71,76 ---- REGSAM,LPSECURITY_ATTRIBUTES,PHKEY,LPDWORD,HANDLE,PVOID); static RegCreateKeyTransactedfunc pfnRegCreateKeyTransacted=NULL; + typedef LONG (WINAPI *RegDeleteKeyExfunc)(HKEY,LPWSTR,REGSAM,DWORD); + static RegDeleteKeyExfunc pfnRegDeleteKeyEx = NULL; typedef LONG (WINAPI *RegDeleteKeyTransactedfunc)(HKEY,LPWSTR,REGSAM,DWORD,HANDLE,PVOID); static RegDeleteKeyTransactedfunc pfnRegDeleteKeyTransacted = NULL; *************** *** 3005,3017 **** } ! // @pymethod |win32api|RegDeleteKeyTransacted|Deletes a registry key as part of a transaction // @comm Accepts keyword args. ! // @comm Requires Vista or later. // @comm Key to be deleted cannot contain subkeys ! static PyObject *PyRegDeleteKeyTransacted(PyObject *self, PyObject *args, PyObject *kwargs) { - CHECK_PFN(RegDeleteKeyTransacted); HKEY hKey; ! PyObject *obKey, *obsubKey, *obtrans, *ret=NULL; PVOID extparam=NULL; // Reserved, ignore for now WCHAR *subKey=NULL; --- 3007,3021 ---- } ! // @pymethod |win32api|RegDeleteKeyEx|Deletes a registry key from 32 or 64 bit registry view ! // @pyseeapi RegDeleteKeyEx // @comm Accepts keyword args. ! // @comm Requires 64-bit XP, Vista, or later. // @comm Key to be deleted cannot contain subkeys ! // @comm If a transaction handle is specified, RegDeleteKeyTransacted is called ! // @pyseeapi RegDeleteKeyTransacted ! static PyObject *PyRegDeleteKeyEx(PyObject *self, PyObject *args, PyObject *kwargs) { HKEY hKey; ! PyObject *obKey, *obsubKey, *obtrans=Py_None, *ret=NULL; PVOID extparam=NULL; // Reserved, ignore for now WCHAR *subKey=NULL; *************** *** 3020,3037 **** HANDLE htrans; long rc; ! static char *keywords[]={"Key","SubKey","Transaction","samDesired", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO|k:RegDeleteKeyTransacted", keywords, &obKey, // @pyparm <o PyHKEY>/int|Key||Registry key or one of win32con.HKEY_* values &obsubKey, // @pyparm <o PyUnicode>|SubKey||Name of subkey to be deleted. ! &obtrans, // @pyparm <o PyHANDLE>|Transaction||Handle to a transaction as returned by <om win32transaction.CreateTransaction> ! &access)) // @pyparm int|samDesired|0|Can be KEY_WOW64_32KEY or KEY_WOW64_64KEY to specify alternate registry view return NULL; if (PyWinObject_AsHKEY(obKey, &hKey) ! &&PyWinObject_AsWCHAR(obsubKey, &subKey, FALSE) ! &&PyWinObject_AsHANDLE(obtrans, &htrans)){ ! rc=(*pfnRegDeleteKeyTransacted)(hKey, subKey, access, reserved, htrans, extparam); if (rc!=ERROR_SUCCESS) ! PyWin_SetAPIError("RegDeleteKeyTransacted", rc); else{ Py_INCREF(Py_None); --- 3024,3052 ---- HANDLE htrans; long rc; ! static char *keywords[]={"Key","SubKey","samDesired","Transaction", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO|kO:RegDeleteKeyEx", keywords, &obKey, // @pyparm <o PyHKEY>/int|Key||Registry key or one of win32con.HKEY_* values &obsubKey, // @pyparm <o PyUnicode>|SubKey||Name of subkey to be deleted. ! &access, // @pyparm int|samDesired|0|Can be KEY_WOW64_32KEY or KEY_WOW64_64KEY to specify alternate registry view ! &obtrans)) // @pyparm <o PyHANDLE>|Transaction|None|Handle to a transaction as returned by <om win32transaction.CreateTransaction> return NULL; + + if (!PyWinObject_AsHANDLE(obtrans, &htrans)) + return NULL; + if (htrans!=NULL){ + CHECK_PFN(RegDeleteKeyTransacted); + } + else{ + CHECK_PFN(RegDeleteKeyEx); + } if (PyWinObject_AsHKEY(obKey, &hKey) ! &&PyWinObject_AsWCHAR(obsubKey, &subKey, FALSE)){ ! if (htrans!=NULL) ! rc=(*pfnRegDeleteKeyTransacted)(hKey, subKey, access, reserved, htrans, extparam); ! else ! rc=(*pfnRegDeleteKeyEx)(hKey, subKey, access, reserved); if (rc!=ERROR_SUCCESS) ! PyWin_SetAPIError("RegDeleteKeyEx", rc); else{ Py_INCREF(Py_None); *************** *** 6007,6011 **** {"RegCreateKeyEx", (PyCFunction)PyRegCreateKeyEx, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegCreateKeyEx|Extended version of RegCreateKey {"RegDeleteKey", PyRegDeleteKey, 1}, // @pymeth RegDeleteKey|Deletes the specified key. ! {"RegDeleteKeyTransacted",(PyCFunction)PyRegDeleteKeyTransacted, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegDeleteKeyTransacted|Deletes a registry key as part of a transaction {"RegDeleteTree", (PyCFunction)PyRegDeleteTree, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegDeleteTree|Recursively deletes a key's subkeys and values {"RegDeleteValue", PyRegDeleteValue, 1}, // @pymeth RegDeleteValue|Removes a named value from the specified registry key. --- 6022,6026 ---- {"RegCreateKeyEx", (PyCFunction)PyRegCreateKeyEx, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegCreateKeyEx|Extended version of RegCreateKey {"RegDeleteKey", PyRegDeleteKey, 1}, // @pymeth RegDeleteKey|Deletes the specified key. ! {"RegDeleteKeyEx", (PyCFunction)PyRegDeleteKeyEx, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegDeleteKeyEx|Deletes a registry key from 32 or 64 bit registry view {"RegDeleteTree", (PyCFunction)PyRegDeleteTree, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegDeleteTree|Recursively deletes a key's subkeys and values {"RegDeleteValue", PyRegDeleteValue, 1}, // @pymeth RegDeleteValue|Removes a named value from the specified registry key. *************** *** 6197,6200 **** --- 6212,6216 ---- pfnRegCreateKeyTransacted=(RegCreateKeyTransactedfunc)GetProcAddress(hmodule, "RegCreateKeyTransactedW"); pfnRegOpenKeyTransacted=(RegOpenKeyTransactedfunc)GetProcAddress(hmodule, "RegOpenKeyTransactedW"); + pfnRegDeleteKeyEx=(RegDeleteKeyExfunc)GetProcAddress(hmodule, "RegDeleteKeyExW"); pfnRegDeleteKeyTransacted=(RegDeleteKeyTransactedfunc)GetProcAddress(hmodule, "RegDeleteKeyTransactedW"); pfnRegCopyTree=(RegCopyTreefunc)GetProcAddress(hmodule, "RegCopyTreeW"); |
From: Mark H. <mha...@us...> - 2008-02-07 03:22:19
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4153 Modified Files: win32service.i Log Message: add more service-control related constants. Index: win32service.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32service.i,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** win32service.i 12 Aug 2007 08:16:29 -0000 1.15 --- win32service.i 7 Feb 2008 03:22:23 -0000 1.16 *************** *** 10,13 **** --- 10,14 ---- #undef PyHANDLE #include "PyWinObjects.h" + #include "Dbt.h" // for device events typedef BOOL (WINAPI *QueryServiceStatusExfunc)(SC_HANDLE,SC_STATUS_TYPE,LPBYTE,DWORD,LPDWORD); *************** *** 1629,1632 **** --- 1630,1644 ---- #define SERVICE_CONTROL_SHUTDOWN SERVICE_CONTROL_SHUTDOWN // The ControlService function fails if this control code is specified. + #define SERVICE_CONTROL_PARAMCHANGE SERVICE_CONTROL_PARAMCHANGE + #define SERVICE_CONTROL_NETBINDADD SERVICE_CONTROL_NETBINDADD + #define SERVICE_CONTROL_NETBINDREMOVE SERVICE_CONTROL_NETBINDREMOVE + #define SERVICE_CONTROL_NETBINDENABLE SERVICE_CONTROL_NETBINDENABLE + #define SERVICE_CONTROL_NETBINDDISABLE SERVICE_CONTROL_NETBINDDISABLE + #define SERVICE_CONTROL_DEVICEEVENT SERVICE_CONTROL_DEVICEEVENT + #define SERVICE_CONTROL_HARDWAREPROFILECHANGE SERVICE_CONTROL_HARDWAREPROFILECHANGE + #define SERVICE_CONTROL_POWEREVENT SERVICE_CONTROL_POWEREVENT + #define SERVICE_CONTROL_SESSIONCHANGE SERVICE_CONTROL_SESSIONCHANGE + #define SERVICE_CONTROL_PRESHUTDOWN SERVICE_CONTROL_PRESHUTDOWN + #define SC_MANAGER_ALL_ACCESS SC_MANAGER_ALL_ACCESS *************** *** 1679,1683 **** #define SERVICE_ACCEPT_SHUTDOWN SERVICE_ACCEPT_SHUTDOWN // The service is notified when system shutdown occurs. This enables the system to send a SERVICE_CONTROL_SHUTDOWN value to the service. The ControlService function cannot send this control ! //#define SERVICE_ERROR_IGNORER_IGNORE SERVICE_ERROR_IGNORER_IGNORE --- 1691,1700 ---- #define SERVICE_ACCEPT_SHUTDOWN SERVICE_ACCEPT_SHUTDOWN // The service is notified when system shutdown occurs. This enables the system to send a SERVICE_CONTROL_SHUTDOWN value to the service. The ControlService function cannot send this control ! #define SERVICE_ACCEPT_PARAMCHANGE SERVICE_ACCEPT_PARAMCHANGE ! #define SERVICE_ACCEPT_NETBINDCHANGE SERVICE_ACCEPT_NETBINDCHANGE ! #define SERVICE_ACCEPT_HARDWAREPROFILECHANGE SERVICE_ACCEPT_HARDWAREPROFILECHANGE ! #define SERVICE_ACCEPT_POWEREVENT SERVICE_ACCEPT_POWEREVENT ! #define SERVICE_ACCEPT_SESSIONCHANGE SERVICE_ACCEPT_SESSIONCHANGE ! #define SERVICE_ACCEPT_PRESHUTDOWN SERVICE_ACCEPT_PRESHUTDOWN //#define SERVICE_ERROR_IGNORER_IGNORE SERVICE_ERROR_IGNORER_IGNORE *************** *** 1753,1754 **** --- 1770,1784 ---- #define SC_ACTION_RUN_COMMAND SC_ACTION_RUN_COMMAND + // These constants relate to events. + // These power related ones aren't strictly related to services, but thats OK + #define DBT_DEVICEARRIVAL DBT_DEVICEARRIVAL // system detected a new device + #define DBT_DEVICEQUERYREMOVE DBT_DEVICEQUERYREMOVE // wants to remove, may fail + #define DBT_DEVICEQUERYREMOVEFAILED DBT_DEVICEQUERYREMOVEFAILED // removal aborted + #define DBT_DEVICEREMOVEPENDING DBT_DEVICEREMOVEPENDING // about to remove, still avail. + #define DBT_DEVICEREMOVECOMPLETE DBT_DEVICEREMOVECOMPLETE // device is gone + #define DBT_DEVICETYPESPECIFIC DBT_DEVICETYPESPECIFIC // type specific event + #define DBT_CUSTOMEVENT DBT_CUSTOMEVENT // user-defined event + + #define DBT_QUERYCHANGECONFIG DBT_QUERYCHANGECONFIG + #define DBT_CONFIGCHANGED DBT_CONFIGCHANGED + #define DBT_CONFIGCHANGECANCELED DBT_CONFIGCHANGECANCELED |
From: Mark H. <mha...@us...> - 2008-02-07 00:25:26
|
Update of /cvsroot/pywin32/pywin32/Pythonwin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6085 Modified Files: win32uimodule.cpp Log Message: win32ui.error finally becomes an exception to prevent errors on new pythons Index: win32uimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/Pythonwin/win32uimodule.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** win32uimodule.cpp 22 Jan 2008 12:28:18 -0000 1.36 --- win32uimodule.cpp 7 Feb 2008 00:25:29 -0000 1.37 *************** *** 48,52 **** static char BASED_CODE uiModName[] = "win32ui"; - static char BASED_CODE errorName[] = "win32ui"; // We can't init exceptionHandler in initwin32ui because the application using --- 48,51 ---- *************** *** 2270,2274 **** dict = PyModule_GetDict(module); if (!dict) return; /* Another serious error!*/ ! ui_module_error = PyString_FromString(errorName); PyDict_SetItemString(dict, "error", ui_module_error); // drop email addy - too many ppl use it for support requests for other --- 2269,2274 ---- dict = PyModule_GetDict(module); if (!dict) return; /* Another serious error!*/ ! ui_module_error = PyErr_NewException("win32ui.error", NULL, NULL); ! if (!ui_module_error) return; /* Another serious error!*/ PyDict_SetItemString(dict, "error", ui_module_error); // drop email addy - too many ppl use it for support requests for other |
From: Roger U. <ru...@us...> - 2008-02-07 00:05:30
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31644 Modified Files: win32apimodule.cpp Log Message: Add RegOpenCurrentUser, combine RegCreateKeyEx/RegCreateKeyTransacted Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -C2 -d -r1.80 -r1.81 *** win32apimodule.cpp 6 Feb 2008 18:42:51 -0000 1.80 --- win32apimodule.cpp 7 Feb 2008 00:05:34 -0000 1.81 *************** *** 79,83 **** typedef LONG (WINAPI *RegDeleteTreefunc)(HKEY,LPWSTR); static RegDeleteTreefunc pfnRegDeleteTree = NULL; ! /* error helper */ --- 79,84 ---- typedef LONG (WINAPI *RegDeleteTreefunc)(HKEY,LPWSTR); static RegDeleteTreefunc pfnRegDeleteTree = NULL; ! typedef LONG (WINAPI *RegOpenCurrentUserfunc)(REGSAM,PHKEY); ! static RegOpenCurrentUserfunc pfnRegOpenCurrentUser = NULL; /* error helper */ *************** *** 2923,2931 **** // @pyseeapi RegCreateKeyEx // @comm Implemented only as Unicode (RegCreateKeyExW). Accepts keyword arguments. static PyObject *PyRegCreateKeyEx(PyObject *self, PyObject *args, PyObject *kwargs) { ! static char *keywords[]={"Key","SubKey","samDesired","Class","Options","SecurityAttributes", NULL}; HKEY hKey; ! PyObject *obKey, *obsubKey, *obclass=Py_None, *obsa=Py_None, *ret=NULL; WCHAR *subKey=NULL, *class_name=NULL; PSECURITY_ATTRIBUTES psa; --- 2924,2934 ---- // @pyseeapi RegCreateKeyEx // @comm Implemented only as Unicode (RegCreateKeyExW). Accepts keyword arguments. + // @comm If a transaction handle is passed in, RegCreateKeyTransacted will be called (requires Vista or later) + // @pyseeapi RegCreateKeyTransacted static PyObject *PyRegCreateKeyEx(PyObject *self, PyObject *args, PyObject *kwargs) { ! static char *keywords[]={"Key","SubKey","samDesired","Class","Options","SecurityAttributes","Transaction", NULL}; HKEY hKey; ! PyObject *obKey, *obsubKey, *obclass=Py_None, *obsa=Py_None, *obtrans=Py_None, *ret=NULL; WCHAR *subKey=NULL, *class_name=NULL; PSECURITY_ATTRIBUTES psa; *************** *** 2933,3002 **** HKEY retKey; long rc; - - if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOk|OkO:RegCreateKeyEx", keywords, - &obKey, // @pyparm <o PyHKEY>/int|Key||Registry key or one of win32con.HKEY_* values - &obsubKey, // @pyparm <o PyUnicode>|SubKey||Name of subkey to open or create. - &access, // @pyparm int|samDesired||Access allowed to handle, combination of win32con.KEY_* constants. Can also contain - // standard access rights such as DELETE, WRITE_OWNER, etc. - &obclass, // @pyparm <o PyUnicode>|Class|None|Name of registry key class - &options, // @pyparm int|Options|REG_OPTION_NON_VOLATILE|One of the winnt.REG_OPTION_* values - &obsa)) // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes|None|Specifies security for key and handle inheritance - return NULL; - if (PyWinObject_AsHKEY(obKey, &hKey) - &&PyWinObject_AsWCHAR(obsubKey, &subKey, TRUE) - &&PyWinObject_AsWCHAR(obclass, &class_name, TRUE) - &&PyWinObject_AsSECURITY_ATTRIBUTES(obsa, &psa, TRUE)){ - rc=RegCreateKeyExW(hKey, subKey, reserved, class_name, options, - access, psa, &retKey, &disp); - if (rc!=ERROR_SUCCESS) - PyWin_SetAPIError("RegCreateKeyEx", rc); - else - ret=Py_BuildValue("Nk", PyWinObject_FromHKEY(retKey), disp); - } - - PyWinObject_FreeWCHAR(subKey); - PyWinObject_FreeWCHAR(class_name); - return ret; - } - - // @pymethod <o PyHKEY>, int|win32api|RegCreateKeyTransacted|Creates a registry key as part of a transaction - // @rdesc Returns a transacted handle and disposition flag (winnt.REG_CREATED_NEW_KEY or winnt.REG_OPENED_EXISTING_KEY) - // @pyseeapi RegCreateKeyTransacted - // @comm Accepts keyword args. - // @comm Requires Vista or later. - static PyObject *PyRegCreateKeyTransacted(PyObject *self, PyObject *args, PyObject *kwargs) - { - CHECK_PFN(RegCreateKeyTransacted); - HKEY hKey; - PyObject *obKey, *obsubKey, *obtrans, *obclass=Py_None, *obsa=Py_None, *ret=NULL; - WCHAR *subKey=NULL, *class_name=NULL; - PSECURITY_ATTRIBUTES psa; - REGSAM access; - DWORD disp, options=REG_OPTION_NON_VOLATILE, reserved=0; - PVOID extparam=NULL; // Documented as Reserved - HKEY retKey; HANDLE htrans; ! long rc; ! static char *keywords[]={"Key","SubKey","samDesired","Transaction","Class","Options","SecurityAttributes", NULL}; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOkO|OkO:RegCreateKeyTransacted", keywords, &obKey, // @pyparm <o PyHKEY>/int|Key||Registry key or one of win32con.HKEY_* values &obsubKey, // @pyparm <o PyUnicode>|SubKey||Name of subkey to open or create. &access, // @pyparm int|samDesired||Access allowed to handle, combination of win32con.KEY_* constants. Can also contain // standard access rights such as DELETE, WRITE_OWNER, etc. - &obtrans, // @pyparm <o PyHANDLE>|Transaction||Handle to a transaction as returned by <om win32transaction.CreateTransaction> &obclass, // @pyparm <o PyUnicode>|Class|None|Name of registry key class &options, // @pyparm int|Options|REG_OPTION_NON_VOLATILE|One of the winnt.REG_OPTION_* values ! &obsa)) // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes|None|Specifies security for key and handle inheritance return NULL; if (PyWinObject_AsHKEY(obKey, &hKey) ! &&PyWinObject_AsWCHAR(obsubKey, &subKey, FALSE) ! &&PyWinObject_AsHANDLE(obtrans, &htrans) &&PyWinObject_AsWCHAR(obclass, &class_name, TRUE) &&PyWinObject_AsSECURITY_ATTRIBUTES(obsa, &psa, TRUE)){ ! rc=(*pfnRegCreateKeyTransacted)(hKey, subKey, reserved, class_name, options, ! access, psa, &retKey, &disp, htrans, extparam); if (rc!=ERROR_SUCCESS) ! PyWin_SetAPIError("RegCreateKeyTransacted", rc); else ret=Py_BuildValue("Nk", PyWinObject_FromHKEY(retKey), disp); --- 2936,2969 ---- HKEY retKey; long rc; HANDLE htrans; ! PVOID extparam=NULL; // Documented as Reserved ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOk|OkOO:RegCreateKeyEx", keywords, &obKey, // @pyparm <o PyHKEY>/int|Key||Registry key or one of win32con.HKEY_* values &obsubKey, // @pyparm <o PyUnicode>|SubKey||Name of subkey to open or create. &access, // @pyparm int|samDesired||Access allowed to handle, combination of win32con.KEY_* constants. Can also contain // standard access rights such as DELETE, WRITE_OWNER, etc. &obclass, // @pyparm <o PyUnicode>|Class|None|Name of registry key class &options, // @pyparm int|Options|REG_OPTION_NON_VOLATILE|One of the winnt.REG_OPTION_* values ! &obsa, // @pyparm <o PySECURITY_ATTRIBUTES>|SecurityAttributes|None|Specifies security for key and handle inheritance ! &obtrans)) // @pyparm <o PyHANDLE>|Transaction|None|Handle to a transaction as returned by <om win32transaction.CreateTransaction> return NULL; + if (!PyWinObject_AsHANDLE(obtrans, &htrans)) + return NULL; + if (htrans!=NULL) + CHECK_PFN(RegCreateKeyTransacted); + if (PyWinObject_AsHKEY(obKey, &hKey) ! &&PyWinObject_AsWCHAR(obsubKey, &subKey, TRUE) &&PyWinObject_AsWCHAR(obclass, &class_name, TRUE) &&PyWinObject_AsSECURITY_ATTRIBUTES(obsa, &psa, TRUE)){ ! if (htrans!=NULL) ! rc=(*pfnRegCreateKeyTransacted)(hKey, subKey, reserved, class_name, options, ! access, psa, &retKey, &disp, htrans, extparam); ! else ! rc=RegCreateKeyExW(hKey, subKey, reserved, class_name, options, ! access, psa, &retKey, &disp); if (rc!=ERROR_SUCCESS) ! PyWin_SetAPIError("RegCreateKeyEx", rc); else ret=Py_BuildValue("Nk", PyWinObject_FromHKEY(retKey), disp); *************** *** 3636,3639 **** --- 3603,3625 ---- } + // @pymethod <o PyHKEY>|win32api|RegOpenCurrentUser|Opens HKEY_CURRENT_USER for impersonated user + // @pyseeapi RegOpenCurrentUser + static PyObject *PyRegOpenCurrentUser(PyObject *self, PyObject *args) + { + CHECK_PFN(RegOpenCurrentUser); + long rc; + HKEY retKey; + REGSAM sam = MAXIMUM_ALLOWED; + // @pyparm int|samDesired|MAXIMUM_ALLOWED|Desired access, combination of win32con.KEY_* + if (!PyArg_ParseTuple(args, "|k:RegOpenCurrentUser", &sam)) + return NULL; + PyW32_BEGIN_ALLOW_THREADS + rc=(*pfnRegOpenCurrentUser)(sam, &retKey); + PyW32_END_ALLOW_THREADS + if (rc!=ERROR_SUCCESS) + return ReturnAPIError("RegOpenCurrentUser", rc); + return PyWinObject_FromHKEY(retKey); + } + // @pymethod <o PyHKEY>|win32api|RegOpenKey|Opens the specified key. // @comm This funcion is implemented using <om win32api.RegOpenKeyEx>, by taking advantage *************** *** 6020,6024 **** {"RegCreateKey", PyRegCreateKey, 1}, // @pymeth RegCreateKey|Creates the specified key, or opens the key if it already exists. {"RegCreateKeyEx", (PyCFunction)PyRegCreateKeyEx, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegCreateKeyEx|Extended version of RegCreateKey - {"RegCreateKeyTransacted",(PyCFunction)PyRegCreateKeyTransacted, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegCreateKeyTransacted|Creates a registry key as part of a transaction {"RegDeleteKey", PyRegDeleteKey, 1}, // @pymeth RegDeleteKey|Deletes the specified key. {"RegDeleteKeyTransacted",(PyCFunction)PyRegDeleteKeyTransacted, METH_KEYWORDS|METH_VARARGS}, // @pymeth RegDeleteKeyTransacted|Deletes a registry key as part of a transaction --- 6006,6009 ---- *************** *** 6037,6040 **** --- 6022,6026 ---- {"RegGetKeySecurity", PyRegGetKeySecurity, 1}, // @pymeth RegGetKeySecurity|Retrieves the security on the specified registry key. {"RegLoadKey", PyRegLoadKey, 1}, // @pymeth RegLoadKey|Creates a subkey under HKEY_USER or HKEY_LOCAL_MACHINE and stores registration information from a specified file into that subkey. + {"RegOpenCurrentUser", PyRegOpenCurrentUser, 1}, // @pymeth RegOpenCurrentUser|Opens HKEY_CURRENT_USER for impersonated user {"RegOpenKey", PyRegOpenKey, 1}, // @pymeth RegOpenKey|Alias for <om win32api.RegOpenKeyEx> {"RegOpenKeyEx", PyRegOpenKey, 1}, // @pymeth RegOpenKeyEx|Opens the specified key. *************** *** 6214,6217 **** --- 6200,6204 ---- pfnRegCopyTree=(RegCopyTreefunc)GetProcAddress(hmodule, "RegCopyTreeW"); pfnRegDeleteTree=(RegDeleteTreefunc)GetProcAddress(hmodule, "RegDeleteTreeW"); + pfnRegOpenCurrentUser=(RegOpenCurrentUserfunc)GetProcAddress(hmodule, "RegOpenCurrentUser"); } |
From: Roger U. <ru...@us...> - 2008-02-06 18:44:07
|
Update of /cvsroot/pywin32/pywin32/win32/src/win32print In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8894 Modified Files: win32print.cpp Log Message: Allow to build with UNICODE defined Index: win32print.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32print/win32print.cpp,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** win32print.cpp 16 Aug 2007 05:09:52 -0000 1.28 --- win32print.cpp 6 Feb 2008 18:44:10 -0000 1.29 *************** *** 13,16 **** --- 13,18 ---- ******************************************************************/ + // #define UNICODE + // #define _UNICODE // _tcs functions require this #include "windows.h" *************** *** 86,89 **** --- 88,96 ---- [...1272 lines suppressed...] ! ret = PyWinObject_FromPrinterHANDLE(hprinter); } ! PyWinObject_FreePRINTER_INFO(level, buf); ! PyWinObject_FreeTCHAR(server_name); ! return ret; } *************** *** 2669,2673 **** AddConstant(dict, "PORT_STATUS_TYPE_INFO",PORT_STATUS_TYPE_INFO); ! HMODULE hmodule=LoadLibrary("winspool.drv"); if (hmodule!=NULL){ pfnEnumForms=(EnumFormsfunc)GetProcAddress(hmodule,"EnumFormsW"); --- 2822,2826 ---- AddConstant(dict, "PORT_STATUS_TYPE_INFO",PORT_STATUS_TYPE_INFO); ! HMODULE hmodule=LoadLibrary(TEXT("winspool.drv")); if (hmodule!=NULL){ pfnEnumForms=(EnumFormsfunc)GetProcAddress(hmodule,"EnumFormsW"); |
From: Roger U. <ru...@us...> - 2008-02-06 18:42:59
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8182 Modified Files: win32api_display.cpp win32api_display.h win32apimodule.cpp win32gui.i Log Message: Allow to build with UNICODE defined Fix some 64-bit warnings Index: win32apimodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32apimodule.cpp,v retrieving revision 1.79 retrieving revision 1.80 diff -C2 -d -r1.79 -r1.80 *** win32apimodule.cpp 17 Dec 2007 03:57:33 -0000 1.79 --- win32apimodule.cpp 6 Feb 2008 18:42:51 -0000 1.80 *************** *** 12,16 **** ******************************************************************/ ! #include "PyWinTypes.h" #include "PyWinObjects.h" --- 12,16 ---- ******************************************************************/ ! // #define UNICODE #include "PyWinTypes.h" [...3811 lines suppressed...] ! hmodule = GetModuleHandle(TEXT("user32.dll")); if (hmodule==NULL) ! hmodule=LoadLibrary(TEXT("user32.dll")); if (hmodule!=NULL){ pfnEnumDisplayMonitors=(EnumDisplayMonitorsfunc)GetProcAddress(hmodule, "EnumDisplayMonitors"); ! pfnEnumDisplayDevices=(EnumDisplayDevicesfunc)GetProcAddress(hmodule, "EnumDisplayDevices" A_OR_W); ! pfnChangeDisplaySettingsEx=(ChangeDisplaySettingsExfunc)GetProcAddress(hmodule, "ChangeDisplaySettingsEx" A_OR_W); pfnMonitorFromWindow=(MonitorFromWindowfunc)GetProcAddress(hmodule,"MonitorFromWindow"); pfnMonitorFromRect=(MonitorFromRectfunc)GetProcAddress(hmodule,"MonitorFromRect"); pfnMonitorFromPoint=(MonitorFromPointfunc)GetProcAddress(hmodule,"MonitorFromPoint"); ! pfnGetMonitorInfo=(GetMonitorInfofunc)GetProcAddress(hmodule, "GetMonitorInfo" A_OR_W); ! pfnEnumDisplaySettingsEx=(EnumDisplaySettingsExfunc)GetProcAddress(hmodule, "EnumDisplaySettingsEx" A_OR_W); } ! hmodule = GetModuleHandle(TEXT("Advapi32.dll")); if (hmodule==NULL) ! hmodule=LoadLibrary(TEXT("Advapi32.dll")); if (hmodule!=NULL){ pfnRegRestoreKey=(RegRestoreKeyfunc)GetProcAddress(hmodule, "RegRestoreKeyW"); Index: win32api_display.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32api_display.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** win32api_display.cpp 3 Jun 2007 14:53:07 -0000 1.6 --- win32api_display.cpp 6 Feb 2008 18:42:51 -0000 1.7 *************** *** 1,4 **** // @doc - This file contains autoduck documentation ! #include "PyWinTypes.h" #include "structmember.h" --- 1,4 ---- // @doc - This file contains autoduck documentation ! // #define UNICODE #include "PyWinTypes.h" #include "structmember.h" *************** *** 148,172 **** if (strcmp(name,"DeviceName")==0) if (pdisplay_device->DeviceName[31]==0) // in case DeviceName fills space and has no trailing NULL ! return PyString_FromString((char *)&pdisplay_device->DeviceName); else ! return PyString_FromStringAndSize((char *)&pdisplay_device->DeviceName, 32); if (strcmp(name,"DeviceString")==0) if (pdisplay_device->DeviceString[127]==0) // in case DeviceString fills space and has no trailing NULL ! return PyString_FromString((char *)&pdisplay_device->DeviceString); else ! return PyString_FromStringAndSize((char *)&pdisplay_device->DeviceString, 128); if (strcmp(name,"DeviceID")==0) if (pdisplay_device->DeviceID[127]==0) // in case DeviceID fills space and has no trailing NULL ! return PyString_FromString((char *)&pdisplay_device->DeviceID); else ! return PyString_FromStringAndSize((char *)&pdisplay_device->DeviceID, 128); if (strcmp(name,"DeviceKey")==0) if (pdisplay_device->DeviceKey[127]==0) // in case DeviceKey fills space and has no trailing NULL ! return PyString_FromString((char *)&pdisplay_device->DeviceKey); else ! return PyString_FromStringAndSize((char *)&pdisplay_device->DeviceKey, 128); return PyObject_GenericGetAttr(self,obname); --- 148,172 ---- if (strcmp(name,"DeviceName")==0) if (pdisplay_device->DeviceName[31]==0) // in case DeviceName fills space and has no trailing NULL ! return PyWinObject_FromTCHAR(pdisplay_device->DeviceName); else ! return PyWinObject_FromTCHAR(pdisplay_device->DeviceName, 32); if (strcmp(name,"DeviceString")==0) if (pdisplay_device->DeviceString[127]==0) // in case DeviceString fills space and has no trailing NULL ! return PyWinObject_FromTCHAR(pdisplay_device->DeviceString); else ! return PyWinObject_FromTCHAR(pdisplay_device->DeviceString, 128); if (strcmp(name,"DeviceID")==0) if (pdisplay_device->DeviceID[127]==0) // in case DeviceID fills space and has no trailing NULL ! return PyWinObject_FromTCHAR(pdisplay_device->DeviceID); else ! return PyWinObject_FromTCHAR(pdisplay_device->DeviceID, 128); if (strcmp(name,"DeviceKey")==0) if (pdisplay_device->DeviceKey[127]==0) // in case DeviceKey fills space and has no trailing NULL ! return PyWinObject_FromTCHAR(pdisplay_device->DeviceKey); else ! return PyWinObject_FromTCHAR(pdisplay_device->DeviceKey, 128); return PyObject_GenericGetAttr(self,obname); *************** *** 175,234 **** int PyDISPLAY_DEVICE::setattro(PyObject *self, PyObject *obname, PyObject *obvalue) { ! char *name, *value; ! Py_ssize_t valuelen; name=PyString_AsString(obname); if (name==NULL) return -1; if (strcmp(name,"DeviceName")==0){ ! if (PyString_AsStringAndSize(obvalue, &value, &valuelen)==-1) return -1; ! if (valuelen > 32){ ! PyErr_Format(PyExc_ValueError,"DeviceName must be a string of length %d or less", 32); return -1; } ! PDISPLAY_DEVICE pdisplay_device=&((PyDISPLAY_DEVICE *)self)->display_device; ! ZeroMemory(&pdisplay_device->DeviceName, 32); ! memcpy(&pdisplay_device->DeviceName, value, valuelen); return 0; } if (strcmp(name,"DeviceString")==0){ ! if (PyString_AsStringAndSize(obvalue, &value, &valuelen)==-1) return -1; ! if (valuelen > 128){ ! PyErr_Format(PyExc_ValueError,"DeviceString must be a string of length %d or less", 128); return -1; } ! PDISPLAY_DEVICE pdisplay_device=&((PyDISPLAY_DEVICE *)self)->display_device; ! ZeroMemory(&pdisplay_device->DeviceString, 128); ! memcpy(&pdisplay_device->DeviceString, value, valuelen); return 0; } if (strcmp(name,"DeviceID")==0){ ! if (PyString_AsStringAndSize(obvalue, &value, &valuelen)==-1) return -1; ! if (valuelen > 128){ ! PyErr_Format(PyExc_ValueError,"DeviceID must be a string of length %d or less", 128); return -1; } ! PDISPLAY_DEVICE pdisplay_device=&((PyDISPLAY_DEVICE *)self)->display_device; ! ZeroMemory(&pdisplay_device->DeviceID, 128); ! memcpy(&pdisplay_device->DeviceID, value, valuelen); return 0; } if (strcmp(name,"DeviceKey")==0){ ! if (PyString_AsStringAndSize(obvalue, &value, &valuelen)==-1) return -1; ! if (valuelen > 128){ ! PyErr_Format(PyExc_ValueError,"DeviceKey must be a string of length %d or less", 128); return -1; } ! PDISPLAY_DEVICE pdisplay_device=&((PyDISPLAY_DEVICE *)self)->display_device; ! ZeroMemory(&pdisplay_device->DeviceKey, 128); ! memcpy(&pdisplay_device->DeviceKey, value, valuelen); return 0; } ! int ret=PyObject_GenericSetAttr(self, obname, obvalue); ! return ret; } --- 175,248 ---- int PyDISPLAY_DEVICE::setattro(PyObject *self, PyObject *obname, PyObject *obvalue) { ! char *name; ! TCHAR *value=NULL; ! DWORD valuelen; name=PyString_AsString(obname); if (name==NULL) return -1; if (strcmp(name,"DeviceName")==0){ ! PDISPLAY_DEVICE pdisplay_device=&((PyDISPLAY_DEVICE *)self)->display_device; ! DWORD cch_max=sizeof(pdisplay_device->DeviceName)/sizeof(TCHAR); ! if (!PyWinObject_AsTCHAR(obvalue, &value, FALSE, &valuelen)) return -1; ! if (valuelen > cch_max){ ! PyErr_Format(PyExc_ValueError,"DeviceName must be a string of length %d or less", cch_max); ! PyWinObject_FreeTCHAR(value); return -1; } ! ZeroMemory(&pdisplay_device->DeviceName, sizeof(pdisplay_device->DeviceName)); ! memcpy(&pdisplay_device->DeviceName, value, valuelen * sizeof(TCHAR)); ! PyWinObject_FreeTCHAR(value); return 0; } if (strcmp(name,"DeviceString")==0){ ! PDISPLAY_DEVICE pdisplay_device=&((PyDISPLAY_DEVICE *)self)->display_device; ! DWORD cch_max=sizeof(pdisplay_device->DeviceString)/sizeof(TCHAR); ! if (!PyWinObject_AsTCHAR(obvalue, &value, FALSE, &valuelen)) return -1; ! if (valuelen > cch_max){ ! PyErr_Format(PyExc_ValueError,"DeviceString must be a string of length %d or less", cch_max); ! PyWinObject_FreeTCHAR(value); return -1; } ! ! ZeroMemory(&pdisplay_device->DeviceString, sizeof(pdisplay_device->DeviceString)); ! memcpy(&pdisplay_device->DeviceString, value, valuelen * sizeof(TCHAR)); ! PyWinObject_FreeTCHAR(value); return 0; } if (strcmp(name,"DeviceID")==0){ ! PDISPLAY_DEVICE pdisplay_device=&((PyDISPLAY_DEVICE *)self)->display_device; ! DWORD cch_max=sizeof(pdisplay_device->DeviceID)/sizeof(TCHAR); ! if (!PyWinObject_AsTCHAR(obvalue, &value, FALSE, &valuelen)) return -1; ! if (valuelen > cch_max){ ! PyErr_Format(PyExc_ValueError,"DeviceID must be a string of length %d or less", cch_max); ! PyWinObject_FreeTCHAR(value); return -1; } ! ! ZeroMemory(&pdisplay_device->DeviceID, sizeof(pdisplay_device->DeviceID)); ! memcpy(&pdisplay_device->DeviceID, value, valuelen * sizeof(TCHAR)); ! PyWinObject_FreeTCHAR(value); return 0; } if (strcmp(name,"DeviceKey")==0){ ! PDISPLAY_DEVICE pdisplay_device=&((PyDISPLAY_DEVICE *)self)->display_device; ! DWORD cch_max=sizeof(pdisplay_device->DeviceKey)/sizeof(TCHAR); ! if (!PyWinObject_AsTCHAR(obvalue, &value, FALSE, &valuelen)) return -1; ! if (valuelen > cch_max){ ! PyErr_Format(PyExc_ValueError,"DeviceKey must be a string of length %d or less", cch_max); ! PyWinObject_FreeTCHAR(value); return -1; } ! ZeroMemory(&pdisplay_device->DeviceKey, sizeof(pdisplay_device->DeviceKey)); ! memcpy(&pdisplay_device->DeviceKey, value, valuelen * sizeof(TCHAR)); ! PyWinObject_FreeTCHAR(value); return 0; } ! return PyObject_GenericSetAttr(self, obname, obvalue); } *************** *** 306,316 **** DWORD Flags=0; ! char *DeviceName=NULL; PDEVMODE pdevmode; ! PyObject *obdevmode=Py_None; long ret; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|zOk:ChangeDisplaySettingsEx", keywords, ! &DeviceName, // @pyparm str|DeviceName|None|Name of device as returned by <om win32api.EnumDisplayDevices>, use None for default display device &obdevmode, // @pyparm <o PyDEVMODE>|DevMode|None|A PyDEVMODE object as returned from <om win32api.EnumDisplaySettings>, or None to reset to default settings from registry &Flags)) // @pyparm int|Flags|0|One of the win32con.CDS_* constants, or 0 --- 320,330 ---- DWORD Flags=0; ! TCHAR *DeviceName=NULL; PDEVMODE pdevmode; ! PyObject *obDeviceName=Py_None, *obdevmode=Py_None; long ret; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOk:ChangeDisplaySettingsEx", keywords, ! &obDeviceName, // @pyparm str|DeviceName|None|Name of device as returned by <om win32api.EnumDisplayDevices>, use None for default display device &obdevmode, // @pyparm <o PyDEVMODE>|DevMode|None|A PyDEVMODE object as returned from <om win32api.EnumDisplaySettings>, or None to reset to default settings from registry &Flags)) // @pyparm int|Flags|0|One of the win32con.CDS_* constants, or 0 *************** *** 319,325 **** if (!PyWinObject_AsDEVMODE(obdevmode, &pdevmode, TRUE)) return NULL; ! // DISP_CHANGE_* errors don't translate as win32 error codes, just return it ret=(*pfnChangeDisplaySettingsEx)(DeviceName, pdevmode, (HWND) NULL, Flags, (LPVOID) NULL); return PyLong_FromLong(ret); } --- 333,341 ---- if (!PyWinObject_AsDEVMODE(obdevmode, &pdevmode, TRUE)) return NULL; ! if (!PyWinObject_AsTCHAR(obDeviceName, &DeviceName, TRUE)) ! return NULL; // DISP_CHANGE_* errors don't translate as win32 error codes, just return it ret=(*pfnChangeDisplaySettingsEx)(DeviceName, pdevmode, (HWND) NULL, Flags, (LPVOID) NULL); + PyWinObject_FreeTCHAR(DeviceName); return PyLong_FromLong(ret); } *************** *** 331,335 **** CHECK_PFN(EnumDisplayDevices); static char *keywords[]={"Device", "DevNum", "Flags", NULL}; ! char *Device=NULL; DWORD DevNum=0; DWORD Flags=0; --- 347,352 ---- CHECK_PFN(EnumDisplayDevices); static char *keywords[]={"Device", "DevNum", "Flags", NULL}; ! TCHAR *Device=NULL; ! PyObject *obDevice = Py_None, *ret=NULL; DWORD DevNum=0; DWORD Flags=0; *************** *** 339,353 **** // @pyparm int|DevNum|0|Index of device of interest, starting with zero // @pyparm int|Flags|0|Reserved, use 0 if passed in ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|zkk:EnumDisplayDevices", keywords, ! &Device, &DevNum, &Flags)) return NULL; - ZeroMemory(&display_device,sizeof(DISPLAY_DEVICE)); display_device.cb=sizeof(DISPLAY_DEVICE); ! if (!(*pfnEnumDisplayDevices)(Device, DevNum, &display_device, Flags)){ PyWin_SetAPIError("EnumDisplayDevices"); ! return NULL; ! } ! return PyWinObject_FromDISPLAY_DEVICE(&display_device); } --- 356,372 ---- // @pyparm int|DevNum|0|Index of device of interest, starting with zero // @pyparm int|Flags|0|Reserved, use 0 if passed in ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Okk:EnumDisplayDevices", keywords, ! &obDevice, &DevNum, &Flags)) ! return NULL; ! if (!PyWinObject_AsTCHAR(obDevice, &Device, TRUE)) return NULL; ZeroMemory(&display_device,sizeof(DISPLAY_DEVICE)); display_device.cb=sizeof(DISPLAY_DEVICE); ! if (!(*pfnEnumDisplayDevices)(Device, DevNum, &display_device, Flags)) PyWin_SetAPIError("EnumDisplayDevices"); ! else ! ret = PyWinObject_FromDISPLAY_DEVICE(&display_device); ! PyWinObject_FreeTCHAR(Device); ! return ret; } *************** *** 357,377 **** { static char *keywords[]={"DeviceName","ModeNum",NULL}; ! char *DeviceName=NULL; DWORD ModeNum=0; DEVMODE devmode; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|zk:EnumDisplaySettings", keywords, ! &DeviceName, // @pyparm string|DeviceName|None|Name of device as returned by <om win32api.EnumDisplayDevices>, use None for default display device &ModeNum)) // @pyparm int|ModeNum|0|Index of setting to return, or one of ENUM_CURRENT_SETTINGS, ENUM_REGISTRY_SETTINGS return NULL; ! ZeroMemory(&devmode,sizeof(DEVMODE)); devmode.dmSize=sizeof(DEVMODE); ! if (!EnumDisplaySettings(DeviceName, ModeNum, &devmode)){ // msdn says GetLastError should return something on win2k and up, I get 0 PyWin_SetAPIError("EnumDisplaySettings"); ! return NULL; ! } ! return PyWinObject_FromDEVMODE(&devmode); } --- 376,399 ---- { static char *keywords[]={"DeviceName","ModeNum",NULL}; ! TCHAR *DeviceName=NULL; ! PyObject *obDeviceName=Py_None, *ret=NULL; DWORD ModeNum=0; DEVMODE devmode; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Ok:EnumDisplaySettings", keywords, ! &obDeviceName, // @pyparm string|DeviceName|None|Name of device as returned by <om win32api.EnumDisplayDevices>, use None for default display device &ModeNum)) // @pyparm int|ModeNum|0|Index of setting to return, or one of ENUM_CURRENT_SETTINGS, ENUM_REGISTRY_SETTINGS return NULL; ! if (!PyWinObject_AsTCHAR(obDeviceName, &DeviceName, TRUE)) ! return NULL; ZeroMemory(&devmode,sizeof(DEVMODE)); devmode.dmSize=sizeof(DEVMODE); ! if (!EnumDisplaySettings(DeviceName, ModeNum, &devmode)) // msdn says GetLastError should return something on win2k and up, I get 0 PyWin_SetAPIError("EnumDisplaySettings"); ! else ! ret = PyWinObject_FromDEVMODE(&devmode); ! PyWinObject_FreeTCHAR(DeviceName); ! return ret; } *************** *** 382,402 **** CHECK_PFN(EnumDisplaySettingsEx); static char *keywords[]={"DeviceName","ModeNum","Flags", NULL}; ! char *DeviceName=NULL; DWORD ModeNum=0; DEVMODE devmode; DWORD Flags=0; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|zkk:EnumDisplaySettingsEx", keywords, ! &DeviceName, // @pyparm string|DeviceName|None|Name of device as returned by <om win32api.EnumDisplayDevices>. Can be None for default display &ModeNum, // @pyparm int|ModeNum||Index of setting to return, or one of ENUM_CURRENT_SETTINGS, ENUM_REGISTRY_SETTINGS &Flags)) // @pyparm int|Flags|0|EDS_RAWMODE (2) is only defined flag return NULL; ZeroMemory(&devmode,sizeof(DEVMODE)); devmode.dmSize=sizeof(DEVMODE); ! if (!(*pfnEnumDisplaySettingsEx)(DeviceName, ModeNum, &devmode, Flags)){ PyWin_SetAPIError("EnumDisplaySettingsEx"); ! return NULL; ! } ! return PyWinObject_FromDEVMODE(&devmode); } --- 404,428 ---- CHECK_PFN(EnumDisplaySettingsEx); static char *keywords[]={"DeviceName","ModeNum","Flags", NULL}; ! TCHAR *DeviceName=NULL; ! PyObject *obDeviceName=Py_None, *ret=NULL; DWORD ModeNum=0; DEVMODE devmode; DWORD Flags=0; ! if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|Okk:EnumDisplaySettingsEx", keywords, ! &obDeviceName, // @pyparm string|DeviceName|None|Name of device as returned by <om win32api.EnumDisplayDevices>. Can be None for default display &ModeNum, // @pyparm int|ModeNum||Index of setting to return, or one of ENUM_CURRENT_SETTINGS, ENUM_REGISTRY_SETTINGS &Flags)) // @pyparm int|Flags|0|EDS_RAWMODE (2) is only defined flag return NULL; + if (!PyWinObject_AsTCHAR(obDeviceName, &DeviceName, TRUE)) + return NULL; ZeroMemory(&devmode,sizeof(DEVMODE)); devmode.dmSize=sizeof(DEVMODE); ! if (!(*pfnEnumDisplaySettingsEx)(DeviceName, ModeNum, &devmode, Flags)) PyWin_SetAPIError("EnumDisplaySettingsEx"); ! else ! ret = PyWinObject_FromDEVMODE(&devmode); ! PyWinObject_FreeTCHAR(DeviceName); ! return ret; } *************** *** 479,487 **** return NULL; } ! return Py_BuildValue("{s:O&,s:O&,s:k,s:s}", "Monitor", PyWinObject_FromRECT, &mi.rcMonitor, "Work", PyWinObject_FromRECT, &mi.rcWork, "Flags", mi.dwFlags, ! "Device", mi.szDevice); } --- 505,513 ---- return NULL; } ! return Py_BuildValue("{s:O&,s:O&,s:k,s:N}", "Monitor", PyWinObject_FromRECT, &mi.rcMonitor, "Work", PyWinObject_FromRECT, &mi.rcWork, "Flags", mi.dwFlags, ! "Device", PyWinObject_FromTCHAR(mi.szDevice)); } Index: win32api_display.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32api_display.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** win32api_display.h 27 May 2006 07:33:21 -0000 1.2 --- win32api_display.h 6 Feb 2008 18:42:51 -0000 1.3 *************** *** 1,4 **** --- 1,11 ---- #define CHECK_PFN(fname) if (pfn##fname==NULL) return PyErr_Format(PyExc_NotImplementedError,"%s is not available on this platform", #fname); + // Macro to allow loading the correct ANSI/wide-character version of a function from a .dll + #ifdef UNICODE + #define A_OR_W "W" + #else + #define A_OR_W "A" + #endif + PyObject *PyChangeDisplaySettings(PyObject *self, PyObject *args); PyObject *PyChangeDisplaySettingsEx(PyObject *self, PyObject *args, PyObject *kwargs); Index: win32gui.i =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/win32gui.i,v retrieving revision 1.114 retrieving revision 1.115 diff -C2 -d -r1.114 -r1.115 *** win32gui.i 21 Jan 2008 11:12:00 -0000 1.114 --- win32gui.i 6 Feb 2008 18:42:51 -0000 1.115 *************** *** 13,16 **** --- 13,18 ---- %{ + // #define UNICODE + // #define _UNICODE // for CRT string functions #define _WIN32_IE 0x0501 // to enable balloon notifications in Shell_NotifyIcon #define _WIN32_WINNT 0x0501 *************** *** 247,253 **** pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; ! HMODULE hmodule=GetModuleHandle("user32.dll"); if (hmodule==NULL) ! hmodule=LoadLibrary("user32.dll"); if (hmodule){ pfnSetLayeredWindowAttributes=(SetLayeredWindowAttributesfunc)GetProcAddress(hmodule,"SetLayeredWindowAttributes"); --- 249,255 ---- pmd->ml_flags = METH_VARARGS | METH_KEYWORDS; ! HMODULE hmodule=GetModuleHandle(TEXT("user32.dll")); if (hmodule==NULL) ! hmodule=LoadLibrary(TEXT("user32.dll")); if (hmodule){ pfnSetLayeredWindowAttributes=(SetLayeredWindowAttributesfunc)GetProcAddress(hmodule,"SetLayeredWindowAttributes"); *************** *** 260,266 **** } ! hmodule=GetModuleHandle("gdi32.dll"); if (hmodule==NULL) ! hmodule=LoadLibrary("gdi32.dll"); if (hmodule){ pfnAngleArc=(AngleArcfunc)GetProcAddress(hmodule,"AngleArc"); --- 262,268 ---- } ! hmodule=GetModuleHandle(TEXT("gdi32.dll")); if (hmodule==NULL) ! hmodule=LoadLibrary(TEXT("gdi32.dll")); if (hmodule){ pfnAngleArc=(AngleArcfunc)GetProcAddress(hmodule,"AngleArc"); *************** *** 275,281 **** } ! hmodule=GetModuleHandle("msimg32.dll"); if (hmodule==NULL) ! hmodule=LoadLibrary("msimg32.dll"); if (hmodule){ pfnGradientFill=(GradientFillfunc)GetProcAddress(hmodule,"GradientFill"); --- 277,283 ---- } ! hmodule=GetModuleHandle(TEXT("msimg32.dll")); if (hmodule==NULL) ! hmodule=LoadLibrary(TEXT("msimg32.dll")); if (hmodule){ pfnGradientFill=(GradientFillfunc)GetProcAddress(hmodule,"GradientFill"); *************** *** 530,534 **** %typemap(python,argout) PAINTSTRUCT *OUTPUT { PyObject *o; ! o = Py_BuildValue("(Nl(iiii)lls#)", PyWinLong_FromHANDLE($source->hdc), $source->fErase, --- 532,536 ---- %typemap(python,argout) PAINTSTRUCT *OUTPUT { PyObject *o; ! o = Py_BuildValue("(Nl(iiii)llN)", PyWinLong_FromHANDLE($source->hdc), $source->fErase, *************** *** 536,541 **** $source->fRestore, $source->fIncUpdate, ! (char *)$source->rgbReserved, ! sizeof($source->rgbReserved)); if (!$target) { $target = o; --- 538,542 ---- $source->fRestore, $source->fIncUpdate, ! PyString_FromStringAndSize((char *)$source->rgbReserved,sizeof($source->rgbReserved))); if (!$target) { $target = o; *************** *** 562,581 **** %typemap(python,in) PAINTSTRUCT *INPUT(PAINTSTRUCT ps_input) { char *szReserved; ! int lenReserved; ! PyObject *obdc; if (PyTuple_Check($source)) { if (!PyArg_ParseTuple($source, ! "Ol(iiii)lls#", ! &obdc, ! &ps_input.fErase, ! &ps_input.rcPaint.left, &ps_input.rcPaint.top, &ps_input.rcPaint.right, &ps_input.rcPaint.bottom, ! &ps_input.fRestore, ! &ps_input.fIncUpdate, ! &szReserved, ! &lenReserved)) { return NULL; - } if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&ps_input.hdc)) return NULL; if (lenReserved != sizeof(ps_input.rgbReserved)) return PyErr_Format(PyExc_ValueError, "%s: last element must be string of %d bytes", --- 563,582 ---- %typemap(python,in) PAINTSTRUCT *INPUT(PAINTSTRUCT ps_input) { char *szReserved; ! Py_ssize_t lenReserved; ! PyObject *obdc, *obReserved; if (PyTuple_Check($source)) { if (!PyArg_ParseTuple($source, ! "Ol(iiii)llO", ! &obdc, ! &ps_input.fErase, ! &ps_input.rcPaint.left, &ps_input.rcPaint.top, &ps_input.rcPaint.right, &ps_input.rcPaint.bottom, ! &ps_input.fRestore, ! &ps_input.fIncUpdate, ! &obReserved)) return NULL; if (!PyWinObject_AsHANDLE(obdc, (HANDLE *)&ps_input.hdc)) return NULL; + if (PyString_AsStringAndSize(obReserved, &szReserved, &lenReserved)==-1) + return NULL; if (lenReserved != sizeof(ps_input.rgbReserved)) return PyErr_Format(PyExc_ValueError, "%s: last element must be string of %d bytes", *************** *** 1534,1550 **** { void *addr; ! char *src; ! size_t nbytes; ! #ifdef _WIN64 ! static char *input_fmt="Ls#:PySetMemory"; ! #else ! static char *input_fmt="ls#:PySetMemory"; ! #endif // @pyparm int|addr||Address of the memory to reference // @pyparm string or buffer|String||The string to copy ! if (!PyArg_ParseTuple(args, input_fmt, &addr,&src,&nbytes)) return NULL; - if (IsBadWritePtr(addr, nbytes)) { PyErr_SetString(PyExc_ValueError, --- 1535,1550 ---- { void *addr; ! const void *src; ! PyObject *obaddr, *obsrc; ! Py_ssize_t nbytes; // @pyparm int|addr||Address of the memory to reference // @pyparm string or buffer|String||The string to copy ! if (!PyArg_ParseTuple(args, "OO:PySetMemory", &obaddr, &obsrc)) ! return NULL; ! if (!PyWinLong_AsVoidPtr(obaddr, &addr)) ! return NULL; ! if (PyObject_AsReadBuffer(obsrc, &src, &nbytes)==-1) return NULL; if (IsBadWritePtr(addr, nbytes)) { PyErr_SetString(PyExc_ValueError, *************** *** 1567,1571 **** PyObject *ob; int offset; ! int maxlen; // @pyparm array|array||array object to use --- 1567,1571 ---- PyObject *ob; int offset; ! Py_ssize_t maxlen; // @pyparm array|array||array object to use *************** *** 2376,2383 **** PyObject *PyCreateAcceleratorTable(PyObject *self, PyObject *args) { ! Py_ssize_t num, i; ACCEL *accels = NULL; PyObject *ret = NULL; ! PyObject *obAccels; HACCEL ha; // @pyparm ( (int, int, int), ...)|accels||A sequence of (fVirt, key, cmd), --- 2376,2383 ---- PyObject *PyCreateAcceleratorTable(PyObject *self, PyObject *args) { ! DWORD num, i; ACCEL *accels = NULL; PyObject *ret = NULL; ! PyObject *obAccels, *Accels_tuple; HACCEL ha; // @pyparm ( (int, int, int), ...)|accels||A sequence of (fVirt, key, cmd), *************** *** 2385,2392 **** if (!PyArg_ParseTuple(args, "O:CreateAcceleratorTable", &obAccels)) return NULL; ! if (!PySequence_Check(obAccels)) ! return PyErr_Format(PyExc_TypeError, "accels must be a sequence of tuples (got '%s')", ! obAccels->ob_type->tp_name); ! num = PySequence_Length(obAccels); if (num==0) { PyErr_SetString(PyExc_ValueError, "Can't create an accelerator with zero items"); --- 2385,2391 ---- if (!PyArg_ParseTuple(args, "O:CreateAcceleratorTable", &obAccels)) return NULL; ! if ((Accels_tuple=PyWinSequence_Tuple(obAccels, &num)) == NULL) ! return NULL; ! if (num==0) { PyErr_SetString(PyExc_ValueError, "Can't create an accelerator with zero items"); *************** *** 2400,2410 **** for (i=0;i<num;i++) { ACCEL *p = accels+i; ! PyObject *ob = PySequence_GetItem(obAccels, i); ! if (!ob) goto done; ! if (!PyArg_ParseTuple(ob, "BHH:ACCEL", &p->fVirt, &p->key, &p->cmd)) { ! Py_DECREF(ob); goto done; - } - Py_DECREF(ob); } ha = ::CreateAcceleratorTable(accels, num); --- 2399,2405 ---- for (i=0;i<num;i++) { ACCEL *p = accels+i; ! PyObject *ob = PyTuple_GET_ITEM(Accels_tuple, i); ! if (!PyArg_ParseTuple(ob, "BHH:ACCEL", &p->fVirt, &p->key, &p->cmd)) goto done; } ha = ::CreateAcceleratorTable(accels, num); *************** *** 2414,2417 **** --- 2409,2413 ---- PyWin_SetAPIError("CreateAcceleratorTable"); done: + Py_DECREF(Accels_tuple); if (accels) free(accels); *************** *** 2490,2500 **** // format for the resource bits pointed to by the presbits parameter. // This parameter can be 0x00030000. ! char *bits; ! int nBits; int isIcon; ! int ver = 0x00030000; ! if (!PyArg_ParseTuple(args, "s#i|i", &bits, &nBits, &isIcon, &ver)) return NULL; ! HICON ret = CreateIconFromResource((PBYTE)bits, nBits, isIcon, ver); if (!ret) return PyWin_SetAPIError("CreateIconFromResource"); --- 2486,2499 ---- // format for the resource bits pointed to by the presbits parameter. // This parameter can be 0x00030000. ! PBYTE bits; ! DWORD nBits; int isIcon; ! DWORD ver = 0x00030000; ! PyObject *obbits; ! if (!PyArg_ParseTuple(args, "Oi|i", &obbits, &isIcon, &ver)) return NULL; ! if (!PyWinObject_AsReadBuffer(obbits, (void **)&bits, &nBits, FALSE)) ! return NULL; ! HICON ret = CreateIconFromResource(bits, nBits, isIcon, ver); if (!ret) return PyWin_SetAPIError("CreateIconFromResource"); *************** *** 4314,4320 **** *item_cnt=0; ! if ((trivertex_tuple=PySequence_Tuple(obtvs))==NULL) return FALSE; - *item_cnt=PyTuple_GET_SIZE(trivertex_tuple); bufsize=*item_cnt * sizeof(TRIVERTEX); *ptvs=(TRIVERTEX *)malloc(bufsize); --- 4313,4318 ---- *item_cnt=0; ! if ((trivertex_tuple=PyWinSequence_Tuple(obtvs, item_cnt))==NULL) return FALSE; bufsize=*item_cnt * sizeof(TRIVERTEX); *ptvs=(TRIVERTEX *)malloc(bufsize); *************** *** 4349,4355 **** *item_cnt=0; ! if ((mesh_tuple=PySequence_Tuple(obmesh))==NULL) return FALSE; - *item_cnt=PyTuple_GET_SIZE(mesh_tuple); switch (mode){ case GRADIENT_FILL_TRIANGLE: --- 4347,4352 ---- *item_cnt=0; ! if ((mesh_tuple=PyWinSequence_Tuple(obmesh, item_cnt))==NULL) return FALSE; switch (mode){ case GRADIENT_FILL_TRIANGLE: *************** *** 4887,4893 **** *item_cnt=0; ! if ((points_tuple=PySequence_Tuple(obpoints))==NULL) return FALSE; ! *item_cnt=PyTuple_GET_SIZE(points_tuple); bufsize=*item_cnt * sizeof(POINT); *ppoints=(POINT *)malloc(bufsize); --- 4884,4890 ---- *item_cnt=0; ! if ((points_tuple=PyWinSequence_Tuple(obpoints, item_cnt))==NULL) return FALSE; ! bufsize=*item_cnt * sizeof(POINT); *ppoints=(POINT *)malloc(bufsize); *************** *** 5124,5142 **** static PyObject *PyExtTextOut(PyObject *self, PyObject *args) { ! char *text; ! int strLen, x, y; UINT options; ! PyObject *obdc, *rectObject, *widthObject = NULL; RECT rect, *rectPtr; int *widths = NULL; HDC hdc; ! if (!PyArg_ParseTuple (args, "OiiiOs#|O:ExtTextOut", ! &obdc, &x, // @pyparm x|int||The x coordinate to write the text to. &y, // @pyparm y|int||The y coordinate to write the text to. &options, // @pyparm nOptions|int||Specifies the rectangle type. This parameter can be one, both, or neither of ETO_CLIPPED and ETO_OPAQUE &rectObject, // @pyparm <o PyRECT>|rect||Specifies the text's bounding rectangle. (Can be None.) ! &text, // @pyparm text|string||The text to write. ! &strLen, &widthObject)) // @pyparm (width1, width2, ...)|tuple||Optional array of values that indicate distance between origins of character cells. return NULL; --- 5121,5139 ---- static PyObject *PyExtTextOut(PyObject *self, PyObject *args) { ! TCHAR *text=NULL; ! int x, y; ! DWORD strLen; UINT options; ! PyObject *obdc, *rectObject, *obtext, *widthObject = Py_None; RECT rect, *rectPtr; int *widths = NULL; HDC hdc; ! if (!PyArg_ParseTuple (args, "OiiiOO|O:ExtTextOut", ! &obdc, // @pyparm <o PyHANDLE>|hdc||Handle to a device context &x, // @pyparm x|int||The x coordinate to write the text to. &y, // @pyparm y|int||The y coordinate to write the text to. &options, // @pyparm nOptions|int||Specifies the rectangle type. This parameter can be one, both, or neither of ETO_CLIPPED and ETO_OPAQUE &rectObject, // @pyparm <o PyRECT>|rect||Specifies the text's bounding rectangle. (Can be None.) ! &obtext, // @pyparm text|string||The text to write. &widthObject)) // @pyparm (width1, width2, ...)|tuple||Optional array of values that indicate distance between origins of character cells. return NULL; *************** *** 5153,5161 **** rectPtr = NULL; // Parse out widths ! if (widthObject) { BOOL error = !PyTuple_Check(widthObject); if (!error) { ! int len = PyTuple_Size(widthObject); if (len == (strLen - 1)) { widths = new int[len + 1]; --- 5150,5161 ---- rectPtr = NULL; + if (!PyWinObject_AsTCHAR(obtext, &text, FALSE, &strLen)) + return NULL; + // Parse out widths ! if (widthObject != Py_None) { BOOL error = !PyTuple_Check(widthObject); if (!error) { ! Py_ssize_t len = PyTuple_Size(widthObject); if (len == (strLen - 1)) { widths = new int[len + 1]; *************** *** 5170,5173 **** --- 5170,5174 ---- } if (error) { + PyWinObject_FreeTCHAR(text); delete [] widths; return PyErr_Format(PyExc_TypeError, *************** *** 5181,5184 **** --- 5182,5186 ---- ok = ExtTextOut(hdc, x, y, options, rectPtr, text, strLen, widths); Py_END_ALLOW_THREADS; + PyWinObject_FreeTCHAR(text); delete [] widths; if (!ok) *************** *** 5700,5704 **** static char *err_msg="SCROLLINFO must be a tuple of 1-6 ints"; PyObject *obMin=Py_None, *obMax=Py_None, *obPage=Py_None, *obPos=Py_None, *obTrackPos=Py_None; ! int len = PyTuple_Size(args); if (len<1 || len > 6) { PyErr_SetString(PyExc_TypeError, err_msg); --- 5702,5706 ---- static char *err_msg="SCROLLINFO must be a tuple of 1-6 ints"; PyObject *obMin=Py_None, *obMax=Py_None, *obPage=Py_None, *obPos=Py_None, *obTrackPos=Py_None; ! Py_ssize_t len = PyTuple_Size(args); if (len<1 || len > 6) { PyErr_SetString(PyExc_TypeError, err_msg); *************** *** 6029,6033 **** PyObject *obdevmode=NULL; PyObject *obdriver, *obdevice; ! char *driver, *device, *dummyoutput=NULL; HDC hdc; if (!PyArg_ParseTuple(args, "OOO", &obdriver, &obdevice, &obdevmode)) --- 6031,6035 ---- PyObject *obdevmode=NULL; PyObject *obdriver, *obdevice; ! TCHAR *driver, *device, *dummyoutput=NULL; HDC hdc; if (!PyArg_ParseTuple(args, "OOO", &obdriver, &obdevice, &obdevmode)) |
From: Roger U. <ru...@us...> - 2008-02-06 18:37:46
|
Update of /cvsroot/pywin32/pywin32/win32/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6719 Modified Files: PyDEVMODE.cpp PyUnicode.cpp PyWinObjects.h PyWinTypes.h PyWinTypesmodule.cpp Log Message: Changes for unicode build Index: PyWinObjects.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinObjects.h,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** PyWinObjects.h 24 May 2007 06:01:05 -0000 1.12 --- PyWinObjects.h 6 Feb 2008 18:37:46 -0000 1.13 *************** *** 255,256 **** --- 255,290 ---- ~PyDEVMODE(); }; + + // Unicode version of DEVMODE + class PYWINTYPES_EXPORT PyDEVMODEW : public PyObject + { + public: + #ifdef _MSC_VER + #pragma warning( disable : 4251 ) + #endif // _MSC_VER + static struct PyMemberDef members[]; + static struct PyMethodDef methods[]; + #ifdef _MSC_VER + #pragma warning( default : 4251 ) + #endif // _MSC_VER + + static void deallocFunc(PyObject *ob); + PyDEVMODEW(PDEVMODEW); + PyDEVMODEW(void); + PyDEVMODEW(USHORT); + static PyObject *getattro(PyObject *self, PyObject *name); + static int setattro(PyObject *self, PyObject *obname, PyObject *obvalue); + static PyObject *Clear(PyObject *self, PyObject *args); + static PyObject *tp_new(PyTypeObject *, PyObject *, PyObject *); + // use this where a function modifies a passed-in PyDEVMODE to make changes visible to Python + void modify_in_place(void) + {memcpy(&devmode, pdevmode, pdevmode->dmSize);} + PDEVMODEW GetDEVMODE(void); + PyObject *obdummy; + protected: + // Pointer to variable length DEVMODE with dmDriverExtra bytes allocated at end, always use this externally + PDEVMODEW pdevmode; + // copy of fixed portion of DEVMODE for structmember api to access + DEVMODEW devmode; + ~PyDEVMODEW(); + }; Index: PyDEVMODE.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyDEVMODE.cpp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyDEVMODE.cpp 24 May 2007 06:01:05 -0000 1.6 --- PyDEVMODE.cpp 6 Feb 2008 18:37:46 -0000 1.7 *************** *** 68,72 **** {"Collate", T_SHORT, OFF(devmode.dmCollate), 0, "DMCOLLATE_TRUE or DMCOLLATE_FALSE"}, // @prop str|FormName|Name of form as returned by <om win32print.EnumForms>, at most 32 chars ! {"FormName", T_OBJECT, OFF(obdummy), 0, "Name of form as returned by EnumForms, at most 32 chars"}, // same semantics as DeviceName // @prop int|LogPixels|Pixels per inch (only for display devices {"LogPixels", T_USHORT, OFF(devmode.dmLogPixels), 0, "Pixels per inch (only for display devices)"}, --- 68,72 ---- {"Collate", T_SHORT, OFF(devmode.dmCollate), 0, "DMCOLLATE_TRUE or DMCOLLATE_FALSE"}, // @prop str|FormName|Name of form as returned by <om win32print.EnumForms>, at most 32 chars ! {"FormName", T_OBJECT, OFF(obdummy), 0, "Name of form as returned by EnumForms, at most 32 chars"}, // @prop int|LogPixels|Pixels per inch (only for display devices {"LogPixels", T_USHORT, OFF(devmode.dmLogPixels), 0, "Pixels per inch (only for display devices)"}, *************** *** 162,166 **** PyErr_Format(PyExc_MemoryError, "PyDEVMODE::PyDEVMODE - Unable to allocate DEVMODE of size %d", pdm->dmSize + pdm->dmDriverExtra); ! else; memcpy(pdevmode, pdm, pdm->dmSize + pdm->dmDriverExtra); obdummy=NULL; --- 162,166 ---- PyErr_Format(PyExc_MemoryError, "PyDEVMODE::PyDEVMODE - Unable to allocate DEVMODE of size %d", pdm->dmSize + pdm->dmDriverExtra); ! else memcpy(pdevmode, pdm, pdm->dmSize + pdm->dmDriverExtra); obdummy=NULL; *************** *** 381,382 **** --- 381,771 ---- return ret; } + + + // DEVMODEW support + // @object PyDEVMODEW|Unicode version of <o PyDEVMODE> object + /* PyDEVMODEW is only needed when win32api, win32gui, or win32print + are built with UNICODE defined. Currently, you must explicitely ask + for the unicode version. + */ + + struct PyMethodDef PyDEVMODEW::methods[] = { + {"Clear", PyDEVMODEW::Clear, 1}, // @pymeth Clear|Resets all members of the structure + {NULL} + }; + + #define OFFW(e) offsetof(PyDEVMODEW, e) + struct PyMemberDef PyDEVMODEW::members[] = { + // DeviceName is a dummy so it will show up in property list, get and set handle manually + // @prop <o PyUnicode>|DeviceName|String of at most 32 chars + {"DeviceName", T_OBJECT, OFFW(obdummy), 0, "String of at most 32 chars"}, + // @prop int|SpecVersion|Should always be set to DM_SPECVERSION + {"SpecVersion", T_USHORT, OFFW(devmode.dmSpecVersion), 0, "Should always be set to DM_SPECVERSION"}, + // @prop int|DriverVersion|Version nbr assigned to printer driver by vendor + {"DriverVersion", T_USHORT, OFFW(devmode.dmDriverVersion), 0, "Version nbr assigned to printer driver by vendor"}, + // @prop int|Size|Size of structure + {"Size", T_USHORT, OFFW(devmode.dmSize), READONLY, "Size of structure"}, + // @prop int|DriverExtra|Number of extra bytes allocated for driver data, can only be set when new object is created + {"DriverExtra", T_USHORT, OFFW(devmode.dmDriverExtra), READONLY, + "Number of extra bytes allocated for driver data, can only be set when new object is created"}, + // @prop int|Fields|Bitmask of win32con.DM_* constants indicating which members are set + {"Fields", T_ULONG, OFFW(devmode.dmFields), 0, "Bitmask of win32con.DM_* constants indicating which members are set"}, + // @prop int|Orientation|Only applies to printers, DMORIENT_PORTRAIT or DMORIENT_LANDSCAPE + {"Orientation", T_SHORT, OFFW(devmode.dmOrientation), 0, "Only applies to printers, DMORIENT_PORTRAIT or DMORIENT_LANDSCAPE"}, + // @prop int|PaperSize|Use 0 if PaperWidth and PaperLength are set, otherwise win32con.DMPAPER_* constant + {"PaperSize", T_SHORT, OFFW(devmode.dmPaperSize), 0, "Use 0 if PaperWidth and PaperLength are set, otherwise win32con.DMPAPER_* constant"}, + // @prop int|PaperLength|Specified in 1/10 millimeters + {"PaperLength", T_SHORT, OFFW(devmode.dmPaperLength), 0, "Specified in 1/10 millimeters"}, + // @prop int|PaperWidth|Specified in 1/10 millimeters + {"PaperWidth", T_SHORT, OFFW(devmode.dmPaperWidth), 0, "Specified in 1/10 millimeters"}, + #ifndef MS_WINCE + // @prop int|Position_x|Position of display relative to desktop + {"Position_x", T_LONG, OFFW(devmode.dmPosition.x), 0, "Position of display relative to desktop"}, + // @prop int|Position_y|Position of display relative to desktop + {"Position_y", T_LONG, OFFW(devmode.dmPosition.y), 0, "Position of display relative to desktop"}, + #endif + // @prop int|DisplayOrientation|Display rotation: DMDO_DEFAULT,DMDO_90, DMDO_180, DMDO_270 + {"DisplayOrientation",T_ULONG,OFFW(devmode.dmDisplayOrientation), 0, "Display rotation: DMDO_DEFAULT,DMDO_90, DMDO_180, DMDO_270"}, + // @prop int|DisplayFixedOutput|DMDFO_DEFAULT, DMDFO_CENTER, DMDFO_STRETCH + {"DisplayFixedOutput",T_ULONG,OFFW(devmode.dmDisplayFixedOutput), 0, "DMDFO_DEFAULT, DMDFO_CENTER, DMDFO_STRETCH"}, + // @prop int|Scale|Specified as percentage, eg 50 means half size of original + {"Scale", T_SHORT, OFFW(devmode.dmScale), 0, "Specified as percentage, eg 50 means half size of original"}, + // @prop int|Copies|Nbr of copies to print + {"Copies", T_SHORT, OFFW(devmode.dmCopies), 0, "Nbr of copies to print"}, + // @prop int|DefaultSource|DMBIN_* constant, or can be a printer-specific value + {"DefaultSource", T_SHORT, OFFW(devmode.dmDefaultSource), 0, "DMBIN_* constant, or can be a printer-specific value"}, + // @prop int|PrintQuality|DMRES_* constant, interpreted as DPI if positive + {"PrintQuality", T_SHORT, OFFW(devmode.dmPrintQuality), 0, "DMRES_* constant, interpreted as DPI if positive"}, + // @prop int|Color|DMCOLOR_COLOR or DMCOLOR_MONOCHROME + {"Color", T_SHORT, OFFW(devmode.dmColor), 0, "DMCOLOR_COLOR or DMCOLOR_MONOCHROME"}, + // @prop int|Duplex|For printers that do two-sided printing: DMDUP_SIMPLEX, DMDUP_HORIZONTAL, DMDUP_VERTICAL + {"Duplex", T_SHORT, OFFW(devmode.dmDuplex), 0, "For printers that do two-sided printing: DMDUP_SIMPLEX, DMDUP_HORIZONTAL, DMDUP_VERTICAL"}, + // @prop int|YResolution|Vertical printer resolution in DPI - if this is set, PrintQuality indicates horizontal DPI + {"YResolution", T_SHORT, OFFW(devmode.dmYResolution), 0, "Vertical printer resolution in DPI - if this is set, PrintQuality indicates horizontal DPI"}, + // @prop int|TTOption|TrueType options: DMTT_BITMAP, DMTT_DOWNLOAD, DMTT_DOWNLOAD_OUTLINE, DMTT_SUBDEV + {"TTOption", T_SHORT, OFFW(devmode.dmTTOption), 0, "TrueType options: DMTT_BITMAP, DMTT_DOWNLOAD, DMTT_DOWNLOAD_OUTLINE, DMTT_SUBDEV"}, + // @prop int|Collate|DMCOLLATE_TRUE or DMCOLLATE_FALSE + {"Collate", T_SHORT, OFFW(devmode.dmCollate), 0, "DMCOLLATE_TRUE or DMCOLLATE_FALSE"}, + // @prop <o PyUnicode>|FormName|Name of form as returned by <om win32print.EnumForms>, at most 32 chars + {"FormName", T_OBJECT, OFFW(obdummy), 0, "Name of form as returned by EnumForms, at most 32 chars"}, + // @prop int|LogPixels|Pixels per inch (only for display devices + {"LogPixels", T_USHORT, OFFW(devmode.dmLogPixels), 0, "Pixels per inch (only for display devices)"}, + // @prop int|BitsPerPel|Color resolution in bits per pixel + {"BitsPerPel", T_ULONG, OFFW(devmode.dmBitsPerPel), 0, "Color resolution in bits per pixel"}, + // @prop int|PelsWidth|Pixel width of display + {"PelsWidth", T_ULONG, OFFW(devmode.dmPelsWidth), 0, "Pixel width of display"}, + // @prop int|PelsHeight|Pixel height of display + {"PelsHeight", T_ULONG, OFFW(devmode.dmPelsHeight), 0, "Pixel height of display"}, + // @prop int|DisplayFlags|Combination of DM_GRAYSCALE and DM_INTERLACED + {"DisplayFlags", T_ULONG, OFFW(devmode.dmDisplayFlags), 0, "Combination of DM_GRAYSCALE and DM_INTERLACED"}, + // @prop int|DisplayFrequency|Refresh rate + {"DisplayFrequency",T_ULONG, OFFW(devmode.dmDisplayFrequency), 0, "Refresh rate"}, + #ifdef MS_WINCE + // @prop int|DisplayOrientation|Display rotation: DMDO_DEFAULT,DMDO_90, DMDO_180, DMDO_270 + {"DisplayOrientation",T_ULONG,OFFW(devmode.dmDisplayOrientation), 0, "Display rotation: DMDO_DEFAULT,DMDO_90, DMDO_180, DMDO_270"}, + #else + // @prop int|ICMMethod|Indicates where ICM is performed, one of win32con.DMICMMETHOD_* values + {"ICMMethod", T_ULONG, OFFW(devmode.dmICMMethod), 0, "Indicates where ICM is performed, one of win32con.DMICMMETHOD_* values"}, + // @prop int|ICMIntent|Intent of ICM, one of win32con.DMICM_* values + {"ICMIntent", T_ULONG, OFFW(devmode.dmICMIntent), 0, "Intent of ICM, one of win32con.DMICM_* values"}, + // @prop int|MediaType|win32con.DMMEDIA_*, can also be a printer-specific value greater then DMMEDIA_USER + {"MediaType", T_ULONG, OFFW(devmode.dmMediaType), 0, "win32con.DMMEDIA_*, can also be a printer-specific value greater then DMMEDIA_USER"}, + // @prop int|DitherType|Dithering option, win32con.DMDITHER_* + {"DitherType", T_ULONG, OFFW(devmode.dmDitherType), 0, "Dithering options, win32con.DMDITHER_*"}, + // @prop int|Reserved1|Reserved, use only 0 + {"Reserved1", T_ULONG, OFFW(devmode.dmReserved1), 0, "Reserved, use only 0"}, + // @prop int|Reserved2|Reserved, use only 0 + {"Reserved2", T_ULONG, OFFW(devmode.dmReserved2), 0, "Reserved, use only 0"}, + // @prop str|DriverData|Driver data appended to end of structure + {"DriverData", T_OBJECT, OFFW(obdummy), 0, "Driver data appended to end of structure"}, + #if WINVER >= 0x0500 + // @prop int|Nup|Controls printing of multiple logical pages per physical page, DMNUP_SYSTEM or DMNUP_ONEUP + {"Nup", T_ULONG, OFFW(devmode.dmNup), 0, "Controls printing of multiple logical pages per physical page, DMNUP_SYSTEM or DMNUP_ONEUP"}, + // @prop int|PanningWidth|Not used, leave as 0 + {"PanningWidth", T_ULONG, OFFW(devmode.dmPanningWidth), 0, "Not used, leave as 0"}, + // @prop int|PanningHeight|Not used, leave as 0 + {"PanningHeight", T_ULONG, OFFW(devmode.dmPanningHeight), 0, "Not used, leave as 0"}, + #endif // WINVER >= 0x0500 + #endif // !MS_WINCE + {NULL} + }; + + PYWINTYPES_EXPORT PyTypeObject PyDEVMODEWType = + { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "PyDEVMODEW", + sizeof(PyDEVMODEW), + 0, + PyDEVMODEW::deallocFunc, + 0, // tp_print; + 0, // tp_getattr + 0, // tp_setattr + 0, // tp_compare + 0, // tp_repr + 0, // tp_as_number + 0, // tp_as_sequence + 0, // tp_as_mapping + 0, + 0, /* tp_call */ + 0, /* tp_str */ + PyDEVMODEW::getattro, // PyObject_GenericGetAttr + PyDEVMODEW::setattro, // PyObject_GenericSetAttr + 0, // tp_as_buffer; + Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, // tp_flags; + 0, // tp_doc; /* Documentation string */ + 0, // traverseproc tp_traverse; + 0, // tp_clear; + 0, // tp_richcompare; + 0, // tp_weaklistoffset; + 0, // tp_iter + 0, // iternextfunc tp_iternext + PyDEVMODEW::methods, + PyDEVMODEW::members, + 0, // tp_getset; + 0, // tp_base; + 0, // tp_dict; + 0, // tp_descr_get; + 0, // tp_descr_set; + 0, // tp_dictoffset; + 0, // tp_init; + 0, // tp_alloc; + PyDEVMODEW::tp_new // newfunc tp_new; + }; + + PyDEVMODEW::PyDEVMODEW(PDEVMODEW pdm) + { + ob_type = &PyDEVMODEWType; + memcpy(&devmode, pdm, pdm->dmSize); + pdevmode=(PDEVMODEW)malloc(pdm->dmSize + pdm->dmDriverExtra); + if (pdevmode==NULL) + PyErr_Format(PyExc_MemoryError, "PyDEVMODE::PyDEVMODE - Unable to allocate DEVMODE of size %d", + pdm->dmSize + pdm->dmDriverExtra); + else + memcpy(pdevmode, pdm, pdm->dmSize + pdm->dmDriverExtra); + obdummy=NULL; + _Py_NewReference(this); + } + + PyDEVMODEW::PyDEVMODEW(void) + { + ob_type = &PyDEVMODEWType; + static WORD dmSize=sizeof(DEVMODEW); + pdevmode=(PDEVMODEW)malloc(dmSize); + ZeroMemory(pdevmode,dmSize); + pdevmode->dmSize=dmSize; + pdevmode->dmSpecVersion=DM_SPECVERSION; + ZeroMemory(&devmode,dmSize); + devmode.dmSize=dmSize; + devmode.dmSpecVersion=DM_SPECVERSION; + obdummy=NULL; + _Py_NewReference(this); + } + + PyDEVMODEW::PyDEVMODEW(USHORT dmDriverExtra) + { + ob_type = &PyDEVMODEWType; + static WORD dmSize=sizeof(DEVMODEW); + pdevmode=(PDEVMODEW)malloc(dmSize+dmDriverExtra); + ZeroMemory(pdevmode,dmSize+dmDriverExtra); + pdevmode->dmSize=dmSize; + pdevmode->dmSpecVersion=DM_SPECVERSION; + pdevmode->dmDriverExtra=dmDriverExtra; + ZeroMemory(&devmode,dmSize); + devmode.dmSize=dmSize; + devmode.dmSpecVersion=DM_SPECVERSION; + devmode.dmDriverExtra=dmDriverExtra; + obdummy=NULL; + _Py_NewReference(this); + } + + PyDEVMODEW::~PyDEVMODEW() + { + if (pdevmode!=NULL) + free(pdevmode); + } + + BOOL PyDEVMODEW_Check(PyObject *ob) + { + if (ob->ob_type!=&PyDEVMODEWType){ + PyErr_SetString(PyExc_TypeError,"Object must be a PyDEVMODEW"); + return FALSE; + } + return TRUE; + } + + void PyDEVMODEW::deallocFunc(PyObject *ob) + { + delete (PyDEVMODEW *)ob; + } + + PDEVMODEW PyDEVMODEW::GetDEVMODE(void) + { + return pdevmode; + } + + // @pymethod |PyDEVMODE|Clear|Resets all members of the structure + PyObject *PyDEVMODEW::Clear(PyObject *self, PyObject *args) + { + PDEVMODEW pdevmode=((PyDEVMODEW *)self)->pdevmode; + USHORT dmDriverExtra=pdevmode->dmDriverExtra; + WORD dmSize=pdevmode->dmSize; + DWORD totalsize=dmSize + dmDriverExtra; + ZeroMemory(pdevmode, totalsize); + pdevmode->dmDriverExtra=dmDriverExtra; + pdevmode->dmSize=dmSize; + pdevmode->dmSpecVersion=DM_SPECVERSION; + + pdevmode=&((PyDEVMODEW *)self)->devmode; + ZeroMemory(pdevmode, dmSize); + pdevmode->dmDriverExtra=dmDriverExtra; + pdevmode->dmSize=dmSize; + pdevmode->dmSpecVersion=DM_SPECVERSION; + Py_INCREF(Py_None); + return Py_None; + } + + PyObject *PyDEVMODEW::getattro(PyObject *self, PyObject *obname) + { + PDEVMODEW pdevmode=((PyDEVMODEW *)self)->pdevmode; + char *name=PyString_AsString(obname); + if (name==NULL) + return NULL; + if (strcmp(name,"DeviceName")==0) + if (pdevmode->dmDeviceName[CCHDEVICENAME-1]==0) // in case DeviceName fills space and has no trailing NULL + return PyWinObject_FromWCHAR(pdevmode->dmDeviceName); + else + return PyWinObject_FromWCHAR(pdevmode->dmDeviceName, CCHDEVICENAME); + + if (strcmp(name,"FormName")==0) + if (pdevmode->dmFormName[CCHFORMNAME-1]==0) // If dmFormName occupies whole 32 chars, trailing NULL not present + return PyWinObject_FromWCHAR(pdevmode->dmFormName); + else + return PyWinObject_FromWCHAR(pdevmode->dmFormName, CCHFORMNAME); + + if (strcmp(name,"DriverData")==0) + if (pdevmode->dmDriverExtra==0){ // No extra space allocated + Py_INCREF(Py_None); + return Py_None; + } + else + return PyString_FromStringAndSize((char *)((ULONG_PTR)pdevmode + pdevmode->dmSize), pdevmode->dmDriverExtra); + + return PyObject_GenericGetAttr(self,obname); + } + + int PyDEVMODEW::setattro(PyObject *self, PyObject *obname, PyObject *obvalue) + { + char *name; + name=PyString_AsString(obname); + if (name==NULL) + return -1; + if (strcmp(name,"DeviceName")==0){ + WCHAR *devicename; + DWORD cch; + if (!PyWinObject_AsWCHAR(obvalue, &devicename, FALSE, &cch)) + return -1; + if (cch > CCHDEVICENAME){ + PyErr_Format(PyExc_ValueError,"DeviceName must be a string of length %d or less", CCHDEVICENAME); + PyWinObject_FreeWCHAR(devicename); + return -1; + } + PDEVMODEW pdevmode=&((PyDEVMODEW *)self)->devmode; + ZeroMemory(&pdevmode->dmDeviceName, sizeof(pdevmode->dmDeviceName)); + memcpy(&pdevmode->dmDeviceName, devicename, cch * sizeof(WCHAR)); + // update variable length DEVMODE with same value + memcpy(((PyDEVMODEW *)self)->pdevmode, pdevmode, pdevmode->dmSize); + PyWinObject_FreeWCHAR(devicename); + return 0; + } + + if (strcmp(name,"FormName")==0){ + WCHAR *formname; + DWORD cch; + if (!PyWinObject_AsWCHAR(obvalue, &formname, FALSE, &cch)) + return -1; + if (cch > CCHFORMNAME){ + PyErr_Format(PyExc_ValueError,"FormName must be a string of length %d or less", CCHFORMNAME); + PyWinObject_FreeWCHAR(formname); + return -1; + } + PDEVMODEW pdevmode=&((PyDEVMODEW *)self)->devmode; + ZeroMemory(&pdevmode->dmFormName, sizeof(pdevmode->dmFormName)); + memcpy(&pdevmode->dmFormName, formname, cch * sizeof(WCHAR)); + // update variable length PDEVMODE with same value + memcpy(((PyDEVMODEW *)self)->pdevmode, pdevmode, pdevmode->dmSize); + PyWinObject_FreeWCHAR(formname); + return 0; + } + + if (strcmp(name,"DriverData")==0){ + char *value; + Py_ssize_t valuelen; + if (PyString_AsStringAndSize(obvalue, &value, &valuelen)==-1) + return -1; + PDEVMODEW pdevmode=((PyDEVMODEW *)self)->pdevmode; + if (valuelen > pdevmode->dmDriverExtra){ + PyErr_Format(PyExc_ValueError,"Length of DriverData cannot be longer that DriverExtra (%d bytes)", pdevmode->dmDriverExtra); + return -1; + } + // This is not a real struct member, calculate address after end of fixed part of structure + char *driverdata=(char *)((ULONG_PTR)pdevmode + pdevmode->dmSize); + ZeroMemory(driverdata, pdevmode->dmDriverExtra); + memcpy(driverdata, value, valuelen); + return 0; + } + + int ret=PyObject_GenericSetAttr(self, obname, obvalue); + // Propagate changes to the externally usable structure + if (ret==0) + memcpy(((PyDEVMODEW *)self)->pdevmode, &((PyDEVMODEW *)self)->devmode, ((PyDEVMODEW *)self)->devmode.dmSize); + return ret; + } + + PyObject *PyDEVMODEW::tp_new(PyTypeObject *typ, PyObject *args, PyObject *kwargs) + { + USHORT DriverExtra=0; + static char *keywords[]={"DriverExtra", NULL}; + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|H", keywords, &DriverExtra)) + return NULL; + return new PyDEVMODEW(DriverExtra); + } + + BOOL PyWinObject_AsDEVMODE(PyObject *ob, PDEVMODEW *ppDEVMODE, BOOL bNoneOk) + { + if (ob==Py_None) + if (bNoneOk){ + *ppDEVMODE=NULL; + return TRUE; + } + else{ + PyErr_SetString(PyExc_ValueError,"PyDEVMODE cannot be None in this context"); + return FALSE; + } + if (!PyDEVMODEW_Check(ob)) + return FALSE; + *ppDEVMODE=((PyDEVMODEW *)ob)->GetDEVMODE(); + return TRUE; + } + + PyObject *PyWinObject_FromDEVMODE(PDEVMODEW pDEVMODE) + { + static WORD dmSize=sizeof(DEVMODEW); + if (pDEVMODE==NULL){ + Py_INCREF(Py_None); + return Py_None; + } + + // make sure we can't overflow the fixed size DEVMODE in PyDEVMODE + if (pDEVMODE->dmSize>dmSize){ + PyErr_Format(PyExc_WindowsError,"DEVMODE structure of size %d greater than supported size of %d", pDEVMODE->dmSize, dmSize); + return NULL; + } + PyObject *ret=new PyDEVMODEW(pDEVMODE); + // check that variable sized pdevmode is allocated + if (((PyDEVMODEW *)ret)->GetDEVMODE()==NULL){ + Py_DECREF(ret); + ret=NULL; + } + return ret; + } Index: PyWinTypesmodule.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypesmodule.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** PyWinTypesmodule.cpp 30 Oct 2007 09:53:32 -0000 1.36 --- PyWinTypesmodule.cpp 6 Feb 2008 18:37:46 -0000 1.37 *************** *** 919,922 **** --- 919,923 ---- PyDict_SetItemString(dict, "OVERLAPPEDType", (PyObject *)&PyOVERLAPPEDType); PyDict_SetItemString(dict, "DEVMODEType", (PyObject *)&PyDEVMODEType); + PyDict_SetItemString(dict, "DEVMODEWType", (PyObject *)&PyDEVMODEWType); PyDict_SetItemString(dict, "WAVEFORMATEXType", (PyObject *)&PyWAVEFORMATEXType); Index: PyWinTypes.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyWinTypes.h,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** PyWinTypes.h 12 Oct 2007 00:35:09 -0000 1.49 --- PyWinTypes.h 6 Feb 2008 18:37:46 -0000 1.50 *************** *** 216,221 **** #define PyWinObject_AsTCHAR PyWinObject_AsString #define PyWinObject_FreeTCHAR PyWinObject_FreeString ! inline PyObject *PyWinObject_FromTCHAR( TCHAR *str ) {return PyString_FromString(str);} ! inline PyObject *PyWinObject_FromTCHAR( TCHAR *str, int numChars ) {return PyString_FromStringAndSize(str, numChars);} #define PyString_FromTCHAR PyString_FromString #endif --- 216,235 ---- #define PyWinObject_AsTCHAR PyWinObject_AsString #define PyWinObject_FreeTCHAR PyWinObject_FreeString ! inline PyObject *PyWinObject_FromTCHAR( TCHAR *str ) ! { ! if (str==NULL){ ! Py_INCREF(Py_None); ! return Py_None; ! } ! return PyString_FromString(str); ! } ! inline PyObject *PyWinObject_FromTCHAR( TCHAR *str, int numChars ) ! { ! if (str==NULL){ ! Py_INCREF(Py_None); ! return Py_None; ! } ! return PyString_FromStringAndSize(str, numChars); ! } #define PyString_FromTCHAR PyString_FromString #endif *************** *** 228,238 **** // Converts a sequence of str/unicode objects into a series of consecutive null-terminated // wide character strings with extra terminating null ! PYWINTYPES_EXPORT BOOL PyWinObject_AsMultipleString(PyObject *ob, WCHAR **pmultistring, BOOL bNoneOK=TRUE); PYWINTYPES_EXPORT void PyWinObject_FreeMultipleString(WCHAR *pmultistring); // Convert a sequence of strings to an array of WCHAR pointers PYWINTYPES_EXPORT void PyWinObject_FreeWCHARArray(LPWSTR *wchars, DWORD str_cnt); PYWINTYPES_EXPORT BOOL PyWinObject_AsWCHARArray(PyObject *str_seq, LPWSTR **wchars, DWORD *str_cnt, BOOL bNoneOK = FALSE); PYWINTYPES_EXPORT PyObject *PyString_FromUnicode( const OLECHAR *str ); PYWINTYPES_EXPORT PyObject *PyUnicodeObject_FromString(const char *string); --- 242,261 ---- // Converts a sequence of str/unicode objects into a series of consecutive null-terminated // wide character strings with extra terminating null ! PYWINTYPES_EXPORT BOOL PyWinObject_AsMultipleString(PyObject *ob, WCHAR **pmultistring, BOOL bNoneOK=TRUE, DWORD *chars_returned=NULL); PYWINTYPES_EXPORT void PyWinObject_FreeMultipleString(WCHAR *pmultistring); + // Converts a sequence of str/unicode objects into a series of consecutive character strings + // terminated by double null + PYWINTYPES_EXPORT BOOL PyWinObject_AsMultipleString(PyObject *ob, char **pmultistring, BOOL bNoneOK=TRUE, DWORD *chars_returned=NULL); + PYWINTYPES_EXPORT void PyWinObject_FreeMultipleString(char *pmultistring); + // Convert a sequence of strings to an array of WCHAR pointers PYWINTYPES_EXPORT void PyWinObject_FreeWCHARArray(LPWSTR *wchars, DWORD str_cnt); PYWINTYPES_EXPORT BOOL PyWinObject_AsWCHARArray(PyObject *str_seq, LPWSTR **wchars, DWORD *str_cnt, BOOL bNoneOK = FALSE); + // Convert a sequence of string or unicode objects to an array of char * + PYWINTYPES_EXPORT void PyWinObject_FreeCharArray(char **pchars, DWORD str_cnt); + PYWINTYPES_EXPORT BOOL PyWinObject_AsCharArray(PyObject *str_seq, char ***pchars, DWORD *str_cnt, BOOL bNoneOK = FALSE); + PYWINTYPES_EXPORT PyObject *PyString_FromUnicode( const OLECHAR *str ); PYWINTYPES_EXPORT PyObject *PyUnicodeObject_FromString(const char *string); *************** *** 454,463 **** #define PySECURITY_ATTRIBUTES_Check(ob) ((ob)->ob_type == &PySECURITY_ATTRIBUTESType) extern PYWINTYPES_EXPORT PyTypeObject PyDEVMODEType; PYWINTYPES_EXPORT PyObject *PyWinMethod_NewSECURITY_ATTRIBUTES(PyObject *self, PyObject *args); PYWINTYPES_EXPORT BOOL PyWinObject_AsSECURITY_ATTRIBUTES(PyObject *ob, SECURITY_ATTRIBUTES **ppSECURITY_ATTRIBUTES, BOOL bNoneOK = TRUE); PYWINTYPES_EXPORT PyObject *PyWinObject_FromSECURITY_ATTRIBUTES(const SECURITY_ATTRIBUTES &sa); ! PYWINTYPES_EXPORT BOOL PyWinObject_AsDEVMODE(PyObject *ob, PDEVMODE * ppDEVMODE, BOOL bNoneOK = TRUE); ! PYWINTYPES_EXPORT PyObject *PyWinObject_FromDEVMODE(PDEVMODE); /* --- 477,489 ---- #define PySECURITY_ATTRIBUTES_Check(ob) ((ob)->ob_type == &PySECURITY_ATTRIBUTESType) extern PYWINTYPES_EXPORT PyTypeObject PyDEVMODEType; + extern PYWINTYPES_EXPORT PyTypeObject PyDEVMODEWType; PYWINTYPES_EXPORT PyObject *PyWinMethod_NewSECURITY_ATTRIBUTES(PyObject *self, PyObject *args); PYWINTYPES_EXPORT BOOL PyWinObject_AsSECURITY_ATTRIBUTES(PyObject *ob, SECURITY_ATTRIBUTES **ppSECURITY_ATTRIBUTES, BOOL bNoneOK = TRUE); PYWINTYPES_EXPORT PyObject *PyWinObject_FromSECURITY_ATTRIBUTES(const SECURITY_ATTRIBUTES &sa); ! PYWINTYPES_EXPORT BOOL PyWinObject_AsDEVMODE(PyObject *ob, PDEVMODEA * ppDEVMODE, BOOL bNoneOK = TRUE); ! PYWINTYPES_EXPORT BOOL PyWinObject_AsDEVMODE(PyObject *ob, PDEVMODEW * ppDEVMODE, BOOL bNoneOK); ! PYWINTYPES_EXPORT PyObject *PyWinObject_FromDEVMODE(PDEVMODEA); ! PYWINTYPES_EXPORT PyObject *PyWinObject_FromDEVMODE(PDEVMODEW); /* Index: PyUnicode.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/win32/src/PyUnicode.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** PyUnicode.cpp 12 Aug 2007 08:10:28 -0000 1.25 --- PyUnicode.cpp 6 Feb 2008 18:37:46 -0000 1.26 *************** *** 1092,1096 **** // Converts a sequence of str/unicode objects into a series of consecutive null-terminated // wide character strings with extra terminating null ! BOOL PyWinObject_AsMultipleString(PyObject *ob, WCHAR **pmultistring, BOOL bNoneOK) { DWORD numStrings, i; --- 1092,1138 ---- // Converts a sequence of str/unicode objects into a series of consecutive null-terminated // wide character strings with extra terminating null ! BOOL PyWinObject_AsMultipleString(PyObject *ob, char **pmultistring, BOOL bNoneOK, DWORD *chars_returned) ! { ! DWORD numStrings, i; ! char **pchars; ! BOOL rc=FALSE; ! ! *pmultistring=NULL; ! if (chars_returned) ! *chars_returned=0; ! if (!PyWinObject_AsCharArray(ob, &pchars, &numStrings, bNoneOK)) ! return FALSE; ! // Shortcut for None ! if (pchars==NULL) ! return TRUE; ! ! size_t len=numStrings+1; // One null for each string plus extra terminating null ! // Need to loop twice - once to get the buffer length ! for (i=0;i<numStrings;i++) ! len += strlen(pchars[i]); ! ! // Allocate the buffer ! *pmultistring = (char *)malloc(len * sizeof(char)); ! if (*pmultistring == NULL) ! PyErr_NoMemory(); ! else{ ! char *p = *pmultistring; ! for (i=0;i<numStrings;i++) { ! strcpy(p, pchars[i]); ! p += strlen(pchars[i]); ! *p++ = '\0'; ! } ! *p = '\0'; // Add second terminator. ! rc = TRUE; ! if (chars_returned) ! *chars_returned=len; ! } ! PyWinObject_FreeCharArray(pchars, numStrings); ! return rc; ! } ! ! // Converts a sequence of str/unicode objects into a series of consecutive null-terminated ! // char strings with extra terminating null ! BOOL PyWinObject_AsMultipleString(PyObject *ob, WCHAR **pmultistring, BOOL bNoneOK, DWORD *chars_returned) { DWORD numStrings, i; *************** *** 1099,1102 **** --- 1141,1146 ---- *pmultistring=NULL; + if (chars_returned) + *chars_returned=0; if (!PyWinObject_AsWCHARArray(ob, &wchars, &numStrings, bNoneOK)) return FALSE; *************** *** 1123,1126 **** --- 1167,1172 ---- *p = L'\0'; // Add second terminator. rc = TRUE; + if (chars_returned) + *chars_returned=len; } PyWinObject_FreeWCHARArray(wchars, numStrings); *************** *** 1134,1137 **** --- 1180,1189 ---- } + void PyWinObject_FreeMultipleString(char *pmultistring) + { + if (pmultistring) + free (pmultistring); + } + // Converts a aequence of string or unicode objects into an array of WCHAR void PyWinObject_FreeWCHARArray(LPWSTR *wchars, DWORD str_cnt) *************** *** 1177,1178 **** --- 1229,1274 ---- return ret; } + + // Converts a aequence of string or unicode objects into an array of char pointers + void PyWinObject_FreeCharArray(char **pchars, DWORD str_cnt) + { + if (pchars!=NULL){ + for (DWORD pchar_index=0; pchar_index<str_cnt; pchar_index++) + PyWinObject_FreeString(pchars[pchar_index]); + free(pchars); + } + } + + BOOL PyWinObject_AsCharArray(PyObject *str_seq, char ***pchars, DWORD *str_cnt, BOOL bNoneOK) + { + BOOL ret=FALSE; + PyObject *str_tuple=NULL, *tuple_item; + DWORD bufsize, tuple_index; + *pchars=NULL; + *str_cnt=0; + + if (bNoneOK && str_seq==Py_None) + return TRUE; + if ((str_tuple=PyWinSequence_Tuple(str_seq, str_cnt))==NULL) + return FALSE; + bufsize=*str_cnt * sizeof(char *); + *pchars=(char **)malloc(bufsize); + if (*pchars==NULL){ + PyErr_Format(PyExc_MemoryError, "Unable to allocate %d bytes", bufsize); + goto done; + } + ZeroMemory(*pchars, bufsize); + for (tuple_index=0;tuple_index<*str_cnt;tuple_index++){ + tuple_item=PyTuple_GET_ITEM(str_tuple, tuple_index); + if (!PyWinObject_AsString(tuple_item, &((*pchars)[tuple_index]), FALSE)){ + PyWinObject_FreeCharArray(*pchars, *str_cnt); + *pchars=NULL; + *str_cnt=0; + goto done; + } + } + ret=TRUE; + done: + Py_DECREF(str_tuple); + return ret; + } |
From: Sidnei da S. <dre...@us...> - 2008-02-06 09:10:23
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28263 Modified Files: Tag: sidnei-bits setup.py Log Message: - A more complete test exercising more of the (implemented) API, now handles errors and uses a callback for printing status, exits when transfer is finished. Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.64.2.2 retrieving revision 1.64.2.3 diff -C2 -d -r1.64.2.2 -r1.64.2.3 *** setup.py 6 Feb 2008 04:21:20 -0000 1.64.2.2 --- setup.py 6 Feb 2008 09:10:25 -0000 1.64.2.3 *************** *** 1469,1472 **** --- 1469,1473 ---- %(bits)s/PyIBackgroundCopyManager.cpp %(bits)s/PyIBackgroundCopyCallback.cpp + %(bits)s/PyIBackgroundCopyError.cpp %(bits)s/PyIBackgroundCopyJob.cpp %(bits)s/PyIBackgroundCopyJob2.cpp |
From: Sidnei da S. <dre...@us...> - 2008-02-06 09:10:23
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/bits/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28263/com/win32comext/bits/test Modified Files: Tag: sidnei-bits test_bits.py Log Message: - A more complete test exercising more of the (implemented) API, now handles errors and uses a callback for printing status, exits when transfer is finished. Index: test_bits.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/test/Attic/test_bits.py,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** test_bits.py 6 Feb 2008 01:51:28 -0000 1.1.2.1 --- test_bits.py 6 Feb 2008 09:10:25 -0000 1.1.2.2 *************** *** 1,6 **** ! import pythoncom, sys, os, time, win32api from win32com.bits import bits ! job_name = 'download-python' bcm = pythoncom.CoCreateInstance(bits.CLSID_BackgroundCopyManager, --- 1,13 ---- ! import win32com.server.policy ! import pythoncom, sys, os, time, win32api, win32event, tempfile from win32com.bits import bits ! TIMEOUT = 200 # ms ! StopEvent = win32event.CreateEvent(None, 0, 0, None) ! ! job_name = 'bits-pywin32-test' ! states = dict([(val, (name.split('_')[-1])) ! for name, val in vars(bits).items() ! if name.startswith('BG_JOB_STATE_')]) bcm = pythoncom.CoCreateInstance(bits.CLSID_BackgroundCopyManager, *************** *** 8,26 **** pythoncom.CLSCTX_LOCAL_SERVER, bits.IID_IBackgroundCopyManager) ! enum = bcm.EnumJobs(0) ! while True: ! jobs = enum.Next() ! if not jobs: ! break ! for job in jobs: ! print job ! job.Cancel() job = bcm.CreateJob(job_name, bits.BG_JOB_TYPE_DOWNLOAD) print job ! job.AddFile(r'http://www.python.org/favicon.ico', r'c:\src\favicon.ico') ! job.Suspend() ! print job.GetState() enum = job.EnumFiles() --- 15,61 ---- pythoncom.CLSCTX_LOCAL_SERVER, bits.IID_IBackgroundCopyManager) ! ! class BackgroundJobCallback(win32com.server.policy.DesignatedWrapPolicy): ! _com_interfaces_ = [bits.IID_IBackgroundCopyCallback] ! _public_methods_ = ["JobTransferred", "JobError", "JobModification"] ! ! def __init__(self): ! self._wrap_(self) ! ! def JobTransferred(self, job): ! print 'Job Transferred', job ! job.Complete() ! win32event.SetEvent(StopEvent) # exit msg pump ! ! def JobError(self, job, error): ! print 'Job Error', job, error ! f = error.GetFile() ! print 'While downloading', f.GetRemoteName() ! print 'To', f.GetLocalName() ! print 'The following error happened:' ! print error.GetErrorDescription(0) ! if f.GetRemoteName().endswith('missing-favicon.ico'): ! print 'Changing to point to correct file' ! f2 = f.QueryInterface(bits.IID_IBackgroundCopyFile2) ! f2.SetRemoteName(r'http://www.python.org/favicon.ico') ! job.Resume() ! else: ! job.Cancel() ! ! def JobModification(self, job, reserved): ! print 'Job Modification', job, states.get(job.GetState()) job = bcm.CreateJob(job_name, bits.BG_JOB_TYPE_DOWNLOAD) print job ! job.SetNotifyInterface(pythoncom.WrapObject(BackgroundJobCallback(), bits.IID_IBackgroundCopyCallback, pythoncom.IID_IUnknown)) ! job.SetNotifyFlags(bits.BG_NOTIFY_JOB_TRANSFERRED | ! bits.BG_NOTIFY_JOB_ERROR | ! bits.BG_NOTIFY_JOB_MODIFICATION) ! ! job.AddFile(r'http://www.python.org/favicon.ico', os.path.join(tempfile.gettempdir(), 'bits-favicon.ico')) ! job.AddFile(r'http://www.non-existing.domain/missing-favicon.ico', os.path.join(tempfile.gettempdir(), 'bits-missing-favicon.ico')) ! ! # job.Suspend() enum = job.EnumFiles() *************** *** 34,47 **** job.Resume() - print job.GetState() ! while job.GetState() != bits.BG_JOB_STATE_TRANSFERRED: ! if job.GetState() in (bits.BG_JOB_STATE_ERROR, ! bits.BG_JOB_STATE_TRANSIENT_ERROR): ! break ! time.sleep(2) ! print job.GetState() ! ! job.Complete() ! import code; code.interact(local=locals()) --- 69,83 ---- job.Resume() ! while True: ! rc = win32event.MsgWaitForMultipleObjects( ! (StopEvent,), ! 0, ! TIMEOUT, ! win32event.QS_ALLEVENTS) ! if rc == win32event.WAIT_OBJECT_0: ! break ! elif rc == win32event.WAIT_OBJECT_0+1: ! if pythoncom.PumpWaitingMessages(): ! break # wm_quit |
From: Sidnei da S. <dre...@us...> - 2008-02-06 09:10:22
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/bits/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28263/com/win32comext/bits/src Modified Files: Tag: sidnei-bits PyIBackgroundCopyError.cpp PyIBackgroundCopyFile2.cpp PyIBackgroundCopyJob.cpp PyIBackgroundCopyManager.cpp bits.cpp Log Message: - A more complete test exercising more of the (implemented) API, now handles errors and uses a callback for printing status, exits when transfer is finished. Index: PyIBackgroundCopyFile2.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/src/Attic/PyIBackgroundCopyFile2.cpp,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** PyIBackgroundCopyFile2.cpp 6 Feb 2008 04:21:20 -0000 1.1.2.1 --- PyIBackgroundCopyFile2.cpp 6 Feb 2008 09:10:25 -0000 1.1.2.2 *************** *** 63,73 **** if ( pIBCF2 == NULL ) return NULL; ! if ( !PyArg_ParseTuple(args, ":SetRemoteName") ) return NULL; ! LPCWSTR RemoteName; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pIBCF2->SetRemoteName(RemoteName); ! PY_INTERFACE_POSTCALL; --- 63,77 ---- if ( pIBCF2 == NULL ) return NULL; ! PyObject *obpRemoteName; ! if ( !PyArg_ParseTuple(args, "O:SetRemoteName", &obpRemoteName) ) return NULL; ! WCHAR *pRemoteName; ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyWinObject_AsWCHAR( obpRemoteName, &pRemoteName )) bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) return NULL; ! HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pIBCF2->SetRemoteName(pRemoteName); PY_INTERFACE_POSTCALL; Index: bits.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/src/Attic/bits.cpp,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** bits.cpp 6 Feb 2008 04:21:20 -0000 1.1.2.2 --- bits.cpp 6 Feb 2008 09:10:25 -0000 1.1.2.3 *************** *** 254,261 **** --- 254,263 ---- PYCOM_INTERFACE_CLIENT_ONLY( BackgroundCopyManager ), PYCOM_INTERFACE_SERVER_ONLY( BackgroundCopyCallback ), + PYCOM_INTERFACE_CLIENT_ONLY( BackgroundCopyError ), PYCOM_INTERFACE_CLIENT_ONLY( BackgroundCopyJob ), PYCOM_INTERFACE_CLIENT_ONLY( BackgroundCopyJob2 ), PYCOM_INTERFACE_CLIENT_ONLY( BackgroundCopyJob3 ), PYCOM_INTERFACE_CLIENT_ONLY( BackgroundCopyFile ), + PYCOM_INTERFACE_CLIENT_ONLY( BackgroundCopyFile2 ), PYCOM_INTERFACE_CLIENT_ONLY( EnumBackgroundCopyJobs ), PYCOM_INTERFACE_CLIENT_ONLY( EnumBackgroundCopyFiles ) *************** *** 336,338 **** --- 338,347 ---- PyModule_AddIntConstant(module, "BG_JOB_TYPE_UPLOAD_REPLY", BG_JOB_TYPE_UPLOAD_REPLY); + // notify flags + PyModule_AddIntConstant(module, "BG_NOTIFY_JOB_TRANSFERRED", BG_NOTIFY_JOB_TRANSFERRED); + PyModule_AddIntConstant(module, "BG_NOTIFY_JOB_ERROR", BG_NOTIFY_JOB_ERROR); + PyModule_AddIntConstant(module, "BG_NOTIFY_DISABLE", BG_NOTIFY_DISABLE); + PyModule_AddIntConstant(module, "BG_NOTIFY_JOB_MODIFICATION", BG_NOTIFY_JOB_MODIFICATION); + // PyModule_AddIntConstant(module, "BG_NOTIFY_FILE_TRANSFERRED", BG_NOTIFY_FILE_TRANSFERRED); + } Index: PyIBackgroundCopyManager.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/src/Attic/PyIBackgroundCopyManager.cpp,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** PyIBackgroundCopyManager.cpp 6 Feb 2008 01:51:28 -0000 1.1.2.1 --- PyIBackgroundCopyManager.cpp 6 Feb 2008 09:10:25 -0000 1.1.2.2 *************** *** 33,47 **** // @pyparm <o unicode>|DisplayName||Description for DisplayName BG_JOB_TYPE Type; - // PyObject *obType; // @pyparm int|Type||Job Type (See BG_JOB_TYPE_*) GUID pJobId; PyObject *obDisplayName; LPWSTR DisplayName; ! IBackgroundCopyJob * ppJob; if ( !PyArg_ParseTuple(args, "Ol:CreateJob", &obDisplayName, &Type) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyWinObject_AsBstr(obDisplayName, &DisplayName)) bPythonIsHappy = FALSE; - //if (bPythonIsHappy && !PyObject_AsBG_JOB_TYPE( obType, Type )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; --- 33,45 ---- // @pyparm <o unicode>|DisplayName||Description for DisplayName BG_JOB_TYPE Type; // @pyparm int|Type||Job Type (See BG_JOB_TYPE_*) GUID pJobId; PyObject *obDisplayName; LPWSTR DisplayName; ! IBackgroundCopyJob *ppJob; if ( !PyArg_ParseTuple(args, "Ol:CreateJob", &obDisplayName, &Type) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyWinObject_AsBstr(obDisplayName, &DisplayName)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; *************** *** 49,54 **** hr = pIBCM->CreateJob( DisplayName, Type, &pJobId, &ppJob ); SysFreeString(DisplayName); - // PyObject_FreeBG_JOB_TYPE(Type); - // PyObject_FreeGUID *(pJobId); PY_INTERFACE_POSTCALL; --- 47,50 ---- *************** *** 56,61 **** if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCM, IID_IBackgroundCopyManager ); - PyObject *obppJob; obppJob = PyCom_PyObjectFromIUnknown(ppJob, IID_IBackgroundCopyJob, FALSE); PyObject *pyretval = Py_BuildValue("O", obppJob); --- 52,57 ---- if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCM, IID_IBackgroundCopyManager ); + PyObject *obppJob; obppJob = PyCom_PyObjectFromIUnknown(ppJob, IID_IBackgroundCopyJob, FALSE); PyObject *pyretval = Py_BuildValue("O", obppJob); *************** *** 73,77 **** PyObject *objobID; IID jobID; ! IBackgroundCopyJob * ppJob; if ( !PyArg_ParseTuple(args, "O:GetJob", &objobID) ) return NULL; --- 69,73 ---- PyObject *objobID; IID jobID; ! IBackgroundCopyJob *ppJob; if ( !PyArg_ParseTuple(args, "O:GetJob", &objobID) ) return NULL; *************** *** 103,107 **** // @pyparm int|dwFlags||Description for dwFlags DWORD dwFlags; ! IEnumBackgroundCopyJobs * ppEnum; if ( !PyArg_ParseTuple(args, "l:EnumJobs", &dwFlags) ) return NULL; --- 99,103 ---- // @pyparm int|dwFlags||Description for dwFlags DWORD dwFlags; ! IEnumBackgroundCopyJobs *ppEnum; if ( !PyArg_ParseTuple(args, "l:EnumJobs", &dwFlags) ) return NULL; Index: PyIBackgroundCopyError.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/src/Attic/PyIBackgroundCopyError.cpp,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** PyIBackgroundCopyError.cpp 6 Feb 2008 01:51:28 -0000 1.1.2.1 --- PyIBackgroundCopyError.cpp 6 Feb 2008 09:10:25 -0000 1.1.2.2 *************** *** 2,6 **** // Generated by makegw.py ! #include "shell_pch.h" #include "PyIBackgroundCopyError.h" --- 2,6 ---- // Generated by makegw.py ! #include "bits_pch.h" #include "PyIBackgroundCopyError.h" *************** *** 31,55 **** if ( pIBCE == NULL ) return NULL; ! // *** The input argument pContext of type "BG_ERROR_CONTEXT *" was not processed *** ! // Please check the conversion function is appropriate and exists! ! BG_ERROR_CONTEXT * pContext; PyObject *obpContext; ! // @pyparm <o PyBG_ERROR_CONTEXT *>|pContext||Description for pContext ! // *** The input argument pCode of type "HRESULT *" was not processed *** ! // Please check the conversion function is appropriate and exists! ! HRESULT * pCode; PyObject *obpCode; ! // @pyparm <o PyHRESULT *>|pCode||Description for pCode ! if ( !PyArg_ParseTuple(args, "OO:GetError", &obpContext, &obpCode) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyObject_AsBG_ERROR_CONTEXT *( obpContext, &pContext )) bPythonIsHappy = FALSE; - if (bPythonIsHappy && !PyObject_AsHRESULT *( obpCode, &pCode )) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCE->GetError( pContext, pCode ); - PyObject_FreeBG_ERROR_CONTEXT *(pContext); - PyObject_FreeHRESULT *(pCode); PY_INTERFACE_POSTCALL; --- 31,43 ---- if ( pIBCE == NULL ) return NULL; ! BG_ERROR_CONTEXT *pContext; PyObject *obpContext; ! HRESULT *pCode; PyObject *obpCode; ! if ( !PyArg_ParseTuple(args, ":GetError") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCE->GetError( pContext, pCode ); PY_INTERFACE_POSTCALL; *************** *** 57,64 **** if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); ! // *** The output argument pContext of type "BG_ERROR_CONTEXT *" was not processed *** ! // The type 'BG_ERROR_CONTEXT *' (pContext) is unknown. ! // *** The output argument pCode of type "HRESULT *" was not processed *** ! // The type 'HRESULT *' (pCode) is unknown. Py_INCREF(Py_None); return Py_None; --- 45,49 ---- if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); ! Py_INCREF(Py_None); return Py_None; *************** *** 72,89 **** if ( pIBCE == NULL ) return NULL; ! IBackgroundCopyFile ** * pVal; if ( !PyArg_ParseTuple(args, ":GetFile") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pIBCE->GetFile( *pVal ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) ! return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); PyObject *obpVal; ! obpVal = PyCom_PyObjectFromIUnknown(pVal, IID_IBackgroundCopyFile **, FALSE); PyObject *pyretval = Py_BuildValue("O", obpVal); Py_XDECREF(obpVal); --- 57,74 ---- if ( pIBCE == NULL ) return NULL; ! IBackgroundCopyFile *pVal; if ( !PyArg_ParseTuple(args, ":GetFile") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pIBCE->GetFile( &pVal ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) ! return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError); PyObject *obpVal; ! obpVal = PyCom_PyObjectFromIUnknown(pVal, IID_IBackgroundCopyFile, FALSE); PyObject *pyretval = Py_BuildValue("O", obpVal); Py_XDECREF(obpVal); *************** *** 98,126 **** return NULL; // @pyparm int|LanguageId||Description for LanguageId ! // *** The input argument pErrorDescription of type "LPWSTR *" was not processed *** ! // Please check the conversion function is appropriate and exists! ! LPWSTR * pErrorDescription; ! PyObject *obpErrorDescription; ! // @pyparm <o PyLPWSTR *>|pErrorDescription||Description for pErrorDescription DWORD LanguageId; ! if ( !PyArg_ParseTuple(args, "lO:GetErrorDescription", &LanguageId, &obpErrorDescription) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyObject_AsLPWSTR *( obpErrorDescription, &pErrorDescription )) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; HRESULT hr; - PY_INTERFACE_PRECALL; - hr = pIBCE->GetErrorDescription( LanguageId, pErrorDescription ); - PyObject_FreeLPWSTR *(pErrorDescription); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); - // *** The output argument pErrorDescription of type "LPWSTR *" was not processed *** - // The type 'LPWSTR *' (pErrorDescription) is unknown. - Py_INCREF(Py_None); - return Py_None; } --- 83,101 ---- return NULL; // @pyparm int|LanguageId||Description for LanguageId ! WCHAR *pErrorDescription; DWORD LanguageId; ! if ( !PyArg_ParseTuple(args, "l:GetErrorDescription", &LanguageId) ) return NULL; HRESULT hr; + PY_INTERFACE_PRECALL; + hr = pIBCE->GetErrorDescription( LanguageId, &pErrorDescription ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); + PyObject *ret = PyString_FromUnicode(pErrorDescription); + return ret; } *************** *** 132,160 **** return NULL; // @pyparm int|LanguageId||Description for LanguageId ! // *** The input argument pContextDescription of type "LPWSTR *" was not processed *** ! // Please check the conversion function is appropriate and exists! ! LPWSTR * pContextDescription; ! PyObject *obpContextDescription; ! // @pyparm <o PyLPWSTR *>|pContextDescription||Description for pContextDescription DWORD LanguageId; ! if ( !PyArg_ParseTuple(args, "lO:GetErrorContextDescription", &LanguageId, &obpContextDescription) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyObject_AsLPWSTR *( obpContextDescription, &pContextDescription )) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pIBCE->GetErrorContextDescription( LanguageId, pContextDescription ); ! PyObject_FreeLPWSTR *(pContextDescription); ! PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); - // *** The output argument pContextDescription of type "LPWSTR *" was not processed *** - // The type 'LPWSTR *' (pContextDescription) is unknown. - Py_INCREF(Py_None); - return Py_None; } --- 107,124 ---- return NULL; // @pyparm int|LanguageId||Description for LanguageId ! WCHAR *pContextDescription; DWORD LanguageId; ! if ( !PyArg_ParseTuple(args, "l:GetErrorContextDescription", &LanguageId) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pIBCE->GetErrorContextDescription( LanguageId, &pContextDescription ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); + PyObject *ret = PyString_FromUnicode(pContextDescription); + return ret; } *************** *** 165,182 **** if ( pIBCE == NULL ) return NULL; ! // *** The input argument pProtocol of type "LPWSTR *" was not processed *** ! // Please check the conversion function is appropriate and exists! ! LPWSTR * pProtocol; ! PyObject *obpProtocol; ! // @pyparm <o PyLPWSTR *>|pProtocol||Description for pProtocol ! if ( !PyArg_ParseTuple(args, "O:GetProtocol", &obpProtocol) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyObject_AsLPWSTR *( obpProtocol, &pProtocol )) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pIBCE->GetProtocol( pProtocol ); ! PyObject_FreeLPWSTR *(pProtocol); PY_INTERFACE_POSTCALL; --- 129,138 ---- if ( pIBCE == NULL ) return NULL; ! WCHAR *pProtocol; ! if ( !PyArg_ParseTuple(args, ":GetProtocol") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pIBCE->GetProtocol( &pProtocol ); PY_INTERFACE_POSTCALL; *************** *** 184,192 **** if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); - // *** The output argument pProtocol of type "LPWSTR *" was not processed *** - // The type 'LPWSTR *' (pProtocol) is unknown. - Py_INCREF(Py_None); - return Py_None; } --- 140,146 ---- if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); + PyObject *ret = PyString_FromUnicode(pProtocol); + return ret; } Index: PyIBackgroundCopyJob.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/src/Attic/PyIBackgroundCopyJob.cpp,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** PyIBackgroundCopyJob.cpp 6 Feb 2008 01:51:28 -0000 1.1.2.1 --- PyIBackgroundCopyJob.cpp 6 Feb 2008 09:10:25 -0000 1.1.2.2 *************** *** 429,446 **** if ( pIBCJ == NULL ) return NULL; ! // *** The input argument pVal of type "LPWSTR *" was not processed *** ! // Please check the conversion function is appropriate and exists! ! LPWSTR * pVal; ! PyObject *obpVal; ! // @pyparm <o PyLPWSTR *>|pVal||Description for pVal ! if ( !PyArg_ParseTuple(args, "O:GetDisplayName", &obpVal) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyObject_AsLPWSTR_LIST( obpVal, &pVal )) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pIBCJ->GetDisplayName( pVal ); ! PyObject_FreeLPWSTR_LIST(pVal); PY_INTERFACE_POSTCALL; --- 429,438 ---- if ( pIBCJ == NULL ) return NULL; ! WCHAR *pVal; ! if ( !PyArg_ParseTuple(args, ":GetDisplayName") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pIBCJ->GetDisplayName( &pVal ); PY_INTERFACE_POSTCALL; *************** *** 448,456 **** if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); - // *** The output argument pVal of type "LPWSTR *" was not processed *** - // The type 'LPWSTR *' (pVal) is unknown. - Py_INCREF(Py_None); - return Py_None; } --- 440,446 ---- if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); + PyObject *ret = PyString_FromUnicode(pVal); + return ret; } *************** *** 467,476 **** return NULL; BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyWinObject_AsBstr(obVal, &Val)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->SetDescription( Val ); - SysFreeString(Val); PY_INTERFACE_POSTCALL; --- 457,465 ---- return NULL; BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyWinObject_AsWCHAR( obVal, &Val )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->SetDescription( Val ); PY_INTERFACE_POSTCALL; *************** *** 478,481 **** --- 467,471 ---- if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); + Py_INCREF(Py_None); return Py_None; *************** *** 489,515 **** if ( pIBCJ == NULL ) return NULL; ! // *** The input argument pVal of type "LPWSTR *" was not processed *** ! // Please check the conversion function is appropriate and exists! ! LPWSTR * pVal; ! PyObject *obpVal; ! // @pyparm <o PyLPWSTR *>|pVal||Description for pVal ! if ( !PyArg_ParseTuple(args, "O:GetDescription", &obpVal) ) return NULL; - BOOL bPythonIsHappy = TRUE; - if (bPythonIsHappy && !PyObject_AsLPWSTR_LIST( obpVal, &pVal )) bPythonIsHappy = FALSE; - if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pIBCJ->GetDescription( pVal ); ! PyObject_FreeLPWSTR_LIST(pVal); ! PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); ! // *** The output argument pVal of type "LPWSTR *" was not processed *** ! // The type 'LPWSTR *' (pVal) is unknown. ! Py_INCREF(Py_None); ! return Py_None; } --- 479,495 ---- if ( pIBCJ == NULL ) return NULL; ! WCHAR *pVal; ! if ( !PyArg_ParseTuple(args, ":GetDescription") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; ! hr = pIBCJ->GetDescription( &pVal ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); ! ! PyObject *ret = PyString_FromUnicode(pVal); ! return ret; } |
From: Sidnei da S. <dre...@us...> - 2008-02-06 04:21:17
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/bits/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21133/com/win32comext/bits/src Modified Files: Tag: sidnei-bits PyIBackgroundCopyCallback.cpp PyIBackgroundCopyCallback.h bits.cpp bits_pch.h Added Files: Tag: sidnei-bits PyIBackgroundCopyFile2.cpp PyIBackgroundCopyFile2.h PyIBackgroundCopyJob2.cpp PyIBackgroundCopyJob2.h PyIBackgroundCopyJob3.cpp PyIBackgroundCopyJob3.h Log Message: - More makegw fixups, and some evil hacks to get it to at least compile. --- NEW FILE: PyIBackgroundCopyJob3.h --- // This file declares the IBackgroundCopyJob3 Interface for Python. // Generated by makegw.py // --------------------------------------------------- // // Interface Declaration class PyIBackgroundCopyJob3 : public PyIBackgroundCopyJob2 { public: MAKE_PYCOM_CTOR(PyIBackgroundCopyJob3); static IBackgroundCopyJob3 *GetI(PyObject *self); static PyComTypeObject type; // The Python methods static PyObject *ReplaceRemotePrefix(PyObject *self, PyObject *args); static PyObject *AddFileWithRanges(PyObject *self, PyObject *args); static PyObject *SetFileACLFlags(PyObject *self, PyObject *args); static PyObject *GetFileACLFlags(PyObject *self, PyObject *args); protected: PyIBackgroundCopyJob3(IUnknown *pdisp); ~PyIBackgroundCopyJob3(); }; --- NEW FILE: PyIBackgroundCopyFile2.cpp --- // This file implements the IBackgroundCopyFile2 Interface for Python. // Generated by makegw.py #include "bits_pch.h" #include "PyIBackgroundCopyFile.h" #include "PyIBackgroundCopyFile2.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIBackgroundCopyFile2::PyIBackgroundCopyFile2(IUnknown *pdisp): PyIBackgroundCopyFile(pdisp) { ob_type = &type; } PyIBackgroundCopyFile2::~PyIBackgroundCopyFile2() { } /* static */ IBackgroundCopyFile2 *PyIBackgroundCopyFile2::GetI(PyObject *self) { return (IBackgroundCopyFile2 *)PyIBackgroundCopyFile::GetI(self); } // @pymethod |PyIBackgroundCopyFile2|GetFileRanges|Description of GetFileRanges. PyObject *PyIBackgroundCopyFile2::GetFileRanges(PyObject *self, PyObject *args) { IBackgroundCopyFile2 *pIBCF2 = GetI(self); if ( pIBCF2 == NULL ) return NULL; DWORD * RangeCount; PyObject *obRangeCount; BG_FILE_RANGE ** Ranges; PyObject *obRanges; if ( !PyArg_ParseTuple(args, ":GetFileRanges") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCF2->GetFileRanges( RangeCount, Ranges ); // PyObject_FreeDWORD(RangeCount); // PyObject_FreeBG_FILE_RANGE_LIST(Ranges); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCF2, IID_IBackgroundCopyFile2 ); // *** The output argument RangeCount of type "DWORD *" was not processed *** // The type 'DWORD *' (RangeCount) is unknown. // *** The output argument Ranges of type "BG_FILE_RANGE **" was not processed *** // The type 'BG_FILE_RANGE **' (Ranges) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyFile2|SetRemoteName|Description of SetRemoteName. PyObject *PyIBackgroundCopyFile2::SetRemoteName(PyObject *self, PyObject *args) { IBackgroundCopyFile2 *pIBCF2 = GetI(self); if ( pIBCF2 == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":SetRemoteName") ) return NULL; LPCWSTR RemoteName; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCF2->SetRemoteName(RemoteName); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCF2, IID_IBackgroundCopyFile2 ); Py_INCREF(Py_None); return Py_None; } // @object PyIBackgroundCopyFile2|Description of the interface static struct PyMethodDef PyIBackgroundCopyFile2_methods[] = { { "GetFileRanges", PyIBackgroundCopyFile2::GetFileRanges, 1 }, // @pymeth GetFileRanges|Description of GetFileRanges { "SetRemoteName", PyIBackgroundCopyFile2::SetRemoteName, 1 }, // @pymeth SetRemoteName|Description of SetRemoteName { NULL } }; PyComTypeObject PyIBackgroundCopyFile2::type("PyIBackgroundCopyFile2", &PyIBackgroundCopyFile::type, sizeof(PyIBackgroundCopyFile2), PyIBackgroundCopyFile2_methods, GET_PYCOM_CTOR(PyIBackgroundCopyFile2)); --- NEW FILE: PyIBackgroundCopyJob3.cpp --- // This file implements the IBackgroundCopyJob3 Interface for Python. // Generated by makegw.py #include "bits_pch.h" #include "PyIBackgroundCopyJob2.h" #include "PyIBackgroundCopyJob3.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIBackgroundCopyJob3::PyIBackgroundCopyJob3(IUnknown *pdisp): PyIBackgroundCopyJob2(pdisp) { ob_type = &type; } PyIBackgroundCopyJob3::~PyIBackgroundCopyJob3() { } /* static */ IBackgroundCopyJob3 *PyIBackgroundCopyJob3::GetI(PyObject *self) { return (IBackgroundCopyJob3 *)PyIBackgroundCopyJob2::GetI(self); } // @pymethod |PyIBackgroundCopyJob3|ReplaceRemotePrefix|Description of ReplaceRemotePrefix. PyObject *PyIBackgroundCopyJob3::ReplaceRemotePrefix(PyObject *self, PyObject *args) { IBackgroundCopyJob3 *pIBCJ3 = GetI(self); if ( pIBCJ3 == NULL ) return NULL; // @pyparm <o unicode>|OldPrefix||Description for OldPrefix // @pyparm <o unicode>|NewPrefix||Description for NewPrefix PyObject *obOldPrefix; PyObject *obNewPrefix; LPWSTR OldPrefix; LPWSTR NewPrefix; if ( !PyArg_ParseTuple(args, "OO:ReplaceRemotePrefix", &obOldPrefix, &obNewPrefix) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyWinObject_AsBstr(obOldPrefix, &OldPrefix)) bPythonIsHappy = FALSE; if (bPythonIsHappy && !PyWinObject_AsBstr(obNewPrefix, &NewPrefix)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ3->ReplaceRemotePrefix( OldPrefix, NewPrefix ); SysFreeString(OldPrefix); SysFreeString(NewPrefix); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ3, IID_IBackgroundCopyJob3 ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob3|AddFileWithRanges|Description of AddFileWithRanges. PyObject *PyIBackgroundCopyJob3::AddFileWithRanges(PyObject *self, PyObject *args) { IBackgroundCopyJob3 *pIBCJ3 = GetI(self); if ( pIBCJ3 == NULL ) return NULL; // @pyparm <o unicode>|RemoteUrl||Description for RemoteUrl // @pyparm <o unicode>|LocalName||Description for LocalName // @pyparm int|RangeCount||Description for RangeCount // *** The input argument Ranges of type "BG_FILE_RANGE" was not processed *** // Please check the conversion function is appropriate and exists! BG_FILE_RANGE *Ranges; PyObject *obRanges; // @pyparm <o PyBG_FILE_RANGE>|Ranges||Description for Ranges PyObject *obRemoteUrl; PyObject *obLocalName; LPWSTR RemoteUrl; LPWSTR LocalName; DWORD RangeCount; if ( !PyArg_ParseTuple(args, "OOlO:AddFileWithRanges", &obRemoteUrl, &obLocalName, &RangeCount, &obRanges) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyWinObject_AsBstr(obRemoteUrl, &RemoteUrl)) bPythonIsHappy = FALSE; if (bPythonIsHappy && !PyWinObject_AsBstr(obLocalName, &LocalName)) bPythonIsHappy = FALSE; if (bPythonIsHappy && !PyObject_AsBG_FILE_RANGE_LIST( obRanges, &Ranges )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ3->AddFileWithRanges( RemoteUrl, LocalName, RangeCount, Ranges ); SysFreeString(RemoteUrl); SysFreeString(LocalName); PyObject_FreeBG_FILE_RANGE_LIST(Ranges); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ3, IID_IBackgroundCopyJob3 ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob3|SetFileACLFlags|Description of SetFileACLFlags. PyObject *PyIBackgroundCopyJob3::SetFileACLFlags(PyObject *self, PyObject *args) { IBackgroundCopyJob3 *pIBCJ3 = GetI(self); if ( pIBCJ3 == NULL ) return NULL; // @pyparm int|Flags||Description for Flags DWORD Flags; if ( !PyArg_ParseTuple(args, "l:SetFileACLFlags", &Flags) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ3->SetFileACLFlags( Flags ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ3, IID_IBackgroundCopyJob3 ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob3|GetFileACLFlags|Description of GetFileACLFlags. PyObject *PyIBackgroundCopyJob3::GetFileACLFlags(PyObject *self, PyObject *args) { IBackgroundCopyJob3 *pIBCJ3 = GetI(self); if ( pIBCJ3 == NULL ) return NULL; DWORD * Flags; PyObject *obFlags; if ( !PyArg_ParseTuple(args, ":GetFileACLFlags") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ3->GetFileACLFlags( Flags ); PyObject_FreeDWORD(Flags); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ3, IID_IBackgroundCopyJob3 ); // *** The output argument Flags of type "DWORD *" was not processed *** // The type 'DWORD *' (Flags) is unknown. Py_INCREF(Py_None); return Py_None; } // @object PyIBackgroundCopyJob3|Description of the interface static struct PyMethodDef PyIBackgroundCopyJob3_methods[] = { { "ReplaceRemotePrefix", PyIBackgroundCopyJob3::ReplaceRemotePrefix, 1 }, // @pymeth ReplaceRemotePrefix|Description of ReplaceRemotePrefix { "AddFileWithRanges", PyIBackgroundCopyJob3::AddFileWithRanges, 1 }, // @pymeth AddFileWithRanges|Description of AddFileWithRanges { "SetFileACLFlags", PyIBackgroundCopyJob3::SetFileACLFlags, 1 }, // @pymeth SetFileACLFlags|Description of SetFileACLFlags { "GetFileACLFlags", PyIBackgroundCopyJob3::GetFileACLFlags, 1 }, // @pymeth GetFileACLFlags|Description of GetFileACLFlags { NULL } }; PyComTypeObject PyIBackgroundCopyJob3::type("PyIBackgroundCopyJob3", &PyIBackgroundCopyJob2::type, sizeof(PyIBackgroundCopyJob3), PyIBackgroundCopyJob3_methods, GET_PYCOM_CTOR(PyIBackgroundCopyJob3)); Index: bits_pch.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/src/Attic/bits_pch.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** bits_pch.h 6 Feb 2008 01:51:28 -0000 1.1.2.1 --- bits_pch.h 6 Feb 2008 04:21:20 -0000 1.1.2.2 *************** *** 5,8 **** --- 5,11 ---- #include <PythonCOM.h> + BOOL PyObject_AsDWORD(PyObject *ob, DWORD *dw); + void PyObject_FreeDWORD(DWORD *dw); + BOOL PyObject_AsULONG(PyObject *ob, ULONG *ul); void PyObject_FreeULONG(ULONG *ul); *************** *** 38,41 **** --- 41,47 ---- void PyObject_FreeBG_FILE_PROGRESS_LIST(BG_FILE_PROGRESS *fi); + BOOL PyObject_AsBG_FILE_RANGE_LIST(PyObject *ob, BG_FILE_RANGE **fr); + void PyObject_FreeBG_FILE_RANGE_LIST(BG_FILE_RANGE *fr); + BOOL PyObject_AsBG_JOB_STATE(PyObject *ob, BG_JOB_STATE *js); void PyObject_FreeBG_JOB_STATE(BG_JOB_STATE *js); Index: PyIBackgroundCopyCallback.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/src/Attic/PyIBackgroundCopyCallback.cpp,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** PyIBackgroundCopyCallback.cpp 6 Feb 2008 02:43:32 -0000 1.1.2.2 --- PyIBackgroundCopyCallback.cpp 6 Feb 2008 04:21:20 -0000 1.1.2.3 *************** *** 2,6 **** // Generated by makegw.py ! #include "shell_pch.h" #include "PyIBackgroundCopyCallback.h" --- 2,6 ---- // Generated by makegw.py ! #include "bits_pch.h" #include "PyIBackgroundCopyCallback.h" *************** *** 14,18 **** PY_GATEWAY_METHOD; PyObject *obpJob; ! obpJob = PyCom_PyObjectFromIUnknown(&pJob, IID_IBackgroundCopyJob *, TRUE); HRESULT hr=InvokeViaPolicy("JobTransferred", NULL, "O", obpJob); Py_XDECREF(obpJob); --- 14,18 ---- PY_GATEWAY_METHOD; PyObject *obpJob; ! obpJob = PyCom_PyObjectFromIUnknown(pJob, IID_IBackgroundCopyJob, TRUE); HRESULT hr=InvokeViaPolicy("JobTransferred", NULL, "O", obpJob); Py_XDECREF(obpJob); *************** *** 27,32 **** PyObject *obpJob; PyObject *obpError; ! obpJob = PyCom_PyObjectFromIUnknown(&pJob, IID_IBackgroundCopyJob *, TRUE); ! obpError = PyCom_PyObjectFromIUnknown(&pError, IID_IBackgroundCopyError *, TRUE); HRESULT hr=InvokeViaPolicy("JobError", NULL, "OO", obpJob, obpError); Py_XDECREF(obpJob); --- 27,32 ---- PyObject *obpJob; PyObject *obpError; ! obpJob = PyCom_PyObjectFromIUnknown(pJob, IID_IBackgroundCopyJob, TRUE); ! obpError = PyCom_PyObjectFromIUnknown(pError, IID_IBackgroundCopyError, TRUE); HRESULT hr=InvokeViaPolicy("JobError", NULL, "OO", obpJob, obpError); Py_XDECREF(obpJob); *************** *** 41,45 **** PY_GATEWAY_METHOD; PyObject *obpJob; ! obpJob = PyCom_PyObjectFromIUnknown(&pJob, IID_IBackgroundCopyJob *, TRUE); HRESULT hr=InvokeViaPolicy("JobModification", NULL, "Ol", obpJob, dwReserved); Py_XDECREF(obpJob); --- 41,45 ---- PY_GATEWAY_METHOD; PyObject *obpJob; ! obpJob = PyCom_PyObjectFromIUnknown(pJob, IID_IBackgroundCopyJob, TRUE); HRESULT hr=InvokeViaPolicy("JobModification", NULL, "Ol", obpJob, dwReserved); Py_XDECREF(obpJob); --- NEW FILE: PyIBackgroundCopyJob2.cpp --- // This file implements the IBackgroundCopyJob2 Interface for Python. // Generated by makegw.py #include "bits_pch.h" #include "PyIBackgroundCopyJob.h" #include "PyIBackgroundCopyJob2.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIBackgroundCopyJob2::PyIBackgroundCopyJob2(IUnknown *pdisp): PyIBackgroundCopyJob(pdisp) { ob_type = &type; } PyIBackgroundCopyJob2::~PyIBackgroundCopyJob2() { } /* static */ IBackgroundCopyJob2 *PyIBackgroundCopyJob2::GetI(PyObject *self) { return (IBackgroundCopyJob2 *)PyIBackgroundCopyJob::GetI(self); } // @pymethod |PyIBackgroundCopyJob2|SetNotifyCmdLine|Description of SetNotifyCmdLine. PyObject *PyIBackgroundCopyJob2::SetNotifyCmdLine(PyObject *self, PyObject *args) { IBackgroundCopyJob2 *pIBCJ2 = GetI(self); if ( pIBCJ2 == NULL ) return NULL; // @pyparm <o unicode>|Program||Description for Program // @pyparm <o unicode>|Parameters||Description for Parameters PyObject *obProgram; PyObject *obParameters; LPWSTR Program; LPWSTR Parameters; if ( !PyArg_ParseTuple(args, "OO:SetNotifyCmdLine", &obProgram, &obParameters) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyWinObject_AsBstr(obProgram, &Program)) bPythonIsHappy = FALSE; if (bPythonIsHappy && !PyWinObject_AsBstr(obParameters, &Parameters)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ2->SetNotifyCmdLine( Program, Parameters ); SysFreeString(Program); SysFreeString(Parameters); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ2, IID_IBackgroundCopyJob2 ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob2|GetNotifyCmdLine|Description of GetNotifyCmdLine. PyObject *PyIBackgroundCopyJob2::GetNotifyCmdLine(PyObject *self, PyObject *args) { IBackgroundCopyJob2 *pIBCJ2 = GetI(self); if ( pIBCJ2 == NULL ) return NULL; LPWSTR * pProgram; PyObject *obpProgram; LPWSTR * pParameters; PyObject *obpParameters; if ( !PyArg_ParseTuple(args, ":GetNotifyCmdLine") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ2->GetNotifyCmdLine( pProgram, pParameters ); PyObject_FreeLPWSTR(pProgram); PyObject_FreeLPWSTR(pParameters); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ2, IID_IBackgroundCopyJob2 ); // *** The output argument pProgram of type "LPWSTR *" was not processed *** // The type 'LPWSTR *' (pProgram) is unknown. // *** The output argument pParameters of type "LPWSTR *" was not processed *** // The type 'LPWSTR *' (pParameters) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob2|GetReplyProgress|Description of GetReplyProgress. PyObject *PyIBackgroundCopyJob2::GetReplyProgress(PyObject *self, PyObject *args) { IBackgroundCopyJob2 *pIBCJ2 = GetI(self); if ( pIBCJ2 == NULL ) return NULL; BG_JOB_REPLY_PROGRESS * pProgress; PyObject *obpProgress; // @pyparm <o PyBG_JOB_REPLY_PROGRESS *>|pProgress||Description for pProgress if ( !PyArg_ParseTuple(args, ":GetReplyProgress") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ2->GetReplyProgress( pProgress ); // PyObject_FreeBG_JOB_REPLY_PROGRESS(pProgress); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ2, IID_IBackgroundCopyJob2 ); // *** The output argument pProgress of type "BG_JOB_REPLY_PROGRESS *" was not processed *** // The type 'BG_JOB_REPLY_PROGRESS *' (pProgress) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob2|GetReplyData|Description of GetReplyData. PyObject *PyIBackgroundCopyJob2::GetReplyData(PyObject *self, PyObject *args) { IBackgroundCopyJob2 *pIBCJ2 = GetI(self); if ( pIBCJ2 == NULL ) return NULL; byte ** ppBuffer; PyObject *obppBuffer; UINT64 * pLength; PyObject *obpLength; if ( !PyArg_ParseTuple(args, ":GetReplyData") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ2->GetReplyData( ppBuffer, pLength ); // PyObject_Freebyte(ppBuffer); // PyObject_FreeUINT64(pLength); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ2, IID_IBackgroundCopyJob2 ); // *** The output argument ppBuffer of type "byte **" was not processed *** // The type 'byte **' (ppBuffer) is unknown. // *** The output argument pLength of type "UINT64 *" was not processed *** // The type 'UINT64 *' (pLength) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob2|SetReplyFileName|Description of SetReplyFileName. PyObject *PyIBackgroundCopyJob2::SetReplyFileName(PyObject *self, PyObject *args) { IBackgroundCopyJob2 *pIBCJ2 = GetI(self); if ( pIBCJ2 == NULL ) return NULL; // @pyparm <o unicode>|ReplyFileName||Description for ReplyFileName PyObject *obReplyFileName; LPWSTR ReplyFileName; if ( !PyArg_ParseTuple(args, "O:SetReplyFileName", &obReplyFileName) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyWinObject_AsBstr(obReplyFileName, &ReplyFileName)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ2->SetReplyFileName( ReplyFileName ); SysFreeString(ReplyFileName); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ2, IID_IBackgroundCopyJob2 ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob2|GetReplyFileName|Description of GetReplyFileName. PyObject *PyIBackgroundCopyJob2::GetReplyFileName(PyObject *self, PyObject *args) { IBackgroundCopyJob2 *pIBCJ2 = GetI(self); if ( pIBCJ2 == NULL ) return NULL; LPWSTR * pReplyFileName; PyObject *obpReplyFileName; if ( !PyArg_ParseTuple(args, ":GetReplyFileName") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ2->GetReplyFileName( pReplyFileName ); PyObject_FreeLPWSTR(pReplyFileName); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ2, IID_IBackgroundCopyJob2 ); // *** The output argument pReplyFileName of type "LPWSTR *" was not processed *** // The type 'LPWSTR *' (pReplyFileName) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob2|SetCredentials|Description of SetCredentials. PyObject *PyIBackgroundCopyJob2::SetCredentials(PyObject *self, PyObject *args) { IBackgroundCopyJob2 *pIBCJ2 = GetI(self); if ( pIBCJ2 == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":SetCredentials") ) return NULL; BG_AUTH_CREDENTIALS *ac; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ2->SetCredentials(ac); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ2, IID_IBackgroundCopyJob2 ); Py_INCREF(Py_None); return Py_None; } // @object PyIBackgroundCopyJob2|Description of the interface static struct PyMethodDef PyIBackgroundCopyJob2_methods[] = { { "SetNotifyCmdLine", PyIBackgroundCopyJob2::SetNotifyCmdLine, 1 }, // @pymeth SetNotifyCmdLine|Description of SetNotifyCmdLine { "GetNotifyCmdLine", PyIBackgroundCopyJob2::GetNotifyCmdLine, 1 }, // @pymeth GetNotifyCmdLine|Description of GetNotifyCmdLine { "GetReplyProgress", PyIBackgroundCopyJob2::GetReplyProgress, 1 }, // @pymeth GetReplyProgress|Description of GetReplyProgress { "GetReplyData", PyIBackgroundCopyJob2::GetReplyData, 1 }, // @pymeth GetReplyData|Description of GetReplyData { "SetReplyFileName", PyIBackgroundCopyJob2::SetReplyFileName, 1 }, // @pymeth SetReplyFileName|Description of SetReplyFileName { "GetReplyFileName", PyIBackgroundCopyJob2::GetReplyFileName, 1 }, // @pymeth GetReplyFileName|Description of GetReplyFileName { "SetCredentials", PyIBackgroundCopyJob2::SetCredentials, 1 }, // @pymeth SetCredentials|Description of SetCredentials { NULL } }; PyComTypeObject PyIBackgroundCopyJob2::type("PyIBackgroundCopyJob2", &PyIBackgroundCopyJob::type, sizeof(PyIBackgroundCopyJob2), PyIBackgroundCopyJob2_methods, GET_PYCOM_CTOR(PyIBackgroundCopyJob2)); Index: bits.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/src/Attic/bits.cpp,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** bits.cpp 6 Feb 2008 01:51:28 -0000 1.1.2.1 --- bits.cpp 6 Feb 2008 04:21:20 -0000 1.1.2.2 *************** *** 1,13 **** - # include "PythonCOM.h" - # include "PythonCOMRegister.h" # include "Bits.h" - # include "PyIEnumBackgroundCopyJobs.h" - # include "PyIEnumBackgroundCopyFiles.h" # include "PyIBackgroundCopyManager.h" # include "PyIBackgroundCopyJob.h" # include "PyIBackgroundCopyFile.h" # include "PyIBackgroundCopyError.h" ! # include "PyIBackgroundCopyCallback.h" ! # include "PyAsyncIBackgroundCopyCallback.h" BOOL PyObject_AsULONG(PyObject *ob, ULONG *ul) --- 1,24 ---- # include "Bits.h" # include "PyIBackgroundCopyManager.h" + # include "PyIBackgroundCopyCallback.h" # include "PyIBackgroundCopyJob.h" + # include "PyIBackgroundCopyJob2.h" + # include "PyIBackgroundCopyJob3.h" # include "PyIBackgroundCopyFile.h" + # include "PyIBackgroundCopyFile2.h" # include "PyIBackgroundCopyError.h" ! # include "PyIEnumBackgroundCopyJobs.h" ! # include "PyIEnumBackgroundCopyFiles.h" ! ! # include "PythonCOMRegister.h" ! ! BOOL PyObject_AsDWORD(PyObject *ob, DWORD *dw) ! { ! return FALSE; ! } ! ! void PyObject_FreeDWORD(DWORD *dw) ! { ! } BOOL PyObject_AsULONG(PyObject *ob, ULONG *ul) *************** *** 92,110 **** } ! BOOL PyObject_AsBG_FILE_PROGRESS(PyObject *ob, BG_FILE_PROGRESS *jp) { return FALSE; } ! void PyObject_FreeBG_FILE_PROGRESS(BG_FILE_PROGRESS *jp) { } ! BOOL PyObject_AsBG_FILE_PROGRESS_LIST(PyObject *ob, BG_FILE_PROGRESS **jp) { return FALSE; } ! void PyObject_FreeBG_FILE_PROGRESS_LIST(BG_FILE_PROGRESS *jp) { } --- 103,130 ---- } ! BOOL PyObject_AsBG_FILE_PROGRESS(PyObject *ob, BG_FILE_PROGRESS *fp) { return FALSE; } ! void PyObject_FreeBG_FILE_PROGRESS(BG_FILE_PROGRESS *fp) { } ! BOOL PyObject_AsBG_FILE_PROGRESS_LIST(PyObject *ob, BG_FILE_PROGRESS **fp) { return FALSE; } ! void PyObject_FreeBG_FILE_PROGRESS_LIST(BG_FILE_PROGRESS *fp) ! { ! } ! ! BOOL PyObject_AsBG_FILE_RANGE_LIST(PyObject *ob, BG_FILE_RANGE **fr) ! { ! return FALSE; ! } ! ! void PyObject_FreeBG_FILE_RANGE_LIST(BG_FILE_RANGE *fr) { } *************** *** 233,237 **** --- 253,260 ---- PYCOM_INTERFACE_CLSID_ONLY ( BackgroundCopyManager ), PYCOM_INTERFACE_CLIENT_ONLY( BackgroundCopyManager ), + PYCOM_INTERFACE_SERVER_ONLY( BackgroundCopyCallback ), PYCOM_INTERFACE_CLIENT_ONLY( BackgroundCopyJob ), + PYCOM_INTERFACE_CLIENT_ONLY( BackgroundCopyJob2 ), + PYCOM_INTERFACE_CLIENT_ONLY( BackgroundCopyJob3 ), PYCOM_INTERFACE_CLIENT_ONLY( BackgroundCopyFile ), PYCOM_INTERFACE_CLIENT_ONLY( EnumBackgroundCopyJobs ), Index: PyIBackgroundCopyCallback.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/src/Attic/PyIBackgroundCopyCallback.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** PyIBackgroundCopyCallback.h 6 Feb 2008 02:43:32 -0000 1.1.2.2 --- PyIBackgroundCopyCallback.h 6 Feb 2008 04:21:20 -0000 1.1.2.3 *************** *** 5,8 **** --- 5,10 ---- // Gateway Declaration + # include "PythonCOMServer.h" + class PyGBackgroundCopyCallback : public PyGatewayBase, public IBackgroundCopyCallback { --- NEW FILE: PyIBackgroundCopyFile2.h --- // This file declares the IBackgroundCopyFile2 Interface for Python. // Generated by makegw.py // --------------------------------------------------- // // Interface Declaration #include "Bits.h" #include "PythonCOM.h" class PyIBackgroundCopyFile2 : public PyIBackgroundCopyFile { public: MAKE_PYCOM_CTOR(PyIBackgroundCopyFile2); static IBackgroundCopyFile2 *GetI(PyObject *self); static PyComTypeObject type; // The Python methods static PyObject *GetFileRanges(PyObject *self, PyObject *args); static PyObject *SetRemoteName(PyObject *self, PyObject *args); protected: PyIBackgroundCopyFile2(IUnknown *pdisp); ~PyIBackgroundCopyFile2(); }; --- NEW FILE: PyIBackgroundCopyJob2.h --- // This file declares the IBackgroundCopyJob2 Interface for Python. // Generated by makegw.py // --------------------------------------------------- // // Interface Declaration #include "Bits.h" class PyIBackgroundCopyJob2 : public PyIBackgroundCopyJob { public: MAKE_PYCOM_CTOR(PyIBackgroundCopyJob2); static IBackgroundCopyJob2 *GetI(PyObject *self); static PyComTypeObject type; // The Python methods static PyObject *SetNotifyCmdLine(PyObject *self, PyObject *args); static PyObject *GetNotifyCmdLine(PyObject *self, PyObject *args); static PyObject *GetReplyProgress(PyObject *self, PyObject *args); static PyObject *GetReplyData(PyObject *self, PyObject *args); static PyObject *SetReplyFileName(PyObject *self, PyObject *args); static PyObject *GetReplyFileName(PyObject *self, PyObject *args); static PyObject *SetCredentials(PyObject *self, PyObject *args); protected: PyIBackgroundCopyJob2(IUnknown *pdisp); ~PyIBackgroundCopyJob2(); }; |
From: Sidnei da S. <dre...@us...> - 2008-02-06 04:21:17
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21133 Modified Files: Tag: sidnei-bits setup.py Log Message: - More makegw fixups, and some evil hacks to get it to at least compile. Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.64.2.1 retrieving revision 1.64.2.2 diff -C2 -d -r1.64.2.1 -r1.64.2.2 *** setup.py 6 Feb 2008 01:51:28 -0000 1.64.2.1 --- setup.py 6 Feb 2008 04:21:20 -0000 1.64.2.2 *************** *** 1468,1473 **** --- 1468,1477 ---- %(bits)s/bits.cpp %(bits)s/PyIBackgroundCopyManager.cpp + %(bits)s/PyIBackgroundCopyCallback.cpp %(bits)s/PyIBackgroundCopyJob.cpp + %(bits)s/PyIBackgroundCopyJob2.cpp + %(bits)s/PyIBackgroundCopyJob3.cpp %(bits)s/PyIBackgroundCopyFile.cpp + %(bits)s/PyIBackgroundCopyFile2.cpp %(bits)s/PyIEnumBackgroundCopyJobs.cpp %(bits)s/PyIEnumBackgroundCopyFiles.cpp |
Update of /cvsroot/pywin32/pywin32/com/win32comext/bits/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18828 Modified Files: Tag: sidnei-bits PyIBackgroundCopyCallback.cpp PyIBackgroundCopyCallback.h Removed Files: Tag: sidnei-bits PyAsyncIBackgroundCopyCallback.cpp PyAsyncIBackgroundCopyCallback.h Log Message: - Death to (probably not meaningful) Async interfaces. Callbacks should be Gateways (ie, they will be called from COM, not from Python) Index: PyIBackgroundCopyCallback.cpp =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/src/Attic/PyIBackgroundCopyCallback.cpp,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** PyIBackgroundCopyCallback.cpp 6 Feb 2008 01:51:28 -0000 1.1.2.1 --- PyIBackgroundCopyCallback.cpp 6 Feb 2008 02:43:32 -0000 1.1.2.2 *************** *** 1,3 **** ! // This file implements the IBackgroundCopyCallback Interface for Python. // Generated by makegw.py --- 1,3 ---- ! // This file implements the IBackgroundCopyCallback Gateway for Python. // Generated by makegw.py *************** *** 8,135 **** // --------------------------------------------------- // ! // Interface Implementation ! ! PyIBackgroundCopyCallback::PyIBackgroundCopyCallback(IUnknown *pdisp): ! PyIUnknown(pdisp) ! { ! ob_type = &type; ! } ! ! PyIBackgroundCopyCallback::~PyIBackgroundCopyCallback() ! { ! } ! ! /* static */ IBackgroundCopyCallback *PyIBackgroundCopyCallback::GetI(PyObject *self) ! { ! return (IBackgroundCopyCallback *)PyIUnknown::GetI(self); ! } ! ! // @pymethod |PyIBackgroundCopyCallback|JobTransferred|Description of JobTransferred. ! PyObject *PyIBackgroundCopyCallback::JobTransferred(PyObject *self, PyObject *args) { ! IBackgroundCopyCallback *pIBCC = GetI(self); ! if ( pIBCC == NULL ) ! return NULL; ! // @pyparm <o PyIBackgroundCopyJob *>|pJob||Description for pJob PyObject *obpJob; ! IBackgroundCopyJob * * pJob; ! if ( !PyArg_ParseTuple(args, "O:JobTransferred", &obpJob) ) ! return NULL; ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpJob, IID_IBackgroundCopyJob *, (void **)&pJob, TRUE /* bNoneOK */)) ! bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) return NULL; ! HRESULT hr; ! PY_INTERFACE_PRECALL; ! hr = pIBCC->JobTransferred( *pJob ); ! if (pJob) pJob->Release(); ! ! PY_INTERFACE_POSTCALL; ! ! if ( FAILED(hr) ) ! return PyCom_BuildPyException(hr, pIBCC, IID_IBackgroundCopyCallback ); ! Py_INCREF(Py_None); ! return Py_None; ! } ! // @pymethod |PyIBackgroundCopyCallback|JobError|Description of JobError. ! PyObject *PyIBackgroundCopyCallback::JobError(PyObject *self, PyObject *args) { ! IBackgroundCopyCallback *pIBCC = GetI(self); ! if ( pIBCC == NULL ) ! return NULL; ! // @pyparm <o PyIBackgroundCopyJob *>|pJob||Description for pJob ! // @pyparm <o PyIBackgroundCopyError *>|pError||Description for pError PyObject *obpJob; PyObject *obpError; ! IBackgroundCopyJob * * pJob; ! IBackgroundCopyError * * pError; ! if ( !PyArg_ParseTuple(args, "OO:JobError", &obpJob, &obpError) ) ! return NULL; ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpJob, IID_IBackgroundCopyJob *, (void **)&pJob, TRUE /* bNoneOK */)) ! bPythonIsHappy = FALSE; ! if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpError, IID_IBackgroundCopyError *, (void **)&pError, TRUE /* bNoneOK */)) ! bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) return NULL; ! HRESULT hr; ! PY_INTERFACE_PRECALL; ! hr = pIBCC->JobError( *pJob, *pError ); ! if (pJob) pJob->Release(); ! if (pError) pError->Release(); ! ! PY_INTERFACE_POSTCALL; ! ! if ( FAILED(hr) ) ! return PyCom_BuildPyException(hr, pIBCC, IID_IBackgroundCopyCallback ); ! Py_INCREF(Py_None); ! return Py_None; ! } ! // @pymethod |PyIBackgroundCopyCallback|JobModification|Description of JobModification. ! PyObject *PyIBackgroundCopyCallback::JobModification(PyObject *self, PyObject *args) { ! IBackgroundCopyCallback *pIBCC = GetI(self); ! if ( pIBCC == NULL ) ! return NULL; ! // @pyparm <o PyIBackgroundCopyJob *>|pJob||Description for pJob ! // @pyparm int|dwReserved||Description for dwReserved PyObject *obpJob; ! IBackgroundCopyJob * * pJob; ! DWORD dwReserved; ! if ( !PyArg_ParseTuple(args, "Ol:JobModification", &obpJob, &dwReserved) ) ! return NULL; ! BOOL bPythonIsHappy = TRUE; ! if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpJob, IID_IBackgroundCopyJob *, (void **)&pJob, TRUE /* bNoneOK */)) ! bPythonIsHappy = FALSE; ! if (!bPythonIsHappy) return NULL; ! HRESULT hr; ! PY_INTERFACE_PRECALL; ! hr = pIBCC->JobModification( *pJob, dwReserved ); ! if (pJob) pJob->Release(); ! ! PY_INTERFACE_POSTCALL; ! ! if ( FAILED(hr) ) ! return PyCom_BuildPyException(hr, pIBCC, IID_IBackgroundCopyCallback ); ! Py_INCREF(Py_None); ! return Py_None; ! } - // @object PyIBackgroundCopyCallback|Description of the interface - static struct PyMethodDef PyIBackgroundCopyCallback_methods[] = - { - { "JobTransferred", PyIBackgroundCopyCallback::JobTransferred, 1 }, // @pymeth JobTransferred|Description of JobTransferred - { "JobError", PyIBackgroundCopyCallback::JobError, 1 }, // @pymeth JobError|Description of JobError - { "JobModification", PyIBackgroundCopyCallback::JobModification, 1 }, // @pymeth JobModification|Description of JobModification - { NULL } - }; - - PyComTypeObject PyIBackgroundCopyCallback::type("PyIBackgroundCopyCallback", - &PyIUnknown::type, - sizeof(PyIBackgroundCopyCallback), - PyIBackgroundCopyCallback_methods, - GET_PYCOM_CTOR(PyIBackgroundCopyCallback)); --- 8,48 ---- // --------------------------------------------------- // ! // Gateway Implementation ! STDMETHODIMP PyGBackgroundCopyCallback::JobTransferred( ! /* [in] */ IBackgroundCopyJob * pJob) { ! PY_GATEWAY_METHOD; PyObject *obpJob; ! obpJob = PyCom_PyObjectFromIUnknown(&pJob, IID_IBackgroundCopyJob *, TRUE); ! HRESULT hr=InvokeViaPolicy("JobTransferred", NULL, "O", obpJob); ! Py_XDECREF(obpJob); ! return hr; } ! STDMETHODIMP PyGBackgroundCopyCallback::JobError( ! /* [in] */ IBackgroundCopyJob * pJob, ! /* [in] */ IBackgroundCopyError * pError) { ! PY_GATEWAY_METHOD; PyObject *obpJob; PyObject *obpError; ! obpJob = PyCom_PyObjectFromIUnknown(&pJob, IID_IBackgroundCopyJob *, TRUE); ! obpError = PyCom_PyObjectFromIUnknown(&pError, IID_IBackgroundCopyError *, TRUE); ! HRESULT hr=InvokeViaPolicy("JobError", NULL, "OO", obpJob, obpError); ! Py_XDECREF(obpJob); ! Py_XDECREF(obpError); ! return hr; } ! STDMETHODIMP PyGBackgroundCopyCallback::JobModification( ! /* [in] */ IBackgroundCopyJob * pJob, ! /* [in] */ DWORD dwReserved) { ! PY_GATEWAY_METHOD; PyObject *obpJob; ! obpJob = PyCom_PyObjectFromIUnknown(&pJob, IID_IBackgroundCopyJob *, TRUE); ! HRESULT hr=InvokeViaPolicy("JobModification", NULL, "Ol", obpJob, dwReserved); ! Py_XDECREF(obpJob); ! return hr; } --- PyAsyncIBackgroundCopyCallback.h DELETED --- Index: PyIBackgroundCopyCallback.h =================================================================== RCS file: /cvsroot/pywin32/pywin32/com/win32comext/bits/src/Attic/PyIBackgroundCopyCallback.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** PyIBackgroundCopyCallback.h 6 Feb 2008 01:51:28 -0000 1.1.2.1 --- PyIBackgroundCopyCallback.h 6 Feb 2008 02:43:32 -0000 1.1.2.2 *************** *** 1,22 **** ! // This file declares the IBackgroundCopyCallback Interface for Python. // Generated by makegw.py // --------------------------------------------------- // ! // Interface Declaration ! class PyIBackgroundCopyCallback : public PyIUnknown { ! public: ! MAKE_PYCOM_CTOR(PyIBackgroundCopyCallback); ! static IBackgroundCopyCallback *GetI(PyObject *self); ! static PyComTypeObject type; - // The Python methods - static PyObject *JobTransferred(PyObject *self, PyObject *args); - static PyObject *JobError(PyObject *self, PyObject *args); - static PyObject *JobModification(PyObject *self, PyObject *args); ! protected: ! PyIBackgroundCopyCallback(IUnknown *pdisp); ! ~PyIBackgroundCopyCallback(); }; --- 1,27 ---- ! // This file declares the IBackgroundCopyCallback Gateway for Python. // Generated by makegw.py // --------------------------------------------------- // ! // Gateway Declaration ! class PyGBackgroundCopyCallback : public PyGatewayBase, public IBackgroundCopyCallback { ! protected: ! PyGBackgroundCopyCallback(PyObject *instance) : PyGatewayBase(instance) { ; } ! PYGATEWAY_MAKE_SUPPORT2(PyGBackgroundCopyCallback, IBackgroundCopyCallback, IID_IBackgroundCopyCallback, PyGatewayBase) ! ! // IBackgroundCopyCallback ! STDMETHOD(JobTransferred)( ! IBackgroundCopyJob * pJob); ! ! STDMETHOD(JobError)( ! IBackgroundCopyJob * pJob, ! IBackgroundCopyError * pError); ! ! STDMETHOD(JobModification)( ! IBackgroundCopyJob * pJob, ! DWORD dwReserved); ! }; --- PyAsyncIBackgroundCopyCallback.cpp DELETED --- |
From: Sidnei da S. <dre...@us...> - 2008-02-06 01:51:26
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/bits/test In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv472/com/win32comext/bits/test Added Files: Tag: sidnei-bits test_bits.py Log Message: - First step at wrapping BITS --- NEW FILE: test_bits.py --- import pythoncom, sys, os, time, win32api from win32com.bits import bits job_name = 'download-python' bcm = pythoncom.CoCreateInstance(bits.CLSID_BackgroundCopyManager, None, pythoncom.CLSCTX_LOCAL_SERVER, bits.IID_IBackgroundCopyManager) enum = bcm.EnumJobs(0) while True: jobs = enum.Next() if not jobs: break for job in jobs: print job job.Cancel() job = bcm.CreateJob(job_name, bits.BG_JOB_TYPE_DOWNLOAD) print job job.AddFile(r'http://www.python.org/favicon.ico', r'c:\src\favicon.ico') job.Suspend() print job.GetState() enum = job.EnumFiles() while True: files = enum.Next() if not files: break for f in files: print 'Downloading', f.GetRemoteName() print 'To', f.GetLocalName() job.Resume() print job.GetState() while job.GetState() != bits.BG_JOB_STATE_TRANSFERRED: if job.GetState() in (bits.BG_JOB_STATE_ERROR, bits.BG_JOB_STATE_TRANSIENT_ERROR): break time.sleep(2) print job.GetState() job.Complete() import code; code.interact(local=locals()) |
From: Sidnei da S. <dre...@us...> - 2008-02-06 01:51:25
|
Update of /cvsroot/pywin32/pywin32/com/win32comext/bits In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv472/com/win32comext/bits Added Files: Tag: sidnei-bits __init__.py Log Message: - First step at wrapping BITS --- NEW FILE: __init__.py --- # This is a python package # __PackageSupportBuildPath__ not needed for distutil based builds, # but not everyone is there yet. import win32com win32com.__PackageSupportBuildPath__(__path__) |
From: Sidnei da S. <dre...@us...> - 2008-02-06 01:51:25
|
Update of /cvsroot/pywin32/pywin32 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv472 Modified Files: Tag: sidnei-bits setup.py Log Message: - First step at wrapping BITS Index: setup.py =================================================================== RCS file: /cvsroot/pywin32/pywin32/setup.py,v retrieving revision 1.64 retrieving revision 1.64.2.1 diff -C2 -d -r1.64 -r1.64.2.1 *** setup.py 8 Jan 2008 00:41:03 -0000 1.64 --- setup.py 6 Feb 2008 01:51:28 -0000 1.64.2.1 *************** *** 1329,1332 **** --- 1329,1333 ---- 'authorization' : 'com/win32comext/authorization/src', 'taskscheduler' : 'com/win32comext/taskscheduler/src', + 'bits' : 'com/win32comext/bits/src', } *************** *** 1463,1466 **** --- 1464,1477 ---- """ % dirs).split()), + WinExt_win32com('bits', libraries='Bits', pch_header="bits_pch.h", + sources=(""" + %(bits)s/bits.cpp + %(bits)s/PyIBackgroundCopyManager.cpp + %(bits)s/PyIBackgroundCopyJob.cpp + %(bits)s/PyIBackgroundCopyFile.cpp + %(bits)s/PyIEnumBackgroundCopyJobs.cpp + %(bits)s/PyIEnumBackgroundCopyFiles.cpp + + """ % dirs).split()), WinExt_win32com('ifilter', libraries='ntquery'), WinExt_win32com('directsound', pch_header='directsound_pch.h', *************** *** 1648,1651 **** --- 1659,1663 ---- 'win32comext.directsound', 'win32comext.authorization', + 'win32comext.bits', 'pythonwin.pywin', |
Update of /cvsroot/pywin32/pywin32/com/win32comext/bits/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv472/com/win32comext/bits/src Added Files: Tag: sidnei-bits PyAsyncIBackgroundCopyCallback.cpp PyAsyncIBackgroundCopyCallback.h PyIBackgroundCopyCallback.cpp PyIBackgroundCopyCallback.h PyIBackgroundCopyError.cpp PyIBackgroundCopyError.h PyIBackgroundCopyFile.cpp PyIBackgroundCopyFile.h PyIBackgroundCopyJob.cpp PyIBackgroundCopyJob.h PyIBackgroundCopyManager.cpp PyIBackgroundCopyManager.h PyIEnumBackgroundCopyFiles.cpp PyIEnumBackgroundCopyFiles.h PyIEnumBackgroundCopyJobs.cpp PyIEnumBackgroundCopyJobs.h bits.cpp bits_pch.h Log Message: - First step at wrapping BITS --- NEW FILE: PyAsyncIBackgroundCopyCallback.h --- // This file declares the AsyncIBackgroundCopyCallback Interface for Python. // Generated by makegw.py // --------------------------------------------------- // // Interface Declaration class PyAsyncIBackgroundCopyCallback : public PyIUnknown { public: MAKE_PYCOM_CTOR(PyAsyncIBackgroundCopyCallback); static AsyncIBackgroundCopyCallback *GetI(PyObject *self); static PyComTypeObject type; // The Python methods static PyObject *Begin_JobTransferred(PyObject *self, PyObject *args); static PyObject *Finish_JobTransferred(PyObject *self, PyObject *args); static PyObject *Begin_JobError(PyObject *self, PyObject *args); static PyObject *Finish_JobError(PyObject *self, PyObject *args); static PyObject *Begin_JobModification(PyObject *self, PyObject *args); static PyObject *Finish_JobModification(PyObject *self, PyObject *args); protected: PyAsyncIBackgroundCopyCallback(IUnknown *pdisp); ~PyAsyncIBackgroundCopyCallback(); }; --- NEW FILE: PyAsyncIBackgroundCopyCallback.cpp --- // This file implements the AsyncIBackgroundCopyCallback Interface for Python. // Generated by makegw.py #include "shell_pch.h" #include "PyAsyncIBackgroundCopyCallback.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyAsyncIBackgroundCopyCallback::PyAsyncIBackgroundCopyCallback(IUnknown *pdisp): PyIUnknown(pdisp) { ob_type = &type; } PyAsyncIBackgroundCopyCallback::~PyAsyncIBackgroundCopyCallback() { } /* static */ AsyncIBackgroundCopyCallback *PyAsyncIBackgroundCopyCallback::GetI(PyObject *self) { return (AsyncIBackgroundCopyCallback *)PyIUnknown::GetI(self); } // @pymethod |PyAsyncIBackgroundCopyCallback|Begin_JobTransferred|Description of Begin_JobTransferred. PyObject *PyAsyncIBackgroundCopyCallback::Begin_JobTransferred(PyObject *self, PyObject *args) { AsyncIBackgroundCopyCallback *pAIBCC = GetI(self); if ( pAIBCC == NULL ) return NULL; // @pyparm <o PyIBackgroundCopyJob *>|pJob||Description for pJob PyObject *obpJob; IBackgroundCopyJob * * pJob; if ( !PyArg_ParseTuple(args, "O:Begin_JobTransferred", &obpJob) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpJob, IID_IBackgroundCopyJob *, (void **)&pJob, TRUE /* bNoneOK */)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pAIBCC->Begin_JobTransferred( *pJob ); if (pJob) pJob->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pAIBCC, IID_AsyncIBackgroundCopyCallback ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyAsyncIBackgroundCopyCallback|Finish_JobTransferred|Description of Finish_JobTransferred. PyObject *PyAsyncIBackgroundCopyCallback::Finish_JobTransferred(PyObject *self, PyObject *args) { AsyncIBackgroundCopyCallback *pAIBCC = GetI(self); if ( pAIBCC == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":Finish_JobTransferred") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pAIBCC->Finish_JobTransferred( ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pAIBCC, IID_AsyncIBackgroundCopyCallback ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyAsyncIBackgroundCopyCallback|Begin_JobError|Description of Begin_JobError. PyObject *PyAsyncIBackgroundCopyCallback::Begin_JobError(PyObject *self, PyObject *args) { AsyncIBackgroundCopyCallback *pAIBCC = GetI(self); if ( pAIBCC == NULL ) return NULL; // @pyparm <o PyIBackgroundCopyJob *>|pJob||Description for pJob // @pyparm <o PyIBackgroundCopyError *>|pError||Description for pError PyObject *obpJob; PyObject *obpError; IBackgroundCopyJob * * pJob; IBackgroundCopyError * * pError; if ( !PyArg_ParseTuple(args, "OO:Begin_JobError", &obpJob, &obpError) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpJob, IID_IBackgroundCopyJob *, (void **)&pJob, TRUE /* bNoneOK */)) bPythonIsHappy = FALSE; if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpError, IID_IBackgroundCopyError *, (void **)&pError, TRUE /* bNoneOK */)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pAIBCC->Begin_JobError( *pJob, *pError ); if (pJob) pJob->Release(); if (pError) pError->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pAIBCC, IID_AsyncIBackgroundCopyCallback ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyAsyncIBackgroundCopyCallback|Finish_JobError|Description of Finish_JobError. PyObject *PyAsyncIBackgroundCopyCallback::Finish_JobError(PyObject *self, PyObject *args) { AsyncIBackgroundCopyCallback *pAIBCC = GetI(self); if ( pAIBCC == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":Finish_JobError") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pAIBCC->Finish_JobError( ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pAIBCC, IID_AsyncIBackgroundCopyCallback ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyAsyncIBackgroundCopyCallback|Begin_JobModification|Description of Begin_JobModification. PyObject *PyAsyncIBackgroundCopyCallback::Begin_JobModification(PyObject *self, PyObject *args) { AsyncIBackgroundCopyCallback *pAIBCC = GetI(self); if ( pAIBCC == NULL ) return NULL; // @pyparm <o PyIBackgroundCopyJob *>|pJob||Description for pJob // @pyparm int|dwReserved||Description for dwReserved PyObject *obpJob; IBackgroundCopyJob * * pJob; DWORD dwReserved; if ( !PyArg_ParseTuple(args, "Ol:Begin_JobModification", &obpJob, &dwReserved) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obpJob, IID_IBackgroundCopyJob *, (void **)&pJob, TRUE /* bNoneOK */)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pAIBCC->Begin_JobModification( *pJob, dwReserved ); if (pJob) pJob->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pAIBCC, IID_AsyncIBackgroundCopyCallback ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyAsyncIBackgroundCopyCallback|Finish_JobModification|Description of Finish_JobModification. PyObject *PyAsyncIBackgroundCopyCallback::Finish_JobModification(PyObject *self, PyObject *args) { AsyncIBackgroundCopyCallback *pAIBCC = GetI(self); if ( pAIBCC == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":Finish_JobModification") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pAIBCC->Finish_JobModification( ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pAIBCC, IID_AsyncIBackgroundCopyCallback ); Py_INCREF(Py_None); return Py_None; } // @object PyAsyncIBackgroundCopyCallback|Description of the interface static struct PyMethodDef PyAsyncIBackgroundCopyCallback_methods[] = { { "Begin_JobTransferred", PyAsyncIBackgroundCopyCallback::Begin_JobTransferred, 1 }, // @pymeth Begin_JobTransferred|Description of Begin_JobTransferred { "Finish_JobTransferred", PyAsyncIBackgroundCopyCallback::Finish_JobTransferred, 1 }, // @pymeth Finish_JobTransferred|Description of Finish_JobTransferred { "Begin_JobError", PyAsyncIBackgroundCopyCallback::Begin_JobError, 1 }, // @pymeth Begin_JobError|Description of Begin_JobError { "Finish_JobError", PyAsyncIBackgroundCopyCallback::Finish_JobError, 1 }, // @pymeth Finish_JobError|Description of Finish_JobError { "Begin_JobModification", PyAsyncIBackgroundCopyCallback::Begin_JobModification, 1 }, // @pymeth Begin_JobModification|Description of Begin_JobModification { "Finish_JobModification", PyAsyncIBackgroundCopyCallback::Finish_JobModification, 1 }, // @pymeth Finish_JobModification|Description of Finish_JobModification { NULL } }; PyComTypeObject PyAsyncIBackgroundCopyCallback::type("PyAsyncIBackgroundCopyCallback", &PyIUnknown::type, sizeof(PyAsyncIBackgroundCopyCallback), PyAsyncIBackgroundCopyCallback_methods, GET_PYCOM_CTOR(PyAsyncIBackgroundCopyCallback)); --- NEW FILE: PyIEnumBackgroundCopyJobs.cpp --- // This file implements the IEnumBackgroundCopyJobs Interface for Python. // Generated by makegw.py #include "PyIEnumBackgroundCopyJobs.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIEnumBackgroundCopyJobs::PyIEnumBackgroundCopyJobs(IUnknown *pdisp): PyIUnknown(pdisp) { ob_type = &type; } PyIEnumBackgroundCopyJobs::~PyIEnumBackgroundCopyJobs() { } /* static */ IEnumBackgroundCopyJobs *PyIEnumBackgroundCopyJobs::GetI(PyObject *self) { return (IEnumBackgroundCopyJobs *)PyIUnknown::GetI(self); } // @pymethod object|PyIEnumBackgroundCopyJobs|Next|Retrieves a specified number of items in the enumeration sequence. PyObject *PyIEnumBackgroundCopyJobs::Next(PyObject *self, PyObject *args) { long celt = 1; // @pyparm int|num|1|Number of items to retrieve. if ( !PyArg_ParseTuple(args, "|l:Next", &celt) ) return NULL; IEnumBackgroundCopyJobs *pIEnumBackgroundCopyJobs = GetI(self); if ( pIEnumBackgroundCopyJobs == NULL ) return NULL; IBackgroundCopyJob **rgVar = new IBackgroundCopyJob *[celt]; if ( rgVar == NULL ) { PyErr_SetString(PyExc_MemoryError, "allocating result BackgroundCopyJobss"); return NULL; } int i; /* for ( i = celt; i--; ) // *** possibly init each structure element??? */ ULONG celtFetched = 0; PY_INTERFACE_PRECALL; HRESULT hr = pIEnumBackgroundCopyJobs->Next(celt, rgVar, &celtFetched); PY_INTERFACE_POSTCALL; if ( HRESULT_CODE(hr) != ERROR_NO_MORE_ITEMS && FAILED(hr) ) { delete [] rgVar; return PyCom_BuildPyException(hr, pIEnumBackgroundCopyJobs, IID_IEnumBackgroundCopyJobs); } PyObject *result = PyTuple_New(celtFetched); if ( result != NULL ) { for ( i = celtFetched; i--; ) { PyObject *ob = PyCom_PyObjectFromIUnknown(rgVar[i], IID_IBackgroundCopyJob, FALSE); if ( ob == NULL ) { Py_DECREF(result); result = NULL; break; } PyTuple_SET_ITEM(result, i, ob); } } /* for ( i = celtFetched; i--; ) // *** possibly cleanup each structure element??? */ delete [] rgVar; return result; } // @pymethod |PyIEnumBackgroundCopyJobs|Skip|Skips over the next specified elementes. PyObject *PyIEnumBackgroundCopyJobs::Skip(PyObject *self, PyObject *args) { long celt; if ( !PyArg_ParseTuple(args, "l:Skip", &celt) ) return NULL; IEnumBackgroundCopyJobs *pIEnumBackgroundCopyJobs = GetI(self); if ( pIEnumBackgroundCopyJobs == NULL ) return NULL; PY_INTERFACE_PRECALL; HRESULT hr = pIEnumBackgroundCopyJobs->Skip(celt); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIEnumBackgroundCopyJobs, IID_IEnumBackgroundCopyJobs); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIEnumBackgroundCopyJobs|Reset|Resets the enumeration sequence to the beginning. PyObject *PyIEnumBackgroundCopyJobs::Reset(PyObject *self, PyObject *args) { if ( !PyArg_ParseTuple(args, ":Reset") ) return NULL; IEnumBackgroundCopyJobs *pIEnumBackgroundCopyJobs = GetI(self); if ( pIEnumBackgroundCopyJobs == NULL ) return NULL; PY_INTERFACE_PRECALL; HRESULT hr = pIEnumBackgroundCopyJobs->Reset(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIEnumBackgroundCopyJobs, IID_IEnumBackgroundCopyJobs); Py_INCREF(Py_None); return Py_None; } // @pymethod <o PyIEnumBackgroundCopyJobs>|PyIEnumBackgroundCopyJobs|Clone|Creates another enumerator that contains the same enumeration state as the current one PyObject *PyIEnumBackgroundCopyJobs::Clone(PyObject *self, PyObject *args) { if ( !PyArg_ParseTuple(args, ":Clone") ) return NULL; IEnumBackgroundCopyJobs *pIEnumBackgroundCopyJobs = GetI(self); if ( pIEnumBackgroundCopyJobs == NULL ) return NULL; IEnumBackgroundCopyJobs *pClone; PY_INTERFACE_PRECALL; HRESULT hr = pIEnumBackgroundCopyJobs->Clone(&pClone); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIEnumBackgroundCopyJobs, IID_IEnumBackgroundCopyJobs); return PyCom_PyObjectFromIUnknown(pClone, IID_IEnumBackgroundCopyJobs, FALSE); } // @object PyIEnumBackgroundCopyJobs|A Python interface to IEnumBackgroundCopyJobs static struct PyMethodDef PyIEnumBackgroundCopyJobs_methods[] = { { "Next", PyIEnumBackgroundCopyJobs::Next, 1 }, // @pymeth Next|Retrieves a specified number of items in the enumeration sequence. { "Skip", PyIEnumBackgroundCopyJobs::Skip, 1 }, // @pymeth Skip|Skips over the next specified elementes. { "Reset", PyIEnumBackgroundCopyJobs::Reset, 1 }, // @pymeth Reset|Resets the enumeration sequence to the beginning. { "Clone", PyIEnumBackgroundCopyJobs::Clone, 1 }, // @pymeth Clone|Creates another enumerator that contains the same enumeration state as the current one. { NULL } }; PyComTypeObject PyIEnumBackgroundCopyJobs::type("PyIEnumBackgroundCopyJobs", &PyIUnknown::type, sizeof(PyIEnumBackgroundCopyJobs), PyIEnumBackgroundCopyJobs_methods, GET_PYCOM_CTOR(PyIEnumBackgroundCopyJobs)); --- NEW FILE: PyIBackgroundCopyManager.cpp --- // This file implements the IBackgroundCopyManager Interface for Python. // Generated by makegw.py #include "bits_pch.h" #include "PyIBackgroundCopyManager.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIBackgroundCopyManager::PyIBackgroundCopyManager(IUnknown *pdisp): PyIUnknown(pdisp) { ob_type = &type; } PyIBackgroundCopyManager::~PyIBackgroundCopyManager() { } /* static */ IBackgroundCopyManager *PyIBackgroundCopyManager::GetI(PyObject *self) { return (IBackgroundCopyManager *)PyIUnknown::GetI(self); } // @pymethod |PyIBackgroundCopyManager|CreateJob|Description of CreateJob. PyObject *PyIBackgroundCopyManager::CreateJob(PyObject *self, PyObject *args) { IBackgroundCopyManager *pIBCM = GetI(self); if ( pIBCM == NULL ) return NULL; // @pyparm <o unicode>|DisplayName||Description for DisplayName BG_JOB_TYPE Type; // PyObject *obType; // @pyparm int|Type||Job Type (See BG_JOB_TYPE_*) GUID pJobId; PyObject *obDisplayName; LPWSTR DisplayName; IBackgroundCopyJob * ppJob; if ( !PyArg_ParseTuple(args, "Ol:CreateJob", &obDisplayName, &Type) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyWinObject_AsBstr(obDisplayName, &DisplayName)) bPythonIsHappy = FALSE; //if (bPythonIsHappy && !PyObject_AsBG_JOB_TYPE( obType, Type )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCM->CreateJob( DisplayName, Type, &pJobId, &ppJob ); SysFreeString(DisplayName); // PyObject_FreeBG_JOB_TYPE(Type); // PyObject_FreeGUID *(pJobId); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCM, IID_IBackgroundCopyManager ); PyObject *obppJob; obppJob = PyCom_PyObjectFromIUnknown(ppJob, IID_IBackgroundCopyJob, FALSE); PyObject *pyretval = Py_BuildValue("O", obppJob); Py_XDECREF(obppJob); return pyretval; } // @pymethod |PyIBackgroundCopyManager|GetJob|Description of GetJob. PyObject *PyIBackgroundCopyManager::GetJob(PyObject *self, PyObject *args) { IBackgroundCopyManager *pIBCM = GetI(self); if ( pIBCM == NULL ) return NULL; // @pyparm <o PyIID>|jobID||Description for jobID PyObject *objobID; IID jobID; IBackgroundCopyJob * ppJob; if ( !PyArg_ParseTuple(args, "O:GetJob", &objobID) ) return NULL; BOOL bPythonIsHappy = TRUE; if (!PyWinObject_AsIID(objobID, &jobID)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCM->GetJob( jobID, &ppJob ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCM, IID_IBackgroundCopyManager ); PyObject *obppJob; obppJob = PyCom_PyObjectFromIUnknown(ppJob, IID_IBackgroundCopyJob, FALSE); PyObject *pyretval = Py_BuildValue("O", obppJob); Py_XDECREF(obppJob); return pyretval; } // @pymethod |PyIBackgroundCopyManager|EnumJobs|Description of EnumJobs. PyObject *PyIBackgroundCopyManager::EnumJobs(PyObject *self, PyObject *args) { IBackgroundCopyManager *pIBCM = GetI(self); if ( pIBCM == NULL ) return NULL; // @pyparm int|dwFlags||Description for dwFlags DWORD dwFlags; IEnumBackgroundCopyJobs * ppEnum; if ( !PyArg_ParseTuple(args, "l:EnumJobs", &dwFlags) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCM->EnumJobs( dwFlags, &ppEnum ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCM, IID_IBackgroundCopyManager ); PyObject *obppEnum; obppEnum = PyCom_PyObjectFromIUnknown(ppEnum, IID_IEnumBackgroundCopyJobs, FALSE); PyObject *pyretval = Py_BuildValue("O", obppEnum); Py_XDECREF(obppEnum); return pyretval; } // @pymethod |PyIBackgroundCopyManager|GetErrorDescription|Description of GetErrorDescription. PyObject *PyIBackgroundCopyManager::GetErrorDescription(PyObject *self, PyObject *args) { IBackgroundCopyManager *pIBCM = GetI(self); if ( pIBCM == NULL ) return NULL; // @pyparm int|hResult||Description for hResult // @pyparm int|LanguageId||Description for LanguageId WCHAR* pszErrorDescription; PyObject *obpErrorDescription; HRESULT hResult; DWORD LanguageId; if ( !PyArg_ParseTuple(args, "ll:GetErrorDescription", &hResult, &LanguageId) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCM->GetErrorDescription( hResult, LanguageId, &pszErrorDescription ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCM, IID_IBackgroundCopyManager ); obpErrorDescription = PyWinObject_FromWCHAR(pszErrorDescription); return obpErrorDescription; } // @object PyIBackgroundCopyManager|Description of the interface static struct PyMethodDef PyIBackgroundCopyManager_methods[] = { { "CreateJob", PyIBackgroundCopyManager::CreateJob, 1 }, // @pymeth CreateJob|Description of CreateJob { "GetJob", PyIBackgroundCopyManager::GetJob, 1 }, // @pymeth GetJob|Description of GetJob { "EnumJobs", PyIBackgroundCopyManager::EnumJobs, 1 }, // @pymeth EnumJobs|Description of EnumJobs { "GetErrorDescription", PyIBackgroundCopyManager::GetErrorDescription, 1 }, // @pymeth GetErrorDescription|Description of GetErrorDescription { NULL } }; PyComTypeObject PyIBackgroundCopyManager::type("PyIBackgroundCopyManager", &PyIUnknown::type, sizeof(PyIBackgroundCopyManager), PyIBackgroundCopyManager_methods, GET_PYCOM_CTOR(PyIBackgroundCopyManager)); --- NEW FILE: PyIBackgroundCopyError.cpp --- // This file implements the IBackgroundCopyError Interface for Python. // Generated by makegw.py #include "shell_pch.h" #include "PyIBackgroundCopyError.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIBackgroundCopyError::PyIBackgroundCopyError(IUnknown *pdisp): PyIUnknown(pdisp) { ob_type = &type; } PyIBackgroundCopyError::~PyIBackgroundCopyError() { } /* static */ IBackgroundCopyError *PyIBackgroundCopyError::GetI(PyObject *self) { return (IBackgroundCopyError *)PyIUnknown::GetI(self); } // @pymethod |PyIBackgroundCopyError|GetError|Description of GetError. PyObject *PyIBackgroundCopyError::GetError(PyObject *self, PyObject *args) { IBackgroundCopyError *pIBCE = GetI(self); if ( pIBCE == NULL ) return NULL; // *** The input argument pContext of type "BG_ERROR_CONTEXT *" was not processed *** // Please check the conversion function is appropriate and exists! BG_ERROR_CONTEXT * pContext; PyObject *obpContext; // @pyparm <o PyBG_ERROR_CONTEXT *>|pContext||Description for pContext // *** The input argument pCode of type "HRESULT *" was not processed *** // Please check the conversion function is appropriate and exists! HRESULT * pCode; PyObject *obpCode; // @pyparm <o PyHRESULT *>|pCode||Description for pCode if ( !PyArg_ParseTuple(args, "OO:GetError", &obpContext, &obpCode) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsBG_ERROR_CONTEXT *( obpContext, &pContext )) bPythonIsHappy = FALSE; if (bPythonIsHappy && !PyObject_AsHRESULT *( obpCode, &pCode )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCE->GetError( pContext, pCode ); PyObject_FreeBG_ERROR_CONTEXT *(pContext); PyObject_FreeHRESULT *(pCode); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); // *** The output argument pContext of type "BG_ERROR_CONTEXT *" was not processed *** // The type 'BG_ERROR_CONTEXT *' (pContext) is unknown. // *** The output argument pCode of type "HRESULT *" was not processed *** // The type 'HRESULT *' (pCode) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyError|GetFile|Description of GetFile. PyObject *PyIBackgroundCopyError::GetFile(PyObject *self, PyObject *args) { IBackgroundCopyError *pIBCE = GetI(self); if ( pIBCE == NULL ) return NULL; IBackgroundCopyFile ** * pVal; if ( !PyArg_ParseTuple(args, ":GetFile") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCE->GetFile( *pVal ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); PyObject *obpVal; obpVal = PyCom_PyObjectFromIUnknown(pVal, IID_IBackgroundCopyFile **, FALSE); PyObject *pyretval = Py_BuildValue("O", obpVal); Py_XDECREF(obpVal); return pyretval; } // @pymethod |PyIBackgroundCopyError|GetErrorDescription|Description of GetErrorDescription. PyObject *PyIBackgroundCopyError::GetErrorDescription(PyObject *self, PyObject *args) { IBackgroundCopyError *pIBCE = GetI(self); if ( pIBCE == NULL ) return NULL; // @pyparm int|LanguageId||Description for LanguageId // *** The input argument pErrorDescription of type "LPWSTR *" was not processed *** // Please check the conversion function is appropriate and exists! LPWSTR * pErrorDescription; PyObject *obpErrorDescription; // @pyparm <o PyLPWSTR *>|pErrorDescription||Description for pErrorDescription DWORD LanguageId; if ( !PyArg_ParseTuple(args, "lO:GetErrorDescription", &LanguageId, &obpErrorDescription) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsLPWSTR *( obpErrorDescription, &pErrorDescription )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCE->GetErrorDescription( LanguageId, pErrorDescription ); PyObject_FreeLPWSTR *(pErrorDescription); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); // *** The output argument pErrorDescription of type "LPWSTR *" was not processed *** // The type 'LPWSTR *' (pErrorDescription) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyError|GetErrorContextDescription|Description of GetErrorContextDescription. PyObject *PyIBackgroundCopyError::GetErrorContextDescription(PyObject *self, PyObject *args) { IBackgroundCopyError *pIBCE = GetI(self); if ( pIBCE == NULL ) return NULL; // @pyparm int|LanguageId||Description for LanguageId // *** The input argument pContextDescription of type "LPWSTR *" was not processed *** // Please check the conversion function is appropriate and exists! LPWSTR * pContextDescription; PyObject *obpContextDescription; // @pyparm <o PyLPWSTR *>|pContextDescription||Description for pContextDescription DWORD LanguageId; if ( !PyArg_ParseTuple(args, "lO:GetErrorContextDescription", &LanguageId, &obpContextDescription) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsLPWSTR *( obpContextDescription, &pContextDescription )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCE->GetErrorContextDescription( LanguageId, pContextDescription ); PyObject_FreeLPWSTR *(pContextDescription); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); // *** The output argument pContextDescription of type "LPWSTR *" was not processed *** // The type 'LPWSTR *' (pContextDescription) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyError|GetProtocol|Description of GetProtocol. PyObject *PyIBackgroundCopyError::GetProtocol(PyObject *self, PyObject *args) { IBackgroundCopyError *pIBCE = GetI(self); if ( pIBCE == NULL ) return NULL; // *** The input argument pProtocol of type "LPWSTR *" was not processed *** // Please check the conversion function is appropriate and exists! LPWSTR * pProtocol; PyObject *obpProtocol; // @pyparm <o PyLPWSTR *>|pProtocol||Description for pProtocol if ( !PyArg_ParseTuple(args, "O:GetProtocol", &obpProtocol) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsLPWSTR *( obpProtocol, &pProtocol )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCE->GetProtocol( pProtocol ); PyObject_FreeLPWSTR *(pProtocol); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCE, IID_IBackgroundCopyError ); // *** The output argument pProtocol of type "LPWSTR *" was not processed *** // The type 'LPWSTR *' (pProtocol) is unknown. Py_INCREF(Py_None); return Py_None; } // @object PyIBackgroundCopyError|Description of the interface static struct PyMethodDef PyIBackgroundCopyError_methods[] = { { "GetError", PyIBackgroundCopyError::GetError, 1 }, // @pymeth GetError|Description of GetError { "GetFile", PyIBackgroundCopyError::GetFile, 1 }, // @pymeth GetFile|Description of GetFile { "GetErrorDescription", PyIBackgroundCopyError::GetErrorDescription, 1 }, // @pymeth GetErrorDescription|Description of GetErrorDescription { "GetErrorContextDescription", PyIBackgroundCopyError::GetErrorContextDescription, 1 }, // @pymeth GetErrorContextDescription|Description of GetErrorContextDescription { "GetProtocol", PyIBackgroundCopyError::GetProtocol, 1 }, // @pymeth GetProtocol|Description of GetProtocol { NULL } }; PyComTypeObject PyIBackgroundCopyError::type("PyIBackgroundCopyError", &PyIUnknown::type, sizeof(PyIBackgroundCopyError), PyIBackgroundCopyError_methods, GET_PYCOM_CTOR(PyIBackgroundCopyError)); --- NEW FILE: PyIEnumBackgroundCopyFiles.h --- // This file declares the IEnumBackgroundCopyFiles Interface for Python. // Generated by makegw.py // --------------------------------------------------- // // Interface Declaration #include "Bits.h" #include "PythonCOM.h" class PyIEnumBackgroundCopyFiles : public PyIUnknown { public: MAKE_PYCOM_CTOR(PyIEnumBackgroundCopyFiles); static IEnumBackgroundCopyFiles *GetI(PyObject *self); static PyComTypeObject type; // The Python methods static PyObject *Next(PyObject *self, PyObject *args); static PyObject *Skip(PyObject *self, PyObject *args); static PyObject *Reset(PyObject *self, PyObject *args); static PyObject *Clone(PyObject *self, PyObject *args); static PyObject *GetCount(PyObject *self, PyObject *args); protected: PyIEnumBackgroundCopyFiles(IUnknown *pdisp); ~PyIEnumBackgroundCopyFiles(); }; --- NEW FILE: PyIBackgroundCopyFile.h --- // This file declares the IBackgroundCopyFile Interface for Python. // Generated by makegw.py // --------------------------------------------------- // // Interface Declaration #include "Bits.h" #include "PythonCOM.h" class PyIBackgroundCopyFile : public PyIUnknown { public: MAKE_PYCOM_CTOR(PyIBackgroundCopyFile); static IBackgroundCopyFile *GetI(PyObject *self); static PyComTypeObject type; // The Python methods static PyObject *GetRemoteName(PyObject *self, PyObject *args); static PyObject *GetLocalName(PyObject *self, PyObject *args); static PyObject *GetProgress(PyObject *self, PyObject *args); protected: PyIBackgroundCopyFile(IUnknown *pdisp); ~PyIBackgroundCopyFile(); }; --- NEW FILE: bits_pch.h --- // bits_pch.h : header file for PCH generation for the BITS COM extension #include <Bits.h> #include <Python.h> #include <PythonCOM.h> BOOL PyObject_AsULONG(PyObject *ob, ULONG *ul); void PyObject_FreeULONG(ULONG *ul); BOOL PyObject_AsULONG_LIST(PyObject *ob, ULONG **ul); void PyObject_FreeULONG_LIST(ULONG *ul); BOOL PyObject_AsWCHAR_LIST(PyObject *ob, WCHAR **wch); void PyObject_FreeWCHAR_LIST(WCHAR *wch); BOOL PyObject_AsconstWCHAR_LIST(PyObject *ob, const WCHAR **wch); void PyObject_FreeconstWCHAR_LIST(const WCHAR *wch); BOOL PyObject_AsGUID(PyObject *ob, GUID *guid); void PyObject_FreeGUID(GUID *guid); BOOL PyObject_AsLPWSTR(PyObject *ob, LPWSTR *lpw); void PyObject_FreeLPWSTR(LPWSTR *lpw); BOOL PyObject_AsLPWSTR_LIST(PyObject *ob, LPWSTR **lpw); void PyObject_FreeLPWSTR_LIST(LPWSTR *lpw); BOOL PyObject_AsBG_FILE_INFO(PyObject *ob, BG_FILE_INFO *fi); void PyObject_FreeBG_FILE_INFO(BG_FILE_INFO *fi); BOOL PyObject_AsBG_FILE_INFO_LIST(PyObject *ob, BG_FILE_INFO **fi); void PyObject_FreeBG_FILE_INFO_LIST(BG_FILE_INFO *fi); BOOL PyObject_AsBG_FILE_PROGRESS(PyObject *ob, BG_FILE_PROGRESS *fi); void PyObject_FreeBG_FILE_PROGRESS(BG_FILE_PROGRESS *fi); BOOL PyObject_AsBG_FILE_PROGRESS_LIST(PyObject *ob, BG_FILE_PROGRESS **fi); void PyObject_FreeBG_FILE_PROGRESS_LIST(BG_FILE_PROGRESS *fi); BOOL PyObject_AsBG_JOB_STATE(PyObject *ob, BG_JOB_STATE *js); void PyObject_FreeBG_JOB_STATE(BG_JOB_STATE *js); BOOL PyObject_AsBG_JOB_STATE_LIST(PyObject *ob, BG_JOB_STATE **js); void PyObject_FreeBG_JOB_STATE_LIST(BG_JOB_STATE *js); BOOL PyObject_AsBG_JOB_PROGRESS(PyObject *ob, BG_JOB_PROGRESS *jp); void PyObject_FreeBG_JOB_PROGRESS(BG_JOB_PROGRESS *jp); BOOL PyObject_AsBG_JOB_PROGRESS_LIST(PyObject *ob, BG_JOB_PROGRESS **jp); void PyObject_FreeBG_JOB_PROGRESS_LIST(BG_JOB_PROGRESS *jp); BOOL PyObject_AsBG_JOB_TYPE(PyObject *ob, BG_JOB_TYPE *jt); void PyObject_FreeBG_JOB_TYPE(BG_JOB_TYPE *jt); BOOL PyObject_AsBG_JOB_TYPE_LIST(PyObject *ob, BG_JOB_TYPE **jt); void PyObject_FreeBG_JOB_TYPE_LIST(BG_JOB_TYPE *jt); BOOL PyObject_AsBG_JOB_TIMES(PyObject *ob, BG_JOB_TIMES *jt); void PyObject_FreeBG_JOB_TIMES(BG_JOB_TIMES *jt); BOOL PyObject_AsBG_JOB_TIMES_LIST(PyObject *ob, BG_JOB_TIMES **jt); void PyObject_FreeBG_JOB_TIMES_LIST(BG_JOB_TIMES *jt); BOOL PyObject_AsBG_JOB_PRIORITY(PyObject *ob, BG_JOB_PRIORITY *jp); void PyObject_FreeBG_JOB_PRIORITY(BG_JOB_PRIORITY jp); BOOL PyObject_AsBG_JOB_PRIORITY_LIST(PyObject *ob, BG_JOB_PRIORITY **jp); void PyObject_FreeBG_JOB_PRIORITY_LIST(BG_JOB_PRIORITY *jp); BOOL PyObject_AsBG_JOB_PROXY_USAGE(PyObject *ob, BG_JOB_PROXY_USAGE *jp); void PyObject_FreeBG_JOB_PROXY_USAGE(BG_JOB_PROXY_USAGE jp); BOOL PyObject_AsBG_JOB_PROXY_USAGE_LIST(PyObject *ob, BG_JOB_PROXY_USAGE **jp); void PyObject_FreeBG_JOB_PROXY_USAGE_LIST(BG_JOB_PROXY_USAGE *jp); --- NEW FILE: PyIBackgroundCopyJob.h --- // This file declares the IBackgroundCopyJob Interface for Python. // Generated by makegw.py // --------------------------------------------------- // // Interface Declaration #include "Bits.h" #include "PythonCOM.h" class PyIBackgroundCopyJob : public PyIUnknown { public: MAKE_PYCOM_CTOR(PyIBackgroundCopyJob); static IBackgroundCopyJob *GetI(PyObject *self); static PyComTypeObject type; // The Python methods static PyObject *AddFileSet(PyObject *self, PyObject *args); static PyObject *AddFile(PyObject *self, PyObject *args); static PyObject *EnumFiles(PyObject *self, PyObject *args); static PyObject *Suspend(PyObject *self, PyObject *args); static PyObject *Resume(PyObject *self, PyObject *args); static PyObject *Cancel(PyObject *self, PyObject *args); static PyObject *Complete(PyObject *self, PyObject *args); static PyObject *GetId(PyObject *self, PyObject *args); static PyObject *GetType(PyObject *self, PyObject *args); static PyObject *GetProgress(PyObject *self, PyObject *args); static PyObject *GetTimes(PyObject *self, PyObject *args); static PyObject *GetState(PyObject *self, PyObject *args); static PyObject *GetError(PyObject *self, PyObject *args); static PyObject *GetOwner(PyObject *self, PyObject *args); static PyObject *SetDisplayName(PyObject *self, PyObject *args); static PyObject *GetDisplayName(PyObject *self, PyObject *args); static PyObject *SetDescription(PyObject *self, PyObject *args); static PyObject *GetDescription(PyObject *self, PyObject *args); static PyObject *SetPriority(PyObject *self, PyObject *args); static PyObject *GetPriority(PyObject *self, PyObject *args); static PyObject *SetNotifyFlags(PyObject *self, PyObject *args); static PyObject *GetNotifyFlags(PyObject *self, PyObject *args); static PyObject *SetNotifyInterface(PyObject *self, PyObject *args); static PyObject *GetNotifyInterface(PyObject *self, PyObject *args); static PyObject *SetMinimumRetryDelay(PyObject *self, PyObject *args); static PyObject *GetMinimumRetryDelay(PyObject *self, PyObject *args); static PyObject *SetNoProgressTimeout(PyObject *self, PyObject *args); static PyObject *GetNoProgressTimeout(PyObject *self, PyObject *args); static PyObject *GetErrorCount(PyObject *self, PyObject *args); static PyObject *SetProxySettings(PyObject *self, PyObject *args); static PyObject *GetProxySettings(PyObject *self, PyObject *args); static PyObject *TakeOwnership(PyObject *self, PyObject *args); protected: PyIBackgroundCopyJob(IUnknown *pdisp); ~PyIBackgroundCopyJob(); }; --- NEW FILE: PyIBackgroundCopyJob.cpp --- // This file implements the IBackgroundCopyJob Interface for Python. // Generated by makegw.py #include "bits_pch.h" #include "PyIBackgroundCopyJob.h" // @doc - This file contains autoduck documentation // --------------------------------------------------- // // Interface Implementation PyIBackgroundCopyJob::PyIBackgroundCopyJob(IUnknown *pdisp): PyIUnknown(pdisp) { ob_type = &type; } PyIBackgroundCopyJob::~PyIBackgroundCopyJob() { } /* static */ IBackgroundCopyJob *PyIBackgroundCopyJob::GetI(PyObject *self) { return (IBackgroundCopyJob *)PyIUnknown::GetI(self); } // @pymethod |PyIBackgroundCopyJob|AddFileSet|Description of AddFileSet. PyObject *PyIBackgroundCopyJob::AddFileSet(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // @pyparm int|cFileCount||Description for cFileCount // *** The input argument pFileSet of type "BG_FILE_INFO *" was not processed *** // Please check the conversion function is appropriate and exists! BG_FILE_INFO *pFileSet; PyObject *obpFileSet; // @pyparm <o PyBG_FILE_INFO *>|pFileSet||Description for pFileSet ULONG cFileCount; if ( !PyArg_ParseTuple(args, "lO:AddFileSet", &cFileCount, &obpFileSet) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsBG_FILE_INFO_LIST( obpFileSet, &pFileSet )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->AddFileSet( cFileCount, pFileSet ); PyObject_FreeBG_FILE_INFO_LIST(pFileSet); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|AddFile|Description of AddFile. PyObject *PyIBackgroundCopyJob::AddFile(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // @pyparm <o unicode>|RemoteUrl||Description for RemoteUrl // @pyparm <o unicode>|LocalName||Description for LocalName PyObject *obRemoteUrl; PyObject *obLocalName; LPWSTR RemoteUrl; LPWSTR LocalName; if ( !PyArg_ParseTuple(args, "OO:AddFile", &obRemoteUrl, &obLocalName) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyWinObject_AsBstr(obRemoteUrl, &RemoteUrl)) bPythonIsHappy = FALSE; if (bPythonIsHappy && !PyWinObject_AsBstr(obLocalName, &LocalName)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->AddFile( RemoteUrl, LocalName ); SysFreeString(RemoteUrl); SysFreeString(LocalName); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|EnumFiles|Description of EnumFiles. PyObject *PyIBackgroundCopyJob::EnumFiles(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; IEnumBackgroundCopyFiles *pEnum; if ( !PyArg_ParseTuple(args, ":EnumFiles") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->EnumFiles( &pEnum ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); PyObject *obpEnum; obpEnum = PyCom_PyObjectFromIUnknown(pEnum, IID_IEnumBackgroundCopyFiles, FALSE); PyObject *pyretval = Py_BuildValue("O", obpEnum); Py_XDECREF(obpEnum); return pyretval; } // @pymethod |PyIBackgroundCopyJob|Suspend|Description of Suspend. PyObject *PyIBackgroundCopyJob::Suspend(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":Suspend") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->Suspend( ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|Resume|Description of Resume. PyObject *PyIBackgroundCopyJob::Resume(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":Resume") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->Resume( ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|Cancel|Description of Cancel. PyObject *PyIBackgroundCopyJob::Cancel(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":Cancel") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->Cancel( ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|Complete|Description of Complete. PyObject *PyIBackgroundCopyJob::Complete(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":Complete") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->Complete( ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|GetId|Description of GetId. PyObject *PyIBackgroundCopyJob::GetId(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; GUID pVal; PyObject *obpVal; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetId( &pVal ); // PyObject_FreeGUID(pVal); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); obpVal = PyWinObject_FromIID(pVal); return obpVal; } // @pymethod |PyIBackgroundCopyJob|GetType|Description of GetType. PyObject *PyIBackgroundCopyJob::GetType(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // *** The input argument pVal of type "BG_JOB_TYPE *" was not processed *** // Please check the conversion function is appropriate and exists! BG_JOB_TYPE * pVal; PyObject *obpVal; // @pyparm <o PyBG_JOB_TYPE *>|pVal||Description for pVal if ( !PyArg_ParseTuple(args, "O:GetType", &obpVal) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsBG_JOB_TYPE_LIST( obpVal, &pVal )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetType( pVal ); PyObject_FreeBG_JOB_TYPE_LIST(pVal); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); // *** The output argument pVal of type "BG_JOB_TYPE *" was not processed *** // The type 'BG_JOB_TYPE *' (pVal) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|GetProgress|Description of GetProgress. PyObject *PyIBackgroundCopyJob::GetProgress(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // *** The input argument pVal of type "BG_JOB_PROGRESS *" was not processed *** // Please check the conversion function is appropriate and exists! BG_JOB_PROGRESS * pVal; PyObject *obpVal; // @pyparm <o PyBG_JOB_PROGRESS *>|pVal||Description for pVal if ( !PyArg_ParseTuple(args, "O:GetProgress", &obpVal) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsBG_JOB_PROGRESS_LIST( obpVal, &pVal )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetProgress( pVal ); PyObject_FreeBG_JOB_PROGRESS_LIST(pVal); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); // *** The output argument pVal of type "BG_JOB_PROGRESS *" was not processed *** // The type 'BG_JOB_PROGRESS *' (pVal) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|GetTimes|Description of GetTimes. PyObject *PyIBackgroundCopyJob::GetTimes(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // *** The input argument pVal of type "BG_JOB_TIMES *" was not processed *** // Please check the conversion function is appropriate and exists! BG_JOB_TIMES * pVal; PyObject *obpVal; // @pyparm <o PyBG_JOB_TIMES *>|pVal||Description for pVal if ( !PyArg_ParseTuple(args, "O:GetTimes", &obpVal) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsBG_JOB_TIMES_LIST( obpVal, &pVal )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetTimes( pVal ); PyObject_FreeBG_JOB_TIMES_LIST(pVal); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); // *** The output argument pVal of type "BG_JOB_TIMES *" was not processed *** // The type 'BG_JOB_TIMES *' (pVal) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|GetState|Description of GetState. PyObject *PyIBackgroundCopyJob::GetState(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; if ( !PyArg_ParseTuple(args, ":GetState") ) return NULL; BG_JOB_STATE pVal; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetState( &pVal ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); return PyLong_FromLong((long)pVal); } // @pymethod |PyIBackgroundCopyJob|GetError|Description of GetError. PyObject *PyIBackgroundCopyJob::GetError(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; IBackgroundCopyError * ppError; if ( !PyArg_ParseTuple(args, ":GetError") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetError( &ppError ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); PyObject *obppError; obppError = PyCom_PyObjectFromIUnknown(ppError, IID_IBackgroundCopyError, FALSE); PyObject *pyretval = Py_BuildValue("O", obppError); Py_XDECREF(obppError); return pyretval; } // @pymethod |PyIBackgroundCopyJob|GetOwner|Description of GetOwner. PyObject *PyIBackgroundCopyJob::GetOwner(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // *** The input argument pVal of type "LPWSTR *" was not processed *** // Please check the conversion function is appropriate and exists! LPWSTR * pVal; PyObject *obpVal; // @pyparm <o PyLPWSTR *>|pVal||Description for pVal if ( !PyArg_ParseTuple(args, "O:GetOwner", &obpVal) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsLPWSTR_LIST( obpVal, &pVal )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetOwner( pVal ); PyObject_FreeLPWSTR_LIST(pVal); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); // *** The output argument pVal of type "LPWSTR *" was not processed *** // The type 'LPWSTR *' (pVal) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|SetDisplayName|Description of SetDisplayName. PyObject *PyIBackgroundCopyJob::SetDisplayName(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // @pyparm <o unicode>|Val||Description for Val PyObject *obVal; LPWSTR Val; if ( !PyArg_ParseTuple(args, "O:SetDisplayName", &obVal) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyWinObject_AsBstr(obVal, &Val)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->SetDisplayName( Val ); SysFreeString(Val); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|GetDisplayName|Description of GetDisplayName. PyObject *PyIBackgroundCopyJob::GetDisplayName(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // *** The input argument pVal of type "LPWSTR *" was not processed *** // Please check the conversion function is appropriate and exists! LPWSTR * pVal; PyObject *obpVal; // @pyparm <o PyLPWSTR *>|pVal||Description for pVal if ( !PyArg_ParseTuple(args, "O:GetDisplayName", &obpVal) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsLPWSTR_LIST( obpVal, &pVal )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetDisplayName( pVal ); PyObject_FreeLPWSTR_LIST(pVal); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); // *** The output argument pVal of type "LPWSTR *" was not processed *** // The type 'LPWSTR *' (pVal) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|SetDescription|Description of SetDescription. PyObject *PyIBackgroundCopyJob::SetDescription(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // @pyparm <o unicode>|Val||Description for Val PyObject *obVal; LPWSTR Val; if ( !PyArg_ParseTuple(args, "O:SetDescription", &obVal) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyWinObject_AsBstr(obVal, &Val)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->SetDescription( Val ); SysFreeString(Val); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|GetDescription|Description of GetDescription. PyObject *PyIBackgroundCopyJob::GetDescription(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // *** The input argument pVal of type "LPWSTR *" was not processed *** // Please check the conversion function is appropriate and exists! LPWSTR * pVal; PyObject *obpVal; // @pyparm <o PyLPWSTR *>|pVal||Description for pVal if ( !PyArg_ParseTuple(args, "O:GetDescription", &obpVal) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsLPWSTR_LIST( obpVal, &pVal )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetDescription( pVal ); PyObject_FreeLPWSTR_LIST(pVal); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); // *** The output argument pVal of type "LPWSTR *" was not processed *** // The type 'LPWSTR *' (pVal) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|SetPriority|Description of SetPriority. PyObject *PyIBackgroundCopyJob::SetPriority(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // *** The input argument Val of type "BG_JOB_PRIORITY" was not processed *** // Please check the conversion function is appropriate and exists! BG_JOB_PRIORITY Val; PyObject *obVal; // @pyparm <o PyBG_JOB_PRIORITY>|Val||Description for Val if ( !PyArg_ParseTuple(args, "O:SetPriority", &obVal) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsBG_JOB_PRIORITY( obVal, &Val )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->SetPriority( Val ); PyObject_FreeBG_JOB_PRIORITY(Val); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|GetPriority|Description of GetPriority. PyObject *PyIBackgroundCopyJob::GetPriority(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // *** The input argument pVal of type "BG_JOB_PRIORITY *" was not processed *** // Please check the conversion function is appropriate and exists! BG_JOB_PRIORITY * pVal; PyObject *obpVal; // @pyparm <o PyBG_JOB_PRIORITY *>|pVal||Description for pVal if ( !PyArg_ParseTuple(args, "O:GetPriority", &obpVal) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsBG_JOB_PRIORITY_LIST( obpVal, &pVal )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetPriority( pVal ); PyObject_FreeBG_JOB_PRIORITY_LIST(pVal); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); // *** The output argument pVal of type "BG_JOB_PRIORITY *" was not processed *** // The type 'BG_JOB_PRIORITY *' (pVal) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|SetNotifyFlags|Description of SetNotifyFlags. PyObject *PyIBackgroundCopyJob::SetNotifyFlags(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // @pyparm int|Val||Description for Val ULONG Val; if ( !PyArg_ParseTuple(args, "l:SetNotifyFlags", &Val) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->SetNotifyFlags( Val ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|GetNotifyFlags|Description of GetNotifyFlags. PyObject *PyIBackgroundCopyJob::GetNotifyFlags(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // *** The input argument pVal of type "ULONG *" was not processed *** // Please check the conversion function is appropriate and exists! ULONG * pVal; PyObject *obpVal; // @pyparm <o PyULONG *>|pVal||Description for pVal if ( !PyArg_ParseTuple(args, "O:GetNotifyFlags", &obpVal) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsULONG_LIST( obpVal, &pVal )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetNotifyFlags( pVal ); PyObject_FreeULONG_LIST(pVal); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); // *** The output argument pVal of type "ULONG *" was not processed *** // The type 'ULONG *' (pVal) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|SetNotifyInterface|Description of SetNotifyInterface. PyObject *PyIBackgroundCopyJob::SetNotifyInterface(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // @pyparm <o PyIUnknown *>|Val||Description for Val PyObject *obVal; IUnknown *Val; if ( !PyArg_ParseTuple(args, "O:SetNotifyInterface", &obVal) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyCom_InterfaceFromPyInstanceOrObject(obVal, IID_IUnknown, (void **)&Val, TRUE /* bNoneOK */)) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->SetNotifyInterface( Val ); if (Val) Val->Release(); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|GetNotifyInterface|Description of GetNotifyInterface. PyObject *PyIBackgroundCopyJob::GetNotifyInterface(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; IUnknown * pVal; if ( !PyArg_ParseTuple(args, ":GetNotifyInterface") ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetNotifyInterface( &pVal ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); PyObject *obpVal; obpVal = PyCom_PyObjectFromIUnknown(pVal, IID_IUnknown, FALSE); PyObject *pyretval = Py_BuildValue("O", obpVal); Py_XDECREF(obpVal); return pyretval; } // @pymethod |PyIBackgroundCopyJob|SetMinimumRetryDelay|Description of SetMinimumRetryDelay. PyObject *PyIBackgroundCopyJob::SetMinimumRetryDelay(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // @pyparm int|Seconds||Description for Seconds ULONG Seconds; if ( !PyArg_ParseTuple(args, "l:SetMinimumRetryDelay", &Seconds) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->SetMinimumRetryDelay( Seconds ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|GetMinimumRetryDelay|Description of GetMinimumRetryDelay. PyObject *PyIBackgroundCopyJob::GetMinimumRetryDelay(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // *** The input argument Seconds of type "ULONG *" was not processed *** // Please check the conversion function is appropriate and exists! ULONG * Seconds; PyObject *obSeconds; // @pyparm <o PyULONG *>|Seconds||Description for Seconds if ( !PyArg_ParseTuple(args, "O:GetMinimumRetryDelay", &obSeconds) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsULONG_LIST( obSeconds, &Seconds )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetMinimumRetryDelay( Seconds ); PyObject_FreeULONG_LIST(Seconds); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); // *** The output argument Seconds of type "ULONG *" was not processed *** // The type 'ULONG *' (Seconds) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|SetNoProgressTimeout|Description of SetNoProgressTimeout. PyObject *PyIBackgroundCopyJob::SetNoProgressTimeout(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // @pyparm int|Seconds||Description for Seconds ULONG Seconds; if ( !PyArg_ParseTuple(args, "l:SetNoProgressTimeout", &Seconds) ) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->SetNoProgressTimeout( Seconds ); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|GetNoProgressTimeout|Description of GetNoProgressTimeout. PyObject *PyIBackgroundCopyJob::GetNoProgressTimeout(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // *** The input argument Seconds of type "ULONG *" was not processed *** // Please check the conversion function is appropriate and exists! ULONG * Seconds; PyObject *obSeconds; // @pyparm <o PyULONG *>|Seconds||Description for Seconds if ( !PyArg_ParseTuple(args, "O:GetNoProgressTimeout", &obSeconds) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsULONG_LIST( obSeconds, &Seconds )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetNoProgressTimeout( Seconds ); PyObject_FreeULONG_LIST(Seconds); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); // *** The output argument Seconds of type "ULONG *" was not processed *** // The type 'ULONG *' (Seconds) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|GetErrorCount|Description of GetErrorCount. PyObject *PyIBackgroundCopyJob::GetErrorCount(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // *** The input argument Errors of type "ULONG *" was not processed *** // Please check the conversion function is appropriate and exists! ULONG * Errors; PyObject *obErrors; // @pyparm <o PyULONG *>|Errors||Description for Errors if ( !PyArg_ParseTuple(args, "O:GetErrorCount", &obErrors) ) return NULL; BOOL bPythonIsHappy = TRUE; if (bPythonIsHappy && !PyObject_AsULONG_LIST( obErrors, &Errors )) bPythonIsHappy = FALSE; if (!bPythonIsHappy) return NULL; HRESULT hr; PY_INTERFACE_PRECALL; hr = pIBCJ->GetErrorCount( Errors ); PyObject_FreeULONG_LIST(Errors); PY_INTERFACE_POSTCALL; if ( FAILED(hr) ) return PyCom_BuildPyException(hr, pIBCJ, IID_IBackgroundCopyJob ); // *** The output argument Errors of type "ULONG *" was not processed *** // The type 'ULONG *' (Errors) is unknown. Py_INCREF(Py_None); return Py_None; } // @pymethod |PyIBackgroundCopyJob|SetProxySettings|Description of SetProxySettings. PyObject *PyIBackgroundCopyJob::SetProxySettings(PyObject *self, PyObject *args) { IBackgroundCopyJob *pIBCJ = GetI(self); if ( pIBCJ == NULL ) return NULL; // *** The input argument ProxyUsage of type "BG_JOB_PROXY_USAGE" was not processed *** // Please check the conversion function is appropriate and exists! BG_JOB_PROXY_USAGE ProxyUsage; PyObject *obProxyUsage; // @pyparm <o PyBG_JOB_PROXY_USAGE>|ProxyUsage||Description for ProxyUsage // *** The input argument ProxyList of type "const WCHAR *" was not processed *** // Please check the conversion function is appropriate and exists! const WCHAR * ProxyList; PyObject *obProxyList; // @pyparm <o Pyconst WCHAR *>|ProxyList||Description for ProxyList // *** The input argument ProxyBypassList of type "const WCHAR *" was not processed *** // Please check the conversion function is appropriate and exists! const WCHAR * ProxyBypassList; PyObject *obProxyBypassList; // @pyparm <o Pyconst WCHAR *>|ProxyBypassList||Description for Pr... [truncated message content] |