2
** Copyright (C) 2008 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
4
** This program is free software; you can redistribute it and/or modify it
5
** under the terms of the GNU General Public License as published by the
6
** Free Software Foundation; either version 3, or (at your option) any
9
** This program is distributed in the hope that it will be useful,
10
** but WITHOUT ANY WARRANTY; without even the implied warranty of
11
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
** GNU General Public License for more details.
14
** You should have received a copy of the GNU General Public License
15
** along with this program; if not, write to the Free Software Foundation,
16
** Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
#ifndef __MU_QUERY_SQLITE_H__
21
#define __MU_QUERY_SQLITE_H__
26
#include "mu-msg-sqlite.h"
29
* MuQuerySQLite. Usually, it is not used directly, but through
32
struct _MuQuerySQLite;
33
typedef struct _MuQuerySQLite MuQuerySQLite;
36
* create a new MuQuerySqlite instance.
38
* @param dbpath path to the sqlite db to search
39
* @param err receives error information (if there is any)
41
* @return a new MuQuerySqlite instance, or NULL in case of error.
42
* when the instance is no longer needed, use mu_query_sqlite_destroy
45
MuQuerySQLite *mu_query_sqlite_new (const char* dbpath,
49
* destroy the MuQueryMgr instance
51
* @param mgr a MuQueryMgr instance, or NULL
53
void mu_query_sqlite_destroy (MuQuerySQLite *query);
56
* run a SQL query on the database, and return the resulting row
57
* (if it is a SELECT query); you must call mu_msg_sqlite_next to
58
* move to that first row
60
* @param mgr a MuQuerySqliter instance, or NULL
61
* @param sql the sql query to run
62
* @err a GError ptr ptr to return an error (if any), or NULL
64
* @return a new MuMsgSQLite object with the search query, or NULL in
65
* case of error. to get the first result row, do mu_msg_sqlite_next
66
* and get subsequent rows with the next call to mu_msg_sqlite_next
67
* until that call returns FALSE
69
MuMsgSQLite* mu_query_sqlite_run (MuQuerySQLite *query,
70
const char *sql, GError **err);
73
* run a SQL query on the database without returning rows
75
* @param mgr a MuQuerySqliter instance, or NULL
76
* @param sql the sql query to run
77
* @err a GError ptr ptr to return an error (if any), or NULL
79
* @return TRUE if the query succeeded, FALSE otherwise
81
gboolean mu_query_sqlite_exec (MuQuerySQLite *query,
82
const char *sql, GError **err);
85
#define MU_QUERY_STATS_TOP 5
86
struct _MuQueryStats {
88
uint64_t _newest_msg_ids [MU_QUERY_STATS_TOP];
89
uint64_t _oldest_msg_ids [MU_QUERY_STATS_TOP];
90
uint64_t _biggest_msg_ids [MU_QUERY_STATS_TOP];
92
uint64_t _most_popular_sender_ids [MU_QUERY_STATS_TOP];
93
uint64_t _most_popular_recipient_ids [MU_QUERY_STATS_TOP];
95
typedef struct _MuQueryStats MuQueryStats;
99
* get statistics about a table with messages; usually, this table will
100
* be a temp view/table created as a subset of the message table.
102
* @param query MuQuerySQLite instance
103
* @param tmpview the name of the table/view to get stats for
104
* @param stats ptr to a stats struct that will receive the result
106
* @return TRUE if succeeded, FALSE otherwise
108
gboolean mu_query_sqlite_get_stats (MuQuerySQLite *query,
110
MuQueryStats* stats);
113
#endif /*__MU_QUERY_SQLITE_H__*/