Enlightenment CVS committal Author : fletch3k Project : misc Module : enotes
Dir : misc/enotes/src Modified Files: Makefile.am config.c config.h controlcentre.c main.c note.c note.h saveload.c saveload.h storage.c storage.h Removed Files: xml.c xml.h Log Message: Bai Bai Xml :D =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/Makefile.am,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- Makefile.am 6 Oct 2004 17:12:34 -0000 1.5 +++ Makefile.am 9 Oct 2004 16:04:04 -0000 1.6 @@ -1,7 +1,7 @@ ## Process this file with automake to produce Makefile.in INCLUDES = \ - @ecore_cflags@ @evas_cflags@ @ewl_cflags@ @edje_cflags@ @edb_cflags@ @imlib2_cflags@ @libxml2_cflags@ @esmart_cflags@ + @ecore_cflags@ @evas_cflags@ @ewl_cflags@ @edje_cflags@ @edb_cflags@ @imlib2_cflags@ @esmart_cflags@ bin_PROGRAMS = enotes @@ -22,8 +22,6 @@ saveload.h \ ipc.c \ ipc.h \ -xml.c \ -xml.h \ debug.c \ debug.h \ welcome.c \ =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/config.c,v retrieving revision 1.14 retrieving revision 1.15 diff -u -3 -r1.14 -r1.15 --- config.c 6 Oct 2004 19:10:12 -0000 1.14 +++ config.c 9 Oct 2004 16:04:04 -0000 1.15 @@ -76,6 +76,12 @@ int read_configuration(MainConfig * p) { + ecore_config_int_create("controlcentre.x", 0, 0, NULL, "CC x pos"); + ecore_config_int_create("controlcentre.y", 0, 0, NULL, "CC y pos"); + ecore_config_int_create("controlcentre.w", 0, 0, NULL, "CC w pos"); + ecore_config_int_create("controlcentre.h", 0, 0, NULL, "CC h pos"); + + ecore_config_int_create("enotes.debug", 0, 'd', "debug", "Debugging Level [0-2]"); ecore_config_string_create("enotes.engine", "software", 'r', =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/config.h,v retrieving revision 1.9 retrieving revision 1.10 diff -u -3 -r1.9 -r1.10 --- config.h 6 Oct 2004 17:12:34 -0000 1.9 +++ config.h 9 Oct 2004 16:04:04 -0000 1.10 @@ -23,7 +23,6 @@ #include "debug.h" #include "../config.h" -#include "xml.h" typedef struct { char *render_method; =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/controlcentre.c,v retrieving revision 1.17 retrieving revision 1.18 diff -u -3 -r1.17 -r1.18 --- controlcentre.c 6 Oct 2004 17:12:34 -0000 1.17 +++ controlcentre.c 9 Oct 2004 16:04:04 -0000 1.18 @@ -165,63 +165,12 @@ get_cc_pos() { CCPos *p = malloc(sizeof(CCPos)); - char *locfn = malloc(PATH_MAX); - XmlReadHandle *h; - XmlEntry *tmp; - FILE *fp; - - p->x = -50; - p->y = -50; - p->width = -50; - p->height = -50; - - snprintf(locfn, PATH_MAX, DEF_CC_CONFIG_LOC, getenv("HOME")); - - fp = fopen(locfn, "r"); - if (fp == NULL) { - free(locfn); - p->x = 0; - p->y = 0; - p->width = 250; - p->height = 250; - return (p); - } else { - fclose(fp); - } - h = xml_read(locfn); - while (h->cur != NULL) { - tmp = xml_read_entry_get_entry(h); - if (!strcmp(tmp->name, "x")) { - if (tmp->value != NULL) - p->x = atoi(tmp->value); - else - p->x = 0; - } else if (!strcmp(tmp->name, "y")) { - if (tmp->value != NULL) - p->y = atoi(tmp->value); - else - p->y = 0; - } else if (!strcmp(tmp->name, "width")) { - if (tmp->value != NULL) - p->width = atoi(tmp->value); - else - p->width = 250; - } else if (!strcmp(tmp->name, "height")) { - if (tmp->value != NULL) - p->height = atoi(tmp->value); - else - p->height = 250; - } - free_xmlentry(tmp); - if (p->x != -50 && p->y != -50 && p->width != -50 && - p->height != -50) - break; - xml_read_next_entry(h); - } - xml_read_end(h); + p->x = ecore_config_int_get("controlcentre.x"); + p->y = ecore_config_int_get("controlcentre.y"); + p->width = ecore_config_int_get("controlcentre.w"); + p->height = ecore_config_int_get("controlcentre.h"); - free(locfn); return (p); } @@ -235,27 +184,19 @@ void set_cc_pos() { - char *locfn = malloc(PATH_MAX); - XmlWriteHandle *p; int x, y, width, height; if (controlcentre == NULL) { - free(locfn); return; } ecore_evas_geometry_get(controlcentre->win, &x, &y, &width, &height); - snprintf(locfn, PATH_MAX, DEF_CC_CONFIG_LOC, getenv("HOME")); - p = xml_write(locfn); - - xml_write_append_entry_int(p, "x", x); - xml_write_append_entry_int(p, "y", y); - xml_write_append_entry_int(p, "width", width); - xml_write_append_entry_int(p, "height", height); + ecore_config_int_set("controlcentre.x", x); + ecore_config_int_set("controlcentre.y", y); + ecore_config_int_set("controlcentre.w", width); + ecore_config_int_set("controlcentre.h", height); - xml_write_end(p); - free(locfn); return; } =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/main.c,v retrieving revision 1.18 retrieving revision 1.19 diff -u -3 -r1.18 -r1.19 --- main.c 6 Oct 2004 17:12:34 -0000 1.18 +++ main.c 9 Oct 2004 16:04:04 -0000 1.19 @@ -28,6 +28,7 @@ { char *spec_conf; int note_count; + DIR *dir; /* IPC Check */ ecore_ipc_init(); @@ -54,6 +55,8 @@ dml("Successfully Read Configurations and Usage", 1); + process_note_storage_locations(); + if (find_server() == 0) { dml("Server wasn't found.. Creating one", 1); /* Setup Server */ =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/note.c,v retrieving revision 1.39 retrieving revision 1.40 diff -u -3 -r1.39 -r1.40 --- note.c 8 Oct 2004 20:44:40 -0000 1.39 +++ note.c 9 Oct 2004 16:04:04 -0000 1.40 @@ -341,38 +341,32 @@ void configure_scrollbars_default(Ewl_Widget * pane) { - ewl_theme_data_str_set(pane, - "/vscrollbar/button_increment/file", NULL); - ewl_theme_data_str_set(pane, - "/vscrollbar/button_decrement/file", NULL); + ewl_theme_data_str_set(pane, "/vscrollbar/button_increment/file", NULL); + ewl_theme_data_str_set(pane, "/vscrollbar/button_decrement/file", NULL); ewl_theme_data_str_set(pane, "/vscrollbar/vseeker/file", NULL); ewl_theme_data_str_set(pane, "/vscrollbar/vseeker/button/file", NULL); - ewl_theme_data_str_set(pane, - "/hscrollbar/button_increment/file", NULL); - ewl_theme_data_str_set(pane, - "/hscrollbar/button_decrement/file", NULL); + ewl_theme_data_str_set(pane, "/hscrollbar/button_increment/file", NULL); + ewl_theme_data_str_set(pane, "/hscrollbar/button_decrement/file", NULL); ewl_theme_data_str_set(pane, "/hscrollbar/hseeker/file", NULL); ewl_theme_data_str_set(pane, "/hscrollbar/hseeker/button/file", NULL); ewl_theme_data_str_set(pane, - "/vscrollbar/button_increment/group",NULL); + "/vscrollbar/button_increment/group", NULL); ewl_theme_data_str_set(pane, - "/vscrollbar/button_decrement/group",NULL); + "/vscrollbar/button_decrement/group", NULL); - ewl_theme_data_str_set(pane, "/vscrollbar/vseeker/group",NULL); + ewl_theme_data_str_set(pane, "/vscrollbar/vseeker/group", NULL); - ewl_theme_data_str_set(pane, - "/vscrollbar/vseeker/button/group",NULL); + ewl_theme_data_str_set(pane, "/vscrollbar/vseeker/button/group", NULL); ewl_theme_data_str_set(pane, - "/hscrollbar/button_increment/group",NULL); + "/hscrollbar/button_increment/group", NULL); ewl_theme_data_str_set(pane, - "/hscrollbar/button_decrement/group",NULL); + "/hscrollbar/button_decrement/group", NULL); - ewl_theme_data_str_set(pane, "/hscrollbar/hseeker/group",NULL); + ewl_theme_data_str_set(pane, "/hscrollbar/hseeker/group", NULL); - ewl_theme_data_str_set(pane, - "/hscrollbar/hseeker/button/group",NULL); + ewl_theme_data_str_set(pane, "/hscrollbar/hseeker/button/group", NULL); return; } @@ -657,8 +651,8 @@ /* FIXME: What the fuck is happening when * we enable this?: */ // configure_scrollbars(note->pane,edjefn); - }else{ -// configure_scrollbars_default(note->pane); + } else { +// configure_scrollbars_default(note->pane); } } working = get_cycle_next_note(working); =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/note.h,v retrieving revision 1.18 retrieving revision 1.19 diff -u -3 -r1.18 -r1.19 --- note.h 8 Oct 2004 20:44:40 -0000 1.18 +++ note.h 9 Oct 2004 16:04:05 -0000 1.19 @@ -102,7 +102,7 @@ void setup_note(Evas_List ** note, int x, int y, int width, int height, char *content); void configure_scrollbars(Ewl_Widget * pane, char *edjefn); -void configure_scrollbars_default(Ewl_Widget *pane); +void configure_scrollbars_default(Ewl_Widget * pane); /* Menu Callbacks */ void cb_menu_rightclick(Note * p, Evas * e, Evas_Object * obj, =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/saveload.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- saveload.c 9 Sep 2004 11:57:30 -0000 1.16 +++ saveload.c 9 Oct 2004 16:04:05 -0000 1.17 @@ -398,21 +398,28 @@ void fill_load_tree(void) { - NoteStor *p; - XmlReadHandle *r; - - r = stor_cycle_begin(); - - if (r != NULL) { - while (r->cur != NULL) { - p = stor_cycle_get_notestor(r); - setup_load_opt(load->tree, - get_title_by_content(p->content)); - free_note_stor(p); - stor_cycle_next(r); + /* FIXME: These loops using open and read aren't working! */ + DIR *dir; + struct dirent *p; + char *target = malloc(PATH_MAX); + char *targetf = malloc(PATH_MAX); + struct stat buf; + + sprintf(target, "%s/.e/apps/enotes/notes", getenv("HOME")); + if ((dir = opendir(target)) != NULL) { + + while ((p = readdir(dir)) != NULL) { + sprintf(targetf, "%s/%s", target, p->d_name); + stat(targetf, &buf); + if (S_ISREG(buf.st_mode)) { + setup_load_opt(load->tree, p->d_name); + } } - stor_cycle_end(r); + closedir(dir); } + + free(targetf); + free(target); return; } @@ -432,6 +439,7 @@ (void *) ewl_load_listitem_click, NULL); ewl_widget_show(capt); ewl_tree_row_add((Ewl_Tree *) tree, 0, &capt); + return; } @@ -480,28 +488,16 @@ void ewl_load_load(Ewl_Widget * o, void *ev_data, void *null) { - NoteStor *p; - XmlReadHandle *r; - char *tmp; + char *p = malloc(PATH_MAX); dml("Loading Saved Note", 2); - - r = stor_cycle_begin(); - - if (r != NULL) { - while (r->cur != NULL) { - p = stor_cycle_get_notestor(r); - tmp = get_title_by_content(p->content); - if (!strcmp(tmp, load_selected)) - new_note_with_values(p->x, p->y, p->width, - p->height, p->content); - if (tmp != NULL) - free(tmp); - free_note_stor(p); - stor_cycle_next(r); - } - stor_cycle_end(r); + if (load_selected == NULL) { + free(p); + return; } + sprintf(p, "%s/.e/apps/enotes/notes/%s", getenv("HOME"), load_selected); + note_load(p); + free(p); return; } @@ -533,34 +529,14 @@ void ewl_load_delete(Ewl_Widget * o, void *ev_data, void *null) { - NoteStor *p; - XmlReadHandle *r; - char *tmp = NULL; + char *p = malloc(PATH_MAX); dml("Deleting Saved Note", 2); + sprintf(p, "%s/.e/apps/enotes/notes/%s", getenv("HOME"), load_selected); + unlink(p); - r = stor_cycle_begin(); - if (r != NULL) { - while (r->cur != NULL) { - p = stor_cycle_get_notestor(r); - tmp = get_title_by_content(p->content); - if (!strcmp(tmp, load_selected)) { - if (tmp != NULL) - free(tmp); - break; - } - if (tmp != NULL) - free(tmp); - free_note_stor(p); - stor_cycle_next(r); - } - } - - stor_cycle_end(r); - remove_note_stor(p); - - free_note_stor(p); ewl_load_revert(NULL, NULL, NULL); + free(p); return; } =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/saveload.h,v retrieving revision 1.8 retrieving revision 1.9 diff -u -3 -r1.8 -r1.9 --- saveload.h 24 Aug 2004 19:20:19 -0000 1.8 +++ saveload.h 9 Oct 2004 16:04:05 -0000 1.9 @@ -17,6 +17,11 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> #include <Ecore.h> #include <Ecore_Evas.h> =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/storage.c,v retrieving revision 1.10 retrieving revision 1.11 diff -u -3 -r1.10 -r1.11 --- storage.c 24 Sep 2004 16:19:48 -0000 1.10 +++ storage.c 9 Oct 2004 16:04:05 -0000 1.11 @@ -53,56 +53,22 @@ void append_autosave_note_stor(NoteStor * p) { - Evas_List *list; - Evas_List *lt; - XmlReadHandle *r; - XmlWriteHandle *w; - XmlEntry *e; - char *fn; - char *value; - char *val; - - list = NULL; - - /* Making the strings */ - value = get_value_from_notestor(p); - fn = make_autosave_fn(); - - /* Read */ - r = xml_read(fn); - if (r != NULL) { - while (r->cur != NULL) { - e = xml_read_entry_get_entry(r); - list = evas_list_append(list, strdup(e->value)); - free_xmlentry(e); - xml_read_next_entry(r); - } - xml_read_end(r); - } else { - list = NULL; + char *target = malloc(PATH_MAX); + char *title; + char *string = get_value_from_notestor(p); + FILE *fp; + + title = get_title_by_content(p->content); + sprintf(target, "%s/.e/apps/enotes/autosave/%s", getenv("HOME"), title); + free(title); + + if ((fp = fopen(target, "w")) != NULL) { + fputs(string, fp); + fclose(fp); } - /* Write */ - w = xml_write(fn); - if (list != NULL) { - lt = list; - while (lt != NULL) { - xml_write_append_entry(w, "NoteStor", - (char *) evas_list_data(lt)); - free(evas_list_data(lt)); - list = evas_list_remove(lt, evas_list_data(lt)); - lt = evas_list_next(lt); - } - } - val = get_value_from_notestor(p); - xml_write_append_entry(w, "NoteStor", val); - free(val); - xml_write_end(w); - - /* Leaving */ - evas_list_free(list); - free(value); - free(fn); + free(string); + free(target); return; } @@ -114,56 +80,28 @@ void append_note_stor(NoteStor * p) { - Evas_List *list; - Evas_List *lt; - XmlReadHandle *r; - XmlWriteHandle *w; - XmlEntry *e; - char *fn; - char *value; - char *val; - - list = NULL; - - /* Making the strings */ - value = get_value_from_notestor(p); - fn = make_storage_fn(); - - /* Read */ - r = xml_read(fn); - if (r != NULL) { - while (r->cur != NULL) { - e = xml_read_entry_get_entry(r); - list = evas_list_append(list, strdup(e->value)); - free_xmlentry(e); - xml_read_next_entry(r); + char *target = malloc(PATH_MAX); + char *title; + char *string = get_value_from_notestor(p); + FILE *fp; + + title = get_title_by_content(p->content); + sprintf(target, "%s/.e/apps/enotes/notes/%s", getenv("HOME"), title); + free(title); + + if ((fp = fopen(target, "r")) == NULL) { + if ((fp = fopen(target, "w")) != NULL) { + fputs(string, fp); + fclose(fp); } - xml_read_end(r); } else { - list = NULL; + fclose(fp); + msgbox("Note Already Exists", + "Unable to save note because a note with the same title exists.\nPlease delete this note first."); } - /* Write */ - w = xml_write(fn); - if (list != NULL) { - lt = list; - while (lt != NULL) { - xml_write_append_entry(w, "NoteStor", - (char *) evas_list_data(lt)); - free(evas_list_data(lt)); - list = evas_list_remove(lt, evas_list_data(lt)); - lt = evas_list_next(lt); - } - } - val = get_value_from_notestor(p); - xml_write_append_entry(w, "NoteStor", val); - free(val); - xml_write_end(w); - - /* Leaving */ - evas_list_free(list); - free(value); - free(fn); + free(string); + free(target); return; } @@ -175,154 +113,78 @@ void remove_note_stor(NoteStor * p) { - Evas_List *list; - Evas_List *lt; - XmlReadHandle *r; - XmlWriteHandle *w; - XmlEntry *e; - NoteStor *tmp; - char *fn; - char *value; - char *val; - char *tmpstr; - - list = NULL; - - /* Making the strings */ - value = get_value_from_notestor(p); - fn = make_storage_fn(); - - /* Read */ - r = xml_read(fn); - if (r != NULL) { - while (r->cur != NULL) { - e = xml_read_entry_get_entry(r); - tmpstr = strdup(e->value); - tmp = get_notestor_from_value(tmpstr); - free(tmpstr); - if (strcmp(p->content, tmp->content)) { - list = evas_list_append(list, strdup(e->value)); - } - free_note_stor(tmp); - free_xmlentry(e); - xml_read_next_entry(r); - } - xml_read_end(r); - } else { - list = NULL; - } - - /* Write */ - w = xml_write(fn); - if (list != NULL) { - lt = list; - while (lt != NULL) { - xml_write_append_entry(w, "NoteStor", - (char *) evas_list_data(lt)); - free(evas_list_data(lt)); - list = evas_list_remove(lt, evas_list_data(lt)); - lt = evas_list_next(lt); - } - } - xml_write_end(w); - - /* Leaving */ - evas_list_free(list); - free(value); - free(fn); - return; -} + char *target = malloc(PATH_MAX); + char *title; + title = get_title_by_content(p->content); + sprintf(target, "%s/.e/apps/enotes/notes/%s", getenv("HOME"), title); + free(title); -/* Cycle Functions */ + unlink(target); -/** - * @return: The XmlReadHandle for the beginning of the storage cycle. - * @brief: Returns a handle for the beginning of the storage cycle (reading). - */ -XmlReadHandle * -stor_cycle_begin(void) -{ - char *p; - XmlReadHandle *retval; - - p = make_storage_fn(); - retval = xml_read(p); - free(p); - return (retval); + free(target); + return; } -/** - * @return: The XmlReadHandle for the beginning of the autosave storage cycle. - * @brief: Begins the storage cycle for the autosave storage and returns a read - * handle. - */ -XmlReadHandle * -stor_cycle_begin_autosave(void) +void +note_load(char *target) { - char *p; - XmlReadHandle *retval; + FILE *fp; + NoteStor *p; + char *str = malloc(NOTE_LIMIT); + char *fullstr = malloc(NOTE_LIMIT * 2); - p = make_autosave_fn(); - retval = xml_read(p); - free(p); - return (retval); -} + sprintf(fullstr, ""); + if ((fp = fopen(target, "r")) != NULL) { + while ((str = fgets(str, NOTE_LIMIT, fp)) != NULL) { + sprintf(fullstr, "%s%s", fullstr, str); + } + if (strcmp("", fullstr)) + if ((p = get_notestor_from_value(fullstr)) != NULL) + new_note_with_values(p->x, p->y, p->width, + p->height, p->content); + } -/** - * @param p: The read handle which is to be ended and free'd. - * @brief: Ends and free's a storage cycle. - */ -void -stor_cycle_end(XmlReadHandle * p) -{ - xml_read_end(p); + free(str); + free(fullstr); + if (p != NULL) + free_note_stor(p); return; } -/** - * @param p: The cycle handle to move forward in. - * @brief: Move forward in the cycle (next note). - */ void -stor_cycle_next(XmlReadHandle * p) +process_note_storage_locations() { - xml_read_next_entry(p); - return; -} - -/** - * @param p: The cycle handle to move backwards in. - * @brief: Moves backwards in the cycle (previous note). - */ -void -stor_cycle_prev(XmlReadHandle * p) -{ - xml_read_prev_entry(p); - return; -} + DIR *p; + char *f = malloc(PATH_MAX); + sprintf(f, "%s/.e/apps/enotes/notes", getenv("HOME")); + if ((p = opendir(f)) == NULL) { + dml("Note Storage Location Doesn't Exist; Creating...", 1); + if (mkdir(f, (mode_t) 0755) == -1) + dml("Unable to Create Storage Location. Expect problems!", 1); + } else { + dml("Note Storage Location Found", 1); + closedir(p); + } -/** - * @param p: The handle to get the current notestor from. - * @return: The notestor requested, allocated and with values. - * Needs free'ing. - * @brief: Obtains the NoteStor information from the current stage - * in the supplied handle. - */ -NoteStor * -stor_cycle_get_notestor(XmlReadHandle * p) -{ - NoteStor *h; - XmlEntry *info; + sprintf(f, "%s/.e/apps/enotes/autosave", getenv("HOME")); + if ((p = opendir(f)) == NULL) { + dml("Note Autosave Storage Location Doesn't Exist; Creating...", + 1); + if (mkdir(f, (mode_t) 0755) == -1) + dml("Unable to Create Autosave Storage Location. Expect problems!", 1); + } else { + dml("Note Autosave Storage Location Found", 1); + closedir(p); + } - info = xml_read_entry_get_entry(p); - h = get_notestor_from_value(info->value); - free(info); - return (h); + free(f); + return; } + /* Autosave Functions */ /** @@ -330,27 +192,28 @@ */ int autoload(void) -{ - XmlReadHandle *r; - NoteStor *p; - int count; - - dml("Autoloading Saved Notes", 1); - - count = 0; - r = stor_cycle_begin_autosave(); - if (r != NULL) { - while (r->cur != NULL) { - p = stor_cycle_get_notestor(r); - new_note_with_values(p->x, p->y, p->width, p->height, - p->content); - free_note_stor(p); - stor_cycle_next(r); - count++; +{ /* FIXME: Rewrite using dirents */ + DIR *dir; + struct dirent *p; + char *target = malloc(PATH_MAX); + char *targetf = malloc(PATH_MAX); + struct stat buf; + + sprintf(target, "%s/.e/apps/enotes/autosave", getenv("HOME")); + if ((dir = opendir(target)) != NULL) { + + while ((p = readdir(dir)) != NULL) { + sprintf(targetf, "%s/%s", target, p->d_name); + stat(targetf, &buf); + if (S_ISREG(buf.st_mode)) { + note_load(targetf); + } } - stor_cycle_end(r); + closedir(dir); } - return count; + + free(targetf); + free(target); } /** @@ -363,15 +226,38 @@ Note *note; Evas_List *tmp = gbl_notes; NoteStor *n; - XmlWriteHandle *p; - char *pp; + char *path = malloc(PATH_MAX); + char *work = malloc(PATH_MAX); + DIR *dir; + struct dirent *d; + struct stat buf; dml("Autosaving", 1); - pp = make_autosave_fn(); - p = xml_write(pp); - xml_write_end(p); - free(pp); + sprintf(path, "%s/.e/apps/enotes/autosave", getenv("HOME")); + + if ((dir = opendir(path)) != NULL) { + while ((d = readdir(dir)) != NULL) { + sprintf(work, "%s/%s", path, d->d_name); + stat(work, &buf); + if (S_ISREG(buf.st_mode)) { + unlink(work); + } + } + closedir(dir); + } + + if (rmdir(path) != -1) { + if (mkdir(path, 0755) != -1) { + dml("Successfully Cleaned the Autosaves", 1); + } else { + dml("Error Recreating Autosave Directory", 1); + } + } else { + dml("Error Removing the Autosave Location", 1); + } + free(path); + free(work); while (tmp != NULL) { note = evas_list_data(tmp); @@ -387,40 +273,14 @@ tmp = evas_list_next(tmp); } + dml("Autosaved Notes", 1); + return; } /* Internal Functions */ /** - * @return: The storage file location string. - * @brief: Builds up a string containing the location of the storage - * xml file. - */ -char * -make_storage_fn(void) -{ - char *p = malloc(PATH_MAX); - - snprintf(p, PATH_MAX, DEF_STORAGE_LOC, getenv("HOME")); - return (p); -} - -/** - * @return: The storage file location string (autosave). - * @brief: Builds up a string containing the location of the autosave - * storage xml file. - */ -char * -make_autosave_fn(void) -{ - char *p = malloc(PATH_MAX); - - snprintf(p, PATH_MAX, DEF_AUTOSAVE_LOC, getenv("HOME")); - return (p); -} - -/** * @param e: The value to parse and build a notestor from. * @return: The built NoteStor structure (needs free'ing). * @brief: Parses e and builds a NoteStor structure, then returns it. =================================================================== RCS file: /cvsroot/enlightenment/misc/enotes/src/storage.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- storage.h 24 Sep 2004 16:19:48 -0000 1.5 +++ storage.h 9 Oct 2004 16:04:05 -0000 1.6 @@ -18,17 +18,20 @@ #include <stdlib.h> #include <string.h> #include <limits.h> +#include <unistd.h> + +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> #include <Evas.h> // For the list structures. -#include "xml.h" #include "note.h" #include "debug.h" -#define DEF_STORAGE_LOC "%s/.e/notes/notes.xml" -#define DEF_AUTOSAVE_LOC "%s/.e/notes/autosave.xml" #define DEF_VALUE_SEPERATION "|" #define MAX_VALUE 2000 +#define NOTE_LIMIT 9999 typedef struct { char *content; @@ -46,18 +49,11 @@ void append_note_stor(NoteStor * p); void append_autosave_note_stor(NoteStor * p); void remove_note_stor(NoteStor * p); +void process_note_storage_locations(); -/* Cycle Functions */ -XmlReadHandle *stor_cycle_begin(void); -XmlReadHandle *stor_cycle_begin_autosave(void); -void stor_cycle_end(XmlReadHandle * p); - -void stor_cycle_next(XmlReadHandle * p); -void stor_cycle_prev(XmlReadHandle * p); - -NoteStor *stor_cycle_get_notestor(XmlReadHandle * p); /* Autosave Functions */ +void note_load(char *target); int autoload(void); void autosave(void); ------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ enlightenment-cvs mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs