diff --git a/BUGS b/BUGS index a9875bac..99484eb6 100644 --- a/BUGS +++ b/BUGS @@ -1,3 +1,11 @@ +If you wish to report a bug, and the bug is reproduceable it may be helpful to +me if you run jpilot -d to run in debug mode, reproduce the error and then +send me the log file from ~/.jpilot/jpilot.log + +---------------------------------------------------------------------- + +These are the bugs that I know about: + *Priority High: *Priority Medium: @@ -5,18 +13,9 @@ *Priority Low: - Things don't work quite right if you've never synced before. - - - It seems like the sync doesn't always work with xcopilot. - If xcopilot hasn't been run in a while and you don't set the date on it, it - seems to not update the datebase modification times correctly. On every sync - it would not bring back the palm database because the modification time - hadn't changed. pilot-xfer behaves the same way. - I set the time on xcopilot and then could not reproduce this problem again. + - I'll probably fix this some day. *Priority Who Cares?: - - If you click really fast on the buttons to scroll through the months, then - it will segmentation fault. - I think I have fixed this though. *Quirks (not really bugs): diff --git a/CHANGELOG b/CHANGELOG index d4f5727d..398e9b0c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,6 +1,7 @@ 0.90a - 06/23/99 Initial release. -0.91 - + +0.91 - 07/03/99 Fixed some feof() problem that caused datebook to not work on RedHat 6.0 I rewrote the entire datebook.c file Put in code to create and test for writability of ~/.jpilot/ @@ -18,3 +19,20 @@ 4th occurence of that day in the a month, or the last occurence of that day in the month. This is only asked when it cannot be deduced. The Palm Pilot will also ask this question. + Fixed Mobile not being displayed in address app. + +0.92 - 00/00/99 + Fixed problem reading palm db files with 0 records. + Added option for viewing only uncompleted todos. + Fixed a GUI problem when adding an address the phone menus didn't update + right while selecting addresses on the left pane. + Added a window to show the syncing output. + Added a full backup button. + Added forking of a process to do the sync in the background. + Fixed category label in todo, address, and memo apps. + Added modify capability in datebook, address, todo, and memo apps. + Added the ability to check/uncheck todos. + When deleteing repeating appointments it will now ask if you intend to delete + just one occurence, or all occurences. + Added some tooltips to show how many records are in a DB. + diff --git a/INSTALL b/INSTALL index 50d82a79..bb5643f4 100644 --- a/INSTALL +++ b/INSTALL @@ -1,17 +1,28 @@ -you need to have gtk1.2 or better (I haven't tried anything older) +You need to have gtk1.2 or better. gtk requires glib. you can get these at http://www.gtk.org pilot link must be installed and working. ftp://ryeham.ee.ryerson.ca/pub/PalmOS/ +RedHat users must also have the pilot-link-dev rpm installed for the header + files. jpilot currently uses the PILOTPORT and PILOTRATE environment variables, as does pilot-link. -edit the first few lines of Makefile +edit the first few lines of Makefile if neccessary. make mkdir ~/.jpilot/ -cp jpilotrc ~/.jpilot/ -jpilot -you may want to sync before you do anything +cp jpilotrc ~/.jpilot/ (or you can do a cp jpilotrc.blue ~/.jpilot/jpilotrc + if you like blue better) +./jpilot +Put the executable in /usr/local/bin, or somewhere. + + +Currently, you have to sync before the program will behave correctly. +JPilot was written in such a way that it should be very safe to sync. +I have had no reports of data being corrupted, or lost. There is always +that possibility though. As with anything else, backup your data if you +cannot afford to lose it. Just make sure your backup software destroy it +first ;) diff --git a/Makefile b/Makefile index 3d91a374..f4fb678f 100644 --- a/Makefile +++ b/Makefile @@ -2,51 +2,55 @@ PILOT_DIR=/usr/extra/pilot #set CC to your compiler CC = gcc +OPTIONS = -Wunused -Wuninitialized -O3 #you should be all done PILOT_LIB = -L$(PILOT_DIR)/lib -lpisock PILOT_INCLUDE = -I$(PILOT_DIR)/include -all: jpilot jpilot-syncd +all: jpilot jpilot: jpilot.o datebook.o address.o todo.o memo.o \ datebook_gui.o address_gui.o todo_gui.o memo_gui.o \ - utils.o sync.o - $(CC) $(PILOT_LIB) `gtk-config --cflags` `gtk-config --libs` \ - jpilot.o datebook.o address.o todo.o memo.o utils.o sync.o \ + utils.o sync.o log.o + $(CC) $(OPTIONS) $(PILOT_LIB) `gtk-config --cflags` `gtk-config --libs` \ + jpilot.o datebook.o address.o todo.o memo.o utils.o sync.o log.o \ datebook_gui.o address_gui.o todo_gui.o memo_gui.o -o jpilot -jpilot.o: jpilot.c datebook.h utils.h utils.o - $(CC) $(PILOT_INCLUDE) `gtk-config --cflags` -c jpilot.c +jpilot.o: jpilot.c utils.h + $(CC) $(OPTIONS) $(PILOT_INCLUDE) `gtk-config --cflags` -c jpilot.c datebook.o: datebook.c datebook.h utils.h - $(CC) $(PILOT_INCLUDE) `gtk-config --cflags` -c datebook.c + $(CC) $(OPTIONS) $(PILOT_INCLUDE) `gtk-config --cflags` -c datebook.c address.o: address.c address.h utils.h - $(CC) $(PILOT_INCLUDE) `gtk-config --cflags` -c address.c + $(CC) $(OPTIONS) $(PILOT_INCLUDE) `gtk-config --cflags` -c address.c todo.o: todo.c todo.h utils.h - $(CC) $(PILOT_INCLUDE) `gtk-config --cflags` -c todo.c + $(CC) $(OPTIONS) $(PILOT_INCLUDE) `gtk-config --cflags` -c todo.c memo.o: memo.c utils.h - $(CC) $(PILOT_INCLUDE) `gtk-config --cflags` -c memo.c + $(CC) $(OPTIONS) $(PILOT_INCLUDE) `gtk-config --cflags` -c memo.c datebook_gui.o: datebook_gui.c utils.h - $(CC) $(PILOT_INCLUDE) `gtk-config --cflags` -c datebook_gui.c + $(CC) $(OPTIONS) $(PILOT_INCLUDE) `gtk-config --cflags` -c datebook_gui.c address_gui.o: address_gui.c address.o - $(CC) $(PILOT_INCLUDE) `gtk-config --cflags` -c address_gui.c + $(CC) $(OPTIONS) $(PILOT_INCLUDE) `gtk-config --cflags` -c address_gui.c todo_gui.o: todo_gui.c todo.o utils.h - $(CC) $(PILOT_INCLUDE) `gtk-config --cflags` -c todo_gui.c + $(CC) $(OPTIONS) $(PILOT_INCLUDE) `gtk-config --cflags` -c todo_gui.c memo_gui.o: memo_gui.c utils.h - $(CC) $(PILOT_INCLUDE) `gtk-config --cflags` -c memo_gui.c + $(CC) $(OPTIONS) $(PILOT_INCLUDE) `gtk-config --cflags` -c memo_gui.c utils.o: utils.c utils.h - $(CC) $(PILOT_INCLUDE) `gtk-config --cflags` -c utils.c + $(CC) $(OPTIONS) $(PILOT_INCLUDE) `gtk-config --cflags` -c utils.c sync.o: sync.c sync.h - $(CC) $(PILOT_INCLUDE) `gtk-config --cflags` -c sync.c + $(CC) $(OPTIONS) $(PILOT_INCLUDE) `gtk-config --cflags` -c sync.c + +log.o: log.c log.h + $(CC) $(OPTIONS) $(PILOT_INCLUDE) `gtk-config --cflags` -c log.c clean: rm -f *.o *~ @@ -57,26 +61,26 @@ clean: # Pilot needs to be pressed. # jpilot-syncd: jpilot-syncd.o sync.o - $(CC) $(PILOT_LIB) `gtk-config --cflags` `gtk-config --libs` \ + $(CC) $(OPTIONS) $(PILOT_LIB) `gtk-config --cflags` `gtk-config --libs` \ jpilot-syncd.o sync.o utils.o -o jpilot-syncd jpilot-syncd.o: jpilot-syncd.c utils.h utils.o - $(CC) $(PILOT_INCLUDE) `gtk-config --cflags` -c jpilot-syncd.c + $(CC) $(OPTIONS) $(PILOT_INCLUDE) `gtk-config --cflags` -c jpilot-syncd.c # #Some other stuff # ttt: ttt.c - $(CC) `gtk-config --cflags` `gtk-config --libs` ttt.c -o ttt + $(CC) $(OPTIONS) `gtk-config --cflags` `gtk-config --libs` ttt.c -o ttt dump_datebook: dump_datebook.c - $(CC) $(PILOT_LIB) $(PILOT_INCLUDE) dump_datebook.c -o dump_datebook + $(CC) $(OPTIONS) $(PILOT_LIB) $(PILOT_INCLUDE) dump_datebook.c -o dump_datebook dump_address: dump_address.c - $(CC) $(PILOT_LIB) $(PILOT_INCLUDE) utils.o dump_address.c -o dump_address + $(CC) $(OPTIONS) $(PILOT_LIB) $(PILOT_INCLUDE) utils.o dump_address.c -o dump_address dump_todo: dump_todo.c - $(CC) $(PILOT_LIB) $(PILOT_INCLUDE) utils.o dump_todo.c -o dump_todo + $(CC) $(OPTIONS) $(PILOT_LIB) $(PILOT_INCLUDE) utils.o dump_todo.c -o dump_todo install-datebook: install-datebook.c - $(CC) $(INCLUDES) $(PILOT_LIB) install-datebook.c -o install-datebook + $(CC) $(OPTIONS) $(INCLUDES) $(PILOT_LIB) install-datebook.c -o install-datebook diff --git a/README b/README index 6b3c704c..50c1b09d 100644 --- a/README +++ b/README @@ -5,17 +5,22 @@ It is very useable, but still has many planned updates to make it better. If you like it feel to send me donations ;) I collect coins from anywhere, anytime also. -email me and I'll send you my address. - -If you use this program send me an email and let me know. I'd like to know +At least send me an email and let me know you are using it. I'd like to know how many people this is useful to. +Judd Montgomery +P.O. Box 665 +Sunbury, OH 43074 + + jpilot reads the PILOTPORT environment variable to get the port to sync on. -If this is not set, then it defaults to /dev/pilot. +If this is not set, then it defaults to /dev/pilot. It also reads PILOTRATE +to get the serial port rate. jpilot-syncd is a syncing daemon for jpilot. It just sits and waits for the Sync button to be pressed on the Palm pilot and then it syncs it. This is -just an optional program. It is not necessary. +just an optional program. It is not necessary. I removed this in 0.92, +I'll probably put it back. COLORS: @@ -24,10 +29,16 @@ screens. If you create your own cool jpilotrc files feel free to send them back to me and if I like it, I'll include it in the release. I'll probably make a few selectable with a pull-down menu. -MODIFYING RECORDS: +HOME: + +jpilot uses the HOME environment variable to make it easy to allow multiple +pilots to be synced under the same user. Just set HOME to the directory +you want jpilot to use. + +OOPS, REVERTING: -Even though you can't modify records at the moment, the GUI is set up to -make it easy to do. Just click the add line in the left screen, then select -the record that you would like to modify, and it will come up. Make the -changes and add it. Then you can delete the old one. This is what modify -will eventually do for you. +You can always make the databases revert back to the last time that the +pilot was synced. All you have to do is "rm ~/.jpilot/*.pc". +Deleted records will come back, etc. Nothing is permanent until the +sync/backup. You can do this if you make a mistake, or just to play around +with jpilot and then delete the changed records without syncing them. diff --git a/TODO b/TODO index 8e7ce20c..8ff2dc66 100644 --- a/TODO +++ b/TODO @@ -1,23 +1,15 @@ -These are some of the things on my list todo, not neccesarily in this order: +These are some of the things on my list todo, mostly, but not neccesarily +in this order: - -* fix category label in todo, adress, and memo apps -* fix return codes, they are a mess. +* Add in search functions +* Printing +* Make preferences and rc files to remember settings. * Use autoconf to generate a configure script since they are so cool. -* Add in file locking, right now if you run 2 jpilots as the same user - then you may have DB file problems. (who cares?) +* Put in a menubar if needed. * Put up a graph showing the days schedual. -* Make the datebook ask if an event is supposed to be in the 4th week, - or if last week of the month. * Hide, or Show private records. -* Let records be modified instead of just removed, or added. * Do a fast sync, user choice of fast, or slow. (A slow sync allows another PC to do the archiving) -* Make the slow sync faster. -* Archive "to be archived" records? -* allow multiple pilots to sync in separate directories?? -* Add in search functions -* Printing -* Make the output go into a window instead of stdout. -* Put in gtk hints. -* Put in a menubar if needed. +* Add in file locking, right now if you run 2 jpilots as the same user + then you may have DB file problems. (who cares?) +* fix return codes, and clean up the code, it is a little messy. diff --git a/address.c b/address.c index f03937c2..dd35609a 100644 --- a/address.c +++ b/address.c @@ -23,6 +23,7 @@ #include #include "address.h" #include "utils.h" +#include "log.h" #define ADDRESS_EOF 7 @@ -33,7 +34,7 @@ int print_address_list(AddressList **al) for (prev_al=NULL, temp_al=*al; temp_al; prev_al=temp_al, temp_al=temp_al->next) { - printf("entry[0]=[%s]\n", temp_al->ma.a.entry[0]); + logf(LOG_FILE | LOG_STDOUT, "entry[0]=[%s]\n", temp_al->ma.a.entry[0]); } } #endif @@ -133,27 +134,21 @@ static int pc_address_read_next_rec(FILE *in, MyAddress *ma) PCRecordHeader header; int rec_len, num; char *record; - //DatebookRecType rt; if (feof(in)) { return ADDRESS_EOF; } -// if (ftell(in)==0) { -// printf("Error: File header not read\n"); -// return ADDRESS_EOF; -// } num = fread(&header, sizeof(header), 1, in); if (feof(in)) { return ADDRESS_EOF; } if (num != 1) { - printf("error on fread\n"); + logf(LOG_WARN, "error on fread\n"); return ADDRESS_EOF; } rec_len = header.rec_len; ma->rt = header.rt; ma->attrib = header.attrib; - //printf("read attrib = %d\n", ma->attrib); ma->unique_id = header.unique_id; record = malloc(rec_len); if (!record) { @@ -180,18 +175,18 @@ int pc_address_write(struct Address *a, PCRecType rt, unsigned char attrib) get_next_unique_pc_id(&next_unique_id); #ifdef JPILOT_DEBUG - printf("next unique id = %d\n",next_unique_id); + logf(LOG_DEBUG, "next unique id = %d\n",next_unique_id); #endif out = open_file("AddressDB.pc", "a"); if (!out) { - printf("Error opening AddressDB.pc\n"); + logf(LOG_WARN, "Error opening AddressDB.pc\n"); return -1; } rec_len = pack_Address(a, record, 65535); if (!rec_len) { PRINT_FILE_LINE; - printf("pack_Address error\n"); + logf(LOG_WARN, "pack_Address error\n"); } header.rec_len=rec_len; header.rt=rt; @@ -226,19 +221,20 @@ int get_address_app_info(struct AddressAppInfo *ai) in = open_file("AddressDB.pdb", "r"); if (!in) { - printf("Error opening AddressDB.pdb\n"); + logf(LOG_WARN, "Error opening AddressDB.pdb\n"); return -1; } fread(&rdbh, sizeof(RawDBHeader), 1, in); if (feof(in)) { - printf("Error reading AddressDB.pdb\n"); + logf(LOG_WARN, "Error reading AddressDB.pdb\n"); fclose(in); return -1; } raw_header_to_header(&rdbh, &dbh); + get_app_info_size(in, &rec_size); + fseek(in, dbh.app_info_offset, SEEK_SET); - rec_size = 865; buf=malloc(rec_size); if (!buf) { fclose(in); @@ -247,7 +243,7 @@ int get_address_app_info(struct AddressAppInfo *ai) num = fread(buf, 1, rec_size, in); if (feof(in)) { fclose(in); - printf("Error reading AddressDB.pdb\n"); + logf(LOG_WARN, "Error reading AddressDB.pdb\n"); return -1; } unpack_AddressAppInfo(ai, buf, rec_size); @@ -261,15 +257,9 @@ int get_address_app_info(struct AddressAppInfo *ai) int get_addresses(AddressList **address_list) { FILE *in, *pc_in; -// *address_list=NULL; -// char db_name[34]; -// char filler[100]; char *buf; -// unsigned char char_num_records[4]; -// unsigned char char_ai_offset[4];//app info offset - int num_records, i, num, r; + int num_records, recs_returned, i, num, r; unsigned int offset, next_offset, rec_size; -// unsigned char c; long fpos; //file position indicator unsigned char attrib; unsigned int unique_id; @@ -278,41 +268,43 @@ int get_addresses(AddressList **address_list) RawDBHeader rdbh; DBHeader dbh; struct Address a; - struct AddressAppInfo ai; AddressList *temp_address_list; MyAddress ma; mem_rh = NULL; + recs_returned = 0; in = open_file("AddressDB.pdb", "r"); if (!in) { - printf("Error opening AddressDB.pdb\n"); + logf(LOG_WARN, "Error opening AddressDB.pdb\n"); return -1; } //Read the database header fread(&rdbh, sizeof(RawDBHeader), 1, in); if (feof(in)) { - printf("Error opening AddressDB.pdb\n"); + logf(LOG_WARN, "Error opening AddressDB.pdb\n"); return -1; } raw_header_to_header(&rdbh, &dbh); - //printf("db_name = %s\n", dbh.db_name); - //printf("num records = %d\n", dbh.number_of_records); - //printf("app info offset = %d\n", dbh.app_info_offset); + logf(LOG_DEBUG, "db_name = %s\n", dbh.db_name); + logf(LOG_DEBUG, "num records = %d\n", dbh.number_of_records); + logf(LOG_DEBUG, "app info offset = %d\n", dbh.app_info_offset); //fread(filler, 2, 1, in); //Read each record entry header num_records = dbh.number_of_records; - //printf("sizeof(record_header)=%d\n",sizeof(record_header)); + //logf(LOG_DEBUG, "sizeof(record_header)=%d\n",sizeof(record_header)); for (i=1; inext = mem_rh; mem_rh = temp_mem_rh; @@ -322,70 +314,35 @@ int get_addresses(AddressList **address_list) mem_rh->unique_id = (rh.unique_ID[0]*256+rh.unique_ID[1])*256+rh.unique_ID[2]; } - /* - fseek(in, dbh.app_info_offset, SEEK_SET); - find_next_offset(mem_rh, 0, &next_offset, &attrib, &unique_id); - rec_size = next_offset - dbh.app_info_offset; - //printf("rec_size = %u\n",rec_size); - //printf("fpos,next_offset = %u %u\n",fpos,next_offset); - //printf("----------\n"); - buf=malloc(rec_size); - num = fread(buf, 1, rec_size, in); - unpack_AddressAppInfo(&ai, buf, rec_size); - free(buf); -//struct CategoryAppInfo { -// unsigned int renamed[16]; -// char name[16][16]; -// unsigned char ID[16]; -// unsigned char lastUniqueID; -//} - - for (i=0;i<16;i++) { - printf("renamed:[%02d]:\n",ai.category.renamed[i]); - print_string(ai.category.name[i],16); - printf("category name:[%02d]:",i); - print_string(ai.category.name[i],16); - printf("category ID:%d\n", ai.category.ID[i]); - } - - for (i=0;i<22;i++) { - printf("labels[%02d]:",i); - print_string(ai.labels[i],16); - } - for (i=0;i<8;i++) { - printf("phoneLabels[%d]:",i); - print_string(ai.phoneLabels[i],16); - } - printf("country %d\n",ai.country); - printf("sortByCompany %d\n",ai.sortByCompany); - */ - - find_next_offset(mem_rh, 0, &next_offset, &attrib, &unique_id); - fseek(in, next_offset, SEEK_SET); - - while(!feof(in)) { - fpos = ftell(in); - find_next_offset(mem_rh, fpos, &next_offset, &attrib, &unique_id); - //next_offset += 223; - rec_size = next_offset - fpos; - //printf("rec_size = %u\n",rec_size); - //printf("fpos,next_offset = %u %u\n",fpos,next_offset); - //printf("----------\n"); - if (feof(in)) break; - buf = malloc(rec_size); - if (!buf) break; - num = fread(buf, 1, rec_size, in); + if (num_records) { + find_next_offset(mem_rh, 0, &next_offset, &attrib, &unique_id); + fseek(in, next_offset, SEEK_SET); + while(!feof(in)) { + fpos = ftell(in); + find_next_offset(mem_rh, fpos, &next_offset, &attrib, &unique_id); + rec_size = next_offset - fpos; +#ifdef JPILOT_DEBUG + logf(LOG_DEBUG, "rec_size = %u\n",rec_size); + logf(LOG_DEBUG, "fpos,next_offset = %u %u\n",fpos,next_offset); + logf(LOG_DEBUG, "----------\n"); +#endif + if (feof(in)) break; + buf = malloc(rec_size); + if (!buf) break; + num = fread(buf, 1, rec_size, in); - unpack_Address(&a, buf, rec_size); - free(buf); - temp_address_list = malloc(sizeof(AddressList)); - memcpy(&(temp_address_list->ma.a), &a, sizeof(struct Address)); - //temp_address_list->ma.a = temp_a; - temp_address_list->ma.rt = PALM_REC; - temp_address_list->ma.attrib = attrib; - temp_address_list->ma.unique_id = unique_id; - temp_address_list->next = *address_list; - *address_list = temp_address_list; + unpack_Address(&a, buf, rec_size); + free(buf); + temp_address_list = malloc(sizeof(AddressList)); + memcpy(&(temp_address_list->ma.a), &a, sizeof(struct Address)); + //temp_address_list->ma.a = temp_a; + temp_address_list->ma.rt = PALM_REC; + temp_address_list->ma.attrib = attrib; + temp_address_list->ma.unique_id = unique_id; + temp_address_list->next = *address_list; + *address_list = temp_address_list; + recs_returned++; + } } fclose(in); free_mem_rec_header(&mem_rh); @@ -395,7 +352,7 @@ int get_addresses(AddressList **address_list) // pc_in = open_file("AddressDB.pc", "r"); if (pc_in==NULL) { - return 0; + return -1; } //r = pc_datebook_read_file_header(pc_in); while(!feof(pc_in)) { @@ -403,18 +360,20 @@ int get_addresses(AddressList **address_list) if (r==ADDRESS_EOF) break; if ((ma.rt!=DELETED_PC_REC) &&(ma.rt!=DELETED_PALM_REC) + &&(ma.rt!=MODIFIED_PALM_REC) &&(ma.rt!=DELETED_DELETED_PALM_REC)) { temp_address_list = malloc(sizeof(AddressList)); memcpy(&(temp_address_list->ma), &ma, sizeof(MyAddress)); temp_address_list->next = *address_list; *address_list = temp_address_list; + recs_returned++; //temp_address_list->ma.attrib=0; } else { //this doesnt really free it, just the string pointers free_Address(&(ma.a)); } - if (ma.rt==DELETED_PALM_REC) { + if ((ma.rt==DELETED_PALM_REC) || (ma.rt==MODIFIED_PALM_REC)) { for (temp_address_list = *address_list; temp_address_list; temp_address_list=temp_address_list->next) { if (temp_address_list->ma.unique_id == ma.unique_id) { @@ -429,4 +388,6 @@ int get_addresses(AddressList **address_list) print_address_list(address_list); #endif address_sort(address_list); + + return recs_returned; } diff --git a/address_gui.c b/address_gui.c index f667f2bf..92002978 100644 --- a/address_gui.c +++ b/address_gui.c @@ -20,6 +20,7 @@ #include #include "utils.h" #include "address.h" +#include "log.h" //#define SHADOW GTK_SHADOW_IN //#define SHADOW GTK_SHADOW_OUT @@ -31,11 +32,17 @@ GtkWidget *address_text[22]; GtkWidget *vbox2_1, *vbox2_2; GtkWidget *text; GtkWidget *vscrollbar; -GtkWidget *menu_item[9][8]; +GtkWidget *phone_list_menu[5]; +GtkWidget *menu; +GtkWidget *menu_item[8][8]; +GtkWidget *address_cat_menu2; +GtkWidget *address_cat_menu_item[16]; +GtkWidget *category_menu1; struct AddressAppInfo address_app_info; int address_category; int address_phone_label_selected[5]; int clist_row_selected; +extern GtkTooltips *glob_tooltips; void update_address_screen(); @@ -43,23 +50,27 @@ void cb_delete_address(GtkWidget *widget, gpointer data) { MyAddress *ma; - + int flag; + ma = gtk_clist_get_row_data(GTK_CLIST(clist), clist_row_selected); if (ma < (MyAddress *)CLIST_MIN_DATA) { return; } - //printf("ma->unique_id = %d\n",ma->unique_id); - //printf("ma->rt = %d\n",ma->rt); - delete_pc_record(ADDRESS, ma); + flag = GPOINTER_TO_INT(data); + if ((flag==MODIFY_FLAG) || (flag==DELETE_FLAG)) { + delete_pc_record(ADDRESS, ma, flag); + } update_address_screen(); } void cb_phone_menu(GtkWidget *item, unsigned int value) { + if (!item) + return; if ((GTK_CHECK_MENU_ITEM(item))->active) { - //printf("phone_menu = %d\n", (value & 0xF0) >> 4); - //printf("selection = %d\n", value & 0x0F); + logf(LOG_DEBUG, "phone_menu = %d\n", (value & 0xF0) >> 4); + logf(LOG_DEBUG, "selection = %d\n", value & 0x0F); address_phone_label_selected[(value & 0xF0) >> 4] = value & 0x0F; } } @@ -69,88 +80,124 @@ void cb_new_address_done(GtkWidget *widget, { int i, found; struct Address a; + MyAddress *ma; unsigned char attrib; gtk_widget_hide(vbox2_2); gtk_widget_show(vbox2_1); - if (data==0) { + if (GPOINTER_TO_INT(data)==CANCEL_FLAG) { //Cancel button was hit return; } - found=0; - a.showPhone=0; - for (i=0; i<19; i++) { - a.entry[i] = - gtk_editable_get_chars(GTK_EDITABLE(address_text[i]), 0, -1); - //printf("a.entry[%d] = [%s]\n", i, a.entry[i]); - if (i>2 && i<8 && !found) { - if (a.entry[i][0]!='\0') { - found=1; - a.showPhone=i-3; + if ((GPOINTER_TO_INT(data)==NEW_FLAG) || + (GPOINTER_TO_INT(data)==MODIFY_FLAG)) { + //These rec_types are both the same for now + if (GPOINTER_TO_INT(data)==MODIFY_FLAG) { + ma = gtk_clist_get_row_data(GTK_CLIST(clist), clist_row_selected); + if (ma < (MyAddress *)CLIST_MIN_DATA) { + return; + } + if ((ma->rt==DELETED_PALM_REC) || (ma->rt==MODIFIED_PALM_REC)) { + logf(LOG_INFO, "You can't modify a record that is deleted\n"); + return; } } - } - //printf("showPhone = %d\n", a.showPhone); - for (i=0; i<5; i++) { - //printf("phone label selected[%d]=%d\n",i,address_phone_label_selected[i]); - a.phoneLabel[i]=address_phone_label_selected[i]; - } + found=0; + a.showPhone=0; + for (i=0; i<19; i++) { + a.entry[i] = + gtk_editable_get_chars(GTK_EDITABLE(address_text[i]), 0, -1); + if (i>2 && i<8 && !found) { + if (a.entry[i][0]!='\0') { + found=1; + a.showPhone=i-3; + } + } + } + for (i=0; i<5; i++) { + a.phoneLabel[i]=address_phone_label_selected[i]; + } - if (address_category == CATEGORY_ALL) { + //Get the category that is set from the menu attrib = 0; - } else { - attrib = address_category; - } - //printf("attrib = %d\n", attrib); + for (i=0; i<16; i++) { + if (GTK_IS_WIDGET(address_cat_menu_item[i])) { + if (GTK_CHECK_MENU_ITEM(address_cat_menu_item[i])->active) { + attrib = i; + break; + } + } + } - pc_address_write(&a, NEW_PC_REC, attrib); - free_Address(&a); - update_address_screen(); + pc_address_write(&a, NEW_PC_REC, attrib); + free_Address(&a); + if (GPOINTER_TO_INT(data) == MODIFY_FLAG) { + cb_delete_address(NULL, data); + } else { + update_address_screen(); + } + } } -void cb_new_address(GtkWidget *widget, - gpointer data) +void clear_address_entries() { int i; - gtk_widget_hide(vbox2_1); - gtk_widget_show(vbox2_2); - //Clear all the address entry texts for (i=0; i<19; i++) { gtk_text_set_point(GTK_TEXT(address_text[i]), 0); gtk_text_forward_delete(GTK_TEXT(address_text[i]), gtk_text_get_length(GTK_TEXT(address_text[i]))); } + for (i=0; i<5; i++) { + if (GTK_IS_WIDGET(menu_item[i][i])) { + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM + (menu_item[i][i]), TRUE); + gtk_option_menu_set_history(GTK_OPTION_MENU(phone_list_menu[i]), i); + } + } +} +void cb_address_clear(GtkWidget *widget, + gpointer data) +{ + clear_address_entries(); +} + +void cb_new_address_mode(GtkWidget *widget, + gpointer data) +{ + //clear_address_entries(); + gtk_widget_hide(vbox2_1); + gtk_widget_show(vbox2_2); } -void cb_add_category(GtkWidget *item, int selection) +void cb_address_category(GtkWidget *item, int selection) { + if (!item) + return; if ((GTK_CHECK_MENU_ITEM(item))->active) { address_category = selection; - //printf("address_category = %d\n",address_category); + logf(LOG_DEBUG, "address_category = %d\n",address_category); update_address_screen(); } } -void cb_add_clist_sel(GtkWidget *clist, - gint row, - gint column, - GdkEventButton *event, - gpointer data) +void cb_address_clist_sel(GtkWidget *clist, + gint row, + gint column, + GdkEventButton *event, + gpointer data) { //The rename-able phone entries are indexes 3,4,5,6,7 - struct Address *a, new_a; + struct Address *a; MyAddress *ma; int i, i2; //This is because the palm doesn\'t show the address entries in order int order[22]={0,1,13,2,3,4,5,6,7,8,9,10,11,12,14,15,16,17,18,19,20,21 }; - char str[12]; - //GtkWidget *text; clist_row_selected=row; @@ -190,6 +237,13 @@ void cb_add_clist_sel(GtkWidget *clist, //todo - maybe only make this happen in new mode? //Update all the new entry text boxes with info + if (GTK_IS_WIDGET(address_cat_menu_item[ma->attrib & 0x0F])) { + gtk_check_menu_item_set_active + (GTK_CHECK_MENU_ITEM(address_cat_menu_item[ma->attrib & 0x0F]), TRUE); + gtk_option_menu_set_history + (GTK_OPTION_MENU(address_cat_menu2), ma->attrib & 0x0F); + } + for (i=0; i<19; i++) { gtk_text_set_point(GTK_TEXT(address_text[i]), 0); gtk_text_forward_delete(GTK_TEXT(address_text[i]), @@ -199,8 +253,12 @@ void cb_add_clist_sel(GtkWidget *clist, } } for (i=0; i<5; i++) { - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM( - menu_item[i][a->phoneLabel[i]+1]), TRUE); + if (GTK_IS_WIDGET(menu_item[i][a->phoneLabel[i]])) { + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM + (menu_item[i][a->phoneLabel[i]]), TRUE); + gtk_option_menu_set_history(GTK_OPTION_MENU(phone_list_menu[i]), + a->phoneLabel[i]); + } } } @@ -209,7 +267,6 @@ void update_address_screen() int num_entries, entries_shown, i; int show1, show2, show3; gchar *empty_line[] = { "","","" }; - char a_time[16]; GdkPixmap *pixmap_note; GdkPixmap *pixmap_alarm; GdkPixmap *pixmap_check; @@ -228,22 +285,22 @@ void update_address_screen() #ifdef JPILOT_DEBUG for (i=0;i<16;i++) { - printf("renamed:[%02d]:\n",address_app_info.category.renamed[i]); - printf("category name:[%02d]:",i); + logf(LOG_DEBUG, "renamed:[%02d]:\n",address_app_info.category.renamed[i]); + logf(LOG_DEBUG, "category name:[%02d]:",i); print_string(address_app_info.category.name[i],16); - printf("category ID:%d\n", address_app_info.category.ID[i]); + logf(LOG_DEBUG, "category ID:%d\n", address_app_info.category.ID[i]); } for (i=0;i<22;i++) { - printf("labels[%02d]:",i); + logf(LOG_DEBUG, "labels[%02d]:",i); print_string(address_app_info.labels[i],16); } for (i=0;i<8;i++) { - printf("phoneLabels[%d]:",i); + logf(LOG_DEBUG, "phoneLabels[%d]:",i); print_string(address_app_info.phoneLabels[i],16); } - printf("country %d\n",address_app_info.country); - printf("sortByCompany %d\n",address_app_info.sortByCompany); + logf(LOG_DEBUG, "country %d\n",address_app_info.country); + logf(LOG_DEBUG, "sortByCompany %d\n",address_app_info.sortByCompany); #endif num_entries = get_addresses(&address_list); @@ -252,6 +309,7 @@ void update_address_screen() // gtk_text_get_length(GTK_TEXT(text1))); if (address_list==NULL) { + gtk_tooltips_set_tip(glob_tooltips, category_menu1, "0 records", NULL); return; } @@ -279,7 +337,13 @@ void update_address_screen() address_category != CATEGORY_ALL) { continue; } - + if (temp_al->ma.rt == MODIFIED_PALM_REC) { + //todo - this will be in preferences as to whether you want to + //see deleted records, or not. + num_entries--; + continue; + } + entries_shown++; str[0]='\0'; if (temp_al->ma.a.entry[show1] || temp_al->ma.a.entry[show2]) { @@ -318,6 +382,14 @@ void update_address_screen() gdk_color_alloc(colormap, &color); gtk_clist_set_background(GTK_CLIST(clist), 0, &color); } + if (temp_al->ma.rt == MODIFIED_PALM_REC) { + colormap = gtk_widget_get_colormap(clist); + color.red=CLIST_MOD_RED; + color.green=CLIST_MOD_GREEN; + color.blue=CLIST_MOD_BLUE; + gdk_color_alloc(colormap, &color); + gtk_clist_set_background(GTK_CLIST(clist), 0, &color); + } if (temp_al->ma.a.entry[18]) { //Put a note pixmap up @@ -339,55 +411,110 @@ void update_address_screen() } gtk_clist_thaw(GTK_CLIST(clist)); + + sprintf(str, "%d of %d records", entries_shown, num_entries); + gtk_tooltips_set_tip(glob_tooltips, category_menu1, str, NULL); } -//default set is which one is to be set on by default -//set is which set in the array to use -int make_phone_menu(GtkWidget **phone_list_menu, int default_set, - unsigned int callback_id, int set) +//default set is which menu item is to be set on by default +//set is which set in the menu_item array to use +int make_phone_menu(int default_set, unsigned int callback_id, int set) { - int i, i2; - GtkWidget *menu; + int i; GSList *group; - *phone_list_menu = gtk_option_menu_new(); + phone_list_menu[set] = gtk_option_menu_new(); menu = gtk_menu_new(); group = NULL; - //printf("default_set=%d\n",default_set); - //printf("callback_id=%d\n",callback_id); - //gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), TRUE); - //gtk_check_menu_item_select(GTK_CHECK_MENU_ITEM(menu_item)); - //gtk_check_menu_item_activate(GTK_CHECK_MENU_ITEM(menu_item)); - for (i=0; i<9; i++) { - if (i==0) { - i2=default_set; - } else { - i2=i-1; - } - if (address_app_info.phoneLabels[i2][0]) { + for (i=0; i<8; i++) { + if (address_app_info.phoneLabels[i][0]) { menu_item[set][i] = gtk_radio_menu_item_new_with_label( - group, address_app_info.phoneLabels[i2]); + group, address_app_info.phoneLabels[i]); gtk_signal_connect(GTK_OBJECT(menu_item[set][i]), "activate", - cb_phone_menu, GINT_TO_POINTER(callback_id + i2)); - if (i2==default_set) { - gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM( - menu_item[set][i]), TRUE); - } + cb_phone_menu, GINT_TO_POINTER(callback_id + i)); group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item[set][i])); gtk_menu_append(GTK_MENU(menu), menu_item[set][i]); gtk_widget_show(menu_item[set][i]); } } + //Set this one to active + if (GTK_IS_WIDGET(menu_item[set][default_set])) { + gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM( + menu_item[set][default_set]), TRUE); + } + + gtk_option_menu_set_menu(GTK_OPTION_MENU(phone_list_menu[set]), menu); + //Make this one show up by default + gtk_option_menu_set_history(GTK_OPTION_MENU(phone_list_menu[set]), + default_set); + + gtk_widget_show(phone_list_menu[set]); +} + +static int make_category_menu1(GtkWidget **category_menu) +{ + GtkWidget *menu_item; + GtkWidget *menu; + GSList *group; + int i; + + *category_menu = gtk_option_menu_new(); - gtk_option_menu_set_menu(GTK_OPTION_MENU(*phone_list_menu), menu); - //gtk_option_menu_set_history (GTK_OPTION_MENU (category_menu), history); - //gtk_widget_set_usize(GTK_WIDGET(*phone_list_menu), 20, 0); + menu = gtk_menu_new(); + group = NULL; - gtk_widget_show(*phone_list_menu); + menu_item = gtk_radio_menu_item_new_with_label(group, "All"); + gtk_signal_connect(GTK_OBJECT(menu_item), "activate", + cb_address_category, GINT_TO_POINTER(CATEGORY_ALL)); + group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item)); + gtk_menu_append(GTK_MENU(menu), menu_item); + gtk_widget_show(menu_item); + for (i=0; i<16; i++) { + if (address_app_info.category.name[i][0]) { + menu_item = gtk_radio_menu_item_new_with_label( + group, address_app_info.category.name[i]); + gtk_signal_connect(GTK_OBJECT(menu_item), "activate", + cb_address_category, GINT_TO_POINTER(i)); + group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item)); + gtk_menu_append(GTK_MENU(menu), menu_item); + gtk_widget_show(menu_item); + } + } + + gtk_option_menu_set_menu(GTK_OPTION_MENU(*category_menu), menu); } + +static int make_category_menu2() +{ + int i; + + GtkWidget *menu; + GSList *group; + + address_cat_menu2 = gtk_option_menu_new(); + menu = gtk_menu_new(); + group = NULL; + + for (i=0; i<16; i++) { + if (address_app_info.category.name[i][0]) { + address_cat_menu_item[i] = gtk_radio_menu_item_new_with_label + (group, address_app_info.category.name[i]); + group = gtk_radio_menu_item_group + (GTK_RADIO_MENU_ITEM(address_cat_menu_item[i])); + gtk_menu_append(GTK_MENU(menu), address_cat_menu_item[i]); + gtk_widget_show(address_cat_menu_item[i]); + } + } + gtk_option_menu_set_menu(GTK_OPTION_MENU(address_cat_menu2), menu); +} + + +// +//Main function +// int address_gui(GtkWidget *vbox, GtkWidget *hbox) { extern GtkWidget *glob_date_label; @@ -404,11 +531,6 @@ int address_gui(GtkWidget *vbox, GtkWidget *hbox) GtkWidget *table1, *table2, *table3; // GtkWidget *calendar; GtkWidget *scrolled_window; - GtkWidget *category_menu; - GtkWidget *menu_item; - GtkWidget *menu; - GSList *group; - GtkWidget *phone_list_menu; GtkWidget *notebook_tab; time_t ltime; @@ -421,7 +543,11 @@ int address_gui(GtkWidget *vbox, GtkWidget *hbox) clist_row_selected=0; - get_address_app_info(&address_app_info); + if (get_address_app_info(&address_app_info)) { + for (i=0; i<16; i++) { + address_app_info.category.name[i][0]='\0'; + } + } vbox1 = gtk_vbox_new (FALSE, 0); vbox2_1 = gtk_vbox_new (FALSE, 0); @@ -433,14 +559,8 @@ int address_gui(GtkWidget *vbox, GtkWidget *hbox) //Add buttons in left vbox button = gtk_button_new_with_label("Delete"); gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(cb_delete_address), NULL); - gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0); - gtk_widget_show(button); - - //Add buttons in left vbox - button = gtk_button_new_with_label("New"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(cb_new_address), NULL); + GTK_SIGNAL_FUNC(cb_delete_address), + GINT_TO_POINTER(DELETE_FLAG)); gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0); gtk_widget_show(button); @@ -464,38 +584,9 @@ int address_gui(GtkWidget *vbox, GtkWidget *hbox) gtk_widget_show(separator); //Put the category menu up - category_menu = gtk_option_menu_new(); - - menu = gtk_menu_new(); - group = NULL; - - //gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), TRUE); - //gtk_check_menu_item_select(GTK_CHECK_MENU_ITEM(menu_item)); - //gtk_check_menu_item_activate(GTK_CHECK_MENU_ITEM(menu_item)); - menu_item = gtk_radio_menu_item_new_with_label(group, "All"); - gtk_signal_connect(GTK_OBJECT(menu_item), "activate", - cb_add_category, GINT_TO_POINTER(CATEGORY_ALL)); - group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item)); - gtk_menu_append(GTK_MENU(menu), menu_item); - gtk_widget_show(menu_item); - for (i=0; i<16; i++) { - if (address_app_info.category.name[i][0]) { - menu_item = gtk_radio_menu_item_new_with_label( - group, address_app_info.category.name[i]); - gtk_signal_connect(GTK_OBJECT(menu_item), "activate", - cb_add_category, GINT_TO_POINTER(i)); - group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item)); - gtk_menu_append(GTK_MENU(menu), menu_item); - gtk_widget_show(menu_item); - } - } - - gtk_option_menu_set_menu(GTK_OPTION_MENU(category_menu), menu); - //gtk_option_menu_set_history (GTK_OPTION_MENU (category_menu), history); - - gtk_box_pack_start (GTK_BOX (vbox1), category_menu, FALSE, FALSE, 0); - gtk_widget_show (category_menu); - + make_category_menu1(&category_menu1); + gtk_box_pack_start(GTK_BOX(vbox1), category_menu1, FALSE, FALSE, 0); + gtk_widget_show(category_menu1); //Put the address list window up scrolled_window = gtk_scrolled_window_new(NULL, NULL); @@ -508,7 +599,7 @@ int address_gui(GtkWidget *vbox, GtkWidget *hbox) clist = gtk_clist_new(3); gtk_signal_connect(GTK_OBJECT(clist), "select_row", - GTK_SIGNAL_FUNC(cb_add_clist_sel), + GTK_SIGNAL_FUNC(cb_address_clist_sel), text); gtk_clist_set_shadow_type(GTK_CLIST(clist), SHADOW); gtk_clist_set_selection_mode(GTK_CLIST(clist), GTK_SELECTION_BROWSE); @@ -539,6 +630,19 @@ int address_gui(GtkWidget *vbox, GtkWidget *hbox) gtk_widget_show(vbox2_1_sub1); + //The Right hand side of the screen + button = gtk_button_new_with_label("Add or Modify a Record"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_new_address_mode), NULL); + gtk_box_pack_start(GTK_BOX(vbox2_1_sub1), button, FALSE, FALSE, 0); + gtk_widget_show(button); + + //Separator + separator = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(vbox2_1_sub1), separator, FALSE, FALSE, 5); + gtk_widget_show(separator); + + //The text box on the right side hbox_temp = gtk_hbox_new (FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox2_1_sub1), hbox_temp, TRUE, TRUE, 0); @@ -560,18 +664,46 @@ int address_gui(GtkWidget *vbox, GtkWidget *hbox) gtk_box_pack_start(GTK_BOX(vbox2_2), hbox_temp, FALSE, FALSE, 0); gtk_widget_show(hbox_temp); - button = gtk_button_new_with_label("Add it"); + button = gtk_button_new_with_label("Add It"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_new_address_done), + GINT_TO_POINTER(NEW_FLAG)); + gtk_box_pack_start(GTK_BOX(hbox_temp), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + button = gtk_button_new_with_label("Apply Changes"); gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(cb_new_address_done), GINT_TO_POINTER(1)); + GTK_SIGNAL_FUNC(cb_new_address_done), + GINT_TO_POINTER(MODIFY_FLAG)); gtk_box_pack_start(GTK_BOX(hbox_temp), button, TRUE, TRUE, 0); gtk_widget_show(button); button = gtk_button_new_with_label("Cancel"); gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(cb_new_address_done), GINT_TO_POINTER(0)); + GTK_SIGNAL_FUNC(cb_new_address_done), + GINT_TO_POINTER(CANCEL_FLAG)); gtk_box_pack_end(GTK_BOX(hbox_temp), button, TRUE, TRUE, 0); gtk_widget_show(button); + + button = gtk_button_new_with_label("Clear"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_address_clear), NULL); + gtk_box_pack_end(GTK_BOX(hbox_temp), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + + //Separator + separator = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(vbox2_2), separator, FALSE, FALSE, 5); + gtk_widget_show(separator); + + + //Add the new category menu + make_category_menu2(); + gtk_box_pack_start(GTK_BOX(vbox2_2), address_cat_menu2, FALSE, FALSE, 0); + gtk_widget_show(address_cat_menu2); + //Add the notebook for new entries notebook = gtk_notebook_new(); @@ -609,12 +741,13 @@ int address_gui(GtkWidget *vbox, GtkWidget *hbox) table3 = gtk_table_new(9, 2, FALSE); gtk_box_pack_start(GTK_BOX(vbox_temp3), table3, TRUE, TRUE, 0); + label = NULL; for (i=0; i<19; i++) { i2=order[i]; if (i2>2 && i2<8) { - make_phone_menu(&phone_list_menu, i2-3, (i2-3)<<4, i2-3); + make_phone_menu(i2-3, (i2-3)<<4, i2-3); } else { - label = gtk_label_new(address_app_info.labels[i2]); + label = gtk_label_new(address_app_info.labels[i2]); //gtk_label_set_justify(GTK_LABEL(label), GTK_JUSTIFY_LEFT); } address_text[i2] = gtk_text_new(NULL, NULL); @@ -625,7 +758,7 @@ int address_gui(GtkWidget *vbox, GtkWidget *hbox) //hbox_temp = gtk_hbox_new(FALSE, 0); if (i<9) { if (i2>2 && i2<8) { - gtk_table_attach_defaults(GTK_TABLE(table1), GTK_WIDGET(phone_list_menu), + gtk_table_attach_defaults(GTK_TABLE(table1), GTK_WIDGET(phone_list_menu[i2-3]), 0, 1, i, i+1); } else { gtk_table_attach_defaults(GTK_TABLE(table1), GTK_WIDGET(label), diff --git a/datebook.c b/datebook.c index 8616336b..c59346ad 100644 --- a/datebook.c +++ b/datebook.c @@ -30,6 +30,7 @@ #include "datebook.h" #include "utils.h" +#include "log.h" #ifndef FALSE #define FALSE 0 @@ -45,13 +46,11 @@ int datebook_sort(AppointmentList **al) AppointmentList *temp_al, *prev_al, *next; int found_one; - //printf("datebook_sort()\n"); found_one=1; while (found_one) { found_one=0; for (prev_al=NULL, temp_al=*al; temp_al; prev_al=temp_al, temp_al=temp_al->next) { - //printf("begin %d\n", temp_al->ma.a.begin.tm_hour); if (temp_al->next) { if (temp_al->ma.a.begin.tm_hour > temp_al->next->ma.a.begin.tm_hour) { found_one=1; @@ -81,24 +80,23 @@ static int pc_datebook_read_next_rec(FILE *in, MyAppointment *ma) if (feof(in)) { return DATEBOOK_EOF; } -// if (ftell(in)==0) { -// printf("Error: File header not read\n"); -// return DATEBOOK_EOF; -// } num = fread(&header, sizeof(header), 1, in); if (feof(in)) { return DATEBOOK_EOF; } if (num != 1) { - printf("error on fread\n"); + logf(LOG_DEBUG, "error on fread\n"); return DATEBOOK_EOF; } rec_len = header.rec_len; ma->rt = header.rt; ma->attrib = header.attrib; - //printf("read attrib = %d\n", ma->attrib); ma->unique_id = header.unique_id; record = malloc(rec_len); + if (!record) { + logf(LOG_WARN, "Out of memory\n"); + return -1; + } fread(record, rec_len, 1, in); if (feof(in)) { free(record); @@ -115,11 +113,11 @@ int does_pc_appt_exist(int unique_id, PCRecType rt) PCRecordHeader header; int num; - //printf("looking for unique id = %d\n",unique_id); - //printf("looking for rt = %d\n",rt); + logf(LOG_DEBUG, "looking for unique id = %d\n",unique_id); + logf(LOG_DEBUG, "looking for rt = %d\n",rt); pc_in=open_file("DatebookDB.pc", "r"); if (pc_in==NULL) { - printf("Couldn't open PC records file\n"); + logf(LOG_WARN, "Couldn't open PC records file\n"); return 0; } while(!feof(pc_in)) { @@ -127,16 +125,13 @@ int does_pc_appt_exist(int unique_id, PCRecType rt) if (feof(pc_in) || (!num)) { break; } - //printf("read unique id = %d\n",header.unique_id); - //printf("read rt = %d\n",header.rt); if ((header.unique_id==unique_id) && (header.rt==rt)) { fclose(pc_in); - //printf("TRUE\n"); return 1; } if (fseek(pc_in, header.rec_len, SEEK_CUR)) { - printf("fseek failed\n"); + logf(LOG_WARN, "fseek failed\n"); } } fclose(pc_in); @@ -146,7 +141,6 @@ int does_pc_appt_exist(int unique_id, PCRecType rt) int pc_datebook_write(struct Appointment *a, PCRecType rt, unsigned char attrib) { PCRecordHeader header; - //PCFileHeader file_header; FILE *out; char record[65536]; int rec_len; @@ -154,18 +148,19 @@ int pc_datebook_write(struct Appointment *a, PCRecType rt, unsigned char attrib) get_next_unique_pc_id(&next_unique_id); #ifdef JPILOT_DEBUG - printf("next unique id = %d\n",next_unique_id); + logf(LOG_DEBUG, "next unique id = %d\n",next_unique_id); #endif out = open_file("DatebookDB.pc", "a"); if (!out) { - printf("Error opening DatebookDB.pc\n"); + logf(LOG_WARN, "Error opening DatebookDB.pc\n"); return -1; } rec_len = pack_Appointment(a, record, 65535); if (!rec_len) { PRINT_FILE_LINE; - printf("pack_Appointment error\n"); + logf(LOG_WARN, "pack_Appointment error\n"); + fclose(out); return -1; } header.rec_len=rec_len; @@ -190,6 +185,72 @@ void free_AppointmentList(AppointmentList **al) *al = NULL; } +// +//If a copy is made, then it should be freed through free_Appointment +// +int datebook_copy_appointment(struct Appointment *a1, + struct Appointment **a2) +{ + *a2=malloc(sizeof(struct Appointment)); + if (!(*a2)) { + logf(LOG_WARN, "Out of memory\n"); + return -1; + } + memcpy(*a2, a1, sizeof(struct Appointment)); + + (*a2)->exception = (struct tm *)malloc(a1->exceptions * sizeof(struct tm)); + if (!(*a2)->exception) { + logf(LOG_WARN, "Out of memory\n"); + return -1; + } + memcpy((*a2)->exception, a1->exception, a1->exceptions * sizeof(struct tm)); + + if (a1->description) { + (*a2)->description=(char *)strdup(a1->description); + } + if (a1->note) { + (*a2)->note=(char *)strdup(a1->note); + } + + return 0; +} + + +// Year is years since 1900 +// Mon is 0-11 +// Day is 1-31 +// +int datebook_add_exception(struct Appointment *a, int year, int mon, int day) +{ + struct tm *new_exception, *Ptm; + + if (a->exceptions==0) { + a->exception=NULL; + } + + new_exception = malloc((a->exceptions + 1) * sizeof(struct tm)); + if (!new_exception) { + logf(LOG_WARN, "Out of memory\n"); + return -1; + } + memcpy(new_exception, a->exception, (a->exceptions) * sizeof(struct tm)); + free(a->exception); + a->exceptions++; + a->exception = new_exception; + Ptm = &(a->exception[a->exceptions - 1]); + Ptm->tm_year = year; + Ptm->tm_mon = mon; + Ptm->tm_mday = day; + Ptm->tm_hour = 0; + Ptm->tm_min = 0; + Ptm->tm_sec = 0; + Ptm->tm_isdst = -1; + mktime(Ptm); + return 0; +} + + + int dateToDays(struct tm *tm1) { time_t t1; @@ -273,7 +334,6 @@ unsigned int isApptOnDate(struct Appointment *a, struct tm *date) //See if this appt repeats on this day begin_days = dateToDays(&(a->begin)); days = dateToDays(date); - //g_print("days=%d begin_days=%d\n",days, begin_days); ret = (((days - begin_days)%(a->repeatFrequency))==0); break; case repeatWeekly: @@ -351,25 +411,26 @@ unsigned int isApptOnDate(struct Appointment *a, struct tm *date) } break; default: - g_print("unknown repeatType (%d) found in DatebookDB\n", - a->repeatType); - printf("repeatMonthlyByDate = %d\n", repeatMonthlyByDate); + logf(LOG_WARN, "unknown repeatType (%d) found in DatebookDB\n", + a->repeatType); ret = FALSE; }//switch if (ret) { //Check for exceptions for (i=0; iexceptions; i++) { - //printf("exception %d mon %d\n", i, a->exception[i].tm_mon); - //printf("exception %d day %d\n", i, a->exception[i].tm_mday); - //printf("exception %d year %d\n", i, a->exception[i].tm_year); - //printf("exception %d yday %d\n", i, a->exception[i].tm_yday); - //printf("today is yday %d\n", date->tm_yday); +#ifdef JPILOT_DEBUG + logf(LOG_DEBUG, "exception %d mon %d\n", i, a->exception[i].tm_mon); + logf(LOG_DEBUG, "exception %d day %d\n", i, a->exception[i].tm_mday); + logf(LOG_DEBUG, "exception %d year %d\n", i, a->exception[i].tm_year); + logf(LOG_DEBUG, "exception %d yday %d\n", i, a->exception[i].tm_yday); + logf(LOG_DEBUG, "today is yday %d\n", date->tm_yday); +#endif begin_days = dateToDays(&(a->exception[i])); days = dateToDays(date); - //printf("%d == %d\n", begin_days, days); if (begin_days == days) { ret = FALSE; + break; } } } @@ -405,34 +466,33 @@ int get_days_appointments(AppointmentList **appointment_list, struct tm *now) in = open_file("DatebookDB.pdb", "r"); if (!in) { - printf("Error opening DatebookDB.pdb\n"); + logf(LOG_WARN, "Error opening DatebookDB.pdb\n"); return -1; } //Read the database header fread(&rdbh, sizeof(RawDBHeader), 1, in); if (feof(in)) { - printf("Error reading DatebookDB.pdb\n"); + logf(LOG_WARN, "Error reading DatebookDB.pdb\n"); fclose(in); return -1; } raw_header_to_header(&rdbh, &dbh); - //printf("db_name = %s\n", dbh.db_name); - //printf("num records = %d\n", dbh.number_of_records); - //printf("app info offset = %d\n", dbh.app_info_offset); - - //fread(filler, 2, 1, in); + logf(LOG_DEBUG, "db_name = %s\n", dbh.db_name); + logf(LOG_DEBUG, "num records = %d\n", dbh.number_of_records); + logf(LOG_DEBUG, "app info offset = %d\n", dbh.app_info_offset); //Read each record entry header num_records = dbh.number_of_records; - //printf("sizeof(record_header)=%d\n",sizeof(record_header)); for (i=1; inext = mem_rh; mem_rh = temp_mem_rh; @@ -442,37 +502,40 @@ int get_days_appointments(AppointmentList **appointment_list, struct tm *now) mem_rh->unique_id = (rh.unique_ID[0]*256+rh.unique_ID[1])*256+rh.unique_ID[2]; } - find_next_offset(mem_rh, 0, &next_offset, &attrib, &unique_id); - fseek(in, next_offset, SEEK_SET); - - while(!feof(in)) { - fpos = ftell(in); - find_next_offset(mem_rh, fpos, &next_offset, &attrib, &unique_id); - //next_offset += 223; - rec_size = next_offset - fpos; - //printf("rec_size = %u\n",rec_size); - //printf("fpos,next_offset = %u %u\n",fpos,next_offset); - //printf("----------\n"); - if (feof(in)) break; - buf = malloc(rec_size); - if (!buf) { - break; - } - num = fread(buf, 1, rec_size, in); - if (feof(in) || (!num)) break; + if (num_records) { + find_next_offset(mem_rh, 0, &next_offset, &attrib, &unique_id); + fseek(in, next_offset, SEEK_SET); + while(!feof(in)) { + fpos = ftell(in); + find_next_offset(mem_rh, fpos, &next_offset, &attrib, &unique_id); + //next_offset += 223; + rec_size = next_offset - fpos; +#ifdef JPILOT_DEBUG + logf(LOG_DEBUG, "rec_size = %u\n",rec_size); + logf(LOG_DEBUG, "fpos,next_offset = %u %u\n",fpos,next_offset); + logf(LOG_DEBUG, "----------\n"); +#endif + if (feof(in)) break; + buf = malloc(rec_size); + if (!buf) { + break; + } + num = fread(buf, 1, rec_size, in); + if (feof(in) || (!num)) break; - unpack_Appointment(&a, buf, rec_size); - free(buf); - if (isApptOnDate(&a, now) - && (!does_pc_appt_exist(unique_id, PALM_REC))) { - temp_appointment_list = malloc(sizeof(AppointmentList)); - memcpy(&(temp_appointment_list->ma.a), &a, sizeof(struct Appointment)); - //temp_appointment_list->ma.a = temp_a; - temp_appointment_list->ma.rt = PALM_REC; - temp_appointment_list->ma.attrib = attrib; - temp_appointment_list->ma.unique_id = unique_id; - temp_appointment_list->next = *appointment_list; - *appointment_list = temp_appointment_list; + unpack_Appointment(&a, buf, rec_size); + free(buf); + if (isApptOnDate(&a, now) + && (!does_pc_appt_exist(unique_id, PALM_REC))) { + temp_appointment_list = malloc(sizeof(AppointmentList)); + memcpy(&(temp_appointment_list->ma.a), &a, sizeof(struct Appointment)); + //temp_appointment_list->ma.a = temp_a; + temp_appointment_list->ma.rt = PALM_REC; + temp_appointment_list->ma.attrib = attrib; + temp_appointment_list->ma.unique_id = unique_id; + temp_appointment_list->next = *appointment_list; + *appointment_list = temp_appointment_list; + } } } fclose(in); @@ -492,6 +555,7 @@ int get_days_appointments(AppointmentList **appointment_list, struct tm *now) if ((isApptOnDate(&(ma.a), now)) &&(ma.rt!=DELETED_PC_REC) &&(ma.rt!=DELETED_PALM_REC) + &&(ma.rt!=MODIFIED_PALM_REC) &&(ma.rt!=DELETED_DELETED_PALM_REC)) { temp_appointment_list = malloc(sizeof(AppointmentList)); memcpy(&(temp_appointment_list->ma), &ma, sizeof(MyAppointment)); @@ -503,7 +567,7 @@ int get_days_appointments(AppointmentList **appointment_list, struct tm *now) //this doesnt really free it, just the string pointers free_Appointment(&(ma.a)); } - if (ma.rt==DELETED_PALM_REC) { + if ((ma.rt==DELETED_PALM_REC) || (ma.rt==MODIFIED_PALM_REC)) { for (temp_appointment_list = *appointment_list; temp_appointment_list; temp_appointment_list=temp_appointment_list->next) { if (temp_appointment_list->ma.unique_id == ma.unique_id) { @@ -516,3 +580,41 @@ int get_days_appointments(AppointmentList **appointment_list, struct tm *now) datebook_sort(appointment_list); } + + +int datebook_create_bogus_record(char *record, int size, int *rec_len) +{ + struct Appointment a; + char desc[]="jpilot hack"; + + memset(&a, '\0', sizeof(struct Appointment)); + a.event=1; + + a.begin.tm_sec=0; + a.begin.tm_min=0; + a.begin.tm_hour=11; + a.begin.tm_mday=1; + a.begin.tm_mon=0; + a.begin.tm_year=80; + a.begin.tm_isdst=-1; + + a.end.tm_sec=0; + a.end.tm_min=0; + a.end.tm_hour=11; + a.end.tm_mday=1; + a.end.tm_mon=0; + a.end.tm_year=80; + a.end.tm_isdst=-1; + + mktime(&a.begin); + mktime(&a.end); + + a.description=desc; + + *rec_len = pack_Appointment(&a, record, size); + if (!*rec_len) { + return -1; + } + return 0; +} + diff --git a/datebook.h b/datebook.h index 52752a15..e8caadaa 100644 --- a/datebook.h +++ b/datebook.h @@ -28,3 +28,10 @@ int datebook_cleanup(); int pc_datebook_write(struct Appointment *a, PCRecType rt, unsigned char attrib); void free_AppointmentList(AppointmentList **al); int get_days_appointments(AppointmentList **al_out, struct tm *now); +int datebook_dup_appointment(struct Appointment *a1, + struct Appointment **a2); +// Year is years since 1900 +// Mon is 0-11 +// Day is 1-31 +// +int datebook_add_exception(struct Appointment *a, int year, int mon, int day); diff --git a/datebook_gui.c b/datebook_gui.c index 96952701..8d89c651 100644 --- a/datebook_gui.c +++ b/datebook_gui.c @@ -23,6 +23,8 @@ //I suspect that this is a GTK bug. I have worked around it with this hack //for now. +#define EASTER + #include #include #include @@ -30,6 +32,9 @@ #include #include "datebook.h" +#include "log.h" + +//extern GtkTooltips *glob_tooltips; #define PAGE_NONE 0 #define PAGE_DAY 1 @@ -45,8 +50,14 @@ #define SHADOW GTK_SHADOW_ETCHED_OUT -#define DIALOG_SAID_LAST 454 -#define DIALOG_SAID_4TH 455 +#define DIALOG_SAID_1 454 +#define DIALOG_SAID_FOURTH 454 +#define DIALOG_SAID_CURRENT 454 +#define DIALOG_SAID_2 455 +#define DIALOG_SAID_LAST 455 +#define DIALOG_SAID_ALL 455 +#define DIALOG_SAID_3 456 +#define DIALOG_SAID_CANCEL 456 //#define DATE_CHART @@ -96,7 +107,6 @@ int get_date_chart(GtkWidget *widget, GtkWidget **out_pixmapwid) #endif - void cb_clist1_selection(GtkWidget *clist, gint row, gint column, @@ -147,9 +157,9 @@ GtkWidget *toggle_button_repeat_days[7]; GtkWidget *toggle_button_repeat_mon_byday; GtkWidget *toggle_button_repeat_mon_bydate; GtkWidget *notebook; -int current_day; //range 1-31 +int current_day; //range 1-31 int current_month; //range 0-11 -int current_year; +int current_year; //years since 1900 int clist_row_selected; AppointmentList *current_al; @@ -174,6 +184,7 @@ GtkWidget *scrolled_window1; GtkWidget *dialog; int dialog_result; + char *nums[]={"1","2","3","4","5","6","7","8","9","10","11","12","13","14", "15","16","17","18","19","20","21","22","23","24","25","26","27","28", "29","30","31" @@ -188,7 +199,7 @@ char *days[]={"S","M","T","W","R","F","S"}; init() { - time_t ltime, t; + time_t ltime; struct tm *now; time( <ime ); @@ -202,20 +213,33 @@ init() clist_row_selected=0; } -void cb_dialog_button_4th(GtkWidget *widget, - gpointer data) + +// +//Start of Dialog window code for 4th, or last +// +void cb_dialog_button_1(GtkWidget *widget, + gpointer data) { //dialog_result=GPOINTER_TO_INT(data); - dialog_result=DIALOG_SAID_4TH; + dialog_result=DIALOG_SAID_1; gtk_widget_destroy(dialog); } -void cb_dialog_button_last(GtkWidget *widget, - gpointer data) +void cb_dialog_button_2(GtkWidget *widget, + gpointer data) { //dialog_result=GPOINTER_TO_INT(data); - dialog_result=DIALOG_SAID_LAST; + dialog_result=DIALOG_SAID_2; + + gtk_widget_destroy(dialog); +} + +void cb_dialog_button_3(GtkWidget *widget, + gpointer data) +{ + //dialog_result=GPOINTER_TO_INT(data); + dialog_result=DIALOG_SAID_3; gtk_widget_destroy(dialog); } @@ -227,7 +251,8 @@ static gboolean cb_destroy_dialog(GtkWidget *widget) return FALSE; } -int dialog_4_or_last(int dow) { +//nob = number of buttons (1-3) +int dialog_generic(char *text, int nob, char *button_text[]) { GtkWidget *button, *label1; GdkWindow *main_window; gint px, py, pw, ph = 0; @@ -235,15 +260,13 @@ int dialog_4_or_last(int dow) { GtkWidget *hbox1, *vbox1; GtkWidget *frame1; - char *days[]={"Sunday","Monday","Tuesday","Wednesday","Thurday", - "Friday","Saturday"}; - char text[255]; main_window = scrolled_window1->parent->window; gdk_window_get_position(main_window, &px, &py); gdk_window_get_size(main_window, &pw, &ph); + //Center the window in the main window w=200; h=200; x=px+pw/2-w/2; @@ -276,31 +299,35 @@ int dialog_4_or_last(int dow) { gtk_container_add(GTK_CONTAINER(frame1), vbox1); label1 = gtk_label_new(text); - sprintf(text, - "This appointment can either\n " - "repeat on the 4th %s of\n " - "the month, or on the Last\n " - "%s of the month.\n " - "Which do you want?", - days[dow], days[dow]); - label1 = gtk_label_new(text); - //This doesn't seem to work... + //This doesn\'t seem to work... //gtk_label_set_line_wrap(GTK_LABEL(label1), TRUE); - gtk_box_pack_start(GTK_BOX(vbox1), label1, FALSE, FALSE, 5); - gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 5); + gtk_box_pack_start(GTK_BOX(vbox1), label1, FALSE, FALSE, 2); + gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 2); - button = gtk_button_new_with_label("4th"); - gtk_signal_connect_object(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(cb_dialog_button_4th), - GINT_TO_POINTER(DIALOG_SAID_4TH)); - gtk_box_pack_start(GTK_BOX(hbox1), button, TRUE, TRUE, 5); + if (nob > 0) { + button = gtk_button_new_with_label(button_text[0]); + gtk_signal_connect_object(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_dialog_button_1), + GINT_TO_POINTER(DIALOG_SAID_1)); + gtk_box_pack_start(GTK_BOX(hbox1), button, TRUE, TRUE, 1); + } - button = gtk_button_new_with_label("Last"); - gtk_signal_connect_object(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(cb_dialog_button_last), - GINT_TO_POINTER(DIALOG_SAID_LAST)); - gtk_box_pack_start(GTK_BOX(hbox1), button, TRUE, TRUE, 5); + if (nob > 1) { + button = gtk_button_new_with_label(button_text[1]); + gtk_signal_connect_object(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_dialog_button_2), + GINT_TO_POINTER(DIALOG_SAID_2)); + gtk_box_pack_start(GTK_BOX(hbox1), button, TRUE, TRUE, 1); + } + + if (nob > 2) { + button = gtk_button_new_with_label(button_text[2]); + gtk_signal_connect_object(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_dialog_button_3), + GINT_TO_POINTER(DIALOG_SAID_3)); + gtk_box_pack_start(GTK_BOX(hbox1), button, TRUE, TRUE, 1); + } gtk_widget_show_all(dialog); @@ -309,6 +336,65 @@ int dialog_4_or_last(int dow) { return dialog_result; } +int dialog_4_or_last(int dow) +{ + char *days[]={"Sunday","Monday","Tuesday","Wednesday","Thurday", + "Friday","Saturday"}; + char text[255]; + char *button_text[]={"4th","Last" + }; + + sprintf(text, + "This appointment can either \n" + "repeat on the 4th %s \n" + "of the month, or on the Last \n" + "%s of the month. \n" + "Which do you want?", + days[dow], days[dow]); + return dialog_generic(text, 2, button_text); +} + +int dialog_current_all_cancel() +{ + char text[]= + //--------------------------- + "This is a repeating event. \n" + "Do you want to apply these \n" + "changes to just the CURRENT \n" + "event, or ALL of the \n" + "occurrences of this event?"; + char *button_text[]={"Current","All","Cancel" + }; + + return dialog_generic(text, 3, button_text); +} + +#ifdef EASTER +int dialog_easter(int mday) +{ + char text[255]; + char who[50]; + char *button_text[]={"I'll send a present!!!" + }; + if (mday==29) { + strcpy(who, "Judd Montgomery"); + } + if (mday==20) { + strcpy(who, "Jacki Montgomery"); + } + sprintf(text, + //--------------------------- + "Today is \n" + "%s\'s \n" + "Birthday! \n", who); + + return dialog_generic(text, 1, button_text); +} +// +//End of Dialog window code +// +#endif + // // month = 0-11 // dom = day of month 1-31 @@ -320,7 +406,6 @@ int dialog_4_or_last(int dow) { long get_dom_type(int month, int dom, int year, int dow) { long r; - int occurrence; int ndim; // ndim = number of days in month 28-31 int dow_fdof; //Day of the week for the first day of the month int result; @@ -357,8 +442,10 @@ long get_dom_type(int month, int dom, int year, int dow) return r; } -clear_details() +static void clear_details() { + int i; + gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner_begin_mon), current_month+1); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner_begin_day), current_day); gtk_spin_button_set_value(GTK_SPIN_BUTTON(spinner_begin_year), current_year+1900); @@ -374,11 +461,28 @@ clear_details() gtk_text_backward_delete(GTK_TEXT(text2), gtk_text_get_length(GTK_TEXT(text2))); gtk_notebook_set_page(GTK_NOTEBOOK(notebook), PAGE_NONE); + // Clear the notebook pages + + gtk_entry_set_text(GTK_ENTRY(repeat_day_entry), "1"); + gtk_entry_set_text(GTK_ENTRY(repeat_week_entry), "1"); + gtk_entry_set_text(GTK_ENTRY(repeat_mon_entry), "1"); + gtk_entry_set_text(GTK_ENTRY(repeat_year_entry), "1"); + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_day_endon), FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_week_endon), FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_mon_endon), FALSE); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(check_button_year_endon), FALSE); + + for(i=0; i<7; i++) { + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_button_repeat_days[i]), FALSE); + } + + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toggle_button_repeat_mon_bydate), TRUE); } get_details(struct Appointment *a) { - int s, i; + int i; time_t ltime; struct tm *now; char str[30]; @@ -415,7 +519,7 @@ get_details(struct Appointment *a) if (GTK_TOGGLE_BUTTON(check_button_notime)->active) { a->event=1; - //printf("notime\n"); + //This event doesn't have a time a->begin.tm_hour = 12; a->begin.tm_min = 0; a->begin.tm_sec = 0; @@ -427,29 +531,25 @@ get_details(struct Appointment *a) } mktime(&a->begin); - strftime(str,30,"%x %X",&a->begin); - //printf("begin time = %s\n",str); mktime(&a->end); - strftime(str,30,"%x %X",&a->end); - //printf("end time = %s\n",str); if (GTK_TOGGLE_BUTTON(check_button_alarm)->active) { a->alarm = 1; text = gtk_entry_get_text(GTK_ENTRY(units_entry)); a->advance=atoi(text); - //printf("alarm advance %s", text); + logf(LOG_DEBUG, "alarm advance %s", text); if (GTK_TOGGLE_BUTTON(radio_button_alarm_min)->active) { a->advanceUnits = advMinutes; - //printf("min\n"); + logf(LOG_DEBUG, "min\n"); } if (GTK_TOGGLE_BUTTON(radio_button_alarm_hour)->active) { a->advanceUnits = advHours; - //printf("hour\n"); + logf(LOG_DEBUG, "hour\n"); } if (GTK_TOGGLE_BUTTON(radio_button_alarm_day)->active) { a->advanceUnits = advDays; - //printf("day\n"); + logf(LOG_DEBUG, "day\n"); } } else { a->alarm = 0; @@ -465,16 +565,16 @@ get_details(struct Appointment *a) switch (page) { case PAGE_NONE: a->repeatType=repeatNone; - //printf("no repeat\n"); + logf(LOG_DEBUG, "no repeat\n"); break; case PAGE_DAY: a->repeatType=repeatDaily; text = gtk_entry_get_text(GTK_ENTRY(repeat_day_entry)); a->repeatFrequency = atoi(text); - //printf("every %s day(s)\n", text); + logf(LOG_DEBUG, "every %s day(s)\n", text); if (GTK_TOGGLE_BUTTON(check_button_day_endon)->active) { a->repeatForever=0; - //printf("end on day\n"); + logf(LOG_DEBUG, "end on day\n"); a->repeatEnd.tm_mon = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spinner_endon_day_mon)) - 1; @@ -485,8 +585,6 @@ get_details(struct Appointment *a) gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spinner_endon_day_year)) - 1900; mktime(&a->repeatEnd); - strftime(str,30,"%x %X",&a->repeatEnd); - //printf("repeat_end time = %s\n",str); } else { a->repeatForever=1; } @@ -495,10 +593,10 @@ get_details(struct Appointment *a) a->repeatType=repeatWeekly; text = gtk_entry_get_text(GTK_ENTRY(repeat_week_entry)); a->repeatFrequency = atoi(text); - //printf("every %s week(s)\n", text); + logf(LOG_DEBUG, "every %s week(s)\n", text); if (GTK_TOGGLE_BUTTON(check_button_week_endon)->active) { a->repeatForever=0; - //printf("end on week\n"); + logf(LOG_DEBUG, "end on week\n"); a->repeatEnd.tm_mon = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spinner_endon_week_mon)) - 1; @@ -510,24 +608,23 @@ get_details(struct Appointment *a) (GTK_SPIN_BUTTON(spinner_endon_week_year)) - 1900; mktime(&a->repeatEnd); strftime(str,30,"%x %X",&a->repeatEnd); - //printf("repeat_end time = %s\n",str); + logf(LOG_DEBUG, "repeat_end time = %s\n",str); } else { a->repeatForever=1; } - //printf("Repeat Days:"); + logf(LOG_DEBUG, "Repeat Days:"); for (i=0; i<7; i++) { a->repeatDays[i]=(GTK_TOGGLE_BUTTON(toggle_button_repeat_days[i])->active); - //printf("%d",(GTK_TOGGLE_BUTTON(toggle_button_repeat_days[i])->active)); } - //printf("\n"); + logf(LOG_DEBUG, "\n"); break; case PAGE_MONTH: text = gtk_entry_get_text(GTK_ENTRY(repeat_mon_entry)); a->repeatFrequency = atoi(text); - //printf("every %s month(s)\n", text); + logf(LOG_DEBUG, "every %s month(s)\n", text); if (GTK_TOGGLE_BUTTON(check_button_mon_endon)->active) { a->repeatForever=0; - //printf("end on month\n"); + logf(LOG_DEBUG, "end on month\n"); a->repeatEnd.tm_mon = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spinner_endon_mon_mon)) - 1; @@ -539,28 +636,28 @@ get_details(struct Appointment *a) (GTK_SPIN_BUTTON(spinner_endon_mon_year)) - 1900; mktime(&a->repeatEnd); strftime(str,30,"%x %X",&a->repeatEnd); - //printf("repeat_end time = %s\n",str); + logf(LOG_DEBUG, "repeat_end time = %s\n",str); } else { a->repeatForever=1; } if (GTK_TOGGLE_BUTTON(toggle_button_repeat_mon_byday)->active) { a->repeatType=repeatMonthlyByDay; a->repeatDay = get_dom_type(a->begin.tm_mon, a->begin.tm_mday, a->begin.tm_year, a->begin.tm_wday); - //printf("***by day\n"); + logf(LOG_DEBUG, "***by day\n"); } if (GTK_TOGGLE_BUTTON(toggle_button_repeat_mon_bydate)->active) { a->repeatType=repeatMonthlyByDate; - //printf("***by date\n"); + logf(LOG_DEBUG, "***by date\n"); } break; case PAGE_YEAR: a->repeatType=repeatYearly; text = gtk_entry_get_text(GTK_ENTRY(repeat_year_entry)); a->repeatFrequency = atoi(text); - //printf("every %s years(s)\n", text); + logf(LOG_DEBUG, "every %s years(s)\n", text); if (GTK_TOGGLE_BUTTON(check_button_year_endon)->active) { a->repeatForever=0; - //printf("end on year\n"); + logf(LOG_DEBUG, "end on year\n"); a->repeatEnd.tm_mon = gtk_spin_button_get_value_as_int (GTK_SPIN_BUTTON(spinner_endon_year_mon)) - 1; @@ -572,7 +669,7 @@ get_details(struct Appointment *a) (GTK_SPIN_BUTTON(spinner_endon_year_year)) - 1900; mktime(&a->repeatEnd); strftime(str,30,"%x %X",&a->repeatEnd); - //printf("repeat_end time = %s\n",str); + logf(LOG_DEBUG, "repeat_end time = %s\n",str); } else { a->repeatForever=1; } @@ -580,13 +677,13 @@ get_details(struct Appointment *a) } a->description = gtk_editable_get_chars(GTK_EDITABLE(text1), 0, -1); - //printf("text1=[%s]\n",a->description); + logf(LOG_DEBUG, "text1=[%s]\n",a->description); a->note = gtk_editable_get_chars(GTK_EDITABLE(text2), 0, -1); if (a->note[0]=='\0') { a->note=NULL; } else { - //printf("text2=[%s]\n",a->note); + logf(LOG_DEBUG, "text2=[%s]\n",a->note); } //We won't allow a repeat frequency of less than 1 @@ -633,6 +730,12 @@ int update_dayview_screen() gtk_text_get_length(GTK_TEXT(text1))); for (temp_al = current_al, i=0; temp_al; temp_al=temp_al->next, i++) { + if (temp_al->ma.rt == MODIFIED_PALM_REC) { + //todo - this will be in preferences as to whether you want to + //see deleted records, or not. + i--; + continue; + } gtk_clist_append(GTK_CLIST(clist1), empty_line); if (temp_al->ma.a.event) { //This is a timeless event @@ -662,7 +765,15 @@ int update_dayview_screen() gdk_color_alloc(colormap, &color); gtk_clist_set_background(GTK_CLIST(clist1), i, &color); } - + if (temp_al->ma.rt == MODIFIED_PALM_REC) { + colormap = gtk_widget_get_colormap(clist1); + color.red=CLIST_MOD_RED; + color.green=CLIST_MOD_GREEN; + color.blue=CLIST_MOD_BLUE; + gdk_color_alloc(colormap, &color); + gtk_clist_set_background(GTK_CLIST(clist1), i, &color); + } + if ( (temp_al->ma.a.note) || (temp_al->ma.a.alarm) ) { get_pixmaps(scrolled_window1, &pixmap_note, &pixmap_alarm, &pixmap_check, &pixmap_checked, @@ -679,11 +790,13 @@ int update_dayview_screen() gtk_clist_set_pixmap(GTK_CLIST(clist1), i, 3, pixmap_alarm, mask_alarm); } } +#ifdef OLD_ENTRY gtk_clist_append(GTK_CLIST(clist1), empty_line); gtk_clist_set_text(GTK_CLIST(clist1), i, 0, "New"); gtk_clist_set_text(GTK_CLIST(clist1), i, 1, "Select to add an appointment"); gtk_clist_set_row_data(GTK_CLIST(clist1), i, GINT_TO_POINTER(CLIST_NEW_ENTRY_DATA)); +#endif //If there is an item in the list, select the first one if (i>0) { gtk_clist_select_row(GTK_CLIST(clist1), 0, 1); @@ -698,6 +811,8 @@ void cb_spin_mon_day_year(GtkAdjustment *adj, gpointer data) int total1, total2; int days_in_month[]={31,28,31,30,31,30,31,31,30,31,30,31 }; + + year=mon=day=0; //allow the days range to only go as high as the number of days //in the month if (GPOINTER_TO_INT(data) == 1) { @@ -772,16 +887,129 @@ void cb_spin_mon_day_year(GtkAdjustment *adj, gpointer data) } +static void cb_add_new_record(GtkWidget *widget, + gpointer data) +{ + MyAppointment *ma; + struct Appointment *a; + struct Appointment new_a; + int flag; + int create_exception=0; + + flag=GPOINTER_TO_INT(data); + + if (flag==CLEAR_FLAG) { + //Clear button was hit + clear_details(); + return; + } + if ((flag!=NEW_FLAG) && (flag!=MODIFY_FLAG)) { + return; + } + if (flag==MODIFY_FLAG) { + ma = gtk_clist_get_row_data(GTK_CLIST(clist1), clist_row_selected); + if (ma < (MyAppointment *)CLIST_MIN_DATA) { + return; + } + if ((ma->rt==DELETED_PALM_REC) || (ma->rt==MODIFIED_PALM_REC)) { + logf(LOG_INFO, "You can't modify a record that is deleted\n"); + return; + } + } else { + ma=NULL; + } + get_details(&new_a); + if ((flag==MODIFY_FLAG) && (new_a.repeatType != repeatNone)) { + //We need more user input + //Pop up a dialog + dialog_current_all_cancel(); + if (dialog_result==DIALOG_SAID_CANCEL) { + return; + } + if (dialog_result==DIALOG_SAID_CURRENT) { + //Create an exception in the appointment + create_exception=1; + new_a.repeatType = repeatNone; + new_a.begin.tm_year = current_year; + new_a.begin.tm_mon = current_month; + new_a.begin.tm_mday = current_day; + mktime(&new_a.begin); + new_a.repeatType = repeatNone; + new_a.end.tm_year = current_year; + new_a.end.tm_mon = current_month; + new_a.end.tm_mday = current_day; + mktime(&new_a.end); + } + if (dialog_result==DIALOG_SAID_ALL) { + //We still need to keep the exceptions of the original record + new_a.exception = (struct tm *)malloc(ma->a.exceptions * sizeof(struct tm)); + memcpy(new_a.exception, ma->a.exception, ma->a.exceptions * sizeof(struct tm)); + new_a.exceptions = ma->a.exceptions; + } + } + pc_datebook_write(&new_a, NEW_PC_REC, 0); + free_Appointment(&new_a); + if (flag==MODIFY_FLAG) { + // + //We need to take care of the 2 options allowed when modifying + //repeating appointments + // + if (create_exception) { + datebook_copy_appointment(&(ma->a), &a); + datebook_add_exception(a, current_year, current_month, current_day); + pc_datebook_write(a, NEW_PC_REC, 0); + free_Appointment(a); + free(a); + } + delete_pc_record(DATEBOOK, ma, flag); + } + //update_dayview_screen(); + //Force the DOW week button to be clicked on to force a re-read, redraw + gtk_signal_emit_by_name(GTK_OBJECT(day_button[current_day-1]), "clicked"); + + return; +} + + void cb_delete_appt(GtkWidget *widget, gpointer data) { MyAppointment *ma; + struct Appointment *a; + int flag; ma = gtk_clist_get_row_data(GTK_CLIST(clist1), clist_row_selected); if (ma < (MyAppointment *)CLIST_MIN_DATA) { return; } - delete_pc_record(DATEBOOK, ma); - //pc_datebook_delete(ma); + flag = GPOINTER_TO_INT(data); + if ((flag!=MODIFY_FLAG) && (flag!=DELETE_FLAG)) { + return; + } + + // + //We need to take care of the 2 options allowed when modifying + //repeating appointments + // + if (ma->a.repeatType != repeatNone) { + //We need more user input + //Pop up a dialog + dialog_current_all_cancel(); + if (dialog_result==DIALOG_SAID_CANCEL) { + return; + } + if (dialog_result==DIALOG_SAID_CURRENT) { + //Create an exception in the appointment + datebook_copy_appointment(&(ma->a), &a); + datebook_add_exception(a, current_year, current_month, current_day); + pc_datebook_write(a, NEW_PC_REC, 0); + free_Appointment(a); + free(a); + //Since this was really a modify, and not a delete + flag=MODIFY_FLAG; + } + } + delete_pc_record(DATEBOOK, ma, flag); + //Force the DOW week button to be clicked on to force a re-read, redraw gtk_signal_emit_by_name(GTK_OBJECT(day_button[current_day-1]), "clicked"); } @@ -807,26 +1035,6 @@ void cb_check_button_alarm(GtkWidget *widget, gpointer data) } } -/* -int cb_backup( GtkWidget *widget, - gpointer data ) -{ - cleanup_pc_files(); - return 0; - - g_print("fork\n"); - switch ( fork(0) ){ - case -1: - perror("fork"); - exit(7); - case 0: - //system("ls"); - exit(0); - default: - return; - } -} -*/ void cb_clist1_selection(GtkWidget *clist, gint row, @@ -834,23 +1042,24 @@ void cb_clist1_selection(GtkWidget *clist, GdkEventButton *event, gpointer data) { - struct Appointment *a, new_a; +#ifdef OLD_ENTRY + struct Appointment new_a; +#endif + struct Appointment *a; MyAppointment *ma; char temp[20]; - gchar *text; - int i, rec_len, found; - char record[65536]; + int i; - //g_print("event %d\n",event); - //g_print("data %d\n",data); if (!event) return; clist_row_selected=row; + a=NULL; ma = gtk_clist_get_row_data(GTK_CLIST(clist1), row); if (ma) { a=&(ma->a); } +#ifdef OLD_ENTRY //Hack #1 //If we are not in add data mode then switch the mode on the clist //back to what its supposed to be @@ -880,6 +1089,7 @@ void cb_clist1_selection(GtkWidget *clist, clear_details(); return; } +#endif gtk_text_set_point(GTK_TEXT(text1), 0); gtk_text_forward_delete(GTK_TEXT(text1), gtk_text_get_length(GTK_TEXT(text1))); @@ -920,7 +1130,7 @@ void cb_clist1_selection(GtkWidget *clist, (radio_button_alarm_day), TRUE); break; default: - g_print("Error in DateBookDB advanceUnits = %d\n",a->advanceUnits); + logf(LOG_WARN, "Error in DateBookDB advanceUnits = %d\n",a->advanceUnits); } sprintf(temp, "%d", a->advance); gtk_entry_set_text(GTK_ENTRY(units_entry), temp); @@ -997,7 +1207,7 @@ void cb_clist1_selection(GtkWidget *clist, break; case repeatMonthlyByDate: case repeatMonthlyByDay: - //for day: printf("repeat day=%d\n",a->repeatDay); + logf(LOG_DEBUG, "repeat day=%d\n",a->repeatDay); if ((a->repeatForever)) { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON (check_button_mon_endon), FALSE); @@ -1044,7 +1254,8 @@ void cb_clist1_selection(GtkWidget *clist, gtk_notebook_set_page(GTK_NOTEBOOK(notebook), PAGE_YEAR); break; - default: g_print("unknown repeatType found in DatebookDB\n"); + default: + logf(LOG_WARN, "unknown repeatType found in DatebookDB\n"); } return; @@ -1078,14 +1289,17 @@ void cb_day_button(GtkWidget *widget, gpointer data) { int num; +#ifdef EASTER + static int Easter=0; +#endif num = GPOINTER_TO_INT(data); if ((num<1) || (num>31)) { PRINT_FILE_LINE; - printf("num is out of range\n"); + logf(LOG_WARN, "cb_day_button: num is out of range\n"); return; } - //g_print ("%d:cb_day_button\n", num); + logf(LOG_DEBUG, "cb_day_button, num = %d\n", num); if (GTK_IS_BUTTON(day_button[current_day-1])) { gtk_widget_set_name(GTK_WIDGET(day_button[current_day-1]), "button"); } @@ -1094,6 +1308,21 @@ void cb_day_button(GtkWidget *widget, gtk_widget_set_name(GTK_WIDGET(day_button[current_day-1]), "button_set"); } set_date_labels(); + // + //Easter Egg + // +#ifdef EASTER + if (((current_day==29) && (current_month==7)) || + ((current_day==20) && (current_month==11))) { + Easter++; + if (Easter>4) { + Easter=0; + dialog_easter(current_day); + } + } else { + Easter=0; + } +#endif update_dayview_screen(); } @@ -1126,7 +1355,6 @@ void paint_calendar(GtkWidget *widget, gpointer data) //gtk_signal_handlers_destroy(GTK_OBJECT(day_button[i])); gtk_widget_destroy(GTK_WIDGET(day_button[i])); } - //g_print("destroying %d\n",i+1); } if (GPOINTER_TO_INT(data) == CAL_LEFT_MON) { current_month--; @@ -1209,7 +1437,6 @@ void paint_calendar(GtkWidget *widget, gpointer data) } } - int datebook_gui(GtkWidget *vbox, GtkWidget *hbox) { extern GtkWidget *glob_date_label; @@ -1218,6 +1445,7 @@ int datebook_gui(GtkWidget *vbox, GtkWidget *hbox) GtkWidget *hbox2; GtkWidget *hbox_text1, *hbox_text2; GtkWidget *hbox_table; + GtkWidget *hbox_temp; GtkWidget *hbox_notime; GtkWidget *vbox_detail; GtkWidget *vbox_todays_sched; @@ -1237,7 +1465,6 @@ int datebook_gui(GtkWidget *vbox, GtkWidget *hbox) GtkWidget *hbox_repeat_year2; GtkWidget *vbox_filler; GtkWidget *vbox_begin_labels; - //GtkWidget *hbox_end_date; GtkWidget *dow_hbox; GtkWidget *button; GtkWidget *separator; @@ -1252,21 +1479,6 @@ int datebook_gui(GtkWidget *vbox, GtkWidget *hbox) GtkWidget *vscrollbar; GtkWidget *arrow; - GdkPixmap *pixmap_note; - GdkPixmap *pixmap_alarm; - GdkPixmap *pixmap_check; - GdkPixmap *pixmap_checked; - GdkBitmap *mask_note; - GdkBitmap *mask_alarm; - GdkBitmap *mask_check; - GdkBitmap *mask_checked; - - GtkWidget *pixmapwid; - //GdkPixmap *pixmap; - //GdkPixmap *pixmap_note; - //GdkBitmap *mask; - //GtkStyle *style; - //GtkWidget *list; GSList *group; time_t ltime; @@ -1275,7 +1487,6 @@ int datebook_gui(GtkWidget *vbox, GtkWidget *hbox) int i; #define MAX_STR 100 char str[MAX_STR]; - char dow[50]; char *day_letters[] = {"S","M","T","W","R","F","S"}; init(); @@ -1293,19 +1504,12 @@ int datebook_gui(GtkWidget *vbox, GtkWidget *hbox) // Create "Delete" button in left column button = gtk_button_new_with_label ("Delete"); - gtk_signal_connect(GTK_OBJECT (button), "clicked", - GTK_SIGNAL_FUNC (cb_delete_appt), NULL); - gtk_box_pack_start(GTK_BOX (vbox), button, FALSE, FALSE, 0); - gtk_widget_show(button); - - /* - // Create "Backup" button in left column - button = gtk_button_new_with_label ("Backup"); gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(cb_backup), NULL); + GTK_SIGNAL_FUNC(cb_delete_appt), + GINT_TO_POINTER(DELETE_FLAG)); gtk_box_pack_start(GTK_BOX (vbox), button, FALSE, FALSE, 0); gtk_widget_show(button); -*/ + //Make the Today is: label time(<ime); now = localtime(<ime); @@ -1474,24 +1678,51 @@ int datebook_gui(GtkWidget *vbox, GtkWidget *hbox) //gtk_clist_set_auto_sort(GTK_CLIST(clist1), TRUE); gtk_widget_show(clist1); - //start details - frame = gtk_frame_new ("Details"); - gtk_frame_set_label_align( GTK_FRAME(frame), 0.5, 0.0); - //gtk_container_set_border_width (GTK_CONTAINER (frame), 5); - gtk_box_pack_start (GTK_BOX (vbox2), frame, TRUE, TRUE, 0); + // + // The right hand part of the main window follows: + // + hbox_temp = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox2), hbox_temp, FALSE, FALSE, 0); + gtk_widget_show(hbox_temp); + + + //Add record modification buttons on right side + button = gtk_button_new_with_label("Add It"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_add_new_record), + GINT_TO_POINTER(NEW_FLAG)); + gtk_box_pack_start(GTK_BOX(hbox_temp), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + button = gtk_button_new_with_label("Apply Changes"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_add_new_record), + GINT_TO_POINTER(MODIFY_FLAG)); + gtk_box_pack_start(GTK_BOX(hbox_temp), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + button = gtk_button_new_with_label("Clear"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_add_new_record), + GINT_TO_POINTER(CLEAR_FLAG)); + gtk_box_pack_start(GTK_BOX(hbox_temp), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + + //start details - vbox_detail = gtk_vbox_new (FALSE, 0); + frame = gtk_frame_new("Details"); + gtk_frame_set_label_align(GTK_FRAME(frame), 0.5, 0.0); + gtk_container_set_border_width(GTK_CONTAINER(frame), 0); + gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); - //Get away from the edge - //vbox_filler = gtk_vbox_new (FALSE, 0); - //gtk_box_pack_start (GTK_BOX (hbox_alarm), vbox_filler, FALSE, FALSE, 2); - //gtk_widget_show (vbox_filler); + vbox_detail = gtk_vbox_new(FALSE, 0); //The checkbox for Alarm - hbox_alarm1 = gtk_hbox_new (FALSE, 0); - gtk_box_pack_start (GTK_BOX (vbox_detail), hbox_alarm1, FALSE, FALSE, 0); - gtk_widget_show (hbox_alarm1); + hbox_alarm1 = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox_detail), hbox_alarm1, FALSE, FALSE, 0); + gtk_widget_show(hbox_alarm1); check_button_alarm = gtk_check_button_new_with_label ("Alarm"); gtk_box_pack_start (GTK_BOX (hbox_alarm1), check_button_alarm, FALSE, FALSE, 5); @@ -1501,7 +1732,7 @@ int datebook_gui(GtkWidget *vbox, GtkWidget *hbox) hbox_alarm2 = gtk_hbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (hbox_alarm1), hbox_alarm2, FALSE, FALSE, 0); - gtk_widget_show (hbox_alarm2); + //gtk_widget_show(hbox_alarm2); //Units entry for alarm units_entry = gtk_entry_new_with_max_length(2); diff --git a/icons/README b/icons/README new file mode 100644 index 00000000..51bea3f9 --- /dev/null +++ b/icons/README @@ -0,0 +1,4 @@ +Ubiratan Oliverio + contributed jpilot-icon1.xpm +vik vik@asi.org + contributed jpilot-icon2.xpm diff --git a/icons/jpilot-icon1.xpm b/icons/jpilot-icon1.xpm new file mode 100644 index 00000000..7e011230 --- /dev/null +++ b/icons/jpilot-icon1.xpm @@ -0,0 +1,1748 @@ +/* XPM */ +static char * icon_jpilot_xpm[] = { +"48 48 1697 2", +" c None", +". c #007E7E", +"+ c #008584", +"@ c #017977", +"# c #027874", +"$ c #037873", +"% c #047973", +"& c #057A72", +"* c #057B71", +"= c #067B71", +"- c #087C70", +"; c #097D70", +"> c #0A7D6F", +", c #0B7D6F", +"' c #0C7D6E", +") c #0C7E6D", +"! c #0E7F6C", +"~ c #0F806B", +"{ c #10806B", +"] c #11816A", +"^ c #12826A", +"/ c #128269", +"( c #138368", +"_ c #148368", +": c #168467", +"< c #178467", +"[ c #178566", +"} c #188565", +"| c #1A8665", +"1 c #1B8764", +"2 c #1C8864", +"3 c #1D8864", +"4 c #1D8963", +"5 c #1E8962", +"6 c #208A61", +"7 c #218A60", +"8 c #218B60", +"9 c #238B5F", +"0 c #248C5F", +"a c #248C5E", +"b c #258D5D", +"c c #268E5D", +"d c #288F5C", +"e c #298F5B", +"f c #2A905A", +"g c #2B9159", +"h c #2C9159", +"i c #298350", +"j c #008988", +"k c #019A97", +"l c #029B96", +"m c #039C94", +"n c #059C94", +"o c #079D94", +"p c #089E92", +"q c #089F91", +"r c #0A9F91", +"s c #0BA090", +"t c #0DA190", +"u c #0EA28F", +"v c #10A28E", +"w c #10A38C", +"x c #11A48C", +"y c #13A58B", +"z c #15A58A", +"A c #15A68A", +"B c #17A789", +"C c #18A788", +"D c #19A987", +"E c #1BAA86", +"F c #1CAA85", +"G c #1DAB85", +"H c #1EAB84", +"I c #20AC83", +"J c #21AC82", +"K c #22AE81", +"L c #23AF81", +"M c #25AF80", +"N c #26B07F", +"O c #27B17E", +"P c #29B17D", +"Q c #2AB37C", +"R c #2BB37C", +"S c #2CB47C", +"T c #2EB57B", +"U c #2FB579", +"V c #30B678", +"W c #31B777", +"X c #33B777", +"Y c #34B877", +"Z c #35B976", +"` c #37BA75", +" . c #38BA73", +".. c #39BC72", +"+. c #3ABB71", +"@. c #319A5C", +"#. c #017B78", +"$. c #02928D", +"%. c #03948D", +"&. c #05968E", +"*. c #06968D", +"=. c #07978D", +"-. c #08988B", +";. c #0A998B", +">. c #0A998A", +",. c #0C9A8A", +"'. c #0D9B89", +"). c #0F9B89", +"!. c #109C87", +"~. c #119D86", +"{. c #129E85", +"]. c #149F84", +"^. c #16A084", +"/. c #17A182", +"(. c #18A181", +"_. c #19A281", +":. c #1BA380", +"<. c #1CA47F", +"[. c #1FA57D", +"}. c #20A67D", +"|. c #21A67C", +"1. c #22A77B", +"2. c #23A87B", +"3. c #24A97A", +"4. c #26AA79", +"5. c #27AA78", +"6. c #28AB77", +"7. c #29AC77", +"8. c #2AAC76", +"9. c #2BAD76", +"0. c #2EAE74", +"a. c #2EAF73", +"b. c #2FAF73", +"c. c #31B072", +"d. c #31B172", +"e. c #33B171", +"f. c #35B270", +"g. c #36B36F", +"h. c #36B36E", +"i. c #37B36D", +"j. c #36AA66", +"k. c #277A49", +"l. c #027975", +"m. c #03918A", +"n. c #048F88", +"o. c #069087", +"p. c #079186", +"q. c #0A9285", +"r. c #0A9384", +"s. c #0C9484", +"t. c #0D9583", +"u. c #0E9582", +"v. c #0F9682", +"w. c #109780", +"x. c #12977F", +"y. c #13987F", +"z. c #14997E", +"A. c #15997E", +"B. c #169A7D", +"C. c #179B7C", +"D. c #189B7B", +"E. c #199C7B", +"F. c #1B9D7A", +"G. c #1C9E7A", +"H. c #1D9E79", +"I. c #1F9F77", +"J. c #1FA076", +"K. c #20A076", +"L. c #22A175", +"M. c #23A275", +"N. c #24A274", +"O. c #26A373", +"P. c #27A472", +"Q. c #29A571", +"R. c #2AA671", +"S. c #2BA670", +"T. c #2CA76F", +"U. c #2DA86E", +"V. c #2FA96D", +"W. c #30AA6D", +"X. c #31AA6C", +"Y. c #32AB6B", +"Z. c #33AC6A", +"`. c #34AC69", +" + c #35AC68", +".+ c #34A462", +"++ c #2F9256", +"@+ c #21683D", +"#+ c #027A74", +"$+ c #049189", +"%+ c #068F86", +"&+ c #078D83", +"*+ c #078C81", +"=+ c #098E80", +"-+ c #0A8F80", +";+ c #0B8F7F", +">+ c #0C907F", +",+ c #0E907E", +"'+ c #0E917D", +")+ c #10917C", +"!+ c #11927B", +"~+ c #12937B", +"{+ c #13937B", +"]+ c #14957A", +"^+ c #159579", +"/+ c #169678", +"(+ c #189777", +"_+ c #199877", +":+ c #1A9877", +"<+ c #1B9976", +"[+ c #1C9975", +"}+ c #1D9A74", +"|+ c #1E9B72", +"1+ c #1F9B72", +"2+ c #219C72", +"3+ c #229D71", +"4+ c #239D70", +"5+ c #249E6F", +"6+ c #269F6E", +"7+ c #27A06E", +"8+ c #29A06D", +"9+ c #2AA16C", +"0+ c #2AA16B", +"a+ c #2CA26A", +"b+ c #2DA36A", +"c+ c #2DA46A", +"d+ c #2FA569", +"e+ c #31A668", +"f+ c #32A667", +"g+ c #33A766", +"h+ c #34A765", +"i+ c #34A362", +"j+ c #309559", +"k+ c #2C8950", +"l+ c #22673B", +"m+ c #047A74", +"n+ c #069289", +"o+ c #068F85", +"p+ c #088D81", +"q+ c #098B7E", +"r+ c #098A7C", +"s+ c #0A8B7C", +"t+ c #0C8C7C", +"u+ c #0D8D7B", +"v+ c #0E8D7A", +"w+ c #0F8E79", +"x+ c #108F78", +"y+ c #128F78", +"z+ c #129078", +"A+ c #139177", +"B+ c #159176", +"C+ c #169275", +"D+ c #179374", +"E+ c #189374", +"F+ c #199474", +"G+ c #1A9473", +"H+ c #1B9572", +"I+ c #1D9671", +"J+ c #1D9670", +"K+ c #1E9770", +"L+ c #20986F", +"M+ c #21996F", +"N+ c #229A6E", +"O+ c #239A6D", +"P+ c #249B6C", +"Q+ c #259C6B", +"R+ c #269C6B", +"S+ c #279D6A", +"T+ c #299D69", +"U+ c #299E68", +"V+ c #2B9F67", +"W+ c #2C9F67", +"X+ c #2DA067", +"Y+ c #2EA166", +"Z+ c #30A165", +"`+ c #31A264", +" @ c #31A363", +".@ c #33A363", +"+@ c #33A061", +"@@ c #31995C", +"#@ c #2E8F54", +"$@ c #2D884F", +"%@ c #23673B", +"&@ c #057B74", +"*@ c #079388", +"=@ c #079084", +"-@ c #098D80", +";@ c #0A8B7D", +">@ c #0A8A7A", +",@ c #0C8778", +"'@ c #0D8777", +")@ c #0D8876", +"!@ c #0F8975", +"~@ c #108974", +"{@ c #118A74", +"]@ c #128B73", +"^@ c #138B73", +"/@ c #148C72", +"(@ c #158D71", +"_@ c #168D70", +":@ c #178E70", +"<@ c #188F6F", +"[@ c #198F6F", +"}@ c #1A906E", +"|@ c #1C906D", +"1@ c #1C916C", +"2@ c #1D926C", +"3@ c #1F926B", +"4@ c #1F936B", +"5@ c #20946A", +"6@ c #229569", +"7@ c #239668", +"8@ c #259767", +"9@ c #269767", +"0@ c #279866", +"a@ c #289965", +"b@ c #299964", +"c@ c #2A9A64", +"d@ c #2B9B63", +"e@ c #2C9B63", +"f@ c #2D9C61", +"g@ c #2E9D60", +"h@ c #2F9D5F", +"i@ c #319E5F", +"j@ c #329D5E", +"k@ c #31995B", +"l@ c #309457", +"m@ c #2F8F53", +"n@ c #2E894E", +"o@ c #067C73", +"p@ c #089487", +"q@ c #099183", +"r@ c #0A8E7F", +"s@ c #0C8A7A", +"t@ c #0D8776", +"u@ c #0D8673", +"v@ c #0E8673", +"w@ c #0F8772", +"x@ c #108872", +"y@ c #118871", +"z@ c #128970", +"A@ c #138A6F", +"B@ c #148A6F", +"C@ c #158B6E", +"D@ c #168C6D", +"E@ c #178C6D", +"F@ c #188D6C", +"G@ c #198D6B", +"H@ c #1B8E6B", +"I@ c #1C8F6A", +"J@ c #1C8F69", +"K@ c #1E9069", +"L@ c #1F9168", +"M@ c #209168", +"N@ c #219267", +"O@ c #229366", +"P@ c #239366", +"Q@ c #249465", +"R@ c #259464", +"S@ c #269564", +"T@ c #279563", +"U@ c #289662", +"V@ c #299762", +"W@ c #2A9761", +"X@ c #2B9860", +"Y@ c #2D9960", +"Z@ c #2D995F", +"`@ c #2E9A5E", +" # c #309B5E", +".# c #319B5D", +"+# c #329B5C", +"@# c #319859", +"## c #319456", +"$# c #308F52", +"%# c #2F894E", +"&# c #24683B", +"*# c #077D72", +"=# c #0A9487", +"-# c #0A9283", +";# c #0C8B7C", +"># c #0D8A79", +",# c #0D8775", +"'# c #128971", +")# c #215E55", +"!# c #234A48", +"~# c #234948", +"{# c #294F4D", +"]# c #274D49", +"^# c #325753", +"/# c #2D524F", +"(# c #284E4B", +"_# c #2B5250", +":# c #264D4A", +"<# c #244A47", +"[# c #264C48", +"}# c #264D48", +"|# c #264E47", +"1# c #285049", +"2# c #285047", +"3# c #2A5048", +"4# c #2A5147", +"5# c #2A7453", +"6# c #2B9861", +"7# c #319C5D", +"8# c #329B5B", +"9# c #329858", +"0# c #329555", +"a# c #319052", +"b# c #30894D", +"c# c #25683A", +"d# c #087D71", +"e# c #0B9586", +"f# c #0C9382", +"g# c #0C8F7E", +"h# c #0D8C7B", +"i# c #0E8B78", +"j# c #0F8874", +"k# c #118971", +"l# c #138A70", +"m# c #148B6E", +"n# c #295455", +"o# c #2F404D", +"p# c #2F3F4D", +"q# c #59656F", +"r# c #7D8489", +"s# c #7F858B", +"t# c #767C82", +"u# c #7A8389", +"v# c #3D4C56", +"w# c #2F404C", +"x# c #2F3F4C", +"y# c #2F414D", +"z# c #2D3F4A", +"A# c #296850", +"B# c #329C5C", +"C# c #339C5C", +"D# c #349B5A", +"E# c #339957", +"F# c #339555", +"G# c #339051", +"H# c #318A4D", +"I# c #256939", +"J# c #087E70", +"K# c #0C9686", +"L# c #0D9382", +"M# c #0E8D79", +"N# c #0F8C77", +"O# c #108973", +"P# c #108871", +"Q# c #2A5455", +"R# c #30414D", +"S# c #4F5B62", +"T# c #636D70", +"U# c #505C5E", +"V# c #576367", +"W# c #4F5C61", +"X# c #3C4C53", +"Y# c #3A4B52", +"Z# c #394A51", +"`# c #3A4A51", +" $ c #3B4B51", +".$ c #3A4B50", +"+$ c #394B50", +"@$ c #34454E", +"#$ c #2E3E49", +"$$ c #2A684F", +"%$ c #349D5B", +"&$ c #349C59", +"*$ c #349957", +"=$ c #349654", +"-$ c #349151", +";$ c #318A4C", +">$ c #266939", +",$ c #097E70", +"'$ c #0D9785", +")$ c #0E9481", +"!$ c #0E907D", +"~$ c #108C76", +"{$ c #118973", +"]$ c #2F414C", +"^$ c #334547", +"/$ c #48664E", +"($ c #517454", +"_$ c #527555", +":$ c #527556", +"<$ c #527656", +"[$ c #517557", +"}$ c #517556", +"|$ c #517656", +"1$ c #4F7154", +"2$ c #3A4E4B", +"3$ c #2D3E4A", +"4$ c #2B684F", +"5$ c #349D5A", +"6$ c #359D59", +"7$ c #359A56", +"8$ c #359654", +"9$ c #349250", +"0$ c #328B4B", +"a$ c #276A38", +"b$ c #0B7E70", +"c$ c #0E9784", +"d$ c #0F9480", +"e$ c #10927C", +"f$ c #118D76", +"g$ c #128A73", +"h$ c #178C6E", +"i$ c #188C6D", +"j$ c #2B5555", +"k$ c #2E404C", +"l$ c #314345", +"m$ c #4A6F4D", +"n$ c #568357", +"o$ c #578458", +"p$ c #568358", +"q$ c #568458", +"r$ c #537D54", +"s$ c #39504A", +"t$ c #2D3F49", +"u$ c #2C694F", +"v$ c #359E5A", +"w$ c #369E5A", +"x$ c #379D59", +"y$ c #379B55", +"z$ c #369753", +"A$ c #35924F", +"B$ c #338C4A", +"C$ c #276B38", +"D$ c #0C7F6F", +"E$ c #0F9883", +"F$ c #10957F", +"G$ c #128F77", +"H$ c #128E75", +"I$ c #138B72", +"J$ c #106852", +"K$ c #0F5D49", +"L$ c #13755B", +"M$ c #324447", +"N$ c #4A6F4E", +"O$ c #4D744E", +"P$ c #3C5B3D", +"Q$ c #3F6040", +"R$ c #547F55", +"S$ c #39573A", +"T$ c #507A51", +"U$ c #39514A", +"V$ c #2D3E49", +"W$ c #379F59", +"X$ c #389E58", +"Y$ c #379852", +"Z$ c #36934E", +"`$ c #348C4A", +" % c #286B38", +".% c #0D7F6E", +"+% c #109882", +"@% c #11967E", +"#% c #129077", +"$% c #138E75", +"%% c #148B71", +"&% c #062B21", +"*% c #010B09", +"=% c #286347", +"-% c #218C69", +";% c #2B5554", +">% c #324346", +",% c #385539", +"'% c #0C120C", +")% c #1A281A", +"!% c #558156", +"~% c #070A07", +"{% c #121D13", +"]% c #486E49", +"^% c #578358", +"/% c #547D54", +"(% c #394F49", +"_% c #2E3E4A", +":% c #2D6A4F", +"<% c #329152", +"[% c #2B7A44", +"}% c #2E8046", +"|% c #389C54", +"1% c #389851", +"2% c #36944E", +"3% c #358D4A", +"4% c #0E806D", +"5% c #129981", +"6% c #13967E", +"7% c #13947A", +"8% c #149176", +"9% c #148F74", +"0% c #158C70", +"a% c #114534", +"b% c #264831", +"c% c #477750", +"d% c #1B8E6A", +"e% c #314346", +"f% c #416341", +"g% c #2B412B", +"h% c #416242", +"i% c #3C5D3D", +"j% c #000000", +"k% c #4E774F", +"l% c #3A504A", +"m% c #369D58", +"n% c #1A4B29", +"o% c #204227", +"p% c #409754", +"q% c #399951", +"r% c #38944D", +"s% c #368E49", +"t% c #296B37", +"u% c #0F816D", +"v% c #139A81", +"w% c #13977E", +"x% c #14947A", +"y% c #159175", +"z% c #159073", +"A% c #168D6F", +"B% c #158164", +"C% c #155D46", +"D% c #286A4D", +"E% c #2B8762", +"F% c #198361", +"G% c #135F46", +"H% c #1F3B3B", +"I% c #26353E", +"J% c #1B2527", +"K% c #253727", +"L% c #446845", +"M% c #548055", +"N% c #436644", +"O% c #3A583A", +"P% c #4F7950", +"Q% c #2B422B", +"R% c #263A26", +"S% c #4F7650", +"T% c #2A3C35", +"U% c #161F25", +"V% c #173527", +"W% c #206238", +"X% c #309152", +"Y% c #236337", +"Z% c #0D2715", +"`% c #223824", +" & c #377C45", +".& c #3A9A50", +"+& c #39944D", +"@& c #378E48", +"#& c #2A6C36", +"$& c #10816C", +"%& c #149A80", +"&& c #14987D", +"*& c #159275", +"=& c #169072", +"-& c #178D6F", +";& c #0D523F", +">& c #020B09", +",& c #173B2A", +"'& c #268460", +")& c #125C44", +"!& c #020C08", +"~& c #090F0D", +"{& c #070A0C", +"]& c #010102", +"^& c #111B12", +"/& c #416241", +"(& c #4A714B", +"_& c #162217", +":& c #070B07", +"<& c #4D764E", +"[& c #192619", +"}& c #030503", +"|& c #324C33", +"1& c #213221", +"2& c #060908", +"3& c #030905", +"4& c #14371F", +"5& c #349051", +"6& c #389F59", +"7& c #040C06", +"8& c #010402", +"9& c #09110A", +"0& c #315F38", +"a& c #3E9751", +"b& c #3A944C", +"c& c #10826C", +"d& c #159B7F", +"e& c #16987C", +"f& c #189172", +"g& c #188E6F", +"h& c #093428", +"i& c #010101", +"j& c #2D452E", +"k& c #328B63", +"l& c #0D3F2D", +"m& c #050805", +"n& c #2A3F2B", +"o& c #39563B", +"p& c #101811", +"q& c #243624", +"r& c #537E54", +"s& c #426543", +"t& c #4B734C", +"u& c #101810", +"v& c #090D09", +"w& c #3D5D3E", +"x& c #203120", +"y& c #141F14", +"z& c #27422C", +"A& c #050B06", +"B& c #285533", +"C& c #379352", +"D& c #225C32", +"E& c #416743", +"F& c #47804E", +"G& c #3F9750", +"H& c #3B954B", +"I& c #398F47", +"J& c #2C6D35", +"K& c #11836B", +"L& c #169C7E", +"M& c #17997A", +"N& c #179677", +"O& c #189473", +"P& c #199271", +"Q& c #198E6E", +"R& c #188566", +"S& c #051F17", +"T& c #050905", +"U& c #345438", +"V& c #2B8D65", +"W& c #051D15", +"X& c #273C28", +"Y& c #4B7154", +"Z& c #3B5549", +"`& c #1E2D21", +" * c #1C2B1C", +".* c #4F7850", +"+* c #365236", +"@* c #0A100A", +"#* c #0F170F", +"$* c #0E150E", +"%* c #426544", +"&* c #3E5B4E", +"** c #356D4C", +"=* c #0D2415", +"-* c #29432C", +";* c #409A57", +">* c #266335", +",* c #4E8D56", +"'* c #419B52", +")* c #3D9A4E", +"!* c #3C964A", +"~* c #3A8F47", +"{* c #13836A", +"]* c #179D7E", +"^* c #189A7A", +"/* c #199473", +"(* c #1A8F6D", +"_* c #16785A", +":* c #041812", +"<* c #0C130C", +"[* c #3C6A47", +"}* c #288E65", +"|* c #010604", +"1* c #364D4E", +"2* c #304244", +"3* c #202F23", +"4* c #253926", +"5* c #273C27", +"6* c #2F472F", +"7* c #223523", +"8* c #45674E", +"9* c #2E4049", +"0* c #306B4C", +"a* c #0D2716", +"b* c #010201", +"c* c #2E472F", +"d* c #429A56", +"e* c #1A4625", +"f* c #499455", +"g* c #3E9F50", +"h* c #3D9C4D", +"i* c #3D964A", +"j* c #3A9047", +"k* c #2D6E35", +"l* c #138469", +"m* c #199E7D", +"n* c #199A79", +"o* c #1A9876", +"p* c #1A9572", +"q* c #1B9370", +"r* c #1C8F6C", +"s* c #115B44", +"t* c #010907", +"u* c #131E14", +"v* c #3E825A", +"w* c #1C7251", +"x* c #406146", +"y* c #2D3F40", +"z* c #0B0F0D", +"A* c #3C5B3C", +"B* c #2D442D", +"C* c #152116", +"D* c #2B422C", +"E* c #3C574C", +"F* c #234738", +"G* c #07160C", +"H* c #090E09", +"I* c #3C613E", +"J* c #419C56", +"K* c #0B1E0F", +"L* c #449C53", +"M* c #3FA050", +"N* c #3F9C4D", +"O* c #3E974A", +"P* c #3B9146", +"Q* c #2E6E34", +"R* c #158569", +"S* c #1A9E7D", +"T* c #1A9B79", +"U* c #1B9875", +"V* c #1B9571", +"W* c #1C936F", +"X* c #1C906B", +"Y* c #0F4B38", +"Z* c #000201", +"`* c #3D8A5F", +" = c #13553B", +".= c #385440", +"+= c #2E3F4B", +"@= c #1C282C", +"#= c #030505", +"$= c #0B120C", +"%= c #456A46", +"&= c #39583A", +"*= c #213322", +"== c #344B45", +"-= c #2A3A44", +";= c #101B1A", +">= c #4A8552", +",= c #3D9852", +"'= c #446B46", +")= c #42A252", +"!= c #41A150", +"~= c #409D4D", +"{= c #3F984A", +"]= c #3C9145", +"^= c #168568", +"/= c #1B9F7C", +"(= c #1B9C78", +"_= c #1C9974", +":= c #1D946E", +"<= c #1B8864", +"[= c #0B3627", +"}= c #2D4B32", +"|= c #358C61", +"1= c #0C3626", +"2= c #0C130E", +"3= c #0B0F12", +"4= c #050708", +"5= c #2F4830", +"6= c #152015", +"7= c #4C734C", +"8= c #496F4A", +"9= c #101911", +"0= c #2C452D", +"a= c #060906", +"b= c #0C1110", +"c= c #090D0F", +"d= c #010202", +"e= c #436945", +"f= c #489556", +"g= c #318042", +"h= c #213923", +"i= c #42A451", +"j= c #41A14F", +"k= c #409E4C", +"l= c #3F9849", +"m= c #3D9244", +"n= c #2F6F33", +"o= c #178668", +"p= c #1CA07B", +"q= c #1D9D77", +"r= c #1E9973", +"s= c #1E956E", +"t= c #1B7F5D", +"u= c #07241A", +"v= c #3F6C48", +"w= c #2E885E", +"x= c #082117", +"y= c #233926", +"z= c #131E15", +"A= c #101910", +"B= c #355135", +"C= c #3B5A3C", +"D= c #517B52", +"E= c #253825", +"F= c #1F2F1F", +"G= c #446C47", +"H= c #4B9256", +"I= c #3FA254", +"J= c #3B994E", +"K= c #0E2011", +"L= c #1A291B", +"M= c #4D9354", +"N= c #42A24E", +"O= c #429E4B", +"P= c #409948", +"Q= c #3E9243", +"R= c #2F6F32", +"S= c #188667", +"T= c #1DA07A", +"U= c #1E9E76", +"V= c #1E9A72", +"W= c #1E976F", +"X= c #1F956D", +"Y= c #176D4F", +"Z= c #4C875A", +"`= c #1F714E", +" - c #04140E", +".- c #396946", +"+- c #365749", +"@- c #3B5744", +"#- c #3F5F47", +"$- c #507A52", +"%- c #558256", +"&- c #4B724C", +"*- c #3E5C43", +"=- c #3C5A46", +"-- c #467A50", +";- c #479756", +">- c #3FA454", +",- c #40A453", +"'- c #3E934B", +")- c #407B46", +"!- c #457F4A", +"~- c #4A9852", +"{- c #44A24E", +"]- c #439F4A", +"^- c #419A47", +"/- c #3F9343", +"(- c #307032", +"_- c #188666", +":- c #1FA179", +"<- c #1F9E75", +"[- c #20966D", +"}- c #051811", +"|- c #172317", +"1- c #46885C", +"2- c #186445", +"3- c #030D09", +"4- c #448357", +"5- c #345652", +"6- c #31454C", +"7- c #334746", +"8- c #455C4A", +"9- c #4E6650", +"0- c #4E6750", +"a- c #4E6751", +"b- c #4F6752", +"c- c #4F6751", +"d- c #4E664E", +"e- c #4D664E", +"f- c #4E6651", +"g- c #4E684F", +"h- c #4B634C", +"i- c #394E48", +"j- c #31444A", +"k- c #35704B", +"l- c #3EA355", +"m- c #41A552", +"n- c #43A552", +"o- c #44A451", +"p- c #46A451", +"q- c #46A44F", +"r- c #44A34D", +"s- c #43A04A", +"t- c #429A47", +"u- c #409343", +"v- c #317032", +"w- c #1A8765", +"x- c #20A278", +"y- c #209F75", +"z- c #219B72", +"A- c #21996E", +"B- c #21976C", +"C- c #0B2418", +"D- c #416543", +"E- c #358E60", +"F- c #175C3E", +"G- c #122216", +"H- c #2A422C", +"I- c #3F8D5D", +"J- c #2F5753", +"K- c #324647", +"L- c #3A4D42", +"M- c #3E4F43", +"N- c #415648", +"O- c #435B4A", +"P- c #455B4A", +"Q- c #445A49", +"R- c #445A48", +"S- c #435847", +"T- c #465B4A", +"U- c #475B4B", +"V- c #404B42", +"W- c #475749", +"X- c #364847", +"Y- c #2D3E48", +"Z- c #336D49", +"`- c #40A552", +" ; c #43A652", +".; c #44A751", +"+; c #44A750", +"@; c #46A850", +"#; c #46A74E", +"$; c #45A44C", +"%; c #45A04A", +"&; c #439B46", +"*; c #419342", +"=; c #317031", +"-; c #1A8865", +";; c #21A278", +">; c #22A075", +",; c #219C71", +"'; c #21996D", +"); c #23976B", +"!; c #299265", +"~; c #3D8B5E", +"{; c #3B8C5E", +"]; c #279364", +"^; c #398F5F", +"/; c #33925F", +"(; c #2E5752", +"_; c #344748", +":; c #425248", +"<; c #38443B", +"[; c #4D6552", +"}; c #506854", +"|; c #4F6854", +"1; c #506853", +"2; c #516954", +"3; c #4F6953", +"4; c #4F6853", +"5; c #47594A", +"6; c #383E38", +"7; c #434F45", +"8; c #354746", +"9; c #43A651", +"0; c #46A84F", +"a; c #47A74E", +"b; c #47A44C", +"c; c #46A149", +"d; c #449B46", +"e; c #419441", +"f; c #327131", +"g; c #22A377", +"h; c #22A074", +"i; c #229D70", +"j; c #24986A", +"k; c #239566", +"l; c #249365", +"m; c #259465", +"n; c #299761", +"o; c #2F5752", +"p; c #4A5F52", +"q; c #495B4F", +"r; c #4A5F50", +"s; c #4E6653", +"t; c #506954", +"u; c #516854", +"v; c #506855", +"w; c #4F6855", +"x; c #506955", +"y; c #485D4D", +"z; c #46584B", +"A; c #495B4E", +"B; c #374A49", +"C; c #336D48", +"D; c #47A94E", +"E; c #48A84D", +"F; c #48A54B", +"G; c #47A149", +"H; c #459C45", +"I; c #429441", +"J; c #337131", +"K; c #1D8964", +"L; c #23A476", +"M; c #24A173", +"N; c #249D6F", +"O; c #259B6C", +"P; c #25996A", +"Q; c #259566", +"R; c #279662", +"S; c #2A9861", +"T; c #2E5751", +"U; c #2B3831", +"V; c #424D44", +"W; c #43584A", +"X; c #4A6150", +"Y; c #4F6753", +"Z; c #4C6351", +"`; c #475D4C", +" > c #28302A", +".> c #404E41", +"+> c #364747", +"@> c #346E48", +"#> c #49AA4E", +"$> c #4AA94D", +"%> c #49A54A", +"&> c #48A248", +"*> c #469C44", +"=> c #449540", +"-> c #347130", +";> c #1E8A64", +">> c #24A575", +",> c #25A272", +"'> c #259F6E", +")> c #259B6B", +"!> c #269969", +"~> c #269665", +"{> c #269563", +"]> c #2C995F", +"^> c #305751", +"/> c #2E414C", +"(> c #334747", +"_> c #313F36", +":> c #414E43", +"<> c #425849", +"[> c #445849", +"}> c #46594A", +"|> c #49604D", +"1> c #495F4C", +"2> c #485F4D", +"3> c #48604C", +"4> c #4A614D", +"5> c #485D4B", +"6> c #455749", +"7> c #465C4A", +"8> c #353E35", +"9> c #3B4A3D", +"0> c #354846", +"a> c #356E48", +"b> c #4AAA4D", +"c> c #4AA94C", +"d> c #4AA64A", +"e> c #49A347", +"f> c #479D43", +"g> c #449640", +"h> c #347230", +"i> c #1F8B63", +"j> c #26A575", +"k> c #26A271", +"l> c #269B6B", +"m> c #279A69", +"n> c #279664", +"o> c #305851", +"p> c #2D3D41", +"q> c #2D3D36", +"r> c #2C3B34", +"s> c #2F4137", +"t> c #2D3C35", +"u> c #2D3B33", +"v> c #2D3E35", +"w> c #2E3F35", +"x> c #304036", +"y> c #314138", +"z> c #304037", +"A> c #31433B", +"B> c #303F39", +"C> c #2F3F38", +"D> c #2F4044", +"E> c #356E47", +"F> c #4AAB4D", +"G> c #4BAA4B", +"H> c #4BA649", +"I> c #4AA346", +"J> c #489E43", +"K> c #459640", +"L> c #35722F", +"M> c #208B62", +"N> c #27A674", +"O> c #27A371", +"P> c #28A06E", +"Q> c #289C6A", +"R> c #289A68", +"S> c #289763", +"T> c #315952", +"U> c #2F404B", +"V> c #31424D", +"W> c #33444E", +"X> c #32444E", +"Y> c #30424D", +"Z> c #33444D", +"`> c #32434E", +" , c #35454E", +"., c #34444F", +"+, c #354550", +"@, c #2C3E47", +"#, c #356F46", +"$, c #4BAB4C", +"%, c #4CAB4C", +"&, c #4DAA4A", +"*, c #4CA748", +"=, c #4AA446", +"-, c #499E43", +";, c #46973F", +">, c #35732F", +",, c #218C61", +"', c #28A774", +"), c #28A371", +"!, c #299B67", +"~, c #299863", +"{, c #2F9B5D", +"], c #305F4D", +"^, c #314A4B", +"/, c #35444B", +"(, c #464F51", +"_, c #3C474B", +":, c #3A484F", +"<, c #3A4448", +"[, c #35434A", +"}, c #2E3D45", +"|, c #2F3D45", +"1, c #2F3E47", +"2, c #38464D", +"3, c #485053", +"4, c #404B4E", +"5, c #3D474A", +"6, c #414A4B", +"7, c #37464B", +"8, c #366F46", +"9, c #4DAC4B", +"0, c #4EAB4A", +"a, c #4DA748", +"b, c #4BA445", +"c, c #4A9F42", +"d, c #47983E", +"e, c #36732E", +"f, c #218D61", +"g, c #29A773", +"h, c #29A470", +"i, c #299D68", +"j, c #2A9C66", +"k, c #2A9862", +"l, c #2F744B", +"m, c #306548", +"n, c #323F45", +"o, c #737877", +"p, c #545B5B", +"q, c #303C40", +"r, c #394448", +"s, c #636A6B", +"t, c #2D3B41", +"u, c #313F44", +"v, c #394348", +"w, c #354248", +"x, c #2F3B3F", +"y, c #808483", +"z, c #666C6C", +"A, c #334148", +"B, c #424B4D", +"C, c #707575", +"D, c #394447", +"E, c #2D3F4B", +"F, c #387149", +"G, c #4EAC4A", +"H, c #4EAC49", +"I, c #4EA847", +"J, c #4DA445", +"K, c #4A9F41", +"L, c #48983D", +"M, c #37742E", +"N, c #238D60", +"O, c #2BA872", +"P, c #2BA56E", +"Q, c #2BA26B", +"R, c #2B9E67", +"S, c #2B9C66", +"T, c #2B9962", +"U, c #2D6546", +"V, c #2F5746", +"W, c #2F3C41", +"X, c #6B7171", +"Y, c #333D3E", +"Z, c #27383E", +"`, c #2F3B3E", +" ' c #464E50", +".' c #2C393E", +"+' c #2D3C42", +"@' c #2F3C42", +"#' c #303E45", +"$' c #27363C", +"%' c #485152", +"&' c #3A4345", +"*' c #2C3C45", +"=' c #343E41", +"-' c #4B5355", +";' c #2B3A3E", +">' c #2E3F4A", +",' c #397349", +"'' c #4DAC4A", +")' c #4EAD4A", +"!' c #4FAD4A", +"~' c #50AC49", +"{' c #4FA946", +"]' c #4DA544", +"^' c #4B9F40", +"/' c #49993C", +"(' c #38742E", +"_' c #248D60", +":' c #2CA971", +"<' c #2CA56D", +"[' c #2C9D65", +"}' c #2C9A61", +"|' c #329C5B", +"1' c #345447", +"2' c #324046", +"3' c #283437", +"4' c #2C3A3E", +"5' c #35454C", +"6' c #2D3D44", +"7' c #243339", +"8' c #314149", +"9' c #38454D", +"0' c #33424A", +"a' c #2F404A", +"b' c #25343D", +"c' c #293943", +"d' c #2E404B", +"e' c #2C3B46", +"f' c #2A3840", +"g' c #34444A", +"h' c #376E43", +"i' c #50AE49", +"j' c #51AD48", +"k' c #50A946", +"l' c #4EA643", +"m' c #4DA03F", +"n' c #4A993C", +"o' c #38742D", +"p' c #258E5F", +"q' c #2CA970", +"r' c #2DA66D", +"s' c #2CA067", +"t' c #2D9E65", +"u' c #2D9A60", +"v' c #304E46", +"w' c #2A3A43", +"x' c #2E404A", +"y' c #30414A", +"z' c #38454A", +"A' c #3B484C", +"B' c #3A484D", +"C' c #3B4950", +"D' c #3C4A51", +"E' c #3A4851", +"F' c #394852", +"G' c #3A4A53", +"H' c #3B4A52", +"I' c #37454C", +"J' c #36444A", +"K' c #324245", +"L' c #2D3B42", +"M' c #336940", +"N' c #51AE49", +"O' c #51AE47", +"P' c #50AA45", +"Q' c #50A642", +"R' c #4EA13F", +"S' c #39752D", +"T' c #268E5E", +"U' c #2EAA6F", +"V' c #2FA76C", +"W' c #2EA469", +"X' c #2F9E64", +"Y' c #2E9B5F", +"Z' c #32624C", +"`' c #305445", +" ) c #335546", +".) c #335646", +"+) c #345747", +"@) c #365848", +"#) c #385B4A", +"$) c #3A5D4C", +"%) c #3C5D4B", +"&) c #395A47", +"*) c #375844", +"=) c #385A45", +"-) c #3A5A45", +";) c #3C5C47", +">) c #3F6049", +",) c #3D5F49", +"') c #3B5C46", +")) c #395B43", +"!) c #365745", +"~) c #3C7D46", +"{) c #51AF48", +"]) c #52AF48", +"^) c #53AE46", +"/) c #52AB44", +"() c #51A742", +"_) c #4C9A3B", +":) c #3A752C", +"<) c #278F5D", +"[) c #2FAB6F", +"}) c #2FA86C", +"|) c #2FA468", +"1) c #2FA165", +"2) c #309F63", +"3) c #2F9C5F", +"4) c #309B5D", +"5) c #359E59", +"6) c #38A058", +"7) c #39A057", +"8) c #3AA157", +"9) c #3BA256", +"0) c #3CA255", +"a) c #3DA355", +"b) c #3EA354", +"c) c #3FA453", +"d) c #53B047", +"e) c #54AF46", +"f) c #51A841", +"g) c #50A23F", +"h) c #4D9A3B", +"i) c #3B762C", +"j) c #288F5D", +"k) c #30AB6E", +"l) c #30A96B", +"m) c #30A567", +"n) c #30A264", +"o) c #30A062", +"p) c #309C5E", +"q) c #3BA156", +"r) c #42A651", +"s) c #54B046", +"t) c #55B045", +"u) c #53AC43", +"v) c #52A841", +"w) c #51A23E", +"x) c #4D9B3A", +"y) c #3B762B", +"z) c #29905C", +"A) c #32AC6D", +"B) c #32A96A", +"C) c #31A666", +"D) c #32A061", +"E) c #389F57", +"F) c #3A9F56", +"G) c #3BA055", +"H) c #3BA155", +"I) c #3DA155", +"J) c #3EA254", +"K) c #3FA253", +"L) c #40A352", +"M) c #41A351", +"N) c #43A551", +"O) c #44A550", +"P) c #45A64F", +"Q) c #47A74D", +"R) c #49A94D", +"S) c #4BA94B", +"T) c #4EAB49", +"U) c #51AD47", +"V) c #54AF45", +"W) c #55AF45", +"X) c #55AF44", +"Y) c #54AC42", +"Z) c #54A840", +"`) c #52A33D", +" ! c #4E9C39", +".! c #3C772B", +"+! c #2A915C", +"@! c #33AD6C", +"#! c #33AA69", +"$! c #32A665", +"%! c #32A362", +"&! c #329E5E", +"*! c #30975A", +"=! c #319658", +"-! c #329657", +";! c #339756", +">! c #349856", +",! c #359856", +"'! c #369955", +")! c #379A54", +"!! c #389A53", +"~! c #399B53", +"{! c #3A9C52", +"]! c #3B9C52", +"^! c #3C9D51", +"/! c #3D9D50", +"(! c #3E9E50", +"_! c #3F9F4F", +":! c #409F4E", +"~ c #2F8A4E", +",~ c #308B4E", +"'~ c #318B4D", +")~ c #328C4C", +"!~ c #338C4B", +"~~ c #348D4B", +"{~ c #348E4A", +"]~ c #358E4A", +"^~ c #368F4A", +"/~ c #388F49", +"(~ c #389048", +"_~ c #399048", +":~ c #3A9147", +"<~ c #3B9247", +"[~ c #3B9246", +"}~ c #3D9345", +"|~ c #3E9344", +"1~ c #3F9444", +"2~ c #419543", +"3~ c #429543", +"4~ c #429542", +"5~ c #439641", +"6~ c #449741", +"7~ c #459740", +"8~ c #469840", +"9~ c #47993F", +"0~ c #48993F", +"a~ c #499A3E", +"b~ c #499A3D", +"c~ c #4A9A3D", +"d~ c #4B9B3C", +"e~ c #4C9B3C", +"f~ c #4E9C3B", +"g~ c #4F9D3A", +"h~ c #509E3A", +"i~ c #52A13A", +"j~ c #509D37", +"k~ c #3E7829", +"l~ c #2C935A", +"m~ c #36AD69", +"n~ c #32A060", +"o~ c #2C8A52", +"p~ c #29814B", +"q~ c #2A804A", +"r~ c #2B8149", +"s~ c #2C8149", +"t~ c #2E8248", +"u~ c #2E8247", +"v~ c #2F8347", +"w~ c #318446", +"x~ c #318445", +"y~ c #338545", +"z~ c #348544", +"A~ c #348644", +"B~ c #358643", +"C~ c #368742", +"D~ c #378742", +"E~ c #388841", +"F~ c #398940", +"G~ c #3A8A3F", +"H~ c #3B8A40", +"I~ c #3C8B3F", +"J~ c #3D8B3E", +"K~ c #3E8C3D", +"L~ c #3F8C3D", +"M~ c #408D3C", +"N~ c #418D3C", +"O~ c #428E3B", +"P~ c #438F3A", +"Q~ c #459039", +"R~ c #469038", +"S~ c #479138", +"T~ c #489137", +"U~ c #499236", +"V~ c #4A9335", +"W~ c #4B9335", +"X~ c #4B9435", +"Y~ c #4D9635", +"Z~ c #4F9835", +"`~ c #3E7728", +" { c #277F4D", +".{ c #2B8852", +"+{ c #22693F", +"@{ c #1C5833", +"#{ c #1C5732", +"${ c #1D5732", +"%{ c #1E5831", +"&{ c #1F5831", +"*{ c #1F5930", +"={ c #205930", +"-{ c #21592F", +";{ c #215A2F", +">{ c #225A2F", +",{ c #235A2E", +"'{ c #235B2E", +"){ c #235B2D", +"!{ c #255C2D", +"~{ c #265C2D", +"{{ c #265D2C", +"]{ c #275D2C", +"^{ c #275D2B", +"/{ c #285E2B", +"({ c #295F2B", +"_{ c #295F2A", +":{ c #2A5F29", +"<{ c #2B5F29", +"[{ c #2C6028", +"}{ c #2D6028", +"|{ c #2D6127", +"1{ c #2E6127", +"2{ c #2F6126", +"3{ c #2F6226", +"4{ c #306226", +"5{ c #316325", +"6{ c #316324", +"7{ c #336424", +"8{ c #336524", +"9{ c #346524", +"0{ c #346523", +"a{ c #366823", +"b{ c #336221", +". + @ # $ % & * = - ; > , ' ) ! ~ { ] ^ / ( _ : < [ } | 1 2 3 4 5 6 7 8 9 0 a b c d d e f g h i ", +"j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z ` ...+.@.", +"#.$.%.&.*.=.-.;.>.,.'.).!.~.{.].].^./.(._.:.<.<.[.}.|.1.2.3.4.5.6.7.8.9.0.a.b.c.d.e.f.g.h.i.j.k.", +"l.m.n.o.p.p.q.r.s.t.u.v.w.x.y.z.A.B.C.D.E.F.G.H.I.J.K.L.M.N.O.P.P.Q.R.S.T.U.V.W.X.Y.Z.`. +.+++@+", +"#+$+%+&+*+=+-+;+>+,+'+)+!+~+{+]+^+/+(+_+:+<+[+}+|+1+2+3+4+5+6+6+7+8+9+0+a+b+c+d+e+f+g+h+i+j+k+l+", +"m+n+o+p+q+r+s+t+u+v+w+x+y+z+A+B+C+D+E+F+G+H+I+J+K+L+M+N+O+P+Q+R+S+T+U+V+W+X+Y+Z+`+ @.@+@@@#@$@%@", +"&@*@=@-@;@>@,@'@)@!@~@{@]@^@/@(@_@:@<@[@}@|@1@2@3@4@5@6@7@7@8@9@0@a@b@c@d@e@f@g@h@i@j@k@l@m@n@%@", +"o@p@q@r@s+s@t@u@v@w@x@y@z@A@B@C@D@E@F@G@H@I@J@K@L@M@N@O@P@Q@R@S@T@U@V@W@X@Y@Z@`@ #.#+#@###$#%#&#", +"*#=#-#;+;#>#,#v@w@x@y@'#A@B@)#!#~#{#]#^#/#(#_#:#<#[#[#}#}#|#1#2#3#4#5#6#Y@Z@`@ #.#7#8#9#0#a#b#c#", +"d#e#f#g#h#i#j#w@x@k#z@l#m#C@n#o#p#q#r#s#t#u#v#w#p#x#p#p#p#y#y#y#o#z#A#Y@`@`@ #7#B#C#D#E#F#G#H#I#", +"J#K#L#,+M#N#O#P#y@z@l#B@C@D@Q#o#R#S#T#U#V#W#X#Y#Y#Z#`#`# $.$+$Z#@$#$$$Z@`@ #.#B#C#%$&$*$=$-$;$>$", +",$'$)$!$w+~${$y@'#l#B@C@D@E@n#]$^$/$($_$:$:$:$<$[$}$|$<$:$|$|$1$2$3$4$`@ #.#7#C#%$5$6$7$8$9$0$a$", +"b$c$d$e$x+f$g$z@l#m#C@h$i$F@j$k$l$m$n$n$n$n$n$n$n$o$n$p$q$q$p$r$s$t$u$ #7#B#C#5$v$w$x$y$z$A$B$C$", +"D$E$F$!+G$H$I$A@B@J$K$L$F@G@j$y#M$N$n$n$n$n$O$P$Q$R$n$S$P$T$p$r$U$V$u$.#B#C#%$v$w$W$X$y$Y$Z$`$ %", +".%+%@%~+#%$%%%B@C@&%*%=%-%H@;%y#>%N$n$n$n$n$,%'%)%!%T$~%{%]%^%/%(%_%:%7#C#%$5$w$<%[%}%|%1%2%3% %", +"4%5%6%7%8%9%0%C@h$a%b%c%d%I@;%w#e%N$n$n$n$n$f%g%h%o$i%j%)%k%q$r$l%t$:%C#5$v$w$m%n%j%o%p%q%r%s%t%", +"u%v%w%x%y%z%A%D@B%C%D%E%F%G%H%I%J%K%L%n$n$M%N%O%P%o$Q%j%R%M%p$S%T%U%V%W%X%w$W$Y%Z%j%`% &.&+&@&#&", +"$&%&&&^+*&=&-&E@;&>&,&'&)&!&~&{&]&j%^&/&n$(&_&:&<&o$[&}&|&o$<&1&2&j%j%3&4&5&6&7&8&j%9&0&a&b&@&#&", +"c&d&e&/+D+f&g&F@h&i&j&k&l&j%m&n&o&p&j%q&r&s&}&m&n$t&u&v&w&!%x&i&y&o&z&A&}&B&C&D&}&m&E&F&G&H&I&J&", +"K&L&M&N&O&P&Q&R&S&T&U&V&W&j%X&Y&Z&`&j% *.*+*j%[&n$f%@*#*(&L%j%$*%*&***=*j%-*;*>*j%[&,*'*)*!*~*J&", +"{*]*^*(+/*P&(*_*:*<*[*}*|*~%s&1*2*3*j% *.*4*j%5*n$+*m&y&M%6*j%7*8*9*0*a*b*c*d*e*j%5*f*g*h*i*j*k*", +"l*m*n*o*p*q*r*s*t*u*v*w*j%$*x*]$y*z*b*6*n$u&i&A*!%X&j%B*o$C*j%D*E*V$F*G*H*I*J*K*i&P$L*M*N*O*P*Q*", +"R*S*T*U*V*W*X*Y*Z*x&`* =j%H*.=+=@=#=$=N%r&j%H*%=k%)%j%&=o$[&j%*===-=;=8&)%>=,=j%H*'=)=!=~={=]=Q*", +"^=/=(=_=I+:=<=[=j%}=|=1=j%i&2=3=4=j%5=M%L%j%6=7=8=9=j%t&o$0=j%a=b=c=d=m&e=f=g=j%:&h=i=j=k=l=m=n=", +"o=p=q=r=K+s=t=u=j%v=w=x=:&y=z=$*A=B=n$n$C=6=g%D=]%[&6=n$q$n$E=A=$*#*F=G=H=I=J=K=$*L=M=N=O=P=Q=R=", +"S=T=U=V=W=X=Y=!&}&Z=`= -$=.-+-@-#-$-n$n$n$n$n$n$n$o$n$o$q$q$%-&-*-=---;-I=>-,-'-)-!-~-{-]-^-/-(-", +"_-:-<-1+L+[-}-j%|-1-2-3-u*4-5-6-7-8-9-0-a-b-c-9-9-d-e-9-f-9-g-h-i-j-k-l->-,-m-n-o-p-q-r-s-t-u-v-", +"w-x-y-z-A-B-C-[&D-E-F-G-H-I-J-x#K-L-M-N-O-8-P-Q-R-S-R-R-T-U-V-W-X-Y-Z->-`-m- ;.;+;@;#;$;%;&;*;=;", +"-;;;>;,;';);!;~;{;];S@^;I-/;(;y#_;:;<;M-[;};};|;1;2;3;4;};5;6;7;8;V$Z-,-m- ;9;+;@;0;a;b;c;d;e;f;", +"<=g;h;i;O+j;k;l;m;S@T@U@n;W@o;]$_;p;q;r;s;t;u;v;w;x;x;};};y;z;A;B;t$C;m- ;9;.;@;0;D;E;F;G;H;I;J;", +"K;L;M;N;O;P;Q;R@S@R;U@V@S;X@T;]$_;U;V;W;X;Y;};|;|;t;t;b-Z;`; >.>+>Y-@> ;.;+;@;D;D;#>$>%>&>*>=>->", +";>>>,>'>)>!>~>{>T@U@V@W@X@]>^>/>(>_>:><>[>}>|>1>2>3>4>5>6>7>8>9>0>Y-a>9;+;@;0;D;#>b>c>d>e>f>g>h>", +"i>j>k>6+l>m>n>T@U@V@W@6#]>Z@o>k$p>q>r>s>t>u>v>v>v>w>x>y>z>A>B>C>D>Y-E>.;@;0;D;#>b>F>G>H>I>J>K>L>", +"M>N>O>P>Q>R>S>U@V@S;X@Y@`@`@T>U>V>W>X>Y>W>Z>`>y#]$y#Y> ,W>Y>.,+,V>@,#,@;D;D;#>F>$,%,&,*,=,-,;,>,", +",,',),8+T+!,~,n;W@X@Y@Z@`@{,],^,/,(,_,:,_,<,[,},|,1,2,3,4, ,5,6,7,Y-8,0;D;#>b>$,%,9,0,a,b,c,d,e,", +"f,g,h,9+i,j,k,W@6#Y@Z@`@{,.#l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,D;#>b>F>%,9,G,H,I,J,K,L,M,", +"N,O,P,Q,R,S,T,X@Y@`@`@ #.#B#U,V,W,X,Y,Z,`, '.'+'@'#'$'%'&'*'='-';'>','#>F>$,%,'')'!'~'{']'^'/'('", +"_':'<'a+W+['}'Z@Z@`@ #.#B#|'1'2'2'3'4'5'6'7'Y-8'9'0'a'b'c'd'e'f'g'A,h'b>$,%,9,)'!'i'j'k'l'm'n'o'", +"p'q'r'b+s't'u'Z@`@ #.#7#|'%$v'w'x'a'y'A,z'A'B'C'D'E'F'G'H'2,I'J'K'L'M'F>%,9,G,!'i'N'O'P'Q'R'n'S'", +"T'U'V'W'Y+X'Y'`@ #7#B#C#5$v$Z'`' ).)+)@)#)$)%)&)*)=)-)-);)>),)')))!)~)%,'')'!'i'{)])^)/)()R'_):)", +"<)[)})|)1)2)3)4).#B#C#%$v$5)W$6)7)8)9)0)a)b)c),-m- ;9;+;@;0;D;#>b>$,%,9,)'!'i'{)])d)e)/)f)g)h)i)", +"j)k)l)m)n)o)p).#7#C#%$5$5)W$6&7)8)q)0)a)l-c),-m-r)9;.;@;0;D;#>b>F>%,9,G,!'i'N'])d)s)t)u)v)w)x)y)", +"z)A)B)C) @D)7#@.8#D#&$6$x$X$E)F)G)H)I)J)K)L)M)i=N)O)P)#;Q)E;R)c>S)&,T)T)~'j'U)^)V)W)X)Y)Z)`) !.!", +"+!@!#!$!%!&!*!=!-!;!>!,!'!)!!!~!{!]!^!/!(!_!:!~,~'~)~!~~~{~]~^~/~(~_~:~<~[~}~|~|~1~2~3~4~5~6~7~8~9~0~a~b~c~d~e~f~g~g~h~i~j~k~", +"l~m~n~o~p~q~r~s~s~t~u~v~w~x~x~y~z~A~B~C~D~E~E~F~G~H~I~J~K~L~M~M~N~O~P~P~Q~R~R~S~T~U~V~W~X~Y~Z~`~", +" {.{+{@{#{${%{%{&{*{={-{;{>{>{,{'{){!{!{~{{{]{^{/{({({_{:{<{[{[{}{|{1{2{3{3{4{5{5{6{7{8{9{0{a{b{"}; diff --git a/icons/jpilot-icon2.xpm b/icons/jpilot-icon2.xpm new file mode 100644 index 00000000..7f9e3b7a --- /dev/null +++ b/icons/jpilot-icon2.xpm @@ -0,0 +1,290 @@ +/* XPM */ +static char *jpilot2[] = { +/* width height num_colors chars_per_pixel */ +" 48 48 234 2", +/* colors */ +".. c #240604", +".# c #547664", +".a c #343e3c", +".b c #7c4234", +".c c #7cae9c", +".d c #4c5a54", +".e c #845e4c", +".f c #5c3e34", +".g c #6c9284", +".h c #a45e4c", +".i c #645e64", +".j c #4c1e14", +".k c #74766c", +".l c #a49ea4", +".m c #b4765c", +".n c #44524c", +".o c #945e4c", +".p c #5c5254", +".q c #2c2624", +".r c #648674", +".s c #646a6c", +".t c #b4b2b4", +".u c #a46a5c", +".v c #4c3e3c", +".w c #94523c", +".x c #546a5e", +".y c #c4866c", +".z c #74a28c", +".A c #343237", +".B c #94867c", +".C c #6c423c", +".D c #748a84", +".E c #8c523d", +".F c #946a59", +".G c #7c6a74", +".H c #4c3634", +".I c #b46a54", +".J c #b47e6c", +".K c #746a69", +".L c #3c4644", +".M c #7c4a3c", +".N c #a47661", +".O c #8c9294", +".P c #544e54", +".Q c #647e74", +".R c #a4b2ac", +".S c #546684", +".T c #6c8e80", +".U c #642e24", +".V c #4c625c", +".W c #749a8c", +".X c #845a49", +".Y c #d4d2d4", +".Z c #443234", +".0 c #6c463c", +".1 c #746668", +".2 c #847a7c", +".3 c #6c867c", +".4 c #a47264", +".5 c #8c4a3c", +".6 c #ac7664", +".7 c #547e64", +".8 c #94aea4", +".9 c #5c5a63", +"#. c #8c6654", +"## c #445664", +"#a c #84523f", +"#b c #946654", +"#c c #646e7c", +"#d c #4c4a51", +"#e c #94726c", +"#f c #74564c", +"#g c #3c160c", +"#h c #84b6a0", +"#i c #8c5e4c", +"#j c #a46652", +"#k c #64666c", +"#l c #bc765c", +"#m c #b4c2dc", +"#n c #547264", +"#o c #3c3a3e", +"#p c #848684", +"#q c #8c6a5c", +"#r c #c47e64", +"#s c #844a36", +"#t c #6c4e4c", +"#u c #643a34", +"#v c #74463c", +"#w c #749288", +"#x c #4c525f", +"#y c #9c5e46", +"#z c #ac6a54", +"#A c #8c5a44", +"#B c #9c6e5f", +"#C c #b4725c", +"#D c #747274", +"#E c #a4766c", +"#F c #6c8684", +"#G c #1c1a1c", +"#H c #5c766c", +"#I c #3c3e43", +"#J c #545a5a", +"#K c #7c767c", +"#L c #b47a6c", +"#M c #7c564c", +"#N c #5c565c", +"#O c #6c6a6c", +"#P c #b4babc", +"#Q c #543e3c", +"#R c #945a44", +"#S c #546e61", +"#T c #cc8e74", +"#U c #84a294", +"#V c #34363b", +"#W c #8c5642", +"#X c #5c3a34", +"#Y c #bc7e64", +"#Z c #746a74", +"#0 c #44464b", +"#1 c #54565c", +"#2 c #5c261c", +"#3 c #dcdee0", +"#4 c #3c2e2c", +"#5 c #acaaac", +"#6 c #acbab4", +"#7 c #c4c2c4", +"#8 c #848284", +"#9 c #a48274", +"a. c #7caa9c", +"a# c #743a2c", +"aa c #848e8c", +"ab c #2c2e30", +"ac c #748e84", +"ad c #849a94", +"ae c #644e44", +"af c #743e2c", +"ag c #443a3c", +"ah c #947674", +"ai c #7c727a", +"aj c #4c5654", +"ak c #2c0a0c", +"al c #4c4e54", +"am c #bcb6bc", +"an c #cc8674", +"ao c #543a34", +"ap c #6c7e7c", +"aq c #7c9e94", +"ar c #5c7e6c", +"as c #6c6a74", +"at c #441a14", +"au c #8c8a8c", +"av c #745254", +"aw c #844634", +"ax c #84b29c", +"ay c #643e34", +"az c #74767c", +"aA c #7c8684", +"aB c #946e64", +"aC c #acaeac", +"aD c #6c2e24", +"aE c #54665c", +"aF c #44424c", +"aG c #644a3c", +"aH c #7ca294", +"aI c #846a6c", +"aJ c #744e3f", +"aK c #ac725e", +"aL c #9c7264", +"aM c #ac664e", +"aN c #6c6670", +"aO c #5c726c", +"aP c #6c3a2c", +"aQ c #9c6654", +"aR c #bc725c", +"aS c #bcbabc", +"aT c #9c5a44", +"aU c #846254", +"aV c #646267", +"aW c #b47a64", +"aX c #648a74", +"aY c #646e64", +"aZ c #945644", +"a0 c #4c3a3c", +"a1 c #b46e57", +"a2 c #7c4e3e", +"a3 c #a47a64", +"a4 c #545258", +"a5 c #6c4a40", +"a6 c #6c8a78", +"a7 c #444244", +"a8 c #5c5e64", +"a9 c #845644", +"b. c #84baa4", +"b# c #8c6250", +"ba c #bc7a64", +"bb c #c4826c", +"bc c #844e3c", +"bd c #744a3d", +"be c #749689", +"bf c #9c624c", +"bg c #ac6e59", +"bh c #3c4244", +"bi c #544244", +"bj c #bc826c", +"bk c #444a4c", +"bl c #64524c", +"bm c #744234", +"bn c #547a64", +"bo c #7c4634", +"bp c #7cb29c", +"bq c #4c5e54", +"br c #a4624c", +"bs c #94624c", +"bt c #a46e5c", +"bu c #4c423c", +"bv c #b4826c", +"bw c #648274", +"bx c #749e8c", +"by c #443634", +"bz c #847e7c", +"bA c #8c4e3c", +"bB c #a47a6c", +"bC c #6c8a84", +"bD c #5c7a6c", +"bE c #746e74", +"bF c #5c2a1c", +"bG c #4c5254", +"bH c #cc8a74", +"bI c #5c826c", +"bJ c #747a7c", +"bK c #6c3224", +"bL c #845e54", +"bM c #b47664", +"bN c #7c5244", +/* pixels */ +"#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m", +"#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m", +"#m#m#m#m#m#m#m#m#m#m#m#m#mal#o#I.A#o#oby#o#o#o.Aby#V#o#o#o#o#I#I#o#V#o#V#V#oal#m#m#m#m#m#m#m#m#m", +"#m#m#m#P#m#m#P#m#m#P#m#maj.s.P.P#P#5#6.R#d.P.P.P.P.Pal.P.P.Pa4.PaV#7aC.Ybz#d#V#m#m#m#P#m#m#P#m#m", +"#m#m#m#m#m#m#m#m#m#m.1bAbmasa4a4aAau.Oaaa4.P#xa4a4.Pa4a4#xa4a4#x.9aa.O.OaV#x#d#m#m#m#m#m#m#m#m#m", +"#m#m#m#m#m#m#m#m#mbB#C.h.b#Za4.P#dbk#d#0aF#0#0#0bh#0#0#0#0#0#d#0aF#I#IaFa4a4#d#m#m#m#m#m#m#m#m#m", +"#m#m.R#m#m#m#m#m#m.6a1.h.b#Z#1al.Vbn#H.#.#bD.##H.#.##H.#.#.#.#.#.#.#.#.#ap#1#d#m#m#m#m#m#m#m.R#m", +"#m#m#m#m#m#m#m#m#m#EaM.h.b#Z#1al.#ar.7arbnarbnbnbDbn.7bnbnbDbnbDbnbDbnaO#F.9aF#m#m#m#m#m#m#m#m#m", +"#m#m#m#m#m.R#m#m#m#m#iaT.M#Z.9.P#SarbnbnbD.7bD.7bn.7bDbnbn.7bn.7bnbnbnbD#F#N#d#m.q#t.C#g#m#m#m#m", +"#m#m#m#m#m#m#m#m#m#m.i.wa2bEa8a4.xarbnarbnbDbnbnbDbnbnbnbDbnbDbnbD.7bD.7.Da8a4agaPbfaZbm#m#m#m#m", +"#m#m#m.R#m#m#m#m.H.h.h.U#Xas.i#1.x.7bDbnbn.7bnarbnbnbn.7bn.7bn.7bnbnbnar.Da8a0#g.w#zaTbf#m#m#m#m", +"#m#m#m#m#m#m#m#x.uaMbr.5aGbEa8a4.xbDbn.7bnbDbnbn.7bnbD.abnbDbnbD.#.abnarbCaVagataT#z.h.u#m#m#m#m", +"#m#m#m#m#m#m#m#B.IaKaMaTbcbE#k#1#S.7bDbn.#bnbnbDbn.abn.abDbnbnbn.a.a.abD.DaV.vbF#jaMaT#C#m#m#m#m", +"#m#m#m.R#m#m#mbM#C#E#l#C.Easas#1#narbn.a.#.a.a.Vbn.Vbn#V.#.V.a.V.##obn.7aca8a0aD#jaMbA.u#m#m#m#m", +"#m#m#m#m#m#m#m.2aMbabb#C.5#O#k#N#nbnbnbD.#.abD#Vbn.abn.abn#Vbn#Vbn.abnar.DaV.vbKaMaMaTaM#m#m.R#m", +"#m#m#m#m#m#m#m#maLba#rbr.b#Z#O#1#nbDbn.a.#.a.#.abn.abD#Vbn.abn.a.#.abnbDbC#k.vbKaMaMaZaT#m#m#m#m", +"#m#m#m#m#m#m.RaI.oaTaT.baobE.s#J.#.#.##Vbn#V.abqbD.abn.abq.V#V.Var.V.aar.Da8a0.U.haMaTav#m#m#m#m", +"#m#m.R#m#m#m.1#zaM.w.b.j.Z#K#k#N.#bn.#.abn.abn.7bnbnbnarbnar.7bDbnbnbD.7.D.i.v.U#y.h.o#v#m#m#m#m", +"#m#m#m#m#m#Z#LaRaMaMbAbFay.2.s#1#n.abn.abD.abDbnarbDbnbnbD.7bD.7bnbDbnar.Da8.v.U.Ebs.oa2#m#m#m#m", +"#m#m#m#m#m#9bb#r#LbM#CaT#abE.s#N#n.V#Ibq.7#V.7bDbn.7bnarbnbD.7bDar.7bnarbCaVag#2#s#R.EaG#m#m#m#m", +"#m#m#m#m#mahba#Y#rbHba#Ca9bEaN#1.#bDbnarbnarbnbnarbnbD.7bD.7ar.7arbD.7ar.Da8.v#2aw#b.Ebd#m#m#m#m", +"#m#m#m#m#malaBba#Cba.y.IbN#K.s#N.#.7bDbnbnbD.7bDbnarbnbDbnararbnarbnbnar.Da8a0#2aw#b.E.C#m#m#m#m", +"#m#m#m#m#m#m###ya1#C#laZbd.2#ka4#Sar.7bD.7bnbDbn.7bnbD.7ar.7arbnarbnbD.7#F.9.vaPbcbs#i#t#m#m#m#m", +"#m.R#m#m#m#m#Dba#zaZ.bak.Z.2#k.9.xarbD.7bDar.7bDbnarbnbnbnbDarbnarbnbnar.Da8.va#aw#b#i.0#m.R#m#m", +"#m#m#m#m#m#m.6#la1br.b..#o#Kas.9#nbnarbnarbn.7bD.7bDbnarar.7ararbnbnar.7#F.i.va#bcbs#i#t#m#m#m#m", +"#m#m#m#m#m#e.y#Ya1aK#A#2bi.2.s.9.r.r.#.raXbIbIbIbIbIbIarbIarbIbIbIbwaraX.D.9.va##aaL.obd#m#m#m#m", +"#m#m#m#m.RahaR.y#L.J#zawa5#K#k#1aHaabq#HaHb.b.b.b.b.b.bp#ha.b.b.#w.n.V.g#F.i.va#bcaLbsa2#m#m#m#m", +"#m#m#m#m#m.paQ#rbabb.ybg#MbE#k#N.ga6aj.d.zb.b.b.b.b.b.b.b.b.b.b..g.a.n.QbJ.9.va#a9.u#bbc#m#m#m#m", +"#m#m#m#m#m#m#q.h#l#lbbbraJ#K#O#1ac.zbw.TaHb.b.b.b.b.b.b.b.b.b.b..WbDar.r#K.9.vaf.X#j.obc#m#m#m#m", +"#m#m#m#m#m#m#m#jaMbr.E.U#u#K#k#Nac.8#w.c.zb.b.b.b.b.b.bpb..c.W.c.g#HbDbeap#Nbia2.oaQbs.M#m#m#m#m", +"#m#m.R#m#m#m#m#Q.4aT.EbK.MbE#O#1.3#UbDaraqbpb.b.b.b.b.bpa..WaHa.a6.L.a.D#K#Jaebc#A#bb#bd#m#m#m#m", +"#m#m#m#m#m#m#m#m.BaM.E.b#ybEaV#1a6adbq.3.g.zb.b.b.b.b.b.#hax#hbx.r#HaObeai.9.Ca2.o#b.Eab#m.R#m#m", +"#m#m#m#m#m#m#m#m#m#z.h#la1aia8a4a4.x.xaE.Vbqbqbqbq.n#dalbkalbk#dalbqbG#1aNa8.Ca9#b#..0#m#m#m#m#m", +"#m#m#m#m#m#m#m#m#maL.mbb#Lbz.9#1.9.9.9#1#N#1a4#1a4bGa4a4.Pa4alalal#1a4#1.9.9aJ.e#bbsao#m#m#m#m#m", +"#m#m#m.R#m#m#m.R#m.sbababM.2a4.9.9ala4#1#1#1a4a4a4a7a7alalalal.Pala7a7ala4#xbL#b#.a9#4#m#m#m#m#m", +"#m#m#m#m#m#m#m#m#m#mbLbb#Y#fbka4#Iab#0#N.P#0#o#d#0#o#G#Va7#0#0#da7#VaF#dala7.e#bbsaJ#G#m#m#m#m#m", +"#m#m#m#m#m#m#m#m#m#m#mbabb#e.g.nbkaC.la8#V#8.k#k#Nalab.Aab#3am#OalaS.t.9#1#V.e#.#A.M#m#m#m.R#m#m", +".R#m#m#m#m.R#m#m#m#m#maWbb.Nb..raj.laz#N#0#p#5#daVa8#d#0#d#3aS#O#0#DaNa8al#V.X#b#iaP#m#m#m#m#m#m", +"#m#m#m#m#m#m#m#m#m.R#m.GbM.m.L#xa4al#ka8#1#d#da8bkbE#da7a4#0a8#1#0bkal#0#o.A.e#ba9.0#m#m#m#m#m#m", +"#m#m#m.R#m#m#m#m#m#m#m#m#Bbjbk#dala4#1#1#N#N#1#N#d.9al#dbG#d#d#d#0#0#o#o.Aby.e#.#Wbi#m#m#m#m#m#m", +"#m#m#m#m#m#m.R#m#m#m#m#m.p#Lbu#V#o#o#oaF#0aFaFaF#0#0#da7#o#o#V#V#o.A.A#VagaJ#bbsbc.f#m#m#m#m#m#m", +"#m#m#m#m#m#m#m#m#m#m#m#m#m#.#Y#L#B.Xa2aJ#vaPaP.CaybdaJbd#a.eb##i.e.e.e.e#b.F#.bsbo.Z#m#m#m.R#m#m", +"#m#m#m#m#m#m#m#m#m#m#m#m#m#mbabH#TbH#Y#l#z.haTaTaZ#z#z#C#r#rbbbbbb.Ja3bB#E#B.o#aa5.q#m#m#m#m#m#m", +"#m#m#m#m.R#m#m.R#m#m.R#m#m#mblbvbH#TbHbb#CaM#z#zbr#C#l#l#Y#Y#rbababa#L.N.N.F#aa2bd#m#m#m#m#m#m#m", +"#m#m#m#m#m#m#m#m#m#m#m#m#m#m#m#t#Y#TbH#TanbabaaRa1aR#l.m#rbbbbba#l#zaK.F.F.oaZb##M#x#m#m#m#m#m#m", +".R#m#m#m#m#m#m#m#m#m#m#m#m#m#m#maUbabHbH.ybbbbbabbbb#rbabb.ybb#l.m#l.IaQ#b#b#b#.aN#1#m#m#m#m#m#m", +"#m#m#m#m.R#m#m.R#m#m#m#m#m.R#m#m#m#EbabbbHbbbbbabbbb#Y#r#rbaba#l#l#l#Cbt.F#b#..G#O#1#m#m#m#m.R#m", +"#m#m#m#m#m#m#m#m#m#m.R#m#m#m#m#m#m#m#B#l#T.ybbbb.ybb#r#Yba#l#l#l.m#l.6.N#q.K.KaY#c.S#m#m#m#m#m#m" +}; +SIMPLE = T BITPIX = 8 NAXIS = 2 NAXIS1 = 48 NAXIS2 = 48 HISTORY Written by XV 3.10a END ¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿|Šž™““˜–‘‰‰‰‰‰†ƒsmmlkd¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿„Ž“—“““‘‘ŽŒ‰‰‰„xrqmlY¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿lŒ›œ›““Œ““‘Ž“™’‹‰‰trrrqi\¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿W“žžž˜Œ…€ˆ‰‰‘”“Œ‡}wtlfm`R¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿WŸœ–‡y~~u…ˆˆ‘‘ŽŽŽˆ…€ub[Y¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿Žžœ‘‰}plkjz~ƒ‘‘””“Š†……yn_U(¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿qŠ{fXXSJJJMVXW`kkkkjjjrvqmV=¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿WŒD89:-DXOE;II85AEFKD5DKMCirp[¿¿¿¿¿¿¿¿¿¿¿¿¿¿hŒŒ‰~R\ZOQXWVSSSA@PLNOPLCCNTQfrrb0¿¿¿¿¿¿¿¿¿¿¿¿¿¿~ˆ”Š€[V[\\VXUUUURURQSNPOUUV[[XirpD¿¿¿¿¿¿¿¿¿¿¿¿¿¿~q‹v^TT__^[VVVVMLKLLKKLVOXh]O`rqP¿¿¿¿¿¿¿¿¿¿¿¿¿‰{cRosbW{Uy„££££££Ÿž ‹tnhˆu\O]lqc0¿¿¿¿¿¿¿¿¿¿¿KmbCWrhWz”lrŽ£££££ž—Œ‘—}B9uYT[irlV¿¿¿¿¿¿¿¿¿¿¿yztc=FyhWƒ¤‚˜’££££££ ¡™Œœƒjm‰xYI\kvn`¿¿¿¿¿¿¿¿¿¿utˆŠ•tZzhW„v’£££££££££¢£Šnozx[COgxn`¿¿¿¿¿¿¿¿¿UtŽ–—_pfVƒ}QS’££££££££¤¤¤‚?5>>=><:<<::>=??@@9<89>R¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿¿ \ No newline at end of file diff --git a/jpilot-syncd.c b/jpilot-syncd.c index 1a03d02d..97041f03 100644 --- a/jpilot-syncd.c +++ b/jpilot-syncd.c @@ -22,8 +22,10 @@ //todo - this is a hack for now until I clean up the code int *glob_date_label; +int pipe_in, pipe_out; +extern pid_t glob_child_pid; -#define VERSION_STRING "\nJPilot version 0.91\n"\ +#define VERSION_STRING "\nJPilot version 0.92\n"\ " Copyright (C) 1999 by Judd Montgomery\n" #define USAGE_STRING "\njpilot-syncd [ [-v] || [-h] || [port(/dev/??)] ]\n"\ diff --git a/jpilot.c b/jpilot.c index 4ea8df5c..f4cb3bc2 100644 --- a/jpilot.c +++ b/jpilot.c @@ -18,12 +18,17 @@ */ #include #include +#include +#include #include +#include +#include #include //#include "datebook.h" #include "utils.h" +#include "log.h" #include "datebook.xpm" #include "address.xpm" @@ -39,35 +44,25 @@ GtkWidget *g_hbox, *g_vbox0; GtkWidget *g_hbox2, *g_vbox0_1; GtkWidget *glob_date_label; +GtkTooltips *glob_tooltips; gint glob_date_timer_tag; +pid_t glob_child_pid=0; -void delete_event(GtkWidget *widget, GdkEvent *event, gpointer data); +int pipe_in, pipe_out; + +GtkWidget *sync_window = NULL; -void cb_sync(GtkWidget *widget, gpointer data); +void delete_event(GtkWidget *widget, GdkEvent *event, gpointer data); int create_main_boxes() { - GtkWidget *button; +//todo GtkWidget *button, *separator; g_hbox2 = gtk_hbox_new(FALSE, 0); g_vbox0_1 = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(g_hbox), g_hbox2, TRUE, TRUE, 3); + gtk_box_pack_start(GTK_BOX(g_hbox), g_hbox2, TRUE, TRUE, 0); gtk_box_pack_start(GTK_BOX(g_vbox0), g_vbox0_1, FALSE, FALSE, 0); - - // Create "Quit" button - button = gtk_button_new_with_label ("Quit!"); - gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC (delete_event), NULL); - gtk_box_pack_start(GTK_BOX(g_vbox0_1), button, FALSE, FALSE, 0); - gtk_widget_show(button); - - // Create "Sync" button - button = gtk_button_new_with_label ("Sync"); - gtk_signal_connect (GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(cb_sync), NULL); - gtk_box_pack_start (GTK_BOX (g_vbox0_1), button, FALSE, FALSE, 0); - gtk_widget_show (button); } void cb_datebook(GtkWidget *widget, gpointer data) @@ -114,8 +109,106 @@ void cb_memo(GtkWidget *widget, gpointer data) memo_gui(g_vbox0_1, g_hbox2); } + +void cb_sync_hide(GtkWidget *widget, gpointer data) +{ + GtkWidget *window; + + window=data; + gtk_widget_destroy(window); + + sync_window=NULL; +} + +void cb_read_pipe(gpointer data, + gint in, + GdkInputCondition condition) +{ + int num; + char buf[255]; + fd_set fds; + struct timeval tv; + int ret; + + GtkWidget *main_window, *button, *hbox1, *vbox1, *vscrollbar; + static GtkWidget *text; + int pw, ph, px, py, w, h, x, y; + + main_window = data; + + if (!GTK_IS_WINDOW(sync_window)) { + gdk_window_get_position(main_window->window, &px, &py); + gdk_window_get_size(main_window->window, &pw, &ph); + + w=400; + h=200; + x=px+pw/2-w/2; + y=py+ph/2-h/2; + +#ifdef JPILOT_DEBUG + logf(LOG_DEBUG, "px=%d, py=%d, pw=%d, ph=%d\n", px, py, pw, ph); +#endif + sync_window = gtk_widget_new(GTK_TYPE_WINDOW, + "type", GTK_WINDOW_DIALOG, + "x", x, "y", y, + "width", w, "height", h, + "title", "Output", + NULL); + + vbox1 = gtk_vbox_new(FALSE, 0); + + hbox1 = gtk_hbox_new(FALSE, 0); + + gtk_container_add(GTK_CONTAINER(sync_window), vbox1); + + gtk_box_pack_start(GTK_BOX(vbox1), hbox1, TRUE, TRUE, 0); + + //text box + text = gtk_text_new(NULL, NULL); + gtk_text_set_editable(GTK_TEXT(text), FALSE); + gtk_text_set_word_wrap(GTK_TEXT(text), TRUE); + vscrollbar = gtk_vscrollbar_new(GTK_TEXT(text)->vadj); + gtk_box_pack_start(GTK_BOX(hbox1), text, TRUE, TRUE, 0); + gtk_box_pack_start(GTK_BOX(hbox1), vscrollbar, FALSE, FALSE, 0); + + //Button + button = gtk_button_new_with_label ("Hide this window"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_sync_hide), + sync_window); + gtk_box_pack_start(GTK_BOX(vbox1), button, FALSE, FALSE, 0); + + //show it + gtk_widget_show_all(GTK_WIDGET(sync_window)); + } + + if (GTK_IS_WINDOW(sync_window)) { + gdk_window_raise(sync_window->window); + } + + while(1) { + //Linux modifies tv in the select call + tv.tv_sec=0; + tv.tv_usec=0; + FD_ZERO(&fds); + FD_SET(in, &fds); + ret=select(in+1, &fds, NULL, NULL, &tv); + if (!ret) break; + num = read(in, buf, 250); + if (num>0) { + gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buf, num); + } + } +} + void delete_event(GtkWidget *widget, GdkEvent *event, gpointer data) { + if (glob_child_pid) { + logf(LOG_DEBUG, "killing %d\n", glob_child_pid); + if (glob_child_pid) { + kill(glob_child_pid, SIGTERM); + } + } gtk_main_quit(); } @@ -124,37 +217,69 @@ int main(int argc, { GtkWidget *window; GtkWidget *button_datebook,*button_address,*button_todo,*button_memo; + GtkWidget *button; GtkWidget *separator; GtkStyle *style; GdkBitmap *mask; GtkWidget *pixmapwid; GdkPixmap *pixmap; - - if (argc > 1) { + int filedesc[2]; + int sync_only; + int i; + + sync_only=FALSE; + //log all output to a file + glob_log_file_mask = LOG_INFO | LOG_WARN | LOG_FATAL | LOG_STDOUT; + glob_log_stdout_mask = LOG_INFO | LOG_WARN | LOG_FATAL | LOG_STDOUT; + glob_log_gui_mask = LOG_FATAL | LOG_WARN | LOG_GUI; + + for (i=1; i +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "log.h" +#include "utils.h" +#include "sync.h" + + +extern int pipe_in, pipe_out; + + +int glob_log_file_mask; +int glob_log_stdout_mask; +int glob_log_gui_mask; + +int logf(int level, char *format, ...) +{ +#define WRITE_MAX_BUF 4096 + va_list val; + char buf[WRITE_MAX_BUF]; + int size; + static FILE *fp=NULL; + static int err_count=0; + + buf[0] = '\0'; + + if ((!fp) && (err_count>10)) { + return; + } + if ((!fp) && (err_count==10)) { + fprintf(stderr, "Cannot open log file, giving up.\n"); + err_count++; + return; + } + if ((!fp) && (err_count<10)) { + fp = open_file("jpilot.log", "w"); + if (!fp) { + fprintf(stderr, "Cannot open log file\n"); + err_count++; + } + } + + va_start(val, format); + size = vsnprintf(buf, WRITE_MAX_BUF ,format, val); + //just in case vsnprintf reached the max + if (size == -1) { + buf[WRITE_MAX_BUF-1] = '\0'; + size=WRITE_MAX_BUF-1; + } + va_end(val); + + if ((fp) && (level & glob_log_file_mask)) { + fwrite(buf, size, 1, fp); + } + + if (level & glob_log_stdout_mask) { + fputs(buf, stdout); + } + + if ((pipe_out) && (level & glob_log_gui_mask)) { + write(pipe_out, buf, size); + } + + return 0; +} + diff --git a/log.h b/log.h new file mode 100644 index 00000000..f9da4f21 --- /dev/null +++ b/log.h @@ -0,0 +1,37 @@ +/* + * utils.h + * Copyright (C) 1999 by Judd Montgomery + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef __LOG_H__ +#define __LOG_H__ + + +#define LOG_DEBUG 1 //debugging info for programers, and bug reports +#define LOG_INFO 2 //info, and misc messages +#define LOG_WARN 4 //worse messages +#define LOG_FATAL 8 //even worse messages +#define LOG_STDOUT 256 //messages always go to stdout +#define LOG_FILE 512 //messages always go to the log file +#define LOG_GUI 1024 //messages always go to the gui window + +extern int glob_log_file_mask; +extern int glob_log_stdout_mask; +extern int glob_log_gui_mask; + +int logf(int log_level, char *format, ...); + +#endif diff --git a/memo.c b/memo.c index a580e116..60dae584 100644 --- a/memo.c +++ b/memo.c @@ -23,9 +23,48 @@ #include //#include "memo.h" #include "utils.h" +#include "log.h" #define MEMO_EOF 7 + + +int pc_memo_write(struct Memo *memo, PCRecType rt, unsigned char attrib) +{ + PCRecordHeader header; + //PCFileHeader file_header; + FILE *out; + char record[65536]; + int rec_len; + unsigned int next_unique_id; + + get_next_unique_pc_id(&next_unique_id); +#ifdef JPILOT_DEBUG + logf(LOG_DEBUG, "next unique id = %d\n",next_unique_id); +#endif + + out = open_file("MemoDB.pc", "a"); + if (!out) { + logf(LOG_WARN, "Error opening MemoDB.pc\n"); + return -1; + } + rec_len = pack_Memo(memo, record, 65535); + if (!rec_len) { + PRINT_FILE_LINE; + logf(LOG_WARN, "pack_Memo error\n"); + return -1; + } + header.rec_len=rec_len; + header.rt=rt; + header.attrib=attrib; + header.unique_id=next_unique_id; + fwrite(&header, sizeof(header), 1, out); + fwrite(record, rec_len, 1, out); + fflush(out); + fclose(out); +} + + static int pc_memo_read_next_rec(FILE *in, MyMemo *mmemo) { PCRecordHeader header; @@ -35,10 +74,6 @@ static int pc_memo_read_next_rec(FILE *in, MyMemo *mmemo) if (feof(in)) { return MEMO_EOF; } -// if (ftell(in)==0) { -// printf("Error: File header not read\n"); -// return MEMO_EOF; -// } fread(&header, sizeof(header), 1, in); if (feof(in)) { return MEMO_EOF; @@ -46,7 +81,6 @@ static int pc_memo_read_next_rec(FILE *in, MyMemo *mmemo) rec_len = header.rec_len; mmemo->rt = header.rt; mmemo->attrib = header.attrib; - //printf("read attrib = %d\n", mmemo->attrib); mmemo->unique_id = header.unique_id; record = malloc(rec_len); if (!record) { @@ -85,18 +119,19 @@ int get_memo_app_info(struct MemoAppInfo *ai) in = open_file("MemoDB.pdb", "r"); if (!in) { - printf("Error opening MemoDB.pdb\n"); + logf(LOG_WARN, "Error opening MemoDB.pdb\n"); return -1; } fread(&rdbh, sizeof(RawDBHeader), 1, in); if (feof(in)) { - printf("Error reading MemoDB.pdb\n"); + logf(LOG_WARN, "Error reading MemoDB.pdb\n"); return -1; } raw_header_to_header(&rdbh, &dbh); + get_app_info_size(in, &rec_size); + fseek(in, dbh.app_info_offset, SEEK_SET); - rec_size = 393; buf=malloc(rec_size); if (!buf) { fclose(in); @@ -105,7 +140,7 @@ int get_memo_app_info(struct MemoAppInfo *ai) num = fread(buf, 1, rec_size, in); if (feof(in)) { fclose(in); - printf("Error reading MemoDB.pdb\n"); + logf(LOG_WARN, "Error reading MemoDB.pdb\n"); return -1; } unpack_MemoAppInfo(ai, buf, rec_size); @@ -122,7 +157,7 @@ int get_memos(MemoList **memo_list) char *buf; // unsigned char char_num_records[4]; // unsigned char char_ai_offset[4];//app info offset - int num_records, i, num, r; + int num_records, recs_returned, i, num, r; unsigned int offset, next_offset, rec_size; // unsigned char c; long fpos; //file position indicator @@ -139,36 +174,38 @@ int get_memos(MemoList **memo_list) mem_rh = NULL; *memo_list=NULL; + recs_returned = 0; in = open_file("MemoDB.pdb", "r"); if (!in) { - printf("Error opening MemoDB.pdb\n"); + logf(LOG_WARN, "Error opening MemoDB.pdb\n"); return -1; } //Read the database header fread(&rdbh, sizeof(RawDBHeader), 1, in); if (feof(in)) { - printf("Error opening MemoDB.pdb\n"); + logf(LOG_WARN, "Error opening MemoDB.pdb\n"); return -1; } raw_header_to_header(&rdbh, &dbh); - //printf("db_name = %s\n", dbh.db_name); - //printf("num records = %d\n", dbh.number_of_records); - //printf("app info offset = %d\n", dbh.app_info_offset); + logf(LOG_DEBUG, "db_name = %s\n", dbh.db_name); + logf(LOG_DEBUG, "num records = %d\n", dbh.number_of_records); + logf(LOG_DEBUG, "app info offset = %d\n", dbh.app_info_offset); //fread(filler, 2, 1, in); //Read each record entry header num_records = dbh.number_of_records; - //printf("sizeof(record_header)=%d\n",sizeof(record_header)); for (i=1; inext = mem_rh; mem_rh = temp_mem_rh; @@ -178,69 +215,36 @@ int get_memos(MemoList **memo_list) mem_rh->unique_id = (rh.unique_ID[0]*256+rh.unique_ID[1])*256+rh.unique_ID[2]; } - /* - fseek(in, dbh.app_info_offset, SEEK_SET); - find_next_offset(mem_rh, 0, &next_offset, &attrib, &unique_id); - rec_size = next_offset - dbh.app_info_offset; - //printf("rec_size = %u\n",rec_size); - //printf("fpos,next_offset = %u %u\n",fpos,next_offset); - //printf("----------\n"); - buf=malloc(rec_size); - num = fread(buf, 1, rec_size, in); - unpack_AddressAppInfo(&ai, buf, rec_size); - free(buf); -//struct CategoryAppInfo { -// unsigned int renamed[16]; -// char name[16][16]; -// unsigned char ID[16]; -// unsigned char lastUniqueID; -//} - - for (i=0;i<16;i++) { - printf("renamed:[%02d]:\n",ai.category.renamed[i]); - print_string(ai.category.name[i],16); - printf("category name:[%02d]:",i); - print_string(ai.category.name[i],16); - printf("category ID:%d\n", ai.category.ID[i]); - } - - for (i=0;i<22;i++) { - printf("labels[%02d]:",i); - print_string(ai.labels[i],16); - } - for (i=0;i<8;i++) { - printf("phoneLabels[%d]:",i); - print_string(ai.phoneLabels[i],16); - } - printf("country %d\n",ai.country); - printf("sortByCompany %d\n",ai.sortByCompany); - */ - find_next_offset(mem_rh, 0, &next_offset, &attrib, &unique_id); fseek(in, next_offset, SEEK_SET); - - while(!feof(in)) { - fpos = ftell(in); - find_next_offset(mem_rh, fpos, &next_offset, &attrib, &unique_id); - //next_offset += 223; - rec_size = next_offset - fpos; - //printf("rec_size = %u\n",rec_size); - //printf("fpos,next_offset = %u %u\n",fpos,next_offset); - //printf("----------\n"); - if (feof(in)) break; - buf = malloc(rec_size); - if (!buf) break; - num = fread(buf, 1, rec_size, in); - unpack_Memo(&memo, buf, rec_size); - free(buf); - temp_memo_list = malloc(sizeof(MemoList)); - memcpy(&(temp_memo_list->mmemo.memo), &memo, sizeof(struct Memo)); - temp_memo_list->mmemo.rt = PALM_REC; - temp_memo_list->mmemo.attrib = attrib; - temp_memo_list->mmemo.unique_id = unique_id; - temp_memo_list->next = *memo_list; - *memo_list = temp_memo_list; + if (num_records) { + while(!feof(in)) { + fpos = ftell(in); + find_next_offset(mem_rh, fpos, &next_offset, &attrib, &unique_id); + //next_offset += 223; + rec_size = next_offset - fpos; +#ifdef JPILOT_DEBUG + logf(LOG_DEBUG, "rec_size = %u\n",rec_size); + logf(LOG_DEBUG, "fpos,next_offset = %u %u\n",fpos,next_offset); + logf(LOG_DEBUG, "----------\n"); +#endif + if (feof(in)) break; + buf = malloc(rec_size); + if (!buf) break; + num = fread(buf, 1, rec_size, in); + + unpack_Memo(&memo, buf, rec_size); + free(buf); + temp_memo_list = malloc(sizeof(MemoList)); + memcpy(&(temp_memo_list->mmemo.memo), &memo, sizeof(struct Memo)); + temp_memo_list->mmemo.rt = PALM_REC; + temp_memo_list->mmemo.attrib = attrib; + temp_memo_list->mmemo.unique_id = unique_id; + temp_memo_list->next = *memo_list; + *memo_list = temp_memo_list; + recs_returned++; + } } fclose(in); free_mem_rec_header(&mem_rh); @@ -258,18 +262,20 @@ int get_memos(MemoList **memo_list) if (r==MEMO_EOF) break; if ((mmemo.rt!=DELETED_PC_REC) &&(mmemo.rt!=DELETED_PALM_REC) + &&(mmemo.rt!=MODIFIED_PALM_REC) &&(mmemo.rt!=DELETED_DELETED_PALM_REC)) { temp_memo_list = malloc(sizeof(MemoList)); memcpy(&(temp_memo_list->mmemo), &mmemo, sizeof(MyMemo)); temp_memo_list->next = *memo_list; *memo_list = temp_memo_list; + recs_returned++; //temp_address_list->ma.attrib=0; } else { //this doesnt really free it, just the string pointers free_Memo(&(mmemo.memo)); } - if (mmemo.rt==DELETED_PALM_REC) { + if ((mmemo.rt==DELETED_PALM_REC) || (mmemo.rt==MODIFIED_PALM_REC)) { for (temp_memo_list = *memo_list; temp_memo_list; temp_memo_list=temp_memo_list->next) { if (temp_memo_list->mmemo.unique_id == mmemo.unique_id) { @@ -279,40 +285,6 @@ int get_memos(MemoList **memo_list) } } fclose(pc_in); -} - - -int pc_memo_write(struct Memo *memo, PCRecType rt, unsigned char attrib) -{ - PCRecordHeader header; - //PCFileHeader file_header; - FILE *out; - char record[65536]; - int rec_len; - unsigned int next_unique_id; - get_next_unique_pc_id(&next_unique_id); -#ifdef JPILOT_DEBUG - printf("next unique id = %d\n",next_unique_id); -#endif - - out = open_file("MemoDB.pc", "a"); - if (!out) { - printf("Error opening MemoDB.pc\n"); - return -1; - } - rec_len = pack_Memo(memo, record, 65535); - if (!rec_len) { - PRINT_FILE_LINE; - printf("pack_Memo error\n"); - return -1; - } - header.rec_len=rec_len; - header.rt=rt; - header.attrib=attrib; - header.unique_id=next_unique_id; - fwrite(&header, sizeof(header), 1, out); - fwrite(record, rec_len, 1, out); - fflush(out); - fclose(out); + return recs_returned; } diff --git a/memo_gui.c b/memo_gui.c index 0153abb2..518f1c2c 100644 --- a/memo_gui.c +++ b/memo_gui.c @@ -19,13 +19,18 @@ #include #include #include "utils.h" +#include "log.h" + +extern GtkTooltips *glob_tooltips; struct MemoAppInfo memo_app_info; int memo_category; int clist_row_selected; GtkWidget *clist; GtkWidget *memo_text; -GtkWidget *memo_cat_label; +GtkWidget *memo_cat_menu2; +GtkWidget *memo_cat_menu_item[16]; +GtkWidget *category_menu1; static void update_memo_screen(); @@ -34,14 +39,18 @@ void cb_delete_memo(GtkWidget *widget, gpointer data) { MyMemo *mmemo; + int flag; mmemo = gtk_clist_get_row_data(GTK_CLIST(clist), clist_row_selected); if (mmemo < (MyMemo *)CLIST_MIN_DATA) { return; } - //printf("ma->unique_id = %d\n",ma->unique_id); - //printf("ma->rt = %d\n",ma->rt); - delete_pc_record(MEMO, mmemo); + logf(LOG_DEBUG, "mmemo->unique_id = %d\n",mmemo->unique_id); + logf(LOG_DEBUG, "mmemo->rt = %d\n",mmemo->rt); + flag = GPOINTER_TO_INT(data); + if ((flag==MODIFY_FLAG) || (flag==DELETE_FLAG)) { + delete_pc_record(MEMO, mmemo, flag); + } update_memo_screen(); } @@ -51,7 +60,7 @@ void cb_memo_category(GtkWidget *item, int selection) { if ((GTK_CHECK_MENU_ITEM(item))->active) { memo_category = selection; - //printf("address_category = %d\n",address_category); + logf(LOG_DEBUG, "memo_category = %d\n", memo_category); memo_clear_details(); update_memo_screen(); } @@ -70,6 +79,8 @@ int memo_clear_details() int memo_get_details(struct Memo *new_memo, unsigned char *attrib) { + int i; + new_memo->text = gtk_editable_get_chars (GTK_EDITABLE(memo_text), 0, -1); if (new_memo->text[0]=='\0') { @@ -77,11 +88,54 @@ int memo_get_details(struct Memo *new_memo, unsigned char *attrib) new_memo->text=NULL; } - if (memo_category == CATEGORY_ALL) { - *attrib = 0; + //Get the category that is set from the menu + for (i=0; i<16; i++) { + if (GTK_IS_WIDGET(memo_cat_menu_item[i])) { + if (GTK_CHECK_MENU_ITEM(memo_cat_menu_item[i])->active) { + *attrib = i; + break; + } + } + } +} + +static void cb_add_new_record(GtkWidget *widget, + gpointer data) +{ + MyMemo *mmemo; + struct Memo new_memo; + unsigned char attrib; + int flag; + + flag=GPOINTER_TO_INT(data); + + if (flag==CLEAR_FLAG) { + //Clear button was hit + memo_clear_details(); + return; + } + if ((flag!=NEW_FLAG) && (flag!=MODIFY_FLAG)) { + return; + } + if (flag==MODIFY_FLAG) { + mmemo = gtk_clist_get_row_data(GTK_CLIST(clist), clist_row_selected); + if (mmemo < (MyMemo *)CLIST_MIN_DATA) { + return; + } + if ((mmemo->rt==DELETED_PALM_REC) || (mmemo->rt==MODIFIED_PALM_REC)) { + logf(LOG_INFO, "You can't modify a record that is deleted\n"); + return; + } + } + memo_get_details(&new_memo, &attrib); + pc_memo_write(&new_memo, NEW_PC_REC, attrib); + free_Memo(&new_memo); + if (flag==MODIFY_FLAG) { + cb_delete_memo(NULL, data); } else { - *attrib = memo_category; + update_memo_screen(); } + return; } static void cb_clist_selection(GtkWidget *clist, @@ -92,13 +146,15 @@ static void cb_clist_selection(GtkWidget *clist, { struct Memo *memo;//, new_a; MyMemo *mmemo; +#ifdef OLD_ENTRY struct Memo new_memo; unsigned char attrib; - +#endif clist_row_selected=row; mmemo = gtk_clist_get_row_data(GTK_CLIST(clist), row); +#ifdef OLD_ENTRY if (mmemo == GINT_TO_POINTER(CLIST_NEW_ENTRY_DATA)) { gtk_clist_set_text(GTK_CLIST(clist), row, 0, "Fill in details, then click here again"); @@ -115,12 +171,18 @@ static void cb_clist_selection(GtkWidget *clist, update_memo_screen(); return; } +#endif if (mmemo==NULL) { return; } memo=&(mmemo->memo); + gtk_check_menu_item_set_active + (GTK_CHECK_MENU_ITEM(memo_cat_menu_item[mmemo->attrib & 0x0F]), TRUE); + gtk_option_menu_set_history + (GTK_OPTION_MENU(memo_cat_menu2), mmemo->attrib & 0x0F); + gtk_text_freeze(GTK_TEXT(memo_text)); gtk_text_set_point(GTK_TEXT(memo_text), 0); @@ -138,7 +200,6 @@ static void update_memo_screen() int num_entries, entries_shown, precount; char *last; gchar *empty_line[] = { "" }; - char a_time[16]; GdkColor color; GdkColormap *colormap; MemoList *temp_memo; @@ -156,17 +217,15 @@ static void update_memo_screen() // return; //} - if (memo_category==CATEGORY_ALL) { - sprintf(str, "Category: %s", "All"); - } else { - sprintf(str, "Category: %s", memo_app_info.category.name[memo_category]); - } - gtk_label_set_text(GTK_LABEL(memo_cat_label), str); - //Clear the text box to make things look nice -// gtk_text_set_point(GTK_TEXT(memo_text), 0); -// gtk_text_forward_delete(GTK_TEXT(memo_text), -// gtk_text_get_length(GTK_TEXT(memo_text))); + //gtk_text_set_point(GTK_TEXT(memo_text), 0); + //gtk_text_forward_delete(GTK_TEXT(memo_text), + //gtk_text_get_length(GTK_TEXT(memo_text))); + + if (memo_list==NULL) { + gtk_tooltips_set_tip(glob_tooltips, category_menu1, "0 records", NULL); + return; + } gtk_clist_freeze(GTK_CLIST(clist)); @@ -176,6 +235,12 @@ static void update_memo_screen() memo_category != CATEGORY_ALL) { continue; } + if (temp_memo->mmemo.rt == MODIFIED_PALM_REC) { + //todo - this will be in preferences as to whether you want to + //see deleted records, or not. + num_entries--; + continue; + } precount++; } @@ -185,6 +250,11 @@ static void update_memo_screen() memo_category != CATEGORY_ALL) { continue; } + if (temp_memo->mmemo.rt == MODIFIED_PALM_REC) { + //todo - this will be in preferences as to whether you want to + //see deleted records, or not. + continue; + } entries_shown++; gtk_clist_prepend(GTK_CLIST(clist), empty_line); @@ -215,15 +285,24 @@ static void update_memo_screen() gdk_color_alloc(colormap, &color); gtk_clist_set_background(GTK_CLIST(clist), 0, &color); } + if (temp_memo->mmemo.rt == MODIFIED_PALM_REC) { + colormap = gtk_widget_get_colormap(clist); + color.red=CLIST_MOD_RED; + color.green=CLIST_MOD_GREEN; + color.blue=CLIST_MOD_BLUE; + gdk_color_alloc(colormap, &color); + gtk_clist_set_background(GTK_CLIST(clist), 0, &color); + } } - //printf("entries_shown=%d\n",entries_shown); + logf(LOG_DEBUG, "entries_shown=%d\n",entries_shown); +#ifdef OLD_ENTRY gtk_clist_append(GTK_CLIST(clist), empty_line); gtk_clist_set_text(GTK_CLIST(clist), entries_shown, 0, "Select here to add an entry"); gtk_clist_set_row_data(GTK_CLIST(clist), entries_shown, GINT_TO_POINTER(CLIST_NEW_ENTRY_DATA)); - +#endif //If there is an item in the list, select the first one if (entries_shown>0) { gtk_clist_select_row(GTK_CLIST(clist), 0, 0); @@ -231,26 +310,83 @@ static void update_memo_screen() } gtk_clist_thaw(GTK_CLIST(clist)); + + sprintf(str, "%d of %d records", entries_shown, num_entries); + gtk_tooltips_set_tip(glob_tooltips, category_menu1, str, NULL); +} + +static int make_category_menu1(GtkWidget **category_menu) +{ + GtkWidget *menu_item; + GtkWidget *menu; + GSList *group; + int i; + + *category_menu = gtk_option_menu_new(); + + menu = gtk_menu_new(); + group = NULL; + + menu_item = gtk_radio_menu_item_new_with_label(group, "All"); + gtk_signal_connect(GTK_OBJECT(menu_item), "activate", + cb_memo_category, GINT_TO_POINTER(CATEGORY_ALL)); + group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item)); + gtk_menu_append(GTK_MENU(menu), menu_item); + gtk_widget_show(menu_item); + for (i=0; i<16; i++) { + if (memo_app_info.category.name[i][0]) { + menu_item = gtk_radio_menu_item_new_with_label( + group, memo_app_info.category.name[i]); + gtk_signal_connect(GTK_OBJECT(menu_item), "activate", + cb_memo_category, GINT_TO_POINTER(i)); + group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item)); + gtk_menu_append(GTK_MENU(menu), menu_item); + gtk_widget_show(menu_item); + } + } + + gtk_option_menu_set_menu(GTK_OPTION_MENU(*category_menu), menu); } +static int make_category_menu2() +{ + int i; + + GtkWidget *menu; + GSList *group; + + memo_cat_menu2 = gtk_option_menu_new(); + + menu = gtk_menu_new(); + group = NULL; + + for (i=0; i<16; i++) { + if (memo_app_info.category.name[i][0]) { + memo_cat_menu_item[i] = gtk_radio_menu_item_new_with_label + (group, memo_app_info.category.name[i]); + group = gtk_radio_menu_item_group + (GTK_RADIO_MENU_ITEM(memo_cat_menu_item[i])); + gtk_menu_append(GTK_MENU(menu), memo_cat_menu_item[i]); + gtk_widget_show(memo_cat_menu_item[i]); + } + } + gtk_option_menu_set_menu(GTK_OPTION_MENU(memo_cat_menu2), menu); +} +// +//Main function +// int memo_gui(GtkWidget *vbox, GtkWidget *hbox) { extern GtkWidget *glob_date_label; extern glob_date_timer_tag; GtkWidget *vbox1, *vbox2, *hbox_temp; GtkWidget *separator; - GtkWidget *label; GtkWidget *button; time_t ltime; struct tm *now; #define MAX_STR 100 char str[MAX_STR]; - int i; - GtkWidget *category_menu; - GtkWidget *menu_item; - GtkWidget *menu; - GSList *group; GtkWidget *scrolled_window; GtkWidget *vscrollbar; //GtkWidget *memo_list_menu; @@ -267,7 +403,8 @@ int memo_gui(GtkWidget *vbox, GtkWidget *hbox) //Add buttons in left vbox button = gtk_button_new_with_label("Delete"); gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(cb_delete_memo), NULL); + GTK_SIGNAL_FUNC(cb_delete_memo), + GINT_TO_POINTER(DELETE_FLAG)); gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0); gtk_widget_show(button); @@ -292,40 +429,12 @@ int memo_gui(GtkWidget *vbox, GtkWidget *hbox) gtk_widget_show(separator); - //Put the category menu up - category_menu = gtk_option_menu_new(); - - menu = gtk_menu_new(); - group = NULL; - - //gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), TRUE); - //gtk_check_menu_item_select(GTK_CHECK_MENU_ITEM(menu_item)); - //gtk_check_menu_item_activate(GTK_CHECK_MENU_ITEM(menu_item)); - menu_item = gtk_radio_menu_item_new_with_label(group, "All"); - gtk_signal_connect(GTK_OBJECT(menu_item), "activate", - cb_memo_category, GINT_TO_POINTER(CATEGORY_ALL)); - group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item)); - gtk_menu_append(GTK_MENU(menu), menu_item); - gtk_widget_show(menu_item); - for (i=0; i<16; i++) { - if (memo_app_info.category.name[i][0]) { - menu_item = gtk_radio_menu_item_new_with_label( - group, memo_app_info.category.name[i]); - gtk_signal_connect(GTK_OBJECT(menu_item), "activate", - cb_memo_category, GINT_TO_POINTER(i)); - group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item)); - gtk_menu_append(GTK_MENU(menu), menu_item); - gtk_widget_show(menu_item); - } - } + //Put the left-hand category menu up + make_category_menu1(&category_menu1); + gtk_box_pack_start(GTK_BOX(vbox1), category_menu1, FALSE, FALSE, 0); + gtk_widget_show(category_menu1); + - gtk_option_menu_set_menu(GTK_OPTION_MENU(category_menu), menu); - //gtk_option_menu_set_history (GTK_OPTION_MENU (category_menu), history); - - gtk_box_pack_start (GTK_BOX (vbox1), category_menu, FALSE, FALSE, 0); - gtk_widget_show (category_menu); - - //Put the address list window up scrolled_window = gtk_scrolled_window_new(NULL, NULL); //gtk_widget_set_usize(GTK_WIDGET(scrolled_window), 330, 200); @@ -351,14 +460,54 @@ int memo_gui(GtkWidget *vbox, GtkWidget *hbox) + // + // The right hand part of the main window follows: + // + hbox_temp = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox2), hbox_temp, FALSE, FALSE, 0); + gtk_widget_show(hbox_temp); + + + //Add record modification buttons on right side + button = gtk_button_new_with_label("Add It"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_add_new_record), + GINT_TO_POINTER(NEW_FLAG)); + gtk_box_pack_start(GTK_BOX(hbox_temp), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + button = gtk_button_new_with_label("Apply Changes"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_add_new_record), + GINT_TO_POINTER(MODIFY_FLAG)); + gtk_box_pack_start(GTK_BOX(hbox_temp), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + button = gtk_button_new_with_label("Clear"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_add_new_record), + GINT_TO_POINTER(CLEAR_FLAG)); + gtk_box_pack_start(GTK_BOX(hbox_temp), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + + //Separator + separator = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(vbox2), separator, FALSE, FALSE, 5); + gtk_widget_show(separator); + + + //Put the right-hand category menu up + make_category_menu2(); + gtk_box_pack_start(GTK_BOX (vbox2), memo_cat_menu2, FALSE, FALSE, 0); + gtk_widget_show(memo_cat_menu2); + + //The Description text box on the right side hbox_temp = gtk_hbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox2), hbox_temp, FALSE, FALSE, 0); gtk_widget_show(hbox_temp); - memo_cat_label = gtk_label_new("category:"); - gtk_box_pack_start(GTK_BOX(hbox_temp), memo_cat_label, FALSE, FALSE, 0); - gtk_widget_show(memo_cat_label); hbox_temp = gtk_hbox_new (FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox2), hbox_temp, TRUE, TRUE, 0); diff --git a/sync.c b/sync.c index a855e696..497bb56b 100644 --- a/sync.c +++ b/sync.c @@ -17,35 +17,201 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include +#include +#include +#include +#include +#include #include -#include "utils.h" +#include #include +#include "utils.h" +#include "sync.h" +#include "log.h" //#include #include #include #include -int application_sync(AppType app_type, int sd); +#define SYNC_PI_ACCEPT -12 + +int pipe_in, pipe_out; +pid_t glob_child_pid;extern int pipe_in, pipe_out; +pid_t glob_child_pid; + + +int sync_application(AppType app_type, int sd); +int sync_fetch(int sd, int full_backup); +int jpilot_sync(char *port, int full_backup); +int sync_lock(); +int sync_unlock(); -int jpilot_sync(char *port) +unsigned long hack_record_id; +int wrote_to_datebook; + +void sig_handler(int sig) +{ + logf(LOG_DEBUG, "caught signal SIGCHLD\n"); + fflush(stdout); + glob_child_pid = 0; + + //wait for any child processes + waitpid(-1, NULL, WNOHANG); + + return; +} + +static int writef(int fp, char *format, ...) +{ +#define WRITE_MAX_BUF 4096 + va_list val; + char buf[WRITE_MAX_BUF]; + + buf[0] = '\0'; + + va_start(val, format); + vsnprintf(buf, WRITE_MAX_BUF ,format, val); + //just in case vsnprintf reached the max + buf[WRITE_MAX_BUF-1] = 0; + va_end(val); + + write(fp, buf, strlen(buf)); + + return TRUE; +} + +int sync_loop(char *port, int full_backup) +{ + int r, done, cons_errors; + + done=cons_errors=0; + +// sleep(1); +// while (1) { +// write(pipe_out, "Syncing on device\n", 18); +// sleep(1); +// } + r = sync_lock(); + if (r) { + _exit(0); + } + while(!done) { + r = jpilot_sync(NULL, full_backup); + if (r) { + cons_errors++; + if (cons_errors>3) { + writef(pipe_out, "sync: too many consecutive errors. Quiting\n"); + done=1; + } + } else { + cons_errors=0; + } + } + sync_unlock(); +} + +int sync_lock() +{ + pid_t pid; + char lock_file[256]; + int fd, r; + char str[12]; + + get_home_file_name("sync_pid", lock_file, 255); + fd = open(lock_file, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + if (fd<0) { + logf(LOG_WARN, "open lock file failed\n"); + return -1; + } + r = flock(fd, LOCK_EX | LOCK_NB); + if (r) { + logf(LOG_WARN, "lock failed\n"); + read(fd, str, 10); + pid = atoi(str); + logf(LOG_FATAL, "sync file is locked by pid %d\n", pid); + return -1; + } else { + logf(LOG_DEBUG, "lock succeeded\n"); + pid=getpid(); + sprintf(str, "%d\n", pid); + write(fd, str, strlen(str)+1); + ftruncate(fd, strlen(str)+1); + } + return 0; +} + +int sync_unlock() +{ + pid_t pid; + char lock_file[256]; + int fd, r; + char str[12]; + + get_home_file_name("sync_pid", lock_file, 255); + fd = open(lock_file, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR); + if (fd<0) { + logf(LOG_WARN, "open lock file failed\n"); + return -1; + } + r = flock(fd, LOCK_UN | LOCK_NB); + if (r) { + logf(LOG_WARN, "unlock failed\n"); + read(fd, str, 10); + pid = atoi(str); + logf(LOG_FATAL, "sync is locked by pid %d\n", pid); + return -1; + } else { + logf(LOG_DEBUG, "unlock succeeded\n"); + ftruncate(fd, 0); + } + return 0; +} + +int sync_once(char *port, int full_backup) +{ + int r; + + logf(LOG_DEBUG, "forking sync process\n"); + switch ( glob_child_pid = fork() ){ + case -1: + perror("fork"); + return; + case 0: + //close(pipe_in); + break; + default: + signal(SIGCHLD, sig_handler); + return; + } +#ifdef TEST_SYNC_OUT + for (r=0; r<10; r++) { + writef(pipe_out, "Syncing on device\n"); + writef(pipe_out, "testing %d on the write\n"); + sleep(1); + } + logf(LOG_DEBUG, "sync child exiting\n"); + _exit(0); +#endif + r = sync_lock(); + if (r) { + logf(LOG_DEBUG, "sync child exiting\n"); + _exit(0); + } + jpilot_sync(port, full_backup); + sync_unlock(); + logf(LOG_DEBUG, "sync child exiting\n"); + _exit(0); +} + +int jpilot_sync(char *port, int full_backup) { struct pi_sockaddr addr; int sd; - int i; - int Appointment_size; - unsigned char Appointment_buf[0xffff]; - struct Appointment appointment; - FILE *f; struct PilotUser U; int ret; - int filelen; - char *cPtr; char *device; char default_device[]="/dev/pilot"; - char *file_text; - char *fields[4]; - int fieldno; if (port) { //A port was passed in to use @@ -58,8 +224,10 @@ int jpilot_sync(char *port) } } - printf("Syncing on device %s\n", device); - printf("Press the HotSync button\n"); + writef(pipe_out, "****************************************\n"); + writef(pipe_out, "Syncing on device %s\n", device); + writef(pipe_out, "Press the HotSync button now\n"); + writef(pipe_out, "****************************************\n"); if (!(sd = pi_socket(PI_AF_SLP, PI_SOCK_STREAM, PI_PF_PADP))) { perror("pi_socket"); @@ -84,100 +252,95 @@ int jpilot_sync(char *port) sd = pi_accept(sd, 0, 0); if(sd == -1) { perror("pi_accept"); - return -1; + return SYNC_PI_ACCEPT; } dlp_ReadUserInfo(sd, &U); - printf("username = [%s]\n", U.username); - printf("passwordlen = [%d]\n", U.passwordLength); - //printf("password = [%s]\n", U.password); - - dlp_OpenConduit(sd); + writef(pipe_out, "Username = [%s]\n", U.username); + //writef(pipe_out, "passwordlen = [%d]\n", U.passwordLength); + //writef(pipe_out, "password = [%s]\n", U.password); + if (dlp_OpenConduit(sd)<0) { + writef(pipe_out, "Sync canceled\n"); + //todo - I'm not sure what to do here + return -1; + } + + sync_application(DATEBOOK, sd); + sync_application(ADDRESS, sd); + sync_application(TODO, sd); + sync_application(MEMO, sd); - application_sync(DATEBOOK, sd); - application_sync(ADDRESS, sd); - application_sync(TODO, sd); - application_sync(MEMO, sd); + hack_write_record(sd); + sync_fetch(sd, full_backup); + hack_delete_record(sd); + // Tell the user who it is, with a different PC id. U.lastSyncPC = 0x00010000; U.successfulSyncDate = time(NULL); U.lastSyncDate = U.successfulSyncDate; dlp_WriteUserInfo(sd,&U); - //dlp_AddSyncLogEntry(sd, "Wrote Appointment to Pilot.\n"); - - // All of the following code is now unnecessary, but harmless - + dlp_EndOfSync(sd,0); pi_close(sd); cleanup_pc_files(); - printf("Finished.\n"); + writef(pipe_out, "Finished.\n"); return 0; } -int application_sync(AppType app_type, int sd) +int sync_application(AppType app_type, int sd) { - struct pi_file *pi_fp; - char full_name[256]; unsigned long new_id; int db; int ret; int num; - //time_t start, end; FILE *pc_in; PCRecordHeader header; char *record; int rec_len; - struct DBInfo info; - struct stat statb; - struct utimbuf times; char pc_filename[50]; char palm_dbname[50]; - char db_copy_name[50]; char write_log_message[50]; char error_log_message[50]; char delete_log_message[50]; switch (app_type) { case DATEBOOK: - printf("Syncing Datebook\n"); + wrote_to_datebook = 0; + writef(pipe_out, "Syncing Datebook\n"); strcpy(pc_filename, "DatebookDB.pc"); strcpy(palm_dbname, "DatebookDB"); - strcpy(db_copy_name,"DatebookDB.pdb"); strcpy(write_log_message, "Wrote an Appointment to the Pilot.\n "); strcpy(error_log_message, "Writing an Appointment to the Pilot failed.\n "); strcpy(delete_log_message, "Deleted an Appointment from the Pilot.\n "); break; case ADDRESS: - printf("Syncing Addressbook\n"); + writef(pipe_out, "Syncing Addressbook\n"); strcpy(pc_filename, "AddressDB.pc"); strcpy(palm_dbname, "AddressDB"); - strcpy(db_copy_name,"AddressDB.pdb"); strcpy(write_log_message, "Wrote an Addresss to the Pilot.\n "); strcpy(error_log_message, "Writing an Address to the Pilot failed.\n "); strcpy(delete_log_message, "Deleted an Address from the Pilot.\n "); break; case TODO: - printf("Syncing ToDo\n"); + writef(pipe_out, "Syncing ToDo\n"); strcpy(pc_filename, "ToDoDB.pc"); strcpy(palm_dbname, "ToDoDB"); - strcpy(db_copy_name,"ToDoDB.pdb"); strcpy(write_log_message, "Wrote a ToDo to the Pilot.\n "); strcpy(error_log_message, "Writing a ToDo to the Pilot failed.\n "); strcpy(delete_log_message, "Deleted a ToDo from the Pilot.\n "); break; case MEMO: - printf("Syncing Memo\n"); + writef(pipe_out, "Syncing Memo\n"); strcpy(pc_filename, "MemoDB.pc"); strcpy(palm_dbname, "MemoDB"); - strcpy(db_copy_name,"MemoDB.pdb"); strcpy(write_log_message, "Wrote a Memo to the Pilot.\n "); strcpy(error_log_message, "Writing a Memo to the Pilot failed.\n "); strcpy(delete_log_message, "Deleted a Memo from the Pilot.\n "); @@ -188,21 +351,21 @@ int application_sync(AppType app_type, int sd) pc_in = open_file(pc_filename, "r+"); if (pc_in==NULL) { - printf("Unable to open %s\n",pc_filename); + writef(pipe_out, "Unable to open %s\n",pc_filename); return; } // Open the applications database, store access handle in db - if (dlp_OpenDB(sd, 0, 0x80|0x40, palm_dbname, &db) < 0) { + if (dlp_OpenDB(sd, 0, dlpOpenWrite, palm_dbname, &db) < 0) { dlp_AddSyncLogEntry(sd, "Unable to open "); dlp_AddSyncLogEntry(sd, palm_dbname); dlp_AddSyncLogEntry(sd, "\n."); pi_close(sd); return -1; } - //time(&start); - //time(&end); - //end+=3600; - +#ifdef JPILOT_DEBUG + dlp_ReadOpenDBInfo(sd, db, &num); + writef(pipe_out ,"number of records = %d\n", num); +#endif while(!feof(pc_in)) { num = fread(&header, sizeof(header), 1, pc_in); if (feof(pc_in) || (!num)) { @@ -210,7 +373,7 @@ int application_sync(AppType app_type, int sd) } rec_len = header.rec_len; if (rec_len > 0x10000) { - printf("PC file corrupt?\n"); + writef(pipe_out, "PC file corrupt?\n"); fclose(pc_in); return; } @@ -220,21 +383,26 @@ int application_sync(AppType app_type, int sd) if (feof(pc_in) || (!num)) { break; } - + //Write the record to the Palm Pilot ret = dlp_WriteRecord(sd, db, 0, 0, header.attrib & 0x0F, record, rec_len, &new_id); - //printf("New ID=%d\n", new_id); - free(record); + if (record) { + free(record); + record = NULL; + } + if (ret < 0) { - printf("dlp_WriteRecord failed\n"); + writef(pipe_out, "dlp_WriteRecord failed\n"); dlp_AddSyncLogEntry(sd, error_log_message); } else { + //hack2 + wrote_to_datebook = 1; dlp_AddSyncLogEntry(sd, write_log_message); //Now mark the record as deleted in the pc file if (fseek(pc_in, -(sizeof(header)+rec_len), SEEK_CUR)) { - printf("fseek failed - fatal error\n"); + writef(pipe_out, "fseek failed - fatal error\n"); fclose(pc_in); return; } @@ -243,18 +411,18 @@ int application_sync(AppType app_type, int sd) } } - if (header.rt==DELETED_PALM_REC) { - printf("Deleteing Palm id=%d,\n",header.unique_id); + if ((header.rt==DELETED_PALM_REC) || (header.rt==MODIFIED_PALM_REC)) { + //writef(pipe_out, "Deleting Palm id=%d,\n",header.unique_id); ret = dlp_DeleteRecord(sd, db, 0, header.unique_id); if (ret < 0) { - printf("dlp_DeleteRecord failed\n"); + writef(pipe_out, "dlp_DeleteRecord failed\n"); dlp_AddSyncLogEntry(sd, error_log_message); } else { dlp_AddSyncLogEntry(sd, delete_log_message); //Now mark the record as deleted if (fseek(pc_in, -sizeof(header), SEEK_CUR)) { - printf("fseek failed - fatal error\n"); + writef(pipe_out, "fseek failed - fatal error\n"); fclose(pc_in); return; } @@ -265,7 +433,7 @@ int application_sync(AppType app_type, int sd) //skip this record now that we are done with it if (fseek(pc_in, rec_len, SEEK_CUR)) { - printf("fseek failed - fatal error\n"); + writef(pipe_out, "fseek failed - fatal error\n"); fclose(pc_in); return; } @@ -274,58 +442,147 @@ int application_sync(AppType app_type, int sd) //fields[fieldno++] = cPtr; +#ifdef JPILOT_DEBUG + dlp_ReadOpenDBInfo(sd, db, &num); + writef(pipe_out ,"number of records = %d\n", num); +#endif + // Close the database dlp_CloseDB(sd, db); - // - // Fetch the database from the palm if modified - // - - get_home_file_name(db_copy_name, full_name, 256); +} + +// +// Fetch the databases from the palm if modified +// +int sync_fetch(int sd, int full_backup) +{ +#define MAX_DBNAME 50 + struct pi_file *pi_fp; + char full_name[256]; + struct stat statb; + struct utimbuf times; + int i, found; + int cardno, start; + struct DBInfo info; + char db_copy_name[MAX_DBNAME]; + char *palm_dbname[]={ + "DatebookDB", + "AddressDB", + "ToDoDB", + "MemoDB", + NULL + }; + + start=cardno=0; - //Get the db info for this database - if (dlp_FindDBInfo(sd, 0, 0, palm_dbname, 0, 0, &info) != 0) { - printf("Unable to find %s on the palm, fetch skipped.\n", palm_dbname); - return; - } + while(dlp_ReadDBList(sd, cardno, dlpOpenRead, start, &info)>0) { + start=info.index+1; + //writef(pipe_out, "dbname = %s\n",info.name); + //writef(pipe_out, "type = %x\n",info.type); + //writef(pipe_out, "creator = %x\n",info.creator); + for(i=0, found=0; palm_dbname[i]; i++) { + if (found = !strcmp(info.name, palm_dbname[i])) + break; + } + if (full_backup || found) { + strncpy(db_copy_name, info.name, MAX_DBNAME-5); + db_copy_name[MAX_DBNAME-5]='\0'; + if (info.flags & dlpDBFlagResource) { + strcat(db_copy_name,".prc"); + } else { + strcat(db_copy_name,".pdb"); + } - if (stat(full_name, &statb) != 0) { - statb.st_mtime = 0; - } + get_home_file_name(db_copy_name, full_name, 256); + if (stat(full_name, &statb) != 0) { + statb.st_mtime = 0; + } #ifdef JPILOT_DEBUG - printf("palm dbtime= %d, local dbtime = %d\n", info.modifyDate, statb.st_mtime); + writef(pipe_out, "palm dbtime= %d, local dbtime = %d\n", info.modifyDate, statb.st_mtime); + writef(pipe_out, "flags=0%x\n", info.flags); + writef(pipe_out, "backup_flag=%d\n", info.flags & dlpDBFlagBackup); #endif - //If modification times are the same then we don't need to fetch it - if (info.modifyDate == statb.st_mtime) { - printf("%s is up to date, fetch skipped.\n", palm_dbname); - return; - } + //If modification times are the same then we don't need to fetch it + if (info.modifyDate == statb.st_mtime) { + writef(pipe_out, "%s is up to date, fetch skipped.\n", db_copy_name); + continue; + } - //protect_name(name, dbname); - //if (info.flags & dlpDBFlagResource) - // strcat(name,".prc"); - //else - // strcat(name,".pdb"); + writef(pipe_out, "Fetching '%s'... ", info.name); + fflush(stdout); - printf("Fetching '%s'... ", palm_dbname); - fflush(stdout); + info.flags &= 0xff; - info.flags &= 0xff; + pi_fp = pi_file_create(full_name, &info); + if (pi_fp==0) { + writef(pipe_out, "Failed, unable to create file %s\n", full_name); + continue; + } + if(pi_file_retrieve(pi_fp, sd, 0)<0) { + writef(pipe_out, "Failed, unable to back up database\n"); + } else { + writef(pipe_out, "OK\n"); + } + pi_file_close(pi_fp); - pi_fp = pi_file_create(full_name, &info); - if (pi_fp==0) { - printf("Failed, unable to create file %s\n", full_name); - return; - } - if(pi_file_retrieve(pi_fp, sd, 0)<0) { - printf("Failed, unable to back up database\n"); - } else { - printf("OK\n"); + //Set the create and modify times of local file to same as on palm + times.actime = info.createDate; + times.modtime = info.modifyDate; + utime(full_name, ×); + } } - pi_file_close(pi_fp); +} + +int hack_write_record(int sd) +{ + char record[65536]; + int rec_len; + int db; + int ret; - //Set the create and modify times of local file to same as on palm - times.actime = info.createDate; - times.modtime = info.modifyDate; - utime(full_name, ×); + hack_record_id = 0; + + logf(LOG_DEBUG, "Entering hack_write_record()\n"); + if (wrote_to_datebook) { + // Open the applications database, store access handle in db + if (dlp_OpenDB(sd, 0, dlpOpenWrite, "DatebookDB", &db) < 0) { + dlp_AddSyncLogEntry(sd, "Unable to open "); + dlp_AddSyncLogEntry(sd, "DatebookDB"); + dlp_AddSyncLogEntry(sd, "\n."); + return -1; + } + datebook_create_bogus_record(record, 65536, &rec_len); + + //Write a bogus record to the Palm Pilot, to delete later. + logf(LOG_DEBUG, "writing bogus record\n"); + ret = dlp_WriteRecord(sd, db, 0, 0, 0, + record, rec_len, &hack_record_id); + if (ret<0) { + logf(LOG_WARN, "write bogus record failed\n"); + } + // Close the database + dlp_CloseDB(sd, db); + } +} + +int hack_delete_record(int sd) +{ + int db; + + if (hack_record_id) { + // Open the applications database, store access handle in db + if (dlp_OpenDB(sd, 0, dlpOpenWrite, "DatebookDB", &db) < 0) { + dlp_AddSyncLogEntry(sd, "Unable to open "); + dlp_AddSyncLogEntry(sd, "DatebookDB"); + dlp_AddSyncLogEntry(sd, "\n."); + pi_close(sd); + } + + logf(LOG_DEBUG, "deleting bogus record\n"); + dlp_DeleteRecord(sd, db, 0, hack_record_id); + + // Close the database + dlp_CloseDB(sd, db); + } } diff --git a/sync.h b/sync.h index 96b1a727..8cc597e3 100644 --- a/sync.h +++ b/sync.h @@ -19,6 +19,7 @@ #ifndef _SYNC_H__ #define _SYNC_H__ -int jpilot_sync(char *port); +int sync_once(char *port, int full_backup); +int sync_loop(char *port, int full_backup); #endif diff --git a/todo.c b/todo.c index 2c552d2e..00cd1dac 100644 --- a/todo.c +++ b/todo.c @@ -23,6 +23,7 @@ #include #include "address.h" #include "utils.h" +#include "log.h" #define TODO_EOF 7 @@ -185,10 +186,6 @@ static int pc_todo_read_next_rec(FILE *in, MyToDo *mtodo) if (feof(in)) { return TODO_EOF; } -// if (ftell(in)==0) { -// printf("Error: File header not read\n"); -// return TODO_EOF; -// } fread(&header, sizeof(header), 1, in); if (feof(in)) { return TODO_EOF; @@ -196,7 +193,6 @@ static int pc_todo_read_next_rec(FILE *in, MyToDo *mtodo) rec_len = header.rec_len; mtodo->rt = header.rt; mtodo->attrib = header.attrib; - //printf("read attrib = %d\n", mtodo->attrib); mtodo->unique_id = header.unique_id; record = malloc(rec_len); if (!record) { @@ -223,18 +219,18 @@ int pc_todo_write(struct ToDo *todo, PCRecType rt, unsigned char attrib) get_next_unique_pc_id(&next_unique_id); #ifdef JPILOT_DEBUG - printf("next unique id = %d\n",next_unique_id); + logf(LOG_DEBUG, "next unique id = %d\n",next_unique_id); #endif out = open_file("ToDoDB.pc", "a"); if (!out) { - printf("Error opening ToDoDB.pc\n"); + logf(LOG_WARN, "Error opening ToDoDB.pc\n"); return -1; } //todo check return code - if 0 then buffer was too small rec_len = pack_ToDo(todo, record, 65535); if (!rec_len) { - printf("pack_ToDo failed\n"); + logf(LOG_WARN, "pack_ToDo failed\n"); PRINT_FILE_LINE; return -1; } @@ -273,19 +269,20 @@ int get_todo_app_info(struct ToDoAppInfo *ai) in = open_file("ToDoDB.pdb", "r"); if (!in) { - printf("Error opening ToDoDB.pdb\n"); + logf(LOG_WARN, "Error opening ToDoDB.pdb\n"); return -1; } fread(&rdbh, sizeof(RawDBHeader), 1, in); if (feof(in)) { fclose(in); - printf("Error reading ToDoDB.pdb\n"); + logf(LOG_WARN, "Error reading ToDoDB.pdb\n"); return -1; } raw_header_to_header(&rdbh, &dbh); + get_app_info_size(in, &rec_size); + fseek(in, dbh.app_info_offset, SEEK_SET); - rec_size = 300; buf=malloc(rec_size); if (!buf) { fclose(in); @@ -294,7 +291,7 @@ int get_todo_app_info(struct ToDoAppInfo *ai) num = fread(buf, 1, rec_size, in); if (feof(in)) { fclose(in); - printf("sd Error reading ToDoDB.pdb\n"); + logf(LOG_WARN, "Error reading ToDoDB.pdb\n"); return -1; } unpack_ToDoAppInfo(ai, buf, rec_size); @@ -311,7 +308,7 @@ int get_todos(ToDoList **todo_list) char *buf; // unsigned char char_num_records[4]; // unsigned char char_ai_offset[4];//app info offset - int num_records, i, num, r; + int num_records, recs_returned, i, num, r; unsigned int offset, next_offset, rec_size; // unsigned char c; long fpos; //file position indicator @@ -328,36 +325,37 @@ int get_todos(ToDoList **todo_list) mem_rh = NULL; *todo_list=NULL; + recs_returned = 0; in = open_file("ToDoDB.pdb", "r"); if (!in) { - printf("Error opening ToDoDB.pdb\n"); + logf(LOG_WARN, "Error opening ToDoDB.pdb\n"); return -1; } //Read the database header fread(&rdbh, sizeof(RawDBHeader), 1, in); if (feof(in)) { - printf("Error opening ToDoDB.pdb\n"); + logf(LOG_WARN, "Error opening ToDoDB.pdb\n"); return -1; } raw_header_to_header(&rdbh, &dbh); - - //printf("db_name = %s\n", dbh.db_name); - //printf("num records = %d\n", dbh.number_of_records); - //printf("app info offset = %d\n", dbh.app_info_offset); - - //fread(filler, 2, 1, in); +#ifdef JPILOT_DEBUG + logf(LOG_DEBUG, "db_name = %s\n", dbh.db_name); + logf(LOG_DEBUG, "num records = %d\n", dbh.number_of_records); + logf(LOG_DEBUG, "app info offset = %d\n", dbh.app_info_offset); +#endif //Read each record entry header num_records = dbh.number_of_records; - //printf("sizeof(record_header)=%d\n",sizeof(record_header)); for (i=1; inext = mem_rh; mem_rh = temp_mem_rh; @@ -367,33 +365,36 @@ int get_todos(ToDoList **todo_list) mem_rh->unique_id = (rh.unique_ID[0]*256+rh.unique_ID[1])*256+rh.unique_ID[2]; } - - find_next_offset(mem_rh, 0, &next_offset, &attrib, &unique_id); - fseek(in, next_offset, SEEK_SET); - - while(!feof(in)) { - fpos = ftell(in); - find_next_offset(mem_rh, fpos, &next_offset, &attrib, &unique_id); - //next_offset += 223; - rec_size = next_offset - fpos; - //printf("rec_size = %u\n",rec_size); - //printf("fpos,next_offset = %u %u\n",fpos,next_offset); - //printf("----------\n"); - if (feof(in)) break; - buf = malloc(rec_size); - if (!buf) break; - num = fread(buf, 1, rec_size, in); + if (num_records) { + find_next_offset(mem_rh, 0, &next_offset, &attrib, &unique_id); + fseek(in, next_offset, SEEK_SET); + while(!feof(in)) { + fpos = ftell(in); + find_next_offset(mem_rh, fpos, &next_offset, &attrib, &unique_id); + //next_offset += 223; + rec_size = next_offset - fpos; +#ifdef JPILOT_DEBUG + logf(LOG_DEBUG, "rec_size = %u\n",rec_size); + logf(LOG_DEBUG, "fpos,next_offset = %u %u\n",fpos,next_offset); + logf(LOG_DEBUG, "----------\n"); +#endif + if (feof(in)) break; + buf = malloc(rec_size); + if (!buf) break; + num = fread(buf, 1, rec_size, in); - unpack_ToDo(&todo, buf, rec_size); - free(buf); - temp_todo_list = malloc(sizeof(ToDoList)); - memcpy(&(temp_todo_list->mtodo.todo), &todo, sizeof(struct ToDo)); - //temp_address_list->ma.a = temp_a; - temp_todo_list->mtodo.rt = PALM_REC; - temp_todo_list->mtodo.attrib = attrib; - temp_todo_list->mtodo.unique_id = unique_id; - temp_todo_list->next = *todo_list; - *todo_list = temp_todo_list; + unpack_ToDo(&todo, buf, rec_size); + free(buf); + temp_todo_list = malloc(sizeof(ToDoList)); + memcpy(&(temp_todo_list->mtodo.todo), &todo, sizeof(struct ToDo)); + //temp_address_list->ma.a = temp_a; + temp_todo_list->mtodo.rt = PALM_REC; + temp_todo_list->mtodo.attrib = attrib; + temp_todo_list->mtodo.unique_id = unique_id; + temp_todo_list->next = *todo_list; + *todo_list = temp_todo_list; + recs_returned++; + } } fclose(in); free_mem_rec_header(&mem_rh); @@ -411,18 +412,20 @@ int get_todos(ToDoList **todo_list) if (r==TODO_EOF) break; if ((mtodo.rt!=DELETED_PC_REC) &&(mtodo.rt!=DELETED_PALM_REC) + &&(mtodo.rt!=MODIFIED_PALM_REC) &&(mtodo.rt!=DELETED_DELETED_PALM_REC)) { temp_todo_list = malloc(sizeof(ToDoList)); memcpy(&(temp_todo_list->mtodo), &mtodo, sizeof(MyToDo)); temp_todo_list->next = *todo_list; *todo_list = temp_todo_list; + recs_returned++; //temp_address_list->ma.attrib=0; } else { //this doesnt really free it, just the string pointers free_ToDo(&(mtodo.todo)); } - if (mtodo.rt==DELETED_PALM_REC) { + if ((mtodo.rt==DELETED_PALM_REC) || (mtodo.rt==MODIFIED_PALM_REC)) { for (temp_todo_list = *todo_list; temp_todo_list; temp_todo_list=temp_todo_list->next) { if (temp_todo_list->mtodo.unique_id == mtodo.unique_id) { @@ -434,4 +437,6 @@ int get_todos(ToDoList **todo_list) fclose(pc_in); todo_sort(todo_list); + + return recs_returned; } diff --git a/todo_gui.c b/todo_gui.c index 7348886c..9cb25f08 100644 --- a/todo_gui.c +++ b/todo_gui.c @@ -20,11 +20,12 @@ #include #include "utils.h" #include "todo.h" +#include "log.h" +extern GtkTooltips *glob_tooltips; GtkWidget *clist; GtkWidget *todo_text, *todo_text_note; -GtkWidget *todo_cat_label; GtkWidget *todo_completed_checkbox; GtkWidget *todo_no_due_date_checkbox; GtkWidget *radio_button_todo[5]; @@ -32,6 +33,11 @@ GtkWidget *todo_spinner_due_mon; GtkWidget *todo_spinner_due_day; GtkWidget *todo_spinner_due_year; GtkAdjustment *todo_adj_due_mon, *todo_adj_due_day, *todo_adj_due_year; +GtkWidget *todo_cat_menu2; +GtkWidget *todo_cat_menu_item[16]; +GtkWidget *todo_hide_completed_checkbox; +GtkWidget *todo_modify_button; +GtkWidget *category_menu1; struct ToDoAppInfo todo_app_info; int todo_category; @@ -40,18 +46,22 @@ int clist_row_selected; void update_todo_screen(); int todo_clear_details(); +int glob_hide_completed=0; + void cb_delete_todo(GtkWidget *widget, - gpointer data) + gpointer data) { MyToDo *mtodo; + int flag; mtodo = gtk_clist_get_row_data(GTK_CLIST(clist), clist_row_selected); if (mtodo < (MyToDo *)CLIST_MIN_DATA) { return; } - //printf("ma->unique_id = %d\n",ma->unique_id); - //printf("ma->rt = %d\n",ma->rt); - delete_pc_record(TODO, mtodo); + flag = GPOINTER_TO_INT(data); + if ((flag==MODIFY_FLAG) || (flag==DELETE_FLAG)) { + delete_pc_record(TODO, mtodo, flag); + } update_todo_screen(); } @@ -60,12 +70,20 @@ void cb_todo_category(GtkWidget *item, int selection) { if ((GTK_CHECK_MENU_ITEM(item))->active) { todo_category = selection; - //printf("address_category = %d\n",address_category); + logf(LOG_DEBUG, "todo_category = %d\n",todo_category); todo_clear_details(); update_todo_screen(); } } +void cb_hide_completed(GtkWidget *widget, + gpointer data) +{ + glob_hide_completed = GTK_TOGGLE_BUTTON(todo_hide_completed_checkbox)->active; + todo_clear_details(); + update_todo_screen(); +} + int todo_clear_details() { time_t ltime; @@ -101,6 +119,10 @@ int todo_clear_details() gtk_text_thaw(GTK_TEXT(todo_text)); gtk_text_thaw(GTK_TEXT(todo_text_note)); + + gtk_check_menu_item_set_active + (GTK_CHECK_MENU_ITEM(todo_cat_menu_item[0]), TRUE); + gtk_option_menu_set_history(GTK_OPTION_MENU(todo_cat_menu2), 0); } int todo_get_details(struct ToDo *new_todo, unsigned char *attrib) @@ -136,42 +158,87 @@ int todo_get_details(struct ToDo *new_todo, unsigned char *attrib) new_todo->note=NULL; } - if (todo_category == CATEGORY_ALL) { - *attrib = 0; - } else { - *attrib = todo_category; + for (i=0; i<16; i++) { + if (GTK_IS_WIDGET(todo_cat_menu_item[i])) { + if (GTK_CHECK_MENU_ITEM(todo_cat_menu_item[i])->active) { + *attrib = i; + break; + } + } } #ifdef JPILOT_DEBUG - printf("attrib = %d\n", *attrib); - printf("indefinite=%d\n",new_todo->indefinite); + logf(LOG_DEBUG, "attrib = %d\n", *attrib); + logf(LOG_DEBUG, "indefinite=%d\n",new_todo->indefinite); if (!new_todo->indefinite) - printf("due: %d/%d/%d\n",new_todo->due.tm_mon, + logf(LOG_DEBUG, "due: %d/%d/%d\n",new_todo->due.tm_mon, new_todo->due.tm_mday, new_todo->due.tm_year); - printf("priority=%d\n",new_todo->priority); - printf("complete=%d\n",new_todo->complete); - printf("description=[%s]\n",new_todo->description); - printf("note=[%s]\n",new_todo->note); + logf(LOG_DEBUG, "priority=%d\n",new_todo->priority); + logf(LOG_DEBUG, "complete=%d\n",new_todo->complete); + logf(LOG_DEBUG, "description=[%s]\n",new_todo->description); + logf(LOG_DEBUG, "note=[%s]\n",new_todo->note); #endif } +static void cb_add_new_record(GtkWidget *widget, + gpointer data) +{ + MyToDo *mtodo; + struct ToDo new_todo; + unsigned char attrib; + int flag; + + flag=GPOINTER_TO_INT(data); + + if (flag==CLEAR_FLAG) { + //Clear button was hit + todo_clear_details(); + return; + } + if ((flag!=NEW_FLAG) && (flag!=MODIFY_FLAG)) { + return; + } + if (flag==MODIFY_FLAG) { + mtodo = gtk_clist_get_row_data(GTK_CLIST(clist), clist_row_selected); + if (mtodo < (MyToDo *)CLIST_MIN_DATA) { + return; + } + if ((mtodo->rt==DELETED_PALM_REC) || (mtodo->rt==MODIFIED_PALM_REC)) { + logf(LOG_INFO, "You can't modify a record that is deleted\n"); + return; + } + } + todo_get_details(&new_todo, &attrib); + pc_todo_write(&new_todo, NEW_PC_REC, attrib); + free_ToDo(&new_todo); + if (flag==MODIFY_FLAG) { + cb_delete_todo(NULL, data); + } else { + update_todo_screen(); + } + return; +} + + static void cb_clist_selection(GtkWidget *clist, - gint row, - gint column, - GdkEventButton *event, - gpointer data) + gint row, + gint column, + GdkEventButton *event, + gpointer data) { struct ToDo *todo;//, new_a; MyToDo *mtodo; +#ifdef OLD_ENTRY struct ToDo new_todo; unsigned char attrib; - int i; +#endif clist_row_selected=row; mtodo = gtk_clist_get_row_data(GTK_CLIST(clist), row); +#ifdef OLD_ENTRY if (mtodo == GINT_TO_POINTER(CLIST_NEW_ENTRY_DATA)) { gtk_clist_set_text(GTK_CLIST(clist), row, 2, "Fill in details, then click here again"); @@ -188,7 +255,7 @@ static void cb_clist_selection(GtkWidget *clist, update_todo_screen(); return; } - +#endif if (mtodo==NULL) { return; } @@ -210,6 +277,12 @@ static void cb_clist_selection(GtkWidget *clist, // todo_app_info.category.name[mtodo->attrib & 0x0F], -1); //gtk_text_insert(GTK_TEXT(todo_text), NULL,NULL,NULL, "\n", -1); + gtk_check_menu_item_set_active + (GTK_CHECK_MENU_ITEM(todo_cat_menu_item[mtodo->attrib & 0x0F]), TRUE); + gtk_option_menu_set_history + (GTK_OPTION_MENU(todo_cat_menu2), mtodo->attrib & 0x0F); + + gtk_text_insert(GTK_TEXT(todo_text), NULL,NULL,NULL, todo->description, -1); if (todo->note[0]) { @@ -217,7 +290,7 @@ static void cb_clist_selection(GtkWidget *clist, } if ( (todo->priority<1) || (todo->priority>5) ) { - printf("Priority out of range\n"); + logf(LOG_WARN, "Priority out of range\n"); } else { gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio_button_todo[todo->priority-1]), TRUE); } @@ -241,6 +314,13 @@ static void cb_clist_selection(GtkWidget *clist, gtk_text_thaw(GTK_TEXT(todo_text)); gtk_text_thaw(GTK_TEXT(todo_text_note)); + + //If they have clicked on the checkmark box then do a modify + if (column==0) { + todo->complete = !(todo->complete); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(todo_completed_checkbox), todo->complete); + gtk_signal_emit_by_name(GTK_OBJECT(todo_modify_button), "clicked"); + } } @@ -248,7 +328,6 @@ void update_todo_screen() { int num_entries, entries_shown, i; gchar *empty_line[] = { "","","","" }; - char a_time[16]; GdkPixmap *pixmap_note; GdkPixmap *pixmap_alarm; GdkPixmap *pixmap_check; @@ -267,36 +346,28 @@ void update_todo_screen() #ifdef JPILOT_DEBUG for (i=0;i<16;i++) { - printf("renamed:[%02d]:\n",todo_app_info.category.renamed[i]); - printf("category name:[%02d]:",i); + logf(LOG_DEBUG, "renamed:[%02d]:\n",todo_app_info.category.renamed[i]); + logf(LOG_DEBUG, "category name:[%02d]:",i); print_string(todo_app_info.category.name[i],16); - printf("category ID:%d\n", todo_app_info.category.ID[i]); + logf(LOG_DEBUG, "category ID:%d\n", todo_app_info.category.ID[i]); } - printf("dirty %d\n",todo_app_info.dirty); - printf("sortByCompany %d\n",todo_app_info.sortByPriority); + logf(LOG_DEBUG, "dirty %d\n",todo_app_info.dirty); + logf(LOG_DEBUG, "sortByCompany %d\n",todo_app_info.sortByPriority); #endif num_entries = get_todos(&todo_list); gtk_clist_clear(GTK_CLIST(clist)); - //gtk_text_backward_delete(GTK_TEXT(todo_text1), - // gtk_text_get_length(GTK_TEXT(todo_text1))); - - //if (todo_list==NULL) { - // return; - //} - if (todo_category==CATEGORY_ALL) { - sprintf(str, "Category: %s", "All"); - } else { - sprintf(str, "Category: %s", todo_app_info.category.name[todo_category]); - } - gtk_label_set_text(GTK_LABEL(todo_cat_label), str); - //Clear the text box to make things look nice gtk_text_set_point(GTK_TEXT(todo_text), 0); gtk_text_forward_delete(GTK_TEXT(todo_text), gtk_text_get_length(GTK_TEXT(todo_text))); + if (todo_list==NULL) { + gtk_tooltips_set_tip(glob_tooltips, category_menu1, "0 records", NULL); + return; + } + gtk_clist_freeze(GTK_CLIST(clist)); entries_shown=0; @@ -305,6 +376,16 @@ void update_todo_screen() todo_category != CATEGORY_ALL) { continue; } + //Hide the completed records if need be + if (glob_hide_completed && temp_todo->mtodo.todo.complete) { + continue; + } + if (temp_todo->mtodo.rt == MODIFIED_PALM_REC) { + //todo - this will be in preferences as to whether you want to + //see deleted records, or not. + num_entries--; + continue; + } entries_shown++; gtk_clist_prepend(GTK_CLIST(clist), empty_line); @@ -329,6 +410,14 @@ void update_todo_screen() gdk_color_alloc(colormap, &color); gtk_clist_set_background(GTK_CLIST(clist), 0, &color); } + if (temp_todo->mtodo.rt == MODIFIED_PALM_REC) { + colormap = gtk_widget_get_colormap(clist); + color.red=CLIST_MOD_RED; + color.green=CLIST_MOD_GREEN; + color.blue=CLIST_MOD_BLUE; + gdk_color_alloc(colormap, &color); + gtk_clist_set_background(GTK_CLIST(clist), 0, &color); + } get_pixmaps(clist, &pixmap_note, &pixmap_alarm, &pixmap_check, &pixmap_checked, @@ -348,13 +437,14 @@ void update_todo_screen() } } - //printf("entries_shown=%d\n",entries_shown); + logf(LOG_DEBUG, "entries_shown=%d\n",entries_shown); +#ifdef OLD_ENTRY gtk_clist_append(GTK_CLIST(clist), empty_line); gtk_clist_set_text(GTK_CLIST(clist), entries_shown, 2, "Select here to add an entry"); gtk_clist_set_row_data(GTK_CLIST(clist), entries_shown, GINT_TO_POINTER(CLIST_NEW_ENTRY_DATA)); - +#endif //If there is an item in the list, select the first one if (entries_shown>0) { gtk_clist_select_row(GTK_CLIST(clist), 0, 1); @@ -362,6 +452,67 @@ void update_todo_screen() } gtk_clist_thaw(GTK_CLIST(clist)); + + sprintf(str, "%d of %d records", entries_shown, num_entries); + gtk_tooltips_set_tip(glob_tooltips, category_menu1, str, NULL); +} + +static int make_category_menu1(GtkWidget **category_menu) +{ + int i; + + GtkWidget *menu_item; + GtkWidget *menu; + GSList *group; + + *category_menu = gtk_option_menu_new(); + + menu = gtk_menu_new(); + group = NULL; + + menu_item = gtk_radio_menu_item_new_with_label(group, "All"); + gtk_signal_connect(GTK_OBJECT(menu_item), "activate", + cb_todo_category, GINT_TO_POINTER(CATEGORY_ALL)); + group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item)); + gtk_menu_append(GTK_MENU(menu), menu_item); + gtk_widget_show(menu_item); + for (i=0; i<16; i++) { + if (todo_app_info.category.name[i][0]) { + menu_item = gtk_radio_menu_item_new_with_label( + group, todo_app_info.category.name[i]); + gtk_signal_connect(GTK_OBJECT(menu_item), "activate", + cb_todo_category, GINT_TO_POINTER(i)); + group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item)); + gtk_menu_append(GTK_MENU(menu), menu_item); + gtk_widget_show(menu_item); + } + } + gtk_option_menu_set_menu(GTK_OPTION_MENU(*category_menu), menu); +} + +static int make_category_menu2() +{ + int i; + + GtkWidget *menu; + GSList *group; + + todo_cat_menu2 = gtk_option_menu_new(); + + menu = gtk_menu_new(); + group = NULL; + + for (i=0; i<16; i++) { + if (todo_app_info.category.name[i][0]) { + todo_cat_menu_item[i] = gtk_radio_menu_item_new_with_label + (group, todo_app_info.category.name[i]); + group = gtk_radio_menu_item_group + (GTK_RADIO_MENU_ITEM(todo_cat_menu_item[i])); + gtk_menu_append(GTK_MENU(menu), todo_cat_menu_item[i]); + gtk_widget_show(todo_cat_menu_item[i]); + } + } + gtk_option_menu_set_menu(GTK_OPTION_MENU(todo_cat_menu2), menu); } int todo_gui(GtkWidget *vbox, GtkWidget *hbox) @@ -380,25 +531,22 @@ int todo_gui(GtkWidget *vbox, GtkWidget *hbox) char str[MAX_STR]; int i; GtkWidget *scrolled_window; - GtkWidget *category_menu; - GtkWidget *menu_item; - GtkWidget *menu; GSList *group; - GtkWidget *phone_list_menu; clist_row_selected=0; get_todo_app_info(&todo_app_info); - vbox1 = gtk_vbox_new (FALSE, 0); - vbox2 = gtk_vbox_new (FALSE, 0); + vbox1 = gtk_vbox_new(FALSE, 0); + vbox2 = gtk_vbox_new(FALSE, 0); gtk_box_pack_start(GTK_BOX(hbox), vbox1, TRUE, TRUE, 5); gtk_box_pack_start(GTK_BOX(hbox), vbox2, TRUE, TRUE, 5); //Add buttons in left vbox button = gtk_button_new_with_label("Delete"); gtk_signal_connect(GTK_OBJECT(button), "clicked", - GTK_SIGNAL_FUNC(cb_delete_todo), NULL); + GTK_SIGNAL_FUNC(cb_delete_todo), + GINT_TO_POINTER(DELETE_FLAG)); gtk_box_pack_start(GTK_BOX(vbox), button, TRUE, TRUE, 0); gtk_widget_show(button); @@ -421,43 +569,26 @@ int todo_gui(GtkWidget *vbox, GtkWidget *hbox) gtk_box_pack_start(GTK_BOX(vbox1), separator, FALSE, FALSE, 5); gtk_widget_show(separator); - - - //Put the category menu up - category_menu = gtk_option_menu_new(); - - menu = gtk_menu_new(); - group = NULL; - //gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(menu_item), TRUE); - //gtk_check_menu_item_select(GTK_CHECK_MENU_ITEM(menu_item)); - //gtk_check_menu_item_activate(GTK_CHECK_MENU_ITEM(menu_item)); - menu_item = gtk_radio_menu_item_new_with_label(group, "All"); - gtk_signal_connect(GTK_OBJECT(menu_item), "activate", - cb_todo_category, GINT_TO_POINTER(CATEGORY_ALL)); - group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item)); - gtk_menu_append(GTK_MENU(menu), menu_item); - gtk_widget_show(menu_item); - for (i=0; i<16; i++) { - if (todo_app_info.category.name[i][0]) { - menu_item = gtk_radio_menu_item_new_with_label( - group, todo_app_info.category.name[i]); - gtk_signal_connect(GTK_OBJECT(menu_item), "activate", - cb_todo_category, GINT_TO_POINTER(i)); - group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menu_item)); - gtk_menu_append(GTK_MENU(menu), menu_item); - gtk_widget_show(menu_item); - } - } + //Put the left-hand category menu up + make_category_menu1(&category_menu1); - gtk_option_menu_set_menu(GTK_OPTION_MENU(category_menu), menu); - //gtk_option_menu_set_history (GTK_OPTION_MENU (category_menu), history); + gtk_box_pack_start(GTK_BOX(vbox1), category_menu1, FALSE, FALSE, 0); + gtk_widget_show(category_menu1); - gtk_box_pack_start (GTK_BOX (vbox1), category_menu, FALSE, FALSE, 0); - gtk_widget_show (category_menu); + //The hide completed check box + todo_hide_completed_checkbox = gtk_check_button_new_with_label("Hide Completed ToDos"); + gtk_box_pack_start(GTK_BOX(vbox1), todo_hide_completed_checkbox, FALSE, FALSE, 0); + gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(todo_hide_completed_checkbox), + glob_hide_completed); + gtk_signal_connect_object(GTK_OBJECT(todo_hide_completed_checkbox), + "clicked", GTK_SIGNAL_FUNC(cb_hide_completed), + NULL); + gtk_widget_show(todo_hide_completed_checkbox); + - //Put the address list window up + //Put the todo list window up scrolled_window = gtk_scrolled_window_new(NULL, NULL); gtk_widget_set_usize(GTK_WIDGET(scrolled_window), 200, 0); gtk_container_set_border_width(GTK_CONTAINER(scrolled_window), 0); @@ -479,6 +610,43 @@ int todo_gui(GtkWidget *vbox, GtkWidget *hbox) gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW (scrolled_window), clist); + // + // The right hand part of the main window follows: + // + hbox_temp = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox2), hbox_temp, FALSE, FALSE, 0); + gtk_widget_show(hbox_temp); + + + //Add record modification buttons on right side + button = gtk_button_new_with_label("Add It"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_add_new_record), + GINT_TO_POINTER(NEW_FLAG)); + gtk_box_pack_start(GTK_BOX(hbox_temp), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + todo_modify_button = gtk_button_new_with_label("Apply Changes"); + gtk_signal_connect(GTK_OBJECT(todo_modify_button), "clicked", + GTK_SIGNAL_FUNC(cb_add_new_record), + GINT_TO_POINTER(MODIFY_FLAG)); + gtk_box_pack_start(GTK_BOX(hbox_temp), todo_modify_button, TRUE, TRUE, 0); + gtk_widget_show(todo_modify_button); + + button = gtk_button_new_with_label("Clear"); + gtk_signal_connect(GTK_OBJECT(button), "clicked", + GTK_SIGNAL_FUNC(cb_add_new_record), + GINT_TO_POINTER(CLEAR_FLAG)); + gtk_box_pack_start(GTK_BOX(hbox_temp), button, TRUE, TRUE, 0); + gtk_widget_show(button); + + + //Separator + separator = gtk_hseparator_new(); + gtk_box_pack_start(GTK_BOX(vbox2), separator, FALSE, FALSE, 5); + gtk_widget_show(separator); + + //The completed check box todo_completed_checkbox = gtk_check_button_new_with_label("Completed"); gtk_box_pack_start(GTK_BOX(vbox2), todo_completed_checkbox, FALSE, FALSE, 0); @@ -583,6 +751,10 @@ int todo_gui(GtkWidget *vbox, GtkWidget *hbox) //end spinners + //Put the right-hand category menu up + make_category_menu2(); + gtk_box_pack_start(GTK_BOX(vbox2), todo_cat_menu2, FALSE, FALSE, 5); + gtk_widget_show(todo_cat_menu2); //The Description text box on the right side @@ -590,10 +762,6 @@ int todo_gui(GtkWidget *vbox, GtkWidget *hbox) gtk_box_pack_start(GTK_BOX(vbox2), hbox_temp, FALSE, FALSE, 0); gtk_widget_show(hbox_temp); - todo_cat_label = gtk_label_new("category:"); - gtk_box_pack_start(GTK_BOX(hbox_temp), todo_cat_label, FALSE, FALSE, 0); - gtk_widget_show(todo_cat_label); - hbox_temp = gtk_hbox_new (FALSE, 0); gtk_box_pack_start(GTK_BOX(vbox2), hbox_temp, TRUE, TRUE, 0); diff --git a/utils.c b/utils.c index e9d91669..35696b00 100644 --- a/utils.c +++ b/utils.c @@ -20,9 +20,11 @@ #include #include #include "utils.h" +#include "log.h" #include #include -//#include +#include +#include //#include #include @@ -231,10 +233,10 @@ int get_home_file_name(char *file, char *full_name, int max_size) home = getenv("HOME"); if (!home) {//Not home; - printf("Can't get HOME environment variable\n"); + logf(LOG_WARN, "Can't get HOME environment variable\n"); } if (strlen(home)>(max_size-strlen(file)-2)) { - printf("Your HOME environment variable is too long for me\n"); + logf(LOG_WARN, "Your HOME environment variable is too long for me\n"); home=default_path; } sprintf(full_name, "%s/.jpilot/%s", home, file); @@ -254,23 +256,22 @@ int check_hidden_dir() get_home_file_name("", hidden_dir, 256); hidden_dir[strlen(hidden_dir)-1]='\0'; - //printf("home name = %s\n", hidden_dir); if (stat(hidden_dir, &statb)) { //directory isn\'t there, create it if (mkdir(hidden_dir, 0777)) { //Can\'t create directory - printf("Can't create directory %s\n", hidden_dir); + logf(LOG_WARN, "Can't create directory %s\n", hidden_dir); return 1; } if (stat(hidden_dir, &statb)) { - printf("Can't create directory %s\n", hidden_dir); + logf(LOG_WARN, "Can't create directory %s\n", hidden_dir); return 1; } } //Is it a directory? if (!S_ISDIR(statb.st_mode)) { - printf("%s doesn't appear to be a directory.\n" + logf(LOG_WARN, "%s doesn't appear to be a directory.\n" "I need it to be.\n", hidden_dir); return 1; } @@ -278,7 +279,7 @@ int check_hidden_dir() get_home_file_name("test", test_file, 256); out = fopen(test_file, "w+"); if (!out) { - printf("I can't write files in directory %s\n", hidden_dir); + logf(LOG_WARN, "I can't write files in directory %s\n", hidden_dir); } else { fclose(out); unlink(test_file); @@ -343,16 +344,15 @@ int get_next_unique_pc_id(unsigned int *next_unique_id) pc_in_out = open_file("next_id", "a+"); if (pc_in_out==NULL) { - printf("Error opening %s\n",file_name); + logf(LOG_WARN, "Error opening %s\n",file_name); return -1; } if (ftell(pc_in_out)==0) { //We have to write out the file header - //printf("writing pc header\n"); *next_unique_id=1; if (fwrite(next_unique_id, sizeof(*next_unique_id), 1, pc_in_out) != 1) { - printf("Error writing pc header to file: next_id\n"); + logf(LOG_WARN, "Error writing pc header to file: next_id\n"); fclose(pc_in_out); return 0; } @@ -361,18 +361,18 @@ int get_next_unique_pc_id(unsigned int *next_unique_id) fclose(pc_in_out); pc_in_out = open_file("next_id", "r+"); if (pc_in_out==NULL) { - printf("Error opening %s\n",file_name); + logf(LOG_WARN, "Error opening %s\n",file_name); return -1; } fread(next_unique_id, sizeof(*next_unique_id), 1, pc_in_out); (*next_unique_id)++; if (fseek(pc_in_out, 0, SEEK_SET)) { - printf("fseek failed\n"); + logf(LOG_WARN, "fseek failed\n"); } //rewind(pc_in_out); //todo - if > 16777216 then cleanup (thats a lot of records!) if (fwrite(next_unique_id, sizeof(*next_unique_id), 1, pc_in_out) != 1) { - printf("Error writing pc header to file: next_id\n"); + logf(LOG_WARN, "Error writing pc header to file: next_id\n"); } fflush(pc_in_out); fclose(pc_in_out); @@ -385,10 +385,10 @@ int read_rc_file() home = getenv("HOME"); if (!home) {//Not home; - printf("Can't get HOME environment variable\n"); + logf(LOG_WARN, "Can't get HOME environment variable\n"); } if (strlen(home) > 256-20) { - printf("Your HOME environment variable is too long for me\n"); + logf(LOG_WARN, "Your HOME environment variable is too long for me\n"); home=default_path; } sprintf(file_name, "%s/.jpilot/jpilotrc", home); @@ -404,10 +404,10 @@ FILE *open_file(char *filename, char *mode) home = getenv("HOME"); if (!home) {//Not home; - printf("Can't get HOME environment variable\n"); + logf(LOG_WARN, "Can't get HOME environment variable\n"); } if (strlen(home) > 256-10-strlen(filename)) { - printf("Your HOME environment variable is too long for me\n"); + logf(LOG_WARN, "Your HOME environment variable is too long for me\n"); home=default_path; } sprintf(file_name, "%s/.jpilot/%s", home, filename); @@ -428,10 +428,10 @@ int unlink_file(char *filename) home = getenv("HOME"); if (!home) {//Not home; - printf("Can't get HOME environment variable\n"); + logf(LOG_WARN, "Can't get HOME environment variable\n"); } if (strlen(home) > 256-10-strlen(filename)) { - printf("Your HOME environment variable is too long for me\n"); + logf(LOG_WARN, "Your HOME environment variable is too long for me\n"); home=default_path; } sprintf(file_name, "%s/.jpilot/%s", home, filename); @@ -539,17 +539,56 @@ void print_string(char *str, int len) for (i=0;i= 0x7f) - printf("%x",c); + logf(LOG_STDOUT, "%x",c); else putchar(c); } - printf("\n"); + logf(LOG_STDOUT, "\n"); } // -//This deletes an appointment from the appropriate Datafile +//Warning, this function will move the file pointer // -int delete_pc_record(AppType app_type, void *VP) +int get_app_info_size(FILE *in, int *size) +{ + RawDBHeader rdbh; + DBHeader dbh; + unsigned int offset; + record_header rh; + + fseek(in, 0, SEEK_SET); + + fread(&rdbh, sizeof(RawDBHeader), 1, in); + if (feof(in)) { + logf(LOG_WARN, "Error reading file in get_app_info_size\n"); + return -1; + } + + raw_header_to_header(&rdbh, &dbh); + + if (dbh.app_info_offset==0) { + *size=0; + return 0; + } + if (dbh.sort_info_offset!=0) { + *size = dbh.sort_info_offset - dbh.app_info_offset; + return 0; + } + if (dbh.number_of_records==0) { + fseek(in, 0, SEEK_END); + *size=ftell(in) - dbh.app_info_offset; + return 0; + } + + fread(&rh, sizeof(record_header), 1, in); + offset = ((rh.Offset[0]*256+rh.Offset[1])*256+rh.Offset[2])*256+rh.Offset[3]; + *size=offset - dbh.app_info_offset; +} + +// +//This deletes a record from the appropriate Datafile +// +int delete_pc_record(AppType app_type, void *VP, int flag) { // int unique_id; FILE *pc_in; @@ -571,6 +610,7 @@ int delete_pc_record(AppType app_type, void *VP) return; } + mapp=NULL;//to keep the compiler happy switch (app_type) { case DATEBOOK: mapp = (MyAppointment *) VP; @@ -600,61 +640,65 @@ int delete_pc_record(AppType app_type, void *VP) return; } - if (record_type==DELETED_PALM_REC) { - printf("This record is already deleted.\n"); - printf("It is scheduled to be deleted from the Palm on the next sync.\n"); + if ((record_type==DELETED_PALM_REC) || (record_type==MODIFIED_PALM_REC)) { + logf(LOG_INFO, "This record is already deleted.\n" + "It is scheduled to be deleted from the Palm on the next sync.\n"); return 0; } - //printf("record type %d\n",record_type); switch (record_type) { case NEW_PC_REC: pc_in=open_file(filename, "r+"); if (pc_in==NULL) { - printf("Couldn't open PC records file\n"); + logf(LOG_WARN, "Couldn't open PC records file\n"); return -1; } while(!feof(pc_in)) { fread(&header, sizeof(header), 1, pc_in); if (feof(pc_in)) { - printf("couldn't find record to delete\n"); + logf(LOG_WARN, "couldn't find record to delete\n"); return -1; } if (header.unique_id==unique_id) { if (fseek(pc_in, -sizeof(header), SEEK_CUR)) { - printf("fseek failed\n"); + logf(LOG_WARN, "fseek failed\n"); } header.rt=DELETED_PC_REC; fwrite(&header, sizeof(header), 1, pc_in); - //printf("record deleted\n"); + logf(LOG_DEBUG, "record deleted\n"); fclose(pc_in); return 0; } if (fseek(pc_in, header.rec_len, SEEK_CUR)) { - printf("fseek failed\n"); + logf(LOG_WARN, "fseek failed\n"); } } fclose(pc_in); return -1; case PALM_REC: - printf("Deleteing Palm ID %d\n",unique_id); + logf(LOG_DEBUG, "Deleteing Palm ID %d\n",unique_id); //todo //find_palm_appt_by_ID(unique_id, &a); pc_in=open_file(filename, "a"); if (pc_in==NULL) { - printf("Couldn't open PC records file\n"); + logf(LOG_WARN, "Couldn't open PC records file\n"); return -1; } header.unique_id=unique_id; - header.rt=DELETED_PALM_REC; + if (flag==MODIFY_FLAG) { + header.rt=MODIFIED_PALM_REC; + } else { + header.rt=DELETED_PALM_REC; + } switch (app_type) { case DATEBOOK: - memset(&app, 0, sizeof(app)); + app=mapp->a; + //memset(&app, 0, sizeof(app)); header.rec_len = pack_Appointment(&app, record, 65535); if (!header.rec_len) { PRINT_FILE_LINE; - printf("pack_Appointment error\n"); + logf(LOG_WARN, "pack_Appointment error\n"); } break; case ADDRESS: @@ -662,7 +706,7 @@ int delete_pc_record(AppType app_type, void *VP) header.rec_len = pack_Address(&address, record, 65535); if (!header.rec_len) { PRINT_FILE_LINE; - printf("pack_Address error\n"); + logf(LOG_WARN, "pack_Address error\n"); } break; case TODO: @@ -670,7 +714,7 @@ int delete_pc_record(AppType app_type, void *VP) header.rec_len = pack_ToDo(&todo, record, 65535); if (!header.rec_len) { PRINT_FILE_LINE; - printf("pack_Address error\n"); + logf(LOG_WARN, "pack_ToDo error\n"); } break; case MEMO: @@ -678,10 +722,11 @@ int delete_pc_record(AppType app_type, void *VP) header.rec_len = pack_Memo(&memo, record, 65535); if (!header.rec_len) { PRINT_FILE_LINE; - printf("pack_Address error\n"); + logf(LOG_WARN, "pack_Memo error\n"); } break; default: + fclose(pc_in); return; } //todo check write @@ -691,7 +736,7 @@ int delete_pc_record(AppType app_type, void *VP) //This will be used for making sure that the palm record hasn't changed //before we delete it fwrite(record, header.rec_len, 1, pc_in); - //printf("record deleted\n"); + logf(LOG_DEBUG, "record deleted\n"); fclose(pc_in); return 0; break; @@ -735,7 +780,7 @@ int cleanup_pc_file(AppType app_type) r++; } if (fseek(pc_file, header.rec_len, SEEK_CUR)) { - printf("fseek failed\n"); + logf(LOG_WARN, "fseek failed\n"); return -1; } } @@ -761,10 +806,19 @@ int cleanup_pc_files() } } +void cb_backup(GtkWidget *widget, + gpointer data) +{ + sync_once(NULL, TRUE); + return; +} + + void cb_sync(GtkWidget *widget, gpointer data) { - jpilot_sync(NULL); + sync_once(NULL, FALSE); + return; //datebook_cleanup(); //todo - force a refresh of whatever app is running //Force a refresh of the calendar diff --git a/utils.h b/utils.h index 6dc0e300..2c46af5d 100644 --- a/utils.h +++ b/utils.h @@ -21,6 +21,8 @@ #include #include +#include +#include #include #include #include @@ -28,8 +30,19 @@ #include #define PRINT_FILE_LINE printf("%s line %d\n", __FILE__, __LINE__) -#define VERSION_STRING "\nJPilot version 0.91\n"\ +#define VERSION "0.92" +#define VERSION_STRING "\nJPilot version "VERSION"\n"\ " Copyright (C) 1999 by Judd Montgomery\n" + +#define USAGE_STRING "\njpilot [ [-v] || [-h] || [-d]\n"\ +" -v displays version and exits.\n"\ +" -h displays help and exits.\n"\ +" -d displays debug info to stdout.\n"\ +" The PILOTPORT, and PILOTRATE env variables are used to specify which\n"\ +" port to sync on, and at what speed.\n"\ +" If PILOTPORT is not set then it defaults to /dev/pilot.\n" + + #define CATEGORY_ALL 100 #define SHADOW GTK_SHADOW_ETCHED_OUT @@ -39,15 +52,27 @@ #define CLIST_ADDING_ENTRY_DATA 101 #define CLIST_MIN_DATA 199 -#define CLIST_DEL_RED 65535; -#define CLIST_DEL_GREEN 55000; -#define CLIST_DEL_BLUE 55000; +//#define CLIST_DEL_RED 65535; +//#define CLIST_DEL_GREEN 55000; +//#define CLIST_DEL_BLUE 55000; +#define CLIST_DEL_RED 0xCCCC; +#define CLIST_DEL_GREEN 0xCCCC; +#define CLIST_DEL_BLUE 0xCCCC; #define CLIST_NEW_RED 55000; #define CLIST_NEW_GREEN 55000; #define CLIST_NEW_BLUE 65535; +#define CLIST_MOD_RED 55000; +#define CLIST_MOD_GREEN 65535; +#define CLIST_MOD_BLUE 65535; #define SPENT_PC_RECORD_BIT 256 +#define CLEAR_FLAG 1 +#define CANCEL_FLAG 2 +#define DELETE_FLAG 3 +#define MODIFY_FLAG 4 +#define NEW_FLAG 5 + typedef enum { PALM_REC = 100L, MODIFIED_PALM_REC = 101L, @@ -185,7 +210,7 @@ int find_next_offset(mem_rec_header *mem_rh, long fpos, unsigned char *attrib, unsigned int *unique_id); int get_next_unique_pc_id(unsigned int *next_unique_id); //The VP is a pointer to MyAddress, MyAppointment, etc. -int delete_pc_record(AppType app_type, void *VP); +int delete_pc_record(AppType app_type, void *VP, int flag); void get_month_info(int month, int day, int year, int *dow, int *ndim); void get_this_month_info(int *dow, int *ndim); @@ -194,8 +219,12 @@ unsigned long unix_time_to_pilot_time (time_t t); unsigned int bytes_to_bin(unsigned char *bytes, unsigned int num_bytes); void free_mem_rec_header(mem_rec_header **mem_rh); void print_string(char *str, int len); +// +//Warning, this function will move the file pointer +// +int get_app_info_size(FILE *in, int *size); int cleanup_pc_files(); -void cb_sync(GtkWidget *widget, - gpointer data); +void cb_backup(GtkWidget *widget, gpointer data); +void cb_sync(GtkWidget *widget, gpointer data); #endif