RecurrenceState.i 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. %module RecurrenceState
  2. %{
  3. /* parse header in the wrapper code */
  4. #include <kopano/platform.h>
  5. #include <mapidefs.h>
  6. #include <mapix.h>
  7. /* local version without nested classes */
  8. #include "RecurrenceState.swig.h"
  9. %}
  10. %include "std_string.i"
  11. %include "cstring.i"
  12. %include "cwstring.i"
  13. %include <kopano/typemap.i>
  14. %include "std_vector.i"
  15. %include "std_wstring.i"
  16. %cstring_input_binary(const char *lpData, unsigned int ulLen);
  17. %cstring_output_allocate_size(char **lpData, unsigned int *lpulLen, MAPIFreeBuffer(*$1));
  18. /* parse header file to generate wrappers */
  19. %include "RecurrenceState.swig.h"
  20. namespace std {
  21. %template(UIntVector) vector<unsigned int>;
  22. %template(ExceptionVector) vector<Exception>;
  23. %template(ExtendedExceptionVector) vector<ExtendedException>;
  24. }
  25. %pythoncode%{
  26. import time
  27. # actually functions from platform.h .. probably should move
  28. def FileTimeToUnixTime(llFT):
  29. return int((llFT - 116444736000000000) / 10000000)
  30. def RTimeToFileTime(ulRTime):
  31. return ulRTime * 600000000
  32. def RTimeToUnixTime(ulRTime):
  33. return FileTimeToUnixTime(RTimeToFileTime(ulRTime))
  34. def _weekdaystostring(ulWeekDays):
  35. days = []
  36. days.append('Sunday') if (ulWeekDays & WD_SUNDAY) else ''
  37. days.append('Monday') if (ulWeekDays & WD_MONDAY) else ''
  38. days.append('Tuesday') if (ulWeekDays & WD_TUESDAY) else ''
  39. days.append('Wednesday') if (ulWeekDays & WD_WEDNESDAY) else ''
  40. days.append('Thursday') if (ulWeekDays & WD_THURSDAY) else ''
  41. days.append('Friday') if (ulWeekDays & WD_FRIDAY) else ''
  42. days.append('Saturday') if (ulWeekDays & WD_SATURDAY) else ''
  43. return ', '.join(days)
  44. def _arotostring(ulOverrideFlags):
  45. aro = []
  46. aro.append('Subject') if ulOverrideFlags & ARO_SUBJECT else ''
  47. aro.append('MeetingType') if ulOverrideFlags & ARO_MEETINGTYPE else ''
  48. aro.append('ReminderDelta') if ulOverrideFlags & ARO_REMINDERDELTA else ''
  49. aro.append('ReminderSet') if ulOverrideFlags & ARO_REMINDERSET else ''
  50. aro.append('Location') if ulOverrideFlags & ARO_LOCATION else ''
  51. aro.append('BusyStatus') if ulOverrideFlags & ARO_BUSYSTATUS else ''
  52. aro.append('Attachment') if ulOverrideFlags & ARO_ATTACHMENT else ''
  53. aro.append('SubType') if ulOverrideFlags & ARO_SUBTYPE else ''
  54. aro.append('AppointmentColor') if ulOverrideFlags & ARO_APPTCOLOR else ''
  55. aro.append('Body') if ulOverrideFlags & ARO_EXCEPTIONAL_BODY else ''
  56. return ', '.join(aro)
  57. # print human readable version of recurrencestate class
  58. def Summarize(rs):
  59. print("Versions, reader 0x%04x writer 0x%04x" % (rs.ulReaderVersion, rs.ulWriterVersion))
  60. if rs.ulRecurFrequency == RF_DAILY:
  61. print("Daily")
  62. elif rs.ulRecurFrequency == RF_WEEKLY:
  63. print("Weekly")
  64. elif rs.ulRecurFrequency == RF_MONTHLY:
  65. print("Monthly")
  66. elif rs.ulRecurFrequency == RF_YEARLY:
  67. print("Yearly")
  68. else:
  69. print("ERROR: Unknown ulRecurFrequency: 0x%x" % rs.ulRecurFrequency)
  70. # pattern type is info for reader
  71. # print("Patterntype: %d, ulCalendarType: %d" % (rs.ulPatternType, rs.ulCalendarType))
  72. print("FirstDateTime: %d" % rs.ulFirstDateTime)
  73. print("Period: %d" % rs.ulPeriod)
  74. print("ulSlidingFlag: %d" % rs.ulSlidingFlag)
  75. print("Pattern info, type %d:" % rs.ulPatternType)
  76. if rs.ulPatternType == 0:
  77. pass
  78. elif rs.ulPatternType == 1:
  79. print(" Weekdays: %s" % _weekdaystostring(rs.ulWeekDays))
  80. elif rs.ulPatternType in (2, 4, 0xa, 0xc):
  81. print(" Day of Month: %d" % rs.ulDayOfMonth)
  82. elif rs.ulPatternType in (3, 0xb):
  83. print(" Weekdays: %s" % _weekdaystostring(rs.ulWeekDays))
  84. print(" Weeknr : %d" % rs.ulWeekNumber)
  85. else:
  86. print("ERROR: Invalid pattern type: %d" % rs.ulPatternType)
  87. if rs.ulEndType == ET_DATE:
  88. print("Ending recurrence by date, see EndDate below, end count is: %d" % rs.ulOccurrenceCount)
  89. elif rs.ulEndType == ET_NUMBER:
  90. print("Ending recurrence by count: %d" % rs.ulOccurrenceCount)
  91. elif rs.ulEndType == ET_NEVER:
  92. print("Never ending recurrence, end count is 10: %d" % rs.ulOccurrenceCount)
  93. else:
  94. print("ERROR: Invalid end type: 0x%x" % rs.ulEndType)
  95. print("First Day of Week: %d" % rs.ulFirstDOW)
  96. # for every modify, there is a delete too
  97. print("# of Deleted Exceptions: %d" % (rs.ulDeletedInstanceCount - rs.ulModifiedInstanceCount))
  98. print("# of Modified Exceptions: %d" % rs.ulModifiedInstanceCount)
  99. print("First Occurrence: %s +0000" % time.asctime(time.gmtime(RTimeToUnixTime(rs.ulStartDate))))
  100. print("Last Occurrence: %s +0000" % time.asctime(time.gmtime(RTimeToUnixTime(rs.ulEndDate))))
  101. print("Delete/Modify occurrence times:")
  102. # beware of the crash!
  103. d = rs.lstDeletedInstanceDates
  104. for i in d:
  105. print(" %s +0000" % time.asctime(time.gmtime(RTimeToUnixTime(i))))
  106. print("Modified occurrence times:")
  107. # beware of the crash!
  108. m = rs.lstModifiedInstanceDates
  109. for i in m:
  110. print(" %s +0000" % time.asctime(time.gmtime(RTimeToUnixTime(i))))
  111. if rs.ulReaderVersion2 == 0:
  112. print("Task done")
  113. return
  114. print("Versions2, reader 0x%04x writer 0x%04x" % (rs.ulReaderVersion2, rs.ulWriterVersion2))
  115. print("Start time offset: %s" % rs.ulStartTimeOffset)
  116. print("End time offset: %s" % rs.ulEndTimeOffset)
  117. print("Modified exception count: %d" % rs.ulExceptionCount)
  118. # beware of the crash!
  119. le = rs.lstExceptions
  120. lee = rs.lstExtendedExceptions
  121. for n in xrange(0,rs.ulExceptionCount):
  122. print("Exception " + str(n))
  123. print(" SDT %s +0000" % time.asctime(time.gmtime(RTimeToUnixTime(le[n].ulStartDateTime))))
  124. print(" EDT %s +0000" % time.asctime(time.gmtime(RTimeToUnixTime(le[n].ulEndDateTime))))
  125. print(" OSD %s +0000" % time.asctime(time.gmtime(RTimeToUnixTime(le[n].ulOriginalStartDate))))
  126. if le[n].ulOverrideFlags & (ARO_SUBJECT | ARO_LOCATION):
  127. # should be the same
  128. print(" XSDT %s +0000" % time.asctime(time.gmtime(RTimeToUnixTime(lee[n].ulStartDateTime))))
  129. print(" XEDT %s +0000" % time.asctime(time.gmtime(RTimeToUnixTime(lee[n].ulEndDateTime))))
  130. print(" XOSD %s +0000" % time.asctime(time.gmtime(RTimeToUnixTime(lee[n].ulOriginalStartDate))))
  131. print(" ARO changes: %s" % _arotostring(le[n].ulOverrideFlags))
  132. if le[n].ulOverrideFlags & ARO_SUBJECT:
  133. print(" Subject: %s :: %s" % (le[n].strSubject, lee[n].strWideCharSubject))
  134. if le[n].ulOverrideFlags & ARO_MEETINGTYPE:
  135. print(" MeetingType: %d" % le[n].ulMeetingType)
  136. if le[n].ulOverrideFlags & ARO_REMINDERDELTA:
  137. print(" ReminderDelta: %d" % le[n].ulReminderDelta)
  138. if le[n].ulOverrideFlags & ARO_REMINDERSET:
  139. print(" ReminderSet: %d" % le[n].ulReminderSet)
  140. if le[n].ulOverrideFlags & ARO_LOCATION:
  141. print(" Location: %s :: %s" % (le[n].strLocation, lee[n].strWideCharLocation))
  142. if le[n].ulOverrideFlags & ARO_BUSYSTATUS:
  143. print(" BusyStatus: %d" % le[n].ulBusyStatus)
  144. if le[n].ulOverrideFlags & ARO_ATTACHMENT:
  145. print(" Attachment: %d" % le[n].ulAttachment)
  146. if le[n].ulOverrideFlags & ARO_SUBTYPE:
  147. print(" SubType %d" % le[n].ulSubType)
  148. if le[n].ulOverrideFlags & ARO_APPTCOLOR:
  149. print(" AppointmentColor %d" % le[n].ulAppointmentColor)
  150. if rs.ulWriterVersion2 >= 0x3009:
  151. print(" Extended, highlight: %d" % lee[n].ulChangeHighlightValue)
  152. %}