aboutsummaryrefslogtreecommitdiffstats
path: root/calendar
diff options
context:
space:
mode:
Diffstat (limited to 'calendar')
-rw-r--r--calendar/ChangeLog4
-rw-r--r--calendar/pcs/cal-backend-db.c40
2 files changed, 42 insertions, 2 deletions
diff --git a/calendar/ChangeLog b/calendar/ChangeLog
index acdead7cf6..c1ca40d772 100644
--- a/calendar/ChangeLog
+++ b/calendar/ChangeLog
@@ -1,3 +1,7 @@
+2001-02-23 Rodrigo Moya <rodrigo@ximian.com>
+
+ * pcs/cal-backend-db.c (add_history): fixed generation of history records
+
2001-02-16 Federico Mena Quintero <federico@ximian.com>
* pcs/cal-factory.c (CalFactoryPrivate): Added a `registered'
diff --git a/calendar/pcs/cal-backend-db.c b/calendar/pcs/cal-backend-db.c
index e83b6fd3d1..fca87bd9ab 100644
--- a/calendar/pcs/cal-backend-db.c
+++ b/calendar/pcs/cal-backend-db.c
@@ -542,7 +542,7 @@ open_database_file (CalBackendDB *cbdb, const gchar *str_uri, gboolean only_if_e
str_uri,
"calendar_history",
DB_BTREE,
- DB_CREATE,
+ DB_CREATE | DB_THREAD,
0644);
if (ret == 0) return TRUE;
@@ -1368,6 +1368,39 @@ do_notify (CalBackendDB *cbdb, void (*notify_fn)(Cal *, gchar *), const gchar *u
}
}
+/* adds a record to the history database */
+static gboolean
+add_history (CalBackendDB *cbdb, DB_TXN *tid, const gchar *uid, const gchar *calobj)
+{
+ DBT key;
+ DBT new_data;
+ gint ret;
+
+ g_return_val_if_fail(IS_CAL_BACKEND_DB(cbdb), FALSE);
+ g_return_val_if_fail(uid != NULL, FALSE);
+ g_return_val_if_fail(calobj != NULL, FALSE);
+
+ /* fill in DBT structures */
+ memset(&key, 0, sizeof(key));
+ key.data = (void *) uid;
+ key.size = strlen(uid); // + 1
+
+ memset(&new_data, 0, sizeof(new_data));
+ new_data.data = (void *) calobj;
+ new_data.size = strlen(calobj); // + 1
+
+ /* add the new record to the database */
+ if ((ret = cbdb->priv->history_db->put(cbdb->priv->objects_db,
+ tid,
+ &key,
+ &new_data,
+ 0)) != 0) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
/* update_object handler for the DB backend */
static gboolean
cal_backend_db_update_object (CalBackend *backend, const char *uid, const char *calobj)
@@ -1407,7 +1440,10 @@ cal_backend_db_update_object (CalBackend *backend, const char *uid, const char *
return FALSE;
}
- /* TODO: update history database */
+ if (!add_history(cbdb, tid, uid, calobj)) {
+ rollback_transaction(tid);
+ return FALSE;
+ }
commit_transaction(tid);
do_notify(cbdb, cal_notify_update, uid);