4 * vNote implementation for Citadel
6 * Copyright (C) 1999-2007 by the citadel.org development team.
7 * This code is freely redistributable under the terms of the GNU General
8 * Public License. All other rights reserved.
18 #if TIME_WITH_SYS_TIME
19 # include <sys/time.h>
23 # include <sys/time.h>
34 #include <libcitadel.h>
37 /* move this into the header file when we're done */
38 #define CTDL_VNOTE_MAGIC 0xa1fa
54 struct vnote *vnote_new(void) {
57 v = (struct vnote *) malloc(sizeof(struct vnote));
59 memset(v, 0, sizeof(struct vnote));
60 v->magic = CTDL_VNOTE_MAGIC;
61 v->pos_left = rand() % 256;
62 v->pos_top = rand() % 256;
66 v->color_green = 0xFF;
72 struct vnote *vnote_new_from_str(char *s) {
78 /* FIXME finish this */
81 void vnote_free(struct vnote *v) {
83 if (v->magic != CTDL_VNOTE_MAGIC) return;
85 if (v->uid) free(v->uid);
86 if (v->summary) free(v->summary);
87 if (v->body) free(v->body);
89 memset(v, 0, sizeof(struct vnote));
93 char *vnote_serialize(struct vnote *v) {
98 if (v->magic != CTDL_VNOTE_MAGIC) return NULL;
101 if (v->summary) bytes_needed += strlen(v->summary);
102 if (v->body) bytes_needed += strlen(v->body);
103 s = malloc(bytes_needed);
106 strcpy(s, "BEGIN:vnote\r\n"
108 "PRODID://Citadel//vNote handler library//EN\r\n"
117 strcat(s, "END:vnote\r\n");
122 #ifdef VNOTE_TEST_HARNESS
124 char *bynari_sample =
127 "PRODID://Bynari Insight Connector 3.1.3-0605191//Import from Outlook//EN\n"
129 "UID:040000008200E00074C5B7101A82E00800000000000000000000000000820425CE8571864B8D141CB3FB8CAC62\n"
130 "NOTE;ENCODING=QUOTED-PRINTABLE:blah blah blah=0D=0A=0D=0A\n"
131 "SUMMARY:blah blah blah=0D=0A=0D=0A\n"
132 "X-OUTLOOK-COLOR:#FFFF00\n"
133 "X-OUTLOOK-WIDTH:200\n"
134 "X-OUTLOOK-HEIGHT:166\n"
135 "X-OUTLOOK-LEFT:80\n"
137 "X-OUTLOOK-CREATE-TIME:20070611T204615Z\n"
138 "REV:20070611T204621Z\n"
145 "UID:20061129111109.7chx73xdok1s at 172.16.45.2\n"
147 "DCREATED:20061129T101109Z\n"
156 v = vnote_new_from_str(bynari_sample);
157 s = vnote_serialize(v);