* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
- * along with this program. If not, see http://www.gnu.org/licenses/ .
+ * along with this program. If not, see https://www.gnu.org/licenses/ .
*
* Author: Ali Polatel <alip@exherbo.org>
*/
VALUE
notmuch_rb_database_alloc (VALUE klass)
{
- return Data_Wrap_Struct (klass, NULL, NULL, NULL);
+ return Data_Wrap_Notmuch_Object (klass, ¬much_rb_database_type, NULL);
}
/*
mode = NOTMUCH_DATABASE_MODE_READ_ONLY;
}
- Check_Type (self, T_DATA);
+ rb_check_typeddata (self, ¬much_rb_database_type);
if (create)
ret = notmuch_database_create (path, &database);
else
notmuch_rb_database_close (VALUE self)
{
notmuch_status_t ret;
- notmuch_database_t *db;
-
- Data_Get_Notmuch_Database (self, db);
- ret = notmuch_database_destroy (db);
- DATA_PTR (self) = NULL;
+ ret = notmuch_rb_object_destroy (self, ¬much_rb_database_type);
notmuch_rb_status_raise (ret);
return Qnil;
ret = notmuch_database_get_directory (db, path, &dir);
notmuch_rb_status_raise (ret);
if (dir)
- return Data_Wrap_Struct (notmuch_rb_cDirectory, NULL, NULL, dir);
+ return Data_Wrap_Notmuch_Object (notmuch_rb_cDirectory, ¬much_rb_directory_type, dir);
return Qnil;
}
SafeStringValue (pathv);
path = RSTRING_PTR (pathv);
- ret = notmuch_database_add_message (db, path, &message);
+ ret = notmuch_database_index_file (db, path, NULL, &message);
notmuch_rb_status_raise (ret);
- return rb_assoc_new (Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message),
+ return rb_assoc_new (Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, ¬much_rb_message_type, message),
(ret == NOTMUCH_STATUS_DUPLICATE_MESSAGE_ID) ? Qtrue : Qfalse);
}
notmuch_rb_status_raise (ret);
if (message)
- return Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message);
+ return Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, ¬much_rb_message_type, message);
return Qnil;
}
notmuch_rb_status_raise (ret);
if (message)
- return Data_Wrap_Struct (notmuch_rb_cMessage, NULL, NULL, message);
+ return Data_Wrap_Notmuch_Object (notmuch_rb_cMessage, ¬much_rb_message_type, message);
return Qnil;
}
+/*
+ * call-seq: DB.get_all_tags() => TAGS
+ *
+ * Returns a list of all tags found in the database.
+ */
+VALUE
+notmuch_rb_database_get_all_tags (VALUE self)
+{
+ notmuch_database_t *db;
+ notmuch_tags_t *tags;
+
+ Data_Get_Notmuch_Database (self, db);
+
+ tags = notmuch_database_get_all_tags (db);
+ if (!tags) {
+ const char *msg = notmuch_database_status_string (db);
+ if (!msg)
+ msg = "Unknown notmuch error";
+
+ rb_raise (notmuch_rb_eBaseError, "%s", msg);
+ }
+ return Data_Wrap_Notmuch_Object (notmuch_rb_cTags, ¬much_rb_tags_type, tags);
+}
+
/*
* call-seq: DB.query(query) => QUERY
*
if (!query)
rb_raise (notmuch_rb_eMemoryError, "Out of memory");
- return Data_Wrap_Struct (notmuch_rb_cQuery, NULL, NULL, query);
+ return Data_Wrap_Notmuch_Object (notmuch_rb_cQuery, ¬much_rb_query_type, query);
}