/* Close the given notmuch database, freeing all associated
* resources. See notmuch_database_open. */
-func (self *Database) Close() {
- C.notmuch_database_destroy(self.db)
+func (self *Database) Close() Status {
+ return Status(C.notmuch_database_destroy(self.db))
}
/* Return the database path of the given database.
*
* Can return NULL if a Xapian exception occurs.
*/
-func (self *Database) GetDirectory(path string) *Directory {
+func (self *Database) GetDirectory(path string) (*Directory, Status) {
var c_path *C.char = C.CString(path)
defer C.free(unsafe.Pointer(c_path))
if c_path == nil {
- return nil
+ return nil, STATUS_OUT_OF_MEMORY
}
- c_dir := C.notmuch_database_get_directory(self.db, c_path)
- if c_dir == nil {
- return nil
+ var c_dir *C.notmuch_directory_t
+ st := Status(C.notmuch_database_get_directory(self.db, c_path, &c_dir))
+ if st != STATUS_SUCCESS || c_dir == nil {
+ return nil, st
}
- return &Directory{dir: c_dir}
+ return &Directory{dir: c_dir}, st
}
/* Add a new message to the given notmuch database.
C.notmuch_message_set_flag(self.message, C.notmuch_message_flag_t(flag), v)
}
-// TODO: wrap notmuch_message_get_date
+/* Get the timestamp (seconds since the epoch) of 'message'.
+ *
+ * Return status:
+ *
+ * NOTMUCH_STATUS_SUCCESS: Timestamp successfully retrieved
+ *
+ * NOTMUCH_STATUS_NULL_POINTER: The 'message' argument is NULL
+ *
+ */
+func (self *Message) GetDate() (int64, Status) {
+ if self.message == nil {
+ return -1, STATUS_NULL_POINTER
+ }
+ timestamp := C.notmuch_message_get_date(self.message)
+ return int64(timestamp), STATUS_SUCCESS
+}
/* Get the value of the specified header from 'message'.
*