kpilot Library API Documentation

libplugin.h

00001 /* libplugin.h 00002 * 00003 * Copyright (C) 1999 by Judd Montgomery 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; version 2 of the License. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 */ 00018 #ifndef __LIBPLUGIN_H__ 00019 #define __LIBPLUGIN_H__ 00020 00021 00022 #include <gtk/gtk.h> 00023 00024 /* 00025 * PLUGIN API for J-Pilot 00026 */ 00027 00028 /* 00029 * For versioning of files 00030 */ 00031 #define FILE_VERSION "version" 00032 #define FILE_VERSION2 "version2" 00033 #define FILE_VERSION2_CR "version2\n" 00034 00035 00036 typedef struct { 00037 unsigned char Offset[4]; /*4 bytes offset from BOF to record */ 00038 unsigned char attrib; 00039 unsigned char unique_ID[3]; 00040 } record_header; 00041 00042 typedef struct { 00043 unsigned long header_len; 00044 unsigned long header_version; 00045 unsigned long rec_len; 00046 unsigned long unique_id; 00047 unsigned long rt; /* Record Type */ 00048 unsigned char attrib; 00049 } PC3RecordHeader; 00050 00051 typedef struct mem_rec_header_s { 00052 unsigned int rec_num; 00053 unsigned int offset; 00054 unsigned int unique_id; 00055 unsigned char attrib; 00056 struct mem_rec_header_s *next; 00057 } mem_rec_header; 00058 00059 typedef struct { 00060 unsigned char db_name[32]; 00061 unsigned char flags[2]; 00062 unsigned char version[2]; 00063 unsigned char creation_time[4]; 00064 unsigned char modification_time[4]; 00065 unsigned char backup_time[4]; 00066 unsigned char modification_number[4]; 00067 unsigned char app_info_offset[4]; 00068 unsigned char sort_info_offset[4]; 00069 unsigned char type[4];/*Database ID */ 00070 unsigned char creator_id[4];/*Application ID */ 00071 unsigned char unique_id_seed[4]; 00072 unsigned char next_record_list_id[4]; 00073 unsigned char number_of_records[2]; 00074 } RawDBHeader; 00075 00076 typedef struct { 00077 char db_name[32]; 00078 unsigned int flags; 00079 unsigned int version; 00080 time_t creation_time; 00081 time_t modification_time; 00082 time_t backup_time; 00083 unsigned int modification_number; 00084 unsigned int app_info_offset; 00085 unsigned int sort_info_offset; 00086 char type[5];/*Database ID */ 00087 char creator_id[5];/*Application ID */ 00088 char unique_id_seed[5]; 00089 unsigned int next_record_list_id; 00090 unsigned int number_of_records; 00091 } DBHeader; 00092 00093 int get_next_unique_pc_id(unsigned int *next_unique_id); 00094 00095 /* used for jp_delete_record */ 00096 #define CLEAR_FLAG 1 00097 #define CANCEL_FLAG 2 00098 #define DELETE_FLAG 3 00099 #define MODIFY_FLAG 4 00100 #define NEW_FLAG 5 00101 00102 #define CLIST_DEL_RED 0xCCCC; 00103 #define CLIST_DEL_GREEN 0xCCCC; 00104 #define CLIST_DEL_BLUE 0xCCCC; 00105 #define CLIST_NEW_RED 55000; 00106 #define CLIST_NEW_GREEN 55000; 00107 #define CLIST_NEW_BLUE 65535; 00108 #define CLIST_MOD_RED 55000; 00109 #define CLIST_MOD_GREEN 65535; 00110 #define CLIST_MOD_BLUE 65535; 00111 00112 #define LOG_DEBUG 1 /*debugging info for programers, and bug reports */ 00113 #define LOG_INFO 2 /*info, and misc messages */ 00114 #define LOG_WARN 4 /*worse messages */ 00115 #define LOG_FATAL 8 /*even worse messages */ 00116 #define LOG_STDOUT 256 /*messages always go to stdout */ 00117 #define LOG_FILE 512 /*messages always go to the log file */ 00118 #define LOG_GUI 1024 /*messages always go to the gui window */ 00119 00120 #define JPILOT_EOF -7 00121 00122 int jpilot_logf(int level, char *format, ...); 00123 int jp_logf(int level, char *format, ...); 00124 /* FIXME: Need a policy. Should all symbols available to 00125 * plugins start with jp or jpilot? 00126 */ 00127 /*#define jp_logf jpilot_logf*/ 00128 00129 #define SPENT_PC_RECORD_BIT 256 00130 00131 typedef enum { 00132 PALM_REC = 100L, 00133 MODIFIED_PALM_REC = 101L, 00134 DELETED_PALM_REC = 102L, 00135 NEW_PC_REC = 103L, 00136 DELETED_PC_REC = SPENT_PC_RECORD_BIT + 104L, 00137 DELETED_DELETED_PALM_REC = SPENT_PC_RECORD_BIT + 105L 00138 } PCRecType; 00139 00140 typedef struct 00141 { 00142 PCRecType rt; 00143 unsigned int unique_id; 00144 unsigned char attrib; 00145 void *buf; 00146 int size; 00147 } buf_rec; 00148 00149 typedef struct 00150 { 00151 char *base_dir; 00152 int *major_version; 00153 int *minor_version; 00154 } jp_startup_info; 00155 00156 struct search_result 00157 { 00158 char *line; 00159 unsigned int unique_id; 00160 struct search_result *next; 00161 }; 00162 00163 /* void free_buf_rec_list(GList **br_list); */ 00164 00165 int plugin_get_name(char *name, int len); 00166 int plugin_get_menu_name(char *name, int len); 00167 int plugin_get_db_name(char *db_name, int len); 00168 int plugin_startup(jp_startup_info *info); 00169 int plugin_gui(GtkWidget *vbox, GtkWidget *hbox, unsigned int unique_id); 00170 int plugin_help(char **text, int *width, int *height); 00171 int plugin_gui_cleanup(void); 00172 int plugin_pre_sync(void); 00173 int plugin_sync(int sd); 00174 int plugin_search(char *search_string, int case_sense, struct search_result **sr); 00175 int plugin_post_sync(void); 00176 int plugin_exit_cleanup(void); 00177 /* callbacks are needed for print */ 00178 00179 extern void jp_init(); 00180 extern FILE *jp_open_home_file(char *filename, char *mode); 00181 00182 /* file must not be open elsewhere when this is called, the first line is 0 */ 00183 int jp_install_remove_line(int deleted_line); 00184 00185 int jp_install_append_line(char *line); 00186 00187 /* 00188 * Get the application info block 00189 */ 00190 int jp_get_app_info(char *DB_name, unsigned char **buf, int *buf_size); 00191 /* 00192 * Read a pdb file out of the $(JPILOT_HOME || HOME)/.jpilot/ directory 00193 * It also reads the PC file 00194 */ 00195 int jp_read_DB_files(char *DB_name, GList **records); 00196 00197 /* 00198 *This deletes a record from the appropriate Datafile 00199 */ 00200 int jp_delete_record(char *DB_name, buf_rec *br, int flag); 00201 /* 00202 * Free the record list 00203 */ 00204 int jp_free_DB_records(GList **records); 00205 00206 int jp_pc_write(char *DB_name, buf_rec *br); 00207 00208 const char *jp_strstr(const char *haystack, const char *needle, int case_sense); 00209 00210 int read_header(FILE *pc_in, PC3RecordHeader *header); 00211 00212 int write_header(FILE *pc_out, PC3RecordHeader *header); 00213 00214 /* 00215 * These 2 functions don't take full path names. 00216 * They are relative to $JPILOT_HOME/.jpilot/ 00217 */ 00218 int rename_file(char *old_filename, char *new_filename); 00219 int unlink_file(char *filename); 00220 00221 /* */ 00222 /*Warning, this function will move the file pointer */ 00223 /* */ 00224 int get_app_info_size(FILE *in, int *size); 00225 00226 #endif
KDE Logo
This file is part of the documentation for kpilot Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Jul 28 23:57:49 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003