]> rtime.felk.cvut.cz Git - notmuch.git/blobdiff - bindings/go/src/notmuch/notmuch.go
Use https instead of http where possible
[notmuch.git] / bindings / go / src / notmuch / notmuch.go
index 12de4c8da0a39ce5634039e1ca69a70b3bedd2c0..4d8c2ceb8113917f337b52e595a091847c2880d7 100644 (file)
@@ -144,8 +144,8 @@ func OpenDatabase(path string, mode DatabaseMode) (*Database, Status) {
 
 /* 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.
@@ -191,19 +191,20 @@ func (self *Database) NeedsUpgrade() bool {
  *
  * 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.
@@ -350,7 +351,7 @@ func (self *Database) GetAllTags() *Tags {
  * completely in the future, but it's likely to be a specialized
  * version of the general Xapian query syntax:
  *
- * http://xapian.org/docs/queryparser.html
+ * https://xapian.org/docs/queryparser.html
  *
  * As a special case, passing either a length-zero string, (that is ""),
  * or a string consisting of a single asterisk (that is "*"), will
@@ -800,7 +801,22 @@ func (self *Message) SetFlag(flag Flag, value bool) {
        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'.
  *