X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=webcit%2Fnotes.c;h=e77982d2e96e1e39ee8416143d2d6e5f6decbef9;hb=b3fa5714bd660e14c15705225f06e62cd1942e7c;hp=b4a08b469d14cda35049f6dfc3e570224cb09205;hpb=add79b79bcc86d61a2f8661103f7fce6d554f45c;p=citadel.git 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"); +}