libfreebusy.i 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. %module libfreebusy
  2. %{
  3. #include <mapix.h>
  4. #include <mapidefs.h>
  5. #include <kopano/ECLogger.h>
  6. #include <kopano/memory.hpp>
  7. #include "freebusy.h"
  8. #include "freebusyguid.h"
  9. #include "ECFreeBusySupport.h"
  10. #include "PublishFreeBusy.h"
  11. #include "libfreebusy_conv.h"
  12. %}
  13. %include "std_string.i"
  14. %include "cstring.i"
  15. %include <kopano/typemap.i>
  16. // ICLASS (Class instances of MAPI objects)
  17. // Output
  18. %typemap(in,numinputs=0) ICLASS *($basetype *temp)
  19. "temp = NULL; $1 = &temp;";
  20. %typemap(argout) ICLASS *
  21. {
  22. %append_output(SWIG_NewPointerObj((void*)*($1), $*1_descriptor, SWIG_SHADOW | SWIG_OWNER));
  23. }
  24. // Classes
  25. %apply ICLASS *{IFreeBusySupport**, IFreeBusyData**, IFreeBusyUpdate**, IEnumFBBlock**}
  26. %apply long {time_t}
  27. enum FBStatus {
  28. fbFree = 0, /**< Free */
  29. fbTentative = fbFree + 1, /**< Tentative */
  30. fbBusy = fbTentative + 1, /**< Busy */
  31. fbOutOfOffice = fbBusy + 1, /**< Out Of Office */
  32. fbKopanoAllBusy = 1000 /**< Internal used */
  33. };
  34. %apply (ULONG, MAPIARRAY) { (ULONG cMax, FBUser *rgfbuser), (ULONG cUsers, FBUser *lpUsers) };
  35. %apply (MAPIARRAY, ULONG) { (FBBlock_1 *lpBlocks, ULONG nBlocks), (FBBlock_1 *lpBlocks, ULONG nBlocks) }
  36. %typemap(in) (LONG, FBBLOCK)
  37. {
  38. $1 = PyLong_AsLong($input);
  39. if (MAPIAllocateBuffer($1 * sizeof(FBBlock_1),
  40. reinterpret_cast<void **>(&$2)) != hrSuccess)
  41. SWIG_fail;
  42. }
  43. %apply (LONG, FBBLOCK) { (LONG celt, FBBlock_1 *pblk), (ULONG celt, FBBlock_1 *pblk) }
  44. %apply (MAPIARRAY, LONG) { (FBBlock_1 *pblk, LONG* pcfetch), (FBBlock_1 *pblk, LONG* pcfetch) }
  45. %typemap(argout) LONG *
  46. {
  47. %append_output(PyLong_FromLong(*$1));
  48. }
  49. %typemap(argout) ULONG *
  50. {
  51. %append_output(PyLong_FromUnsignedLong(*$1));
  52. }
  53. class IUnknown {
  54. public:
  55. virtual HRESULT QueryInterface(const IID& USE_IID_FOR_OUTPUT, void **OUTPUT_USE_IID) = 0;
  56. };
  57. %extend IUnknown {
  58. ~IUnknown() { self->Release(); }
  59. };
  60. %init %{
  61. InitFreebusy();
  62. %}
  63. %{
  64. swig_type_info *TypeFromIID(REFIID iid)
  65. {
  66. #define TYPECASE(x) if(iid == IID_##x) return SWIGTYPE_p_##x;
  67. TYPECASE(IFreeBusyUpdate)
  68. TYPECASE(IEnumFBBlock)
  69. TYPECASE(IFreeBusySupport)
  70. TYPECASE(IFreeBusyData)
  71. return NULL;
  72. }
  73. LPCIID IIDFromType(const char *type)
  74. {
  75. #define IIDCASE(x) if(strstr(type, #x) != NULL) return &IID_##x;
  76. IIDCASE(IFreeBusyUpdate)
  77. IIDCASE(IEnumFBBlock)
  78. IIDCASE(IFreeBusySupport)
  79. IIDCASE(IFreeBusyData)
  80. return &IID_IUnknown;
  81. }
  82. %}
  83. class IFreeBusyUpdate : public IUnknown {
  84. public:
  85. virtual HRESULT Reload() = 0;
  86. virtual HRESULT PublishFreeBusy(FBBlock_1 *lpBlocks, ULONG nBlocks) = 0;
  87. virtual HRESULT RemoveAppt() = 0;
  88. virtual HRESULT ResetPublishedFreeBusy() = 0;
  89. virtual HRESULT ChangeAppt() = 0;
  90. virtual HRESULT SaveChanges(FILETIME ftBegin, FILETIME ftEnd) = 0;
  91. virtual HRESULT GetFBTimes() = 0;
  92. virtual HRESULT Intersect() = 0;
  93. %extend {
  94. ~IFreeBusyUpdate() { self->Release(); }
  95. }
  96. };
  97. class IEnumFBBlock : public IUnknown {
  98. public:
  99. virtual HRESULT Next(LONG celt, FBBlock_1 *pblk, LONG *pcfetch) = 0;
  100. virtual HRESULT Skip(LONG celt) = 0;
  101. virtual HRESULT Reset() = 0;
  102. virtual HRESULT Clone(IEnumFBBlock **ppclone) = 0;
  103. virtual HRESULT Restrict(FILETIME ftmStart, FILETIME ftmEnd) = 0;
  104. %extend {
  105. ~IEnumFBBlock() { self->Release(); }
  106. }
  107. };
  108. class IFreeBusyData : public IUnknown {
  109. public:
  110. virtual HRESULT Reload(void*) = 0;
  111. virtual HRESULT EnumBlocks(IEnumFBBlock **ppenumfb, FILETIME ftmStart, FILETIME ftmEnd) = 0;
  112. virtual HRESULT Merge(void *) = 0;
  113. virtual HRESULT GetDelegateInfo(void *) = 0;
  114. virtual HRESULT FindFreeBlock(LONG, LONG, LONG, BOOL, LONG, LONG, LONG, FBBlock_1 *) = 0;
  115. virtual HRESULT InterSect(void *, LONG, void *) = 0;
  116. virtual HRESULT SetFBRange(LONG rtmStart, LONG rtmEnd) = 0;
  117. virtual HRESULT NextFBAppt(void *, ULONG, void *, ULONG, void *, void *) = 0;
  118. virtual HRESULT GetFBPublishRange(LONG *prtmStart, LONG *prtmEnd) = 0;
  119. %extend {
  120. ~IFreeBusyData() { self->Release(); }
  121. }
  122. };
  123. %feature("notabstract") IFreeBusySupport;
  124. class IFreeBusySupport : public IUnknown {
  125. public:
  126. virtual HRESULT Open(IMAPISession* lpMAPISession, IMsgStore* lpMsgStore, BOOL bStore) = 0;
  127. virtual HRESULT Close() = 0;
  128. virtual HRESULT LoadFreeBusyData(ULONG cMax, FBUser *rgfbuser, IFreeBusyData **prgfbdata, HRESULT *phrStatus, ULONG *pcRead) = 0;
  129. virtual HRESULT LoadFreeBusyUpdate(ULONG cUsers, FBUser *lpUsers, IFreeBusyUpdate **lppFBUpdate, ULONG *lpcFBUpdate, void *lpData4) = 0;
  130. virtual HRESULT CommitChanges() = 0;
  131. virtual HRESULT GetDelegateInfo(FBUser, void *) = 0;
  132. virtual HRESULT SetDelegateInfo(void *) = 0;
  133. virtual HRESULT AdviseFreeBusy(void *) = 0;
  134. virtual HRESULT Reload(void *) = 0;
  135. virtual HRESULT GetFBDetailSupport(void **, BOOL ) = 0;
  136. virtual HRESULT HrHandleServerSched(void *) = 0;
  137. virtual HRESULT HrHandleServerSchedAccess() = 0;
  138. virtual BOOL FShowServerSched(BOOL ) = 0;
  139. virtual HRESULT HrDeleteServerSched() = 0;
  140. virtual HRESULT GetFReadOnly(void *) = 0;
  141. virtual HRESULT SetLocalFB(void *) = 0;
  142. virtual HRESULT PrepareForSync() = 0;
  143. virtual HRESULT GetFBPublishMonthRange(void *) = 0;
  144. virtual HRESULT PublishRangeChanged() = 0;
  145. virtual HRESULT CleanTombstone() = 0;
  146. virtual HRESULT GetDelegateInfoEx(FBUser sFBUser, unsigned int *lpulStatus, unsigned int *prtmStart, unsigned int *prtmEnd) = 0;
  147. virtual HRESULT PushDelegateInfoToWorkspace() = 0;
  148. %extend {
  149. IFreeBusySupport() {
  150. HRESULT hr = hrSuccess;
  151. KCHL::object_ptr<ECFreeBusySupport> lpFreeBusySup;
  152. IFreeBusySupport *lpFreeBusySupport = NULL;
  153. hr = ECFreeBusySupport::Create(&~lpFreeBusySup);
  154. if(hr != hrSuccess)
  155. goto exit;
  156. hr = lpFreeBusySup->QueryInterface(IID_IFreeBusySupport, (void**)&lpFreeBusySupport);
  157. if(hr != hrSuccess)
  158. goto exit;
  159. exit:
  160. return lpFreeBusySupport;
  161. }
  162. ~IFreeBusySupport() { self->Release(); }
  163. }
  164. };