Todo DB

Todo DB — Todo Database

Synopsis




enum        item_state;
struct      todo_item;
#define     PRIORITY_HIGH
#define     PRIORITY_STANDARD
#define     PRIORITY_LOW
struct todo_item* todo_db_new_item          (void);
gboolean    todo_db_push_item               (struct todo_item *i);
void        todo_db_delete_item             (struct todo_item *i);
void        todo_db_destroy_item            (struct todo_item *i);
GSList*     todo_db_get_items_list          (void);
int         todo_db_start                   (void);
void        todo_db_stop                    (void);
int         todo_db_refresh                 (void);

Description

Todo database API interface.

Details

enum item_state

typedef enum
{
  NOT_STARTED,
  IN_PROGRESS,
  COMPLETED,
  ABANDONED
} item_state;

Type to describe the progress status of a todo item.

NOT_STARTED Indicates a task which isn't started.
IN_PROGRESS Task currently in progress.
COMPLETED Task is marked as completed.
ABANDONED Indicates an abandoned task.

struct todo_item

struct todo_item {
  int id, pos;
  time_t time;
  const char *what;
  const char *summary;
  item_state state;
  gboolean was_complete;
  GSList *categories;
  guint priority;
};

Data type describing a todo item including description and current status.

int id; Unique id.
int pos; Position marker.
time_t time; Timestamp holding due date.
const char *what; Item title.
const char *summary; Item description.
item_state state; Item status (see item_state).
gboolean was_complete;
GSList *categories; List of categories the item belongs to.
guint priority; Priority information.

PRIORITY_HIGH

#define PRIORITY_HIGH		9

Indicates an item with high priority.


PRIORITY_STANDARD

#define PRIORITY_STANDARD	5

Indicates an item with default priority.


PRIORITY_LOW

#define PRIORITY_LOW		0

Indicates a low priority item.


todo_db_new_item ()

struct todo_item* todo_db_new_item          (void);

Create a new todo item and add it to list and database.

Returns : New todo item.

todo_db_push_item ()

gboolean    todo_db_push_item               (struct todo_item *i);

i :
Returns :

todo_db_delete_item ()

void        todo_db_delete_item             (struct todo_item *i);

Deletes an item from the list and database.

i : Todo item to delete.

todo_db_destroy_item ()

void        todo_db_destroy_item            (struct todo_item *i);

Frees a todo list item struct.

i : Todo item to destroy.

todo_db_get_items_list ()

GSList*     todo_db_get_items_list          (void);

Get a list of all todo items. The returned list points to the internal list used by libtododb and doesn't need to be freed. It is a good idea to consider it to be read only.

Returns : List of todo items.

todo_db_start ()

int         todo_db_start                   (void);

Initialises libtododb for use.

Returns : 0 on success, -1 on failure.

todo_db_stop ()

void        todo_db_stop                    (void);

Deinitialises libtododb and frees all its allocated data.


todo_db_refresh ()

int         todo_db_refresh                 (void);

Update list of todo items from database.

Returns : 0 on success, -1 on failure.