2011-09-02 20:46:16 +02:00
|
|
|
/* See LICENSE file for license and copyright information */
|
|
|
|
|
|
|
|
#ifndef DATABASE_H
|
|
|
|
#define DATABASE_H
|
|
|
|
|
|
|
|
#include <stdbool.h>
|
2011-10-23 17:01:15 +02:00
|
|
|
#include <girara/types.h>
|
2011-09-02 20:46:16 +02:00
|
|
|
|
|
|
|
#include "zathura.h"
|
|
|
|
#include "bookmarks.h"
|
|
|
|
|
2011-09-03 13:49:21 +02:00
|
|
|
/**
|
|
|
|
* Initialize database system.
|
2012-02-08 15:30:13 +01:00
|
|
|
*
|
|
|
|
* @param dir Path to the directory where the database file should be located.
|
2011-09-03 13:49:21 +02:00
|
|
|
* @return A valid zathura_database_t instance or NULL on failure
|
|
|
|
*/
|
2011-10-10 23:46:50 +02:00
|
|
|
zathura_database_t* zathura_db_init(const char* dir);
|
2011-09-02 20:46:16 +02:00
|
|
|
|
2011-09-03 13:49:21 +02:00
|
|
|
/**
|
|
|
|
* Free database instance.
|
2012-02-08 15:30:13 +01:00
|
|
|
*
|
|
|
|
* @param db The database instance to free.
|
2011-09-03 13:49:21 +02:00
|
|
|
*/
|
2011-09-02 20:46:16 +02:00
|
|
|
void zathura_db_free(zathura_database_t* db);
|
|
|
|
|
2011-09-03 13:49:21 +02:00
|
|
|
/**
|
|
|
|
* Add or update bookmark in the database.
|
2012-02-08 15:30:13 +01:00
|
|
|
*
|
2011-09-03 13:49:21 +02:00
|
|
|
* @param db The database instance
|
|
|
|
* @param file The file to which the bookmark belongs to.
|
|
|
|
* @param bookmark The bookmark instance.
|
|
|
|
* @return true on success, false otherwise
|
|
|
|
*/
|
2011-10-10 23:46:50 +02:00
|
|
|
bool zathura_db_add_bookmark(zathura_database_t* db, const char* file,
|
|
|
|
zathura_bookmark_t* bookmark);
|
2011-09-02 20:46:16 +02:00
|
|
|
|
2011-09-03 13:49:21 +02:00
|
|
|
/**
|
|
|
|
* Add or update bookmark in the database.
|
2012-02-08 15:30:13 +01:00
|
|
|
*
|
2011-09-03 13:49:21 +02:00
|
|
|
* @param db The database instance
|
|
|
|
* @param file The file to which the bookmark belongs to.
|
2012-02-08 15:30:13 +01:00
|
|
|
* @param id The id of the bookmark
|
2011-09-03 13:49:21 +02:00
|
|
|
* @return true on success, false otherwise
|
|
|
|
*/
|
2011-10-10 23:46:50 +02:00
|
|
|
bool zathura_db_remove_bookmark(zathura_database_t* db, const char* file, const
|
|
|
|
char* id);
|
2011-09-02 20:46:16 +02:00
|
|
|
|
2011-09-03 13:49:21 +02:00
|
|
|
/**
|
|
|
|
* Loads all bookmarks from the database belonging to a specific file.
|
2012-02-08 15:30:13 +01:00
|
|
|
*
|
2011-09-03 13:49:21 +02:00
|
|
|
* @param db The database instance.
|
|
|
|
* @param file The file for which the bookmarks should be loaded.
|
|
|
|
* @return List of zathura_bookmark_t* or NULL on failure.
|
|
|
|
*/
|
2011-10-10 23:46:50 +02:00
|
|
|
girara_list_t* zathura_db_load_bookmarks(zathura_database_t* db, const char*
|
|
|
|
file);
|
2011-09-02 20:46:16 +02:00
|
|
|
|
2011-09-21 18:31:12 +02:00
|
|
|
/**
|
|
|
|
* Set file info (last site, ...) in the database.
|
2012-02-08 15:30:13 +01:00
|
|
|
*
|
2011-09-21 18:31:12 +02:00
|
|
|
* @param db The database instance
|
|
|
|
* @param file The file to which the file info belongs to.
|
|
|
|
* @param page The last page.
|
|
|
|
* @param offset The last offset.
|
|
|
|
* @param scale The last scale.
|
2012-02-08 22:23:45 +01:00
|
|
|
* @param rotation The last rotation.
|
2011-09-21 18:31:12 +02:00
|
|
|
* @return true on success, false otherwise.
|
|
|
|
*/
|
2011-10-10 23:46:50 +02:00
|
|
|
bool zathura_db_set_fileinfo(zathura_database_t* db, const char* file, unsigned
|
2012-02-08 22:23:45 +01:00
|
|
|
int page, int offset, double scale, int rotation);
|
2011-09-21 18:31:12 +02:00
|
|
|
|
2011-09-22 15:47:58 +02:00
|
|
|
/* Get file info (last site, ...) from the database.
|
2012-02-08 15:30:13 +01:00
|
|
|
*
|
2011-09-22 15:47:58 +02:00
|
|
|
* @param db The database instance
|
|
|
|
* @param file The file to which the file info belongs to.
|
|
|
|
* @param page The last page.
|
|
|
|
* @param offset The last offset.
|
|
|
|
* @param scale The last scale.
|
2012-02-08 22:23:45 +01:00
|
|
|
* @param rotation The rotation.
|
2011-09-22 15:47:58 +02:00
|
|
|
* @return true on success, false otherwise.
|
|
|
|
*/
|
2011-10-10 23:46:50 +02:00
|
|
|
bool zathura_db_get_fileinfo(zathura_database_t* db, const char* file, unsigned
|
2012-02-08 22:23:45 +01:00
|
|
|
int* page, int* offset, double* scale, int* rotation);
|
2011-09-22 15:47:58 +02:00
|
|
|
|
2011-09-02 20:46:16 +02:00
|
|
|
#endif // DATABASE_H
|