[couchdb-glib] Add tasks document class



commit 5351a300f45da5661aee9d32cae1e15e88be2ca9
Author: Miguel Ã?ngel Rodelas Delgado <miguel rodelas gmail com>
Date:   Mon Jul 5 13:11:06 2010 +0200

    Add tasks document class

 desktopcouch-glib/desktopcouch-document-task.c |   84 ++++++++++++++++++++++++
 desktopcouch-glib/desktopcouch-document-task.h |   47 +++++++++++++
 2 files changed, 131 insertions(+), 0 deletions(-)
---
diff --git a/desktopcouch-glib/desktopcouch-document-task.c b/desktopcouch-glib/desktopcouch-document-task.c
new file mode 100755
index 0000000..b0652b7
--- /dev/null
+++ b/desktopcouch-glib/desktopcouch-document-task.c
@@ -0,0 +1,84 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2009 Canonical Services Ltd (www.canonical.com)
+ *
+ * Authors: Miguel Angel Rodelas Delgado <miguel rodelas gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#include "desktopcouch-document-task.h"
+#include "utils.h"
+
+CouchdbDocument *
+desktopcouch_document_task_new (CouchdbSession *couchdb)
+{
+	CouchdbDocument *document;
+
+	g_return_val_if_fail (COUCHDB_IS_SESSION (couchdb), NULL);
+
+	document = couchdb_document_new (couchdb);
+	if (document)
+		desktopcouch_document_set_record_type (document, DESKTOPCOUCH_RECORD_TYPE_TASK);
+
+	return document;
+}
+
+gboolean
+desktopcouch_document_is_task (CouchdbDocument *document)
+{
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT (document), FALSE);
+
+	return !g_ascii_strcasecmp (desktopcouch_document_get_record_type (document),
+				    DESKTOPCOUCH_RECORD_TYPE_TASK);
+}
+
+const char *
+desktopcouch_document_task_get_summary (CouchdbDocument *document)
+{
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT (document), NULL);
+	g_return_val_if_fail (desktopcouch_document_is_task (document), NULL);
+
+	return couchdb_document_get_string_field (document, "summary");
+}
+
+void
+desktopcouch_document_task_set_summary (CouchdbDocument *document, const char *summary)
+{
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT (document));
+	g_return_if_fail (desktopcouch_document_is_task (document));
+	g_return_if_fail (summary != NULL);
+
+	couchdb_document_set_string_field (document, "summary", summary);
+}
+
+const char *
+desktopcouch_document_task_get_description (CouchdbDocument *document)
+{
+	g_return_val_if_fail (COUCHDB_IS_DOCUMENT (document), NULL);
+	g_return_val_if_fail (desktopcouch_document_is_task (document), NULL);
+
+	return couchdb_document_get_string_field (document, "description");
+}
+
+void
+desktopcouch_document_task_set_description (CouchdbDocument *document, const char *description)
+{
+      	g_return_if_fail (COUCHDB_IS_DOCUMENT (document));
+	g_return_if_fail (desktopcouch_document_is_task (document));
+	g_return_if_fail (description != NULL);
+
+	couchdb_document_set_string_field (document, "description", description);
+}
diff --git a/desktopcouch-glib/desktopcouch-document-task.h b/desktopcouch-glib/desktopcouch-document-task.h
new file mode 100755
index 0000000..aa896f7
--- /dev/null
+++ b/desktopcouch-glib/desktopcouch-document-task.h
@@ -0,0 +1,47 @@
+/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
+/*
+ * Copyright (C) 2010 Canonical Services Ltd (www.canonical.com)
+ *
+ * Authors: Miguel Angel Rodelas Delgado <miguel rodelas gmail com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of version 2 of the GNU Lesser General Public
+ * License as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __DESKTOPCOUCH_DOCUMENT_TASK_H__
+#define __DESKTOPCOUCH_DOCUMENT_TASK_H__
+
+#include <couchdb-struct-field.h>
+#include <desktopcouch-document.h>
+
+G_BEGIN_DECLS
+
+#define DESKTOPCOUCH_RECORD_TYPE_TASK "http://www.freedesktop.org/wiki/Specifications/desktopcouch/task";
+
+CouchdbDocument *desktopcouch_document_task_new (CouchdbSession *couchdb);
+gboolean         desktopcouch_document_is_task (CouchdbDocument *document);
+
+/*
+ * Top level functions to manipulate documents representing a task
+ */
+
+const char *desktopcouch_document_task_get_summary (CouchdbDocument *document);
+void        desktopcouch_document_task_set_summary (CouchdbDocument *document, const char *summary);
+
+const char *desktopcouch_document_task_get_description (CouchdbDocument *document);
+void        desktopcouch_document_task_set_description (CouchdbDocument *document, const char *description);
+
+G_END_DECLS
+
+#endif /* __DESKTOPCOUCH_DOCUMENT_TASK_H__ */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]