Funktionierender Prototyp des Serious Games zur Vermittlung von Wissen zu Software-Engineering-Arbeitsmodellen.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ITransferAdviseSink.py 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. # ITransferAdviseSink implementation template
  2. import pythoncom
  3. from win32com.server.policy import DesignatedWrapPolicy
  4. from win32com.shell import shell, shellcon
  5. tsf_flags = list(
  6. (k, v) for k, v in list(shellcon.__dict__.items()) if k.startswith("TSF_")
  7. )
  8. def decode_flags(flags):
  9. if flags == 0:
  10. return "TSF_NORMAL"
  11. flag_txt = ""
  12. for k, v in tsf_flags:
  13. if flags & v:
  14. if flag_txt:
  15. flag_txt = flag_txt + "|" + k
  16. else:
  17. flag_txt = k
  18. return flag_txt
  19. TRANSFER_ADVISE_STATES = {}
  20. for k, v in list(shellcon.__dict__.items()):
  21. if k.startswith("TS_"):
  22. TRANSFER_ADVISE_STATES[v] = k
  23. def decode_flags(flags):
  24. if flags == 0:
  25. return "TSF_NORMAL"
  26. flag_txt = ""
  27. for k, v in tsf_flags:
  28. if flags & v:
  29. if flag_txt:
  30. flag_txt = flag_txt + "|" + k
  31. else:
  32. flag_txt = k
  33. return flag_txt
  34. class TransferAdviseSink(DesignatedWrapPolicy):
  35. _com_interfaces_ = [shell.IID_ITransferAdviseSink]
  36. _public_methods_ = [
  37. "UpdateProgress",
  38. "UpdateTransferState",
  39. "ConfirmOverwrite",
  40. "ConfirmEncryptionLoss",
  41. "FileFailure",
  42. "SubStreamFailure",
  43. "PropertyFailure",
  44. ]
  45. def __init__(self):
  46. self._wrap_(self)
  47. def UpdateProgress(
  48. self,
  49. SizeCurrent,
  50. SizeTotal,
  51. FilesCurrent,
  52. FilesTotal,
  53. FoldersCurrent,
  54. FoldersTotal,
  55. ):
  56. print("UpdateProgress - processed so far:")
  57. print("\t %s out of %s bytes" % (SizeCurrent, SizeTotal))
  58. print("\t %s out of %s files" % (FilesCurrent, FilesTotal))
  59. print("\t %s out of %s folders" % (FoldersCurrent, FoldersTotal))
  60. def UpdateTransferState(self, State):
  61. print(
  62. "Current state: ",
  63. TRANSFER_ADVISE_STATES.get(State, "??? Unknown state %s ???" % State),
  64. )
  65. def ConfirmOverwrite(self, Source, DestParent, Name):
  66. print(
  67. "ConfirmOverwrite: ",
  68. Source.GetDisplayName(shellcon.SHGDN_FORPARSING),
  69. DestParent.GetDisplayName(shellcon.SHGDN_FORPARSING),
  70. Name,
  71. )
  72. def ConfirmEncryptionLoss(self, Source):
  73. print(
  74. "ConfirmEncryptionLoss:", Source.GetDisplayName(shellcon.SHGDN_FORPARSING)
  75. )
  76. def FileFailure(self, Item, ItemName, Error):
  77. print("FileFailure:", Item.GetDisplayName(shellcon.SHGDN_FORPARSING), ItemName)
  78. def SubStreamFailure(self, Item, StreamName, Error):
  79. print("SubStreamFailure:\n")
  80. def PropertyFailure(self, Item, key, Error):
  81. print("PropertyFailure:\n")
  82. def CreateSink():
  83. return pythoncom.WrapObject(
  84. TransferAdviseSink(),
  85. shell.IID_ITransferAdviseSink,
  86. shell.IID_ITransferAdviseSink,
  87. )