From: Art Cancro Date: Tue, 6 May 2008 21:04:59 +0000 (+0000) Subject: Completed 'Add New Note'. The new sticky notes view X-Git-Tag: v7.86~2283 X-Git-Url: https://code.citadel.org/?p=citadel.git;a=commitdiff_plain;h=b3fa5714bd660e14c15705225f06e62cd1942e7c Completed 'Add New Note'. The new sticky notes view is now fully operational, although there are still a few tweaks I still want to make (such as the ability to change a note's color -- it will display any color it's told to but there's not yet a button to change it. --- diff --git a/webcit/notes.c b/webcit/notes.c index b4a08b469..e77982d2e 100644 --- a/webcit/notes.c +++ b/webcit/notes.c @@ -162,6 +162,26 @@ struct vnote *vnote_new_from_msg(long msgnum) { } +/* + * Serialize a vnote and write it to the server + */ +void write_vnote_to_server(struct vnote *v) +{ + char buf[1024]; + + serv_puts("ENT0 1|||4"); + serv_getln(buf, sizeof buf); + if (buf[0] == '4') { + serv_puts("Content-type: text/vnote"); + serv_puts(""); + serv_puts(vnote_serialize(v)); + serv_puts("000"); + } +} + + + + /* * Background ajax call to receive updates from the browser when a note is moved, resized, or updated. */ @@ -229,14 +249,7 @@ void ajax_update_note(void) { } /* Serialize it and save it to the message base. Server will delete the old one. */ - serv_puts("ENT0 1|||4"); - serv_getln(buf, sizeof buf); - if (buf[0] == '4') { - serv_puts("Content-type: text/vnote"); - serv_puts(""); - serv_puts(vnote_serialize(v)); - serv_puts("000"); - } + write_vnote_to_server(v); begin_ajax_response(); if (v->body) { @@ -275,3 +288,22 @@ void display_note(long msgnum, int unread) { } } + + +/* + * Create a new note + */ +void add_new_note(void) { + struct vnote *v; + + v = vnote_new(); + if (v) { + v->uid = malloc(128); + generate_uuid(v->uid); + v->body = strdup(_("Click on any note to edit it.")); + write_vnote_to_server(v); + vnote_free(v); + } + + readloop("readfwd"); +} diff --git a/webcit/roomops.c b/webcit/roomops.c index e9a25ddc9..d8a3d7c5f 100644 --- a/webcit/roomops.c +++ b/webcit/roomops.c @@ -667,7 +667,7 @@ void embed_room_banner(char *got, int navbar_style) { case VIEW_NOTES: wprintf( "
  • " - "" + "" "" "%s" diff --git a/webcit/webcit.c b/webcit/webcit.c index 7aefacf22..d16258f74 100644 --- a/webcit/webcit.c +++ b/webcit/webcit.c @@ -2063,6 +2063,8 @@ void session_loop(struct httprequest *req) dump_vars(); wprintf("
    \n"); wDumpContent(1); + } else if (!strcasecmp(action, "add_new_note")) { + add_new_note(); } else if (!strcasecmp(action, "ajax_update_note")) { ajax_update_note(); } else if (!strcasecmp(action, "display_room_directory")) { diff --git a/webcit/webcit.h b/webcit/webcit.h index bec5aa6c1..74e161428 100644 --- a/webcit/webcit.h +++ b/webcit/webcit.h @@ -694,6 +694,7 @@ void cal_process_attachment(char *part_source, long msgnum, char *cal_partnum); void display_calendar(long msgnum, int unread); void display_task(long msgnum, int unread); void display_note(long msgnum, int unread); +void add_new_note(void); void updatenote(void); void ajax_update_note(void); void do_calendar_view(void);