ECS3Attachment.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #ifndef EC_S3_ATTACHMENT
  2. #define EC_S3_ATTACHMENT
  3. #include "config.h"
  4. #ifdef HAVE_LIBS3_H
  5. #include <kopano/zcdefs.h>
  6. #include <kopano/platform.h>
  7. #include <list>
  8. #include <set>
  9. #include <string>
  10. #include <libs3.h>
  11. #include "ECAttachmentStorage.h"
  12. struct soap;
  13. namespace KC {
  14. class ECSerializer;
  15. class ECLogger;
  16. struct s3_cd;
  17. class ECS3Attachment _kc_final : public ECAttachmentStorage {
  18. public:
  19. static ECRESULT StaticInit(ECConfig *);
  20. static ECRESULT StaticDeinit(void);
  21. ECS3Attachment(ECDatabase *, const char *, const char *, const char *, const char *, const char *, const char *, const char *, unsigned int);
  22. protected:
  23. virtual ~ECS3Attachment(void);
  24. /* Single Instance Attachment handlers */
  25. virtual bool ExistAttachmentInstance(ULONG);
  26. virtual ECRESULT LoadAttachmentInstance(struct soap *, ULONG, size_t *, unsigned char **);
  27. virtual ECRESULT LoadAttachmentInstance(ULONG, size_t *, ECSerializer *);
  28. virtual ECRESULT SaveAttachmentInstance(ULONG, ULONG, size_t, unsigned char *);
  29. virtual ECRESULT SaveAttachmentInstance(ULONG, ULONG, size_t, ECSerializer *);
  30. virtual ECRESULT DeleteAttachmentInstances(const std::list<ULONG> &, bool);
  31. virtual ECRESULT DeleteAttachmentInstance(ULONG, bool);
  32. virtual ECRESULT GetSizeInstance(ULONG, size_t *, bool * = NULL);
  33. virtual ECRESULT Begin(void);
  34. virtual ECRESULT Commit(void);
  35. virtual ECRESULT Rollback(void);
  36. private:
  37. static S3Status response_prop_cb(const S3ResponseProperties *, void *);
  38. static void response_complete_cb(S3Status, const S3ErrorDetails *, void *);
  39. static S3Status get_obj_cb(int, const char *, void *);
  40. static int put_obj_cb(int, char *, void *);
  41. S3Status response_prop(const S3ResponseProperties *, void *);
  42. void response_complete(S3Status, const S3ErrorDetails *, void *);
  43. S3Status get_obj(int, const char *, void *);
  44. int put_obj(int, char *, void *);
  45. std::string make_att_filename(ULONG, bool);
  46. bool should_retry(struct s3_cd *);
  47. struct s3_cd create_cd(void);
  48. /* helper functions for transacted deletion */
  49. ECRESULT mark_att_for_del(ULONG);
  50. ECRESULT del_marked_att(ULONG);
  51. ECRESULT restore_marked_att(ULONG);
  52. /* Variables: */
  53. std::string m_basepath;
  54. S3BucketContext m_bucket_ctx;
  55. std::set<ULONG> m_new_att;
  56. std::set<ULONG> m_deleted_att;
  57. std::set<ULONG> m_marked_att;
  58. bool m_transact = false;
  59. /*
  60. * The Request Context and Response Handler variables are responsible
  61. * for the operation of the handler functions.
  62. */
  63. S3ResponseHandler m_response_handler;
  64. S3PutObjectHandler m_put_obj_handler;
  65. S3GetObjectHandler m_get_obj_handler;
  66. S3GetConditions m_get_conditions;
  67. };
  68. } /* namespace */
  69. #endif /* LIBS3_H */
  70. #endif