]> git.sur5r.net Git - glabels/blob - libglabels/lgl-db.h
Imported Upstream version 3.0.0
[glabels] / libglabels / lgl-db.h
1 /*
2  *  lgl-db.h
3  *  Copyright (C) 2006-2010  Jim Evins <evins@snaught.com>.
4  *
5  *  This file is part of libglabels.
6  *
7  *  libglabels is free software: you can redistribute it and/or modify
8  *  it under the terms of the GNU Lesser General Public License as published by
9  *  the Free Software Foundation, either version 3 of the License, or
10  *  (at your option) any later version.
11  *
12  *  libglabels is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  *  GNU Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public License
18  *  along with libglabels.  If not, see <http://www.gnu.org/licenses/>.
19  */
20
21 #ifndef __LGL_DB_H__
22 #define __LGL_DB_H__
23
24 #include <glib.h>
25
26 #include "lgl-paper.h"
27 #include "lgl-category.h"
28 #include "lgl-vendor.h"
29 #include "lgl-template.h"
30
31 G_BEGIN_DECLS
32
33 typedef enum
34 {
35         LGL_DB_REG_OK                =  0,
36         LGL_DB_REG_BAD_PAPER_ID      = -1,
37         LGL_DB_REG_BRAND_PART_EXISTS = -2,
38         LGL_DB_REG_FILE_WRITE_ERROR  = -3
39 } lglDbRegStatus;
40
41 typedef enum
42 {
43         LGL_DB_DELETE_OK                =  0,
44         LGL_DB_DELETE_DOES_NOT_EXIST    = -1,
45         LGL_DB_DELETE_NOT_USER_DEFINED  = -2,
46         LGL_DB_DELETE_FILE_ERROR        = -3
47 } lglDbDeleteStatus;
48
49
50 typedef void  (*lglDbNotifyFunc) (gpointer user_data);
51
52
53
54
55 /*
56  * Module initialization
57  */
58 void           lgl_db_init                           (void);
59
60
61
62 /*
63  * Notification
64  */
65 gulong         lgl_db_notify_add                     (lglDbNotifyFunc      func,
66                                                       gpointer             user_data);
67
68 void           lgl_db_notify_remove                  (gulong               id);
69
70
71
72 /*
73  * Paper
74  */
75 GList         *lgl_db_get_paper_id_list              (void);
76
77 void           lgl_db_free_paper_id_list             (GList               *ids);
78
79 GList         *lgl_db_get_paper_name_list            (void);
80
81 void           lgl_db_free_paper_name_list           (GList               *names);
82
83 lglPaper      *lgl_db_lookup_paper_from_name         (const gchar         *name);
84
85 lglPaper      *lgl_db_lookup_paper_from_id           (const gchar         *id);
86
87 gchar         *lgl_db_lookup_paper_id_from_name      (const gchar         *name);
88
89 gchar         *lgl_db_lookup_paper_name_from_id      (const gchar         *id);
90
91 gboolean       lgl_db_is_paper_id_known              (const gchar         *id);
92
93 gboolean       lgl_db_is_paper_id_other              (const gchar         *id);
94
95
96
97 /*
98  * Template categories
99  */
100 GList         *lgl_db_get_category_id_list           (void);
101
102 void           lgl_db_free_category_id_list          (GList              *ids);
103
104 GList         *lgl_db_get_category_name_list         (void);
105
106 void           lgl_db_free_category_name_list        (GList               *names);
107
108 lglCategory   *lgl_db_lookup_category_from_name      (const gchar         *name);
109
110 lglCategory   *lgl_db_lookup_category_from_id        (const gchar         *id);
111
112 gchar         *lgl_db_lookup_category_id_from_name   (const gchar         *name);
113
114 gchar         *lgl_db_lookup_category_name_from_id   (const gchar         *id);
115
116 gboolean       lgl_db_is_category_id_known           (const gchar         *id);
117
118
119 /*
120  * Vendor
121  */
122 GList         *lgl_db_get_vendor_name_list           (void);
123
124 void           lgl_db_free_vendor_name_list          (GList               *names);
125
126 lglVendor     *lgl_db_lookup_vendor_from_name        (const gchar         *name);
127
128 gboolean       lgl_db_is_vendor_name_known           (const gchar         *name);
129
130
131 /*
132  * Template brands
133  */
134 GList         *lgl_db_get_brand_list                 (const gchar         *paper_id,
135                                                       const gchar         *category_id);
136
137 void           lgl_db_free_brand_list                (GList               *brands);
138
139
140 /*
141  * Templates
142  */
143 lglDbRegStatus lgl_db_register_template              (const lglTemplate   *template);
144
145 lglDbDeleteStatus lgl_db_delete_template_by_name        (const gchar         *name);
146
147 lglDbDeleteStatus lgl_db_delete_template_by_brand_part  (const gchar         *brand,
148                                                          const gchar         *part);
149
150 gboolean       lgl_db_does_template_exist            (const gchar         *brand,
151                                                       const gchar         *part);
152
153 gboolean       lgl_db_does_template_name_exist       (const gchar         *name);
154
155 GList         *lgl_db_get_template_name_list_all     (const gchar         *brand,
156                                                       const gchar         *paper_id,
157                                                       const gchar         *category_id);
158
159 GList         *lgl_db_get_similar_template_name_list (const gchar         *name);
160
161 void           lgl_db_free_template_name_list        (GList               *names);
162
163 lglTemplate   *lgl_db_lookup_template_from_name      (const gchar         *name);
164
165 lglTemplate   *lgl_db_lookup_template_from_brand_part(const gchar         *brand,
166                                                       const gchar         *part);
167
168
169 /*
170  * Debugging functions
171  */
172 void           lgl_db_print_known_papers             (void);
173
174 void           lgl_db_print_known_categories         (void);
175
176 void           lgl_db_print_known_templates          (void);
177
178 void           lgl_db_print_aliases                  (const lglTemplate    *template);
179
180 void           lgl_db_print_known_vendors            (void);
181
182
183
184 G_END_DECLS
185
186 #endif /* __LGL_DB_H__ */
187
188
189
190 /*
191  * Local Variables:       -- emacs
192  * mode: C                -- emacs
193  * c-basic-offset: 8      -- emacs
194  * tab-width: 8           -- emacs
195  * indent-tabs-mode: nil  -- emacs
196  * End:                   -- emacs
197  */