~ubuntu-branches/ubuntu/quantal/maildir-utils/quantal

« back to all changes in this revision

Viewing changes to find/mu-query-sqlite.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Preining
  • Date: 2010-01-19 20:12:43 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20100119201243-d8qmzgxgexhy1bs0
Tags: 0.6~beta1-1
* new upstream release 0.6-beta
  - that merges the several different programs under one binary mu
  - no sqlite storage is used anymore
* debian packaging changes:
  - debian/patches
    . remove all patches
  - remove debian/HOWTO (upstream document) it is completely outdated
  - debian/control:
    . adjust build-dep for gmime-2.4
    . remove build-dep on quilt and sqlite
    . adjust the description to new reality
  - debian/rules:
    . do not try to install doc files that are not present anymore
    . disable quilt adaptions
  - add debian/NEWS that explains that the separate programs are gone

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* 
2
 
** Copyright (C) 2008 Dirk-Jan C. Binnema <djcb@djcbsoftware.nl>
3
 
**
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
7
 
** later version.
8
 
**
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.
13
 
**
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.  
17
 
**  
18
 
*/
19
 
 
20
 
#ifndef __MU_QUERY_SQLITE_H__
21
 
#define __MU_QUERY_SQLITE_H__
22
 
 
23
 
#include <glib.h>
24
 
#include <inttypes.h>
25
 
 
26
 
#include "mu-msg-sqlite.h"
27
 
 
28
 
/*
29
 
 * MuQuerySQLite. Usually, it is not used directly, but through
30
 
 * MuQueryMgr
31
 
 */
32
 
struct _MuQuerySQLite;
33
 
typedef struct _MuQuerySQLite MuQuerySQLite;
34
 
 
35
 
/** 
36
 
 * create a new MuQuerySqlite instance. 
37
 
 * 
38
 
 * @param dbpath path to the sqlite db to search
39
 
 * @param err receives error information (if there is any)
40
 
 * 
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
43
 
 * to free it
44
 
 */
45
 
MuQuerySQLite *mu_query_sqlite_new      (const char* dbpath,
46
 
                                         GError **err);
47
 
 
48
 
/** 
49
 
 * destroy the MuQueryMgr instance
50
 
 * 
51
 
 * @param mgr a MuQueryMgr instance, or NULL
52
 
 */
53
 
void           mu_query_sqlite_destroy  (MuQuerySQLite *query);
54
 
 
55
 
/** 
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
59
 
 * 
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
63
 
 * 
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
68
 
 */
69
 
MuMsgSQLite*      mu_query_sqlite_run      (MuQuerySQLite *query, 
70
 
                                            const char *sql, GError **err);
71
 
 
72
 
/** 
73
 
 * run a SQL query on the database without returning rows
74
 
 * 
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
78
 
 * 
79
 
 * @return TRUE if the query succeeded, FALSE otherwise
80
 
 */
81
 
gboolean          mu_query_sqlite_exec     (MuQuerySQLite *query, 
82
 
                                            const char *sql, GError **err);
83
 
 
84
 
 
85
 
#define MU_QUERY_STATS_TOP 5
86
 
struct _MuQueryStats {
87
 
        size_t   _msg_num;
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];
91
 
        size_t   _avg_msg_size;    
92
 
        uint64_t _most_popular_sender_ids    [MU_QUERY_STATS_TOP]; 
93
 
        uint64_t _most_popular_recipient_ids [MU_QUERY_STATS_TOP];
94
 
};
95
 
typedef struct _MuQueryStats MuQueryStats;
96
 
 
97
 
 
98
 
/** 
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. 
101
 
 *
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
105
 
 * 
106
 
 * @return TRUE if succeeded, FALSE otherwise
107
 
 */
108
 
gboolean          mu_query_sqlite_get_stats (MuQuerySQLite *query, 
109
 
                                             const char* tmpview,
110
 
                                             MuQueryStats* stats);
111
 
 
112
 
 
113
 
#endif /*__MU_QUERY_SQLITE_H__*/