- Add objectClass to the object: container, message or attachment
authorJulien Kerihuel <j.kerihuel@openchange.org>
Thu, 13 Sep 2007 14:00:48 +0000 (14:00 +0000)
committerJulien Kerihuel <j.kerihuel@openchange.org>
Thu, 13 Sep 2007 14:00:48 +0000 (14:00 +0000)
- Rename content to message in openchangebackup functions
- add objectClass parameter to ocb_record_init

utils/backup/openchangebackup.c
utils/backup/openchangebackup.h
utils/backup/openchangemapidump.c

index 87b6fbfde5f550d542dc52488ccd2661d79e1e52..069b2c3997503ae5b6cae3d2c5d82840e7e54427 100644 (file)
@@ -72,8 +72,8 @@ uint32_t ocb_release(struct ocb_context *ocb_ctx)
  * init and prepare a record
  */
 
-uint32_t ocb_record_init(struct ocb_context *ocb_ctx, const char *dn, const char *id,
-                        struct mapi_SPropValue_array *props)
+uint32_t ocb_record_init(struct ocb_context *ocb_ctx, const char *objclass, const char *dn, 
+                        const char *id, struct mapi_SPropValue_array *props)
 {
        TALLOC_CTX              *mem_ctx;
        struct ldb_context      *ldb_ctx;
@@ -105,6 +105,9 @@ uint32_t ocb_record_init(struct ocb_context *ocb_ctx, const char *dn, const char
        /* add records for cn */
        ldb_msg_add_string(ocb_ctx->msg, "cn", id);
 
+       /* add filters attributes */
+       ldb_msg_add_string(ocb_ctx->msg, "objectClass", objclass);
+
        talloc_free(basedn);
 
        return 0;
@@ -134,6 +137,10 @@ uint32_t ocb_record_commit(struct ocb_context *ocb_ctx)
        return 0;
 }
 
+
+/**
+ * Add a property (attr, value) couple to the current record
+ */
 uint32_t ocb_record_add_property(struct ocb_context *ocb_ctx, 
                                 struct mapi_SPropValue *lpProp)
 {
index f7073c9211eb2736d7283698e3e8608ff7489c2e..1763f246d4fbcb7cad315399f4e555a411c49b76 100644 (file)
@@ -62,7 +62,7 @@ struct ocb_context    *ocb_init(TALLOC_CTX *, const char *);
 uint32_t               ocb_release(struct ocb_context *);
 
 uint32_t               ocb_record_init(struct ocb_context *, const char *, 
-                                       const char *,struct mapi_SPropValue_array *);
+                                       const char *, const char *, struct mapi_SPropValue_array *);
 uint32_t               ocb_record_commit(struct ocb_context *);
 uint32_t               ocb_record_add_property(struct ocb_context *, struct mapi_SPropValue *);
 
@@ -90,4 +90,9 @@ do {                                          \
 #define        DEFAULT_OCBCONF         "%s/.openchange/openchangebackup.conf"
 #define        DEFAULT_OCBDB           "%s/.openchange/openchangebackup_%s.ldb"
 
+/* objectClass */
+#define        OCB_OBJCLASS_CONTAINER  "container"
+#define        OCB_OBJCLASS_MESSAGE    "message"
+#define        OCB_OBJCLASS_ATTACHMENT "attachment"
+
 #endif /* __OPENCHANGEBACKUP_H__ */
index 029bc0b48d218ae624ff1fc6397db3476320bd55..af20cbe4ad80bce2d17934b1519cd604f5ffa5a8 100644 (file)
@@ -45,7 +45,7 @@ static enum MAPISTATUS mapidump_write_attachment(TALLOC_CTX *mem_ctx,
        uint32_t                ret;
        uint32_t                i;
 
-       ret = ocb_record_init(ocb_ctx, contentdn, uuid, props);
+       ret = ocb_record_init(ocb_ctx, OCB_OBJCLASS_ATTACHMENT, contentdn, uuid, props);
        if (ret == -1) return MAPI_E_SUCCESS;
        for (i = 0; i < props->cValues; i++) {
                ret = ocb_record_add_property(ocb_ctx, &props->lpProps[i]);
@@ -56,9 +56,9 @@ static enum MAPISTATUS mapidump_write_attachment(TALLOC_CTX *mem_ctx,
 }
 
 /**
- * write contents to the database (message, appointment, contact, task, note etc.)
+ * write message to the database (email, appointment, contact, task, note etc.)
  */
-static enum MAPISTATUS mapidump_write_content(TALLOC_CTX *mem_ctx,
+static enum MAPISTATUS mapidump_write_message(TALLOC_CTX *mem_ctx,
                                              struct ocb_context *ocb_ctx,
                                              struct mapi_SPropValue_array *props,
                                              const char *contentdn,
@@ -67,7 +67,7 @@ static enum MAPISTATUS mapidump_write_content(TALLOC_CTX *mem_ctx,
        uint32_t                ret;
        uint32_t                i;
 
-       ret = ocb_record_init(ocb_ctx, contentdn, uuid, props);
+       ret = ocb_record_init(ocb_ctx, OCB_OBJCLASS_MESSAGE, contentdn, uuid, props);
        if (ret == -1) return MAPI_E_SUCCESS;
        for (i = 0; i < props->cValues; i++) {
                ret = ocb_record_add_property(ocb_ctx, &props->lpProps[i]);
@@ -89,7 +89,7 @@ static enum MAPISTATUS mapidump_write_container(TALLOC_CTX *mem_ctx,
        uint32_t                ret;
        uint32_t                i;
 
-       ret = ocb_record_init(ocb_ctx, containerdn, uuid, props);
+       ret = ocb_record_init(ocb_ctx, OCB_OBJCLASS_CONTAINER, containerdn, uuid, props);
        if (ret == -1) return MAPI_E_SUCCESS;
        for (i = 0; i < props->cValues; i++) {
                ret = ocb_record_add_property(ocb_ctx, &props->lpProps[i]);
@@ -219,7 +219,7 @@ static enum MAPISTATUS mapidump_walk_content(TALLOC_CTX *mem_ctx,
                                        sbin = (const struct SBinary_short *)find_mapi_SPropValue_data(&props, PR_SOURCE_KEY);
                                        uuid = get_MAPI_uuid(mem_ctx, sbin);
                                        contentdn = talloc_asprintf(mem_ctx, "cn=%s,%s", uuid, containerdn);
-                                       mapidump_write_content(mem_ctx, ocb_ctx, &props, contentdn, uuid);
+                                       mapidump_write_message(mem_ctx, ocb_ctx, &props, contentdn, uuid);
 
                                        /* If Message has attachments then process them */
                                        has_attach = (const uint8_t *)find_mapi_SPropValue_data(&props, PR_HASATTACH);