initial message templates support
[claws.git] / src / jpilot.h
blobdd28795aba35b02aea739b64c53517f9f6b17eda
1 /*
2 * Sylpheed -- a GTK+ based, lightweight, and fast e-mail client
3 * Copyright (C) 2001 Match Grun
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 * Definitions for accessing JPilot database files.
22 * JPilot is Copyright(c) by Judd Montgomery.
23 * Visit http://www.jpilot.org for more details.
26 #ifndef __JPILOT_H__
27 #define __JPILOT_H__
29 #ifdef USE_JPILOT
31 #include <pi-address.h>
33 #include <time.h>
34 #include <stdio.h>
35 #include <glib.h>
37 #include "mgutils.h"
39 typedef struct _JPilotFile JPilotFile;
41 struct _JPilotFile {
42 gchar *name;
43 FILE *file;
44 gchar *path;
45 AddressCache *addressCache;
46 struct AddressAppInfo addrInfo;
47 gboolean readMetadata;
48 GSList *customLabels;
49 GSList *labelInd;
50 gint retVal;
51 GList *categoryList;
52 GList *catAddrList;
55 // Limits
56 #define JPILOT_NUM_LABELS 22 // Number of labels
57 #define JPILOT_NUM_PHONELABELS 8 // Number of phone number labels
58 #define JPILOT_NUM_CATEG 16 // Number of categories
59 #define JPILOT_LEN_LABEL 15 // Max length of label
60 #define JPILOT_LEN_CATEG 15 // Max length of category
61 #define JPILOT_NUM_ADDR_PHONE 5 // Number of phone entries a person can have
63 // Shamelessly copied from JPilot (libplugin.h)
64 typedef struct {
65 unsigned char db_name[32];
66 unsigned char flags[2];
67 unsigned char version[2];
68 unsigned char creation_time[4];
69 unsigned char modification_time[4];
70 unsigned char backup_time[4];
71 unsigned char modification_number[4];
72 unsigned char app_info_offset[4];
73 unsigned char sort_info_offset[4];
74 unsigned char type[4];/*Database ID */
75 unsigned char creator_id[4];/*Application ID */
76 unsigned char unique_id_seed[4];
77 unsigned char next_record_list_id[4];
78 unsigned char number_of_records[2];
79 } RawDBHeader;
81 // Shamelessly copied from JPilot (libplugin.h)
82 typedef struct {
83 char db_name[32];
84 unsigned int flags;
85 unsigned int version;
86 time_t creation_time;
87 time_t modification_time;
88 time_t backup_time;
89 unsigned int modification_number;
90 unsigned int app_info_offset;
91 unsigned int sort_info_offset;
92 char type[5];/*Database ID */
93 char creator_id[5];/*Application ID */
94 char unique_id_seed[5];
95 unsigned int next_record_list_id;
96 unsigned int number_of_records;
97 } DBHeader;
99 // Shamelessly copied from JPilot (libplugin.h)
100 typedef struct {
101 unsigned char Offset[4]; /*4 bytes offset from BOF to record */
102 unsigned char attrib;
103 unsigned char unique_ID[3];
104 } record_header;
106 // Shamelessly copied from JPilot (libplugin.h)
107 typedef struct mem_rec_header_s {
108 unsigned int rec_num;
109 unsigned int offset;
110 unsigned int unique_id;
111 unsigned char attrib;
112 struct mem_rec_header_s *next;
113 } mem_rec_header;
115 // Shamelessly copied from JPilot (libplugin.h)
116 #define SPENT_PC_RECORD_BIT 256
118 typedef enum {
119 PALM_REC = 100L,
120 MODIFIED_PALM_REC = 101L,
121 DELETED_PALM_REC = 102L,
122 NEW_PC_REC = 103L,
123 DELETED_PC_REC = SPENT_PC_RECORD_BIT + 104L,
124 DELETED_DELETED_PALM_REC = SPENT_PC_RECORD_BIT + 105L
125 } PCRecType;
127 // Shamelessly copied from JPilot (libplugin.h)
128 typedef struct {
129 PCRecType rt;
130 unsigned int unique_id;
131 unsigned char attrib;
132 void *buf;
133 int size;
134 } buf_rec;
136 /* Function prototypes */
137 JPilotFile *jpilot_create();
138 JPilotFile *jpilot_create_path( const gchar *path );
139 void jpilot_free( JPilotFile *pilotFile );
140 void jpilot_force_refresh( JPilotFile *pilotFile );
141 gboolean jpilot_get_modified( JPilotFile *pilotFile );
142 void jpilot_print_file( JPilotFile *jpilotFile, FILE *stream );
143 void jpilot_print_list( GSList *list, FILE *stream );
144 gint jpilot_read_file( JPilotFile *pilotFile );
146 GList *jpilot_get_address_list( JPilotFile *pilotFile );
147 GSList *jpilot_load_label( JPilotFile *pilotFile, GSList *labelList );
148 GSList *jpilot_get_category_list( JPilotFile *pilotFile );
149 gchar *jpilot_get_category_name( JPilotFile *pilotFile, gint catID );
150 GSList *jpilot_load_phone_label( JPilotFile *pilotFile, GSList *labelList );
151 GList *jpilot_load_custom_label( JPilotFile *pilotFile, GList *labelList );
153 GList *jpilot_get_category_items( JPilotFile *pilotFile );
154 GList *jpilot_get_address_list_cat( JPilotFile *pilotFile, const gint catID );
156 void jpilot_set_file( JPilotFile* pilotFile, const gchar *path );
157 gboolean jpilot_validate( const JPilotFile *pilotFile );
158 gchar *jpilot_find_pilotdb( void );
159 gint jpilot_test_read_data( const gchar *fileSpec );
161 void jpilot_clear_custom_labels( JPilotFile *pilotFile );
162 void jpilot_add_custom_label( JPilotFile *pilotFile, const gchar *labelName );
163 GList *jpilot_get_custom_labels( JPilotFile *pilotFile );
164 gboolean jpilot_test_custom_label( JPilotFile *pilotFile, const gchar *labelName );
165 gboolean jpilot_setup_labels( JPilotFile *pilotFile );
166 gboolean jpilot_test_pilot_lib();
168 #endif /* USE_JPILOT */
170 #endif /* __JPILOT_H__ */