-rw-r--r-- | library/backend/vobject.cpp | 273 |
1 files changed, 146 insertions, 127 deletions
diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp index 2c5b577..b6d17dc 100644 --- a/library/backend/vobject.cpp +++ b/library/backend/vobject.cpp | |||
@@ -1,44 +1,44 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | (C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International | 2 | (C) Copyright 1996 Apple Computer, Inc., AT&T Corp., International |
3 | Business Machines Corporation and Siemens Rolm Communications Inc. | 3 | Business Machines Corporation and Siemens Rolm Communications Inc. |
4 | 4 | ||
5 | For purposes of this license notice, the term Licensors shall mean, | 5 | For purposes of this license notice, the term Licensors shall mean, |
6 | collectively, Apple Computer, Inc., AT&T Corp., International | 6 | collectively, Apple Computer, Inc., AT&T Corp., International |
7 | Business Machines Corporation and Siemens Rolm Communications Inc. | 7 | Business Machines Corporation and Siemens Rolm Communications Inc. |
8 | The term Licensor shall mean any of the Licensors. | 8 | The term Licensor shall mean any of the Licensors. |
9 | 9 | ||
10 | Subject to acceptance of the following conditions, permission is hereby | 10 | Subject to acceptance of the following conditions, permission is hereby |
11 | granted by Licensors without the need for written agreement and without | 11 | granted by Licensors without the need for written agreement and without |
12 | license or royalty fees, to use, copy, modify and distribute this | 12 | license or royalty fees, to use, copy, modify and distribute this |
13 | software for any purpose. | 13 | software for any purpose. |
14 | 14 | ||
15 | The above copyright notice and the following four paragraphs must be | 15 | The above copyright notice and the following four paragraphs must be |
16 | reproduced in all copies of this software and any software including | 16 | reproduced in all copies of this software and any software including |
17 | this software. | 17 | this software. |
18 | 18 | ||
19 | THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE | 19 | THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS AND NO LICENSOR SHALL HAVE |
20 | ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR | 20 | ANY OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR |
21 | MODIFICATIONS. | 21 | MODIFICATIONS. |
22 | 22 | ||
23 | IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, | 23 | IN NO EVENT SHALL ANY LICENSOR BE LIABLE TO ANY PARTY FOR DIRECT, |
24 | INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT | 24 | INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOST PROFITS ARISING OUT |
25 | OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH | 25 | OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE POSSIBILITY OF SUCH |
26 | DAMAGE. | 26 | DAMAGE. |
27 | 27 | ||
28 | EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, | 28 | EACH LICENSOR SPECIFICALLY DISCLAIMS ANY WARRANTIES, EXPRESS OR IMPLIED, |
29 | INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE | 29 | INCLUDING BUT NOT LIMITED TO ANY WARRANTY OF NONINFRINGEMENT OR THE |
30 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | 30 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
31 | PURPOSE. | 31 | PURPOSE. |
32 | 32 | ||
33 | The software is provided with RESTRICTED RIGHTS. Use, duplication, or | 33 | The software is provided with RESTRICTED RIGHTS. Use, duplication, or |
34 | disclosure by the government are subject to restrictions set forth in | 34 | disclosure by the government are subject to restrictions set forth in |
35 | DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | 35 | DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. |
36 | 36 | ||
37 | ***************************************************************************/ | 37 | ***************************************************************************/ |
38 | 38 | ||
39 | /* | 39 | /* |
40 | * src: vobject.c | 40 | * src: vobject.c |
41 | * doc: vobject and APIs to construct vobject, APIs pretty print | 41 | * doc: vobject and APIs to construct vobject, APIs pretty print |
42 | * vobject, and convert a vobject into its textual representation. | 42 | * vobject, and convert a vobject into its textual representation. |
43 | */ | 43 | */ |
44 | 44 | ||
@@ -46,8 +46,9 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | |||
46 | #include <malloc.h> | 46 | #include <malloc.h> |
47 | #endif | 47 | #endif |
48 | 48 | ||
49 | #include <qtopia/private/vobject_p.h> | 49 | #include <qtopia/config.h> |
50 | #include <qtopia/private/qfiledirect_p.h> | 50 | #include "vobject_p.h" |
51 | #include "qfiledirect_p.h" | ||
51 | #include <string.h> | 52 | #include <string.h> |
52 | #include <stdio.h> | 53 | #include <stdio.h> |
53 | #include <fcntl.h> | 54 | #include <fcntl.h> |
@@ -62,6 +63,10 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | |||
62 | #define ANY_VALUE_OF(o) o->val.any | 63 | #define ANY_VALUE_OF(o) o->val.any |
63 | #define VOBJECT_VALUE_OF(o) o->val.vobj | 64 | #define VOBJECT_VALUE_OF(o) o->val.vobj |
64 | 65 | ||
66 | static char vobj_cs[10]; | ||
67 | static enum { EightBit, QuotedPrintable, Base64 } vobj_enc=EightBit; | ||
68 | static const char *vobj_enc_s=0; | ||
69 | |||
65 | typedef union ValueItem { | 70 | typedef union ValueItem { |
66 | const char *strs; | 71 | const char *strs; |
67 | unsigned int i; | 72 | unsigned int i; |
@@ -86,7 +91,7 @@ struct StrItem { | |||
86 | unsigned int refCnt; | 91 | unsigned int refCnt; |
87 | }; | 92 | }; |
88 | 93 | ||
89 | const char** fieldedProp; | 94 | DLLEXPORT(const char**) fieldedProp; |
90 | 95 | ||
91 | 96 | ||
92 | 97 | ||
@@ -327,18 +332,18 @@ DLLEXPORT(VObject*) setValueWithSize(VObject *prop, void *val, unsigned int size | |||
327 | 332 | ||
328 | DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o) | 333 | DLLEXPORT(void) initPropIterator(VObjectIterator *i, VObject *o) |
329 | { | 334 | { |
330 | i->start = o->prop; | 335 | i->start = o->prop; |
331 | i->next = 0; | 336 | i->next = 0; |
332 | } | 337 | } |
333 | 338 | ||
334 | DLLEXPORT(void) initVObjectIterator(VObjectIterator *i, VObject *o) | 339 | DLLEXPORT(void) initVObjectIterator(VObjectIterator *i, VObject *o) |
335 | { | 340 | { |
336 | i->start = o->next; | 341 | i->start = o->next; |
337 | i->next = 0; | 342 | i->next = 0; |
338 | } | 343 | } |
339 | 344 | ||
340 | DLLEXPORT(int) moreIteration(VObjectIterator *i) | 345 | DLLEXPORT(int) moreIteration(VObjectIterator *i) |
341 | { | 346 | { |
342 | return (i->start && (i->next==0 || i->next!=i->start)); | 347 | return (i->start && (i->next==0 || i->next!=i->start)); |
343 | } | 348 | } |
344 | 349 | ||
@@ -403,7 +408,7 @@ DLLEXPORT(VObject*) addGroup(VObject *o, const char *g) | |||
403 | t = addProp(t,VCGroupingProp); | 408 | t = addProp(t,VCGroupingProp); |
404 | setVObjectStringZValue(t,lookupProp_(n)); | 409 | setVObjectStringZValue(t,lookupProp_(n)); |
405 | } while (n != gs); | 410 | } while (n != gs); |
406 | deleteStr(gs); | 411 | deleteStr(gs); |
407 | return p; | 412 | return p; |
408 | } | 413 | } |
409 | else | 414 | else |
@@ -799,12 +804,12 @@ static struct PreDefProp* lookupPropInfo(const char* str) | |||
799 | { | 804 | { |
800 | /* brute force for now, could use a hash table here. */ | 805 | /* brute force for now, could use a hash table here. */ |
801 | int i; | 806 | int i; |
802 | 807 | ||
803 | for (i = 0; propNames[i].name; i++) | 808 | for (i = 0; propNames[i].name; i++) |
804 | if (qstricmp(str, propNames[i].name) == 0) { | 809 | if (qstricmp(str, propNames[i].name) == 0) { |
805 | return &propNames[i]; | 810 | return &propNames[i]; |
806 | } | 811 | } |
807 | 812 | ||
808 | return 0; | 813 | return 0; |
809 | } | 814 | } |
810 | 815 | ||
@@ -812,7 +817,7 @@ static struct PreDefProp* lookupPropInfo(const char* str) | |||
812 | DLLEXPORT(const char*) lookupProp_(const char* str) | 817 | DLLEXPORT(const char*) lookupProp_(const char* str) |
813 | { | 818 | { |
814 | int i; | 819 | int i; |
815 | 820 | ||
816 | for (i = 0; propNames[i].name; i++) | 821 | for (i = 0; propNames[i].name; i++) |
817 | if (qstricmp(str, propNames[i].name) == 0) { | 822 | if (qstricmp(str, propNames[i].name) == 0) { |
818 | const char* s; | 823 | const char* s; |
@@ -826,7 +831,7 @@ DLLEXPORT(const char*) lookupProp_(const char* str) | |||
826 | DLLEXPORT(const char*) lookupProp(const char* str) | 831 | DLLEXPORT(const char*) lookupProp(const char* str) |
827 | { | 832 | { |
828 | int i; | 833 | int i; |
829 | 834 | ||
830 | for (i = 0; propNames[i].name; i++) | 835 | for (i = 0; propNames[i].name; i++) |
831 | if (qstricmp(str, propNames[i].name) == 0) { | 836 | if (qstricmp(str, propNames[i].name) == 0) { |
832 | const char *s; | 837 | const char *s; |
@@ -953,6 +958,17 @@ static void appendsOFile(OFile *fp, const char *s) | |||
953 | 958 | ||
954 | #endif | 959 | #endif |
955 | 960 | ||
961 | static void appendsOFileEncCs(OFile *fp) | ||
962 | { | ||
963 | if ( vobj_enc_s ) { | ||
964 | appendsOFile(fp, ";" VCEncodingProp "="); | ||
965 | appendsOFile(fp, vobj_enc_s); | ||
966 | } | ||
967 | appendsOFile(fp, ";" VCCharSetProp "="); | ||
968 | appendsOFile(fp, vobj_cs); | ||
969 | } | ||
970 | |||
971 | |||
956 | static void initOFile(OFile *fp, FILE *ofp) | 972 | static void initOFile(OFile *fp, FILE *ofp) |
957 | { | 973 | { |
958 | fp->fp = ofp; | 974 | fp->fp = ofp; |
@@ -1005,41 +1021,20 @@ static int writeBase64(OFile *fp, unsigned char *s, long len) | |||
1005 | return 1; | 1021 | return 1; |
1006 | } | 1022 | } |
1007 | 1023 | ||
1008 | static const char *replaceChar(unsigned char c) | 1024 | static const char *qpReplaceChar(unsigned char c) |
1009 | { | 1025 | { |
1010 | if (c == '\n') { | 1026 | if (c == '\n') { |
1011 | return "=0A=\n"; | 1027 | return "=0A=\n"; |
1012 | } else if ( | 1028 | } else if ( |
1013 | (c >= 'A' && c <= 'Z') | 1029 | // RFC 1521 |
1014 | || | 1030 | (c >= 32 && c <= 60) // Note: " " not allowed at EOL |
1015 | (c >= 'a' && c <= 'z') | ||
1016 | || | ||
1017 | (c >= '0' && c <= '9') | ||
1018 | || | ||
1019 | (c >= '\'' && c <= ')') | ||
1020 | || | ||
1021 | (c >= '+' && c <= '-') | ||
1022 | || | ||
1023 | (c == '/') | ||
1024 | || | ||
1025 | (c == '?') | ||
1026 | || | 1031 | || |
1027 | (c == ' ')) | 1032 | (c >= 62 && c <= 126) |
1028 | { | 1033 | ) |
1034 | { | ||
1029 | return 0; | 1035 | return 0; |
1030 | } | 1036 | } |
1031 | 1037 | ||
1032 | #warning "Bug-Workaround must be fixed !" | ||
1033 | // IF THIS FUNCTION RETURNES TRUE, THE DATA IS EXPORTED | ||
1034 | // AS QUOTED PRINTABLE. | ||
1035 | // BUT THE PARSER IS UNABLE TO IMPORT THIS, THEREFORE | ||
1036 | // I DECIDED TO DISABLE IT UNTIL TROLLTECH FIXES THIS BUG | ||
1037 | // SEE ALSO includesUnprintable(VObject *o) | ||
1038 | // (se) | ||
1039 | |||
1040 | return 0; | ||
1041 | |||
1042 | #if 0 | ||
1043 | static char trans[4]; | 1038 | static char trans[4]; |
1044 | trans[0] = '='; | 1039 | trans[0] = '='; |
1045 | trans[3] = '\0'; | 1040 | trans[3] = '\0'; |
@@ -1057,13 +1052,12 @@ static const char *replaceChar(unsigned char c) | |||
1057 | trans[2] = 'A' + (rem - 10); | 1052 | trans[2] = 'A' + (rem - 10); |
1058 | 1053 | ||
1059 | return trans; | 1054 | return trans; |
1060 | #endif | ||
1061 | } | 1055 | } |
1062 | 1056 | ||
1063 | static void writeQPString(OFile *fp, const char *s) | 1057 | static void writeEncString(OFile *fp, const char *s, bool nosemi) |
1064 | { | 1058 | { |
1065 | /* | 1059 | /* |
1066 | only A-Z, 0-9 and | 1060 | only A-Z, 0-9 and |
1067 | "'" (ASCII code 39) | 1061 | "'" (ASCII code 39) |
1068 | "(" (ASCII code 40) | 1062 | "(" (ASCII code 40) |
1069 | ")" (ASCII code 41) | 1063 | ")" (ASCII code 41) |
@@ -1072,62 +1066,71 @@ static void writeQPString(OFile *fp, const char *s) | |||
1072 | "-" (ASCII code 45) | 1066 | "-" (ASCII code 45) |
1073 | "/" (ASCII code 47) | 1067 | "/" (ASCII code 47) |
1074 | "?" (ASCII code 63) | 1068 | "?" (ASCII code 63) |
1075 | 1069 | ||
1076 | should remain un-encoded. | 1070 | should remain un-encoded. |
1077 | '=' needs to be encoded as it is the escape character. | 1071 | '=' needs to be encoded as it is the escape character. |
1078 | ';' needs to be as it is a field separator. | 1072 | ';' needs to be as it is a field separator. |
1079 | 1073 | ||
1080 | */ | 1074 | */ |
1081 | const char *p = s; | 1075 | const char *p = s; |
1082 | while (*p) { | 1076 | switch ( vobj_enc ) { |
1083 | const char *rep = replaceChar(*p); | 1077 | case EightBit: |
1084 | if (rep) | 1078 | while (*p) { |
1085 | appendsOFile(fp, rep); | 1079 | if ( *p == '\n' || nosemi && ( *p == '\\' || *p == ';' ) ) |
1086 | else | 1080 | appendcOFile(fp, '\\'); |
1087 | appendcOFile(fp, *p); | 1081 | appendcOFile(fp, *p); |
1088 | p++; | 1082 | p++; |
1083 | } | ||
1084 | break; | ||
1085 | case QuotedPrintable: | ||
1086 | while (*p) { | ||
1087 | const char *rep = qpReplaceChar(*p); | ||
1088 | if (rep) | ||
1089 | appendsOFile(fp, rep); | ||
1090 | else if ( *p == ';' && nosemi ) | ||
1091 | appendsOFile(fp, "=3B"); | ||
1092 | else if ( *p == ' ' ) { | ||
1093 | if ( !p[1] || p[1] == '\n' ) // RFC 1521 | ||
1094 | appendsOFile(fp, "=20"); | ||
1095 | else | ||
1096 | appendcOFile(fp, *p); | ||
1097 | } else | ||
1098 | appendcOFile(fp, *p); | ||
1099 | p++; | ||
1100 | } | ||
1101 | break; | ||
1102 | case Base64: | ||
1103 | writeBase64(fp, (unsigned char*)p, strlen(p)); | ||
1104 | break; | ||
1089 | } | 1105 | } |
1090 | } | 1106 | } |
1091 | 1107 | ||
1092 | static bool includesUnprintable(VObject *o) | 1108 | static bool includesUnprintable(VObject *o) |
1093 | { | 1109 | { |
1094 | |||
1095 | #if 0 | ||
1096 | |||
1097 | // IF THIS FUNCTION RETURNES TRUE, THE DATA IS EXPORTED | ||
1098 | // AS QUOTED PRINTABLE. | ||
1099 | // BUT THE PARSER IS UNABLE TO IMPORT THIS, THEREFORE | ||
1100 | // I DECIDED TO DISABLE IT UNTIL TROLLTECH FIXES THIS BUG | ||
1101 | // SEE ALSO *replaceChar(unsigned char c) | ||
1102 | // (se) | ||
1103 | |||
1104 | if (o) { | 1110 | if (o) { |
1105 | if (VALUE_TYPE(o) == VCVT_STRINGZ) { | 1111 | if (VALUE_TYPE(o) == VCVT_STRINGZ) { |
1106 | const char *p = STRINGZ_VALUE_OF(o); | 1112 | const char *p = STRINGZ_VALUE_OF(o); |
1107 | if (p) { | 1113 | if (p) { |
1108 | while (*p) { | 1114 | while (*p) { |
1109 | if (replaceChar(*p)) | 1115 | if (*p==' ' && (!p[1] || p[1]=='\n') // RFC 1521: spaces at ends need quoting |
1116 | || qpReplaceChar(*p) ) | ||
1110 | return TRUE; | 1117 | return TRUE; |
1111 | p++; | 1118 | p++; |
1112 | } | 1119 | } |
1113 | } | 1120 | } |
1114 | } | 1121 | } |
1115 | } | 1122 | } |
1116 | |||
1117 | #endif | ||
1118 | #warning "Bug-Workaround must be fixed !" | ||
1119 | |||
1120 | return FALSE; | 1123 | return FALSE; |
1121 | } | 1124 | } |
1122 | 1125 | ||
1123 | static void writeVObject_(OFile *fp, VObject *o); | 1126 | static void writeVObject_(OFile *fp, VObject *o); |
1124 | 1127 | ||
1125 | static void writeValue(OFile *fp, VObject *o, unsigned long size) | 1128 | static void writeValue(OFile *fp, VObject *o, unsigned long size, bool nosemi) |
1126 | { | 1129 | { |
1127 | if (o == 0) return; | 1130 | if (o == 0) return; |
1128 | switch (VALUE_TYPE(o)) { | 1131 | switch (VALUE_TYPE(o)) { |
1129 | case VCVT_STRINGZ: { | 1132 | case VCVT_STRINGZ: { |
1130 | writeQPString(fp, STRINGZ_VALUE_OF(o)); | 1133 | writeEncString(fp, STRINGZ_VALUE_OF(o), nosemi); |
1131 | break; | 1134 | break; |
1132 | } | 1135 | } |
1133 | case VCVT_UINT: { | 1136 | case VCVT_UINT: { |
@@ -1160,19 +1163,17 @@ static void writeAttrValue(OFile *fp, VObject *o) | |||
1160 | struct PreDefProp *pi; | 1163 | struct PreDefProp *pi; |
1161 | pi = lookupPropInfo(NAME_OF(o)); | 1164 | pi = lookupPropInfo(NAME_OF(o)); |
1162 | if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; | 1165 | if (pi && ((pi->flags & PD_INTERNAL) != 0)) return; |
1163 | if ( includesUnprintable(o) ) { | 1166 | if ( includesUnprintable(o) ) |
1164 | appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); | 1167 | appendsOFileEncCs(fp); |
1165 | appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); | ||
1166 | } | ||
1167 | appendcOFile(fp,';'); | 1168 | appendcOFile(fp,';'); |
1168 | appendsOFile(fp,NAME_OF(o)); | 1169 | appendsOFile(fp,NAME_OF(o)); |
1169 | } | 1170 | } else { |
1170 | else | ||
1171 | appendcOFile(fp,';'); | 1171 | appendcOFile(fp,';'); |
1172 | } | ||
1172 | if (VALUE_TYPE(o)) { | 1173 | if (VALUE_TYPE(o)) { |
1173 | appendcOFile(fp,'='); | 1174 | appendcOFile(fp,'='); |
1174 | writeValue(fp,o,0); | 1175 | writeValue(fp,o,0,TRUE); |
1175 | } | 1176 | } |
1176 | } | 1177 | } |
1177 | 1178 | ||
1178 | static void writeGroup(OFile *fp, VObject *o) | 1179 | static void writeGroup(OFile *fp, VObject *o) |
@@ -1235,10 +1236,8 @@ static void writeProp(OFile *fp, VObject *o) | |||
1235 | fields++; | 1236 | fields++; |
1236 | } | 1237 | } |
1237 | fields = fields_; | 1238 | fields = fields_; |
1238 | if (!printable) { | 1239 | if (!printable) |
1239 | appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); | 1240 | appendsOFileEncCs(fp); |
1240 | appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); | ||
1241 | } | ||
1242 | appendcOFile(fp,':'); | 1241 | appendcOFile(fp,':'); |
1243 | while (*fields) { | 1242 | while (*fields) { |
1244 | VObject *t = isAPropertyOf(o,*fields); | 1243 | VObject *t = isAPropertyOf(o,*fields); |
@@ -1248,24 +1247,22 @@ static void writeProp(OFile *fp, VObject *o) | |||
1248 | } | 1247 | } |
1249 | fields = fields_; | 1248 | fields = fields_; |
1250 | for (i=0;i<n;i++) { | 1249 | for (i=0;i<n;i++) { |
1251 | writeValue(fp,isAPropertyOf(o,*fields),0); | 1250 | writeValue(fp,isAPropertyOf(o,*fields),0,TRUE); |
1252 | fields++; | 1251 | fields++; |
1253 | if (i<(n-1)) appendcOFile(fp,';'); | 1252 | if (i<(n-1)) appendcOFile(fp,';'); |
1254 | } | 1253 | } |
1255 | } | 1254 | } |
1256 | } | 1255 | } |
1257 | 1256 | ||
1258 | 1257 | ||
1259 | if (VALUE_TYPE(o)) { | 1258 | if (VALUE_TYPE(o)) { |
1260 | if ( includesUnprintable(o) ) { | 1259 | if ( includesUnprintable(o) ) |
1261 | appendsOFile(fp, ";" VCEncodingProp "=" VCQuotedPrintableProp); | 1260 | appendsOFileEncCs(fp); |
1262 | appendsOFile(fp, ";" VCCharSetProp "=" "UTF-8"); | ||
1263 | } | ||
1264 | unsigned long size = 0; | 1261 | unsigned long size = 0; |
1265 | VObject *p = isAPropertyOf(o,VCDataSizeProp); | 1262 | VObject *p = isAPropertyOf(o,VCDataSizeProp); |
1266 | if (p) size = LONG_VALUE_OF(p); | 1263 | if (p) size = LONG_VALUE_OF(p); |
1267 | appendcOFile(fp,':'); | 1264 | appendcOFile(fp,':'); |
1268 | writeValue(fp,o,size); | 1265 | writeValue(fp,o,size,FALSE); |
1269 | } | 1266 | } |
1270 | 1267 | ||
1271 | appendcOFile(fp,'\n'); | 1268 | appendcOFile(fp,'\n'); |
@@ -1295,8 +1292,35 @@ static void writeVObject_(OFile *fp, VObject *o) | |||
1295 | } | 1292 | } |
1296 | } | 1293 | } |
1297 | 1294 | ||
1295 | static void initVObjectEncoding() | ||
1296 | { | ||
1297 | Config pimConfig( "Beam" ); | ||
1298 | pimConfig.setGroup("Send"); | ||
1299 | Config devcfg(pimConfig.readEntry("DeviceConfig"),Config::File); | ||
1300 | QString enc = "QP"; | ||
1301 | QString cs = "UTF-8"; | ||
1302 | if ( devcfg.isValid() ) { | ||
1303 | devcfg.setGroup("Send"); | ||
1304 | enc = devcfg.readEntry("Encoding","QP"); | ||
1305 | cs = devcfg.readEntry("CharSet","UTF-8"); | ||
1306 | } | ||
1307 | strncpy(vobj_cs,cs.latin1(),10); | ||
1308 | if ( enc == "QP" ) { | ||
1309 | vobj_enc = QuotedPrintable; | ||
1310 | vobj_enc_s = VCQuotedPrintableProp; | ||
1311 | } else if ( enc == "B64" ) { | ||
1312 | vobj_enc = Base64; | ||
1313 | vobj_enc_s = VCBase64Prop; | ||
1314 | } else { | ||
1315 | vobj_enc = EightBit; | ||
1316 | vobj_enc_s = 0; | ||
1317 | } | ||
1318 | } | ||
1319 | |||
1298 | void writeVObject(FILE *fp, VObject *o) | 1320 | void writeVObject(FILE *fp, VObject *o) |
1299 | { | 1321 | { |
1322 | initVObjectEncoding(); | ||
1323 | |||
1300 | OFile ofp; | 1324 | OFile ofp; |
1301 | // ##### | 1325 | // ##### |
1302 | //_setmode(_fileno(fp), _O_BINARY); | 1326 | //_setmode(_fileno(fp), _O_BINARY); |
@@ -1329,11 +1353,6 @@ DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) | |||
1329 | } | 1353 | } |
1330 | } | 1354 | } |
1331 | 1355 | ||
1332 | #ifndef __SHARP_COMP_ | ||
1333 | |||
1334 | // This function is not available in the Sharp ROM for SL 5500 ! | ||
1335 | // Therefore I have to move it into the header file.. (se) | ||
1336 | |||
1337 | DLLEXPORT(const char *) vObjectTypeInfo(VObject *o) | 1356 | DLLEXPORT(const char *) vObjectTypeInfo(VObject *o) |
1338 | { | 1357 | { |
1339 | const char *type = vObjectName( o ); | 1358 | const char *type = vObjectName( o ); |
@@ -1341,6 +1360,6 @@ DLLEXPORT(const char *) vObjectTypeInfo(VObject *o) | |||
1341 | type = vObjectStringZValue( o ); | 1360 | type = vObjectStringZValue( o ); |
1342 | return type; | 1361 | return type; |
1343 | } | 1362 | } |
1344 | #endif | 1363 | |
1345 | 1364 | ||
1346 | // end of source file vobject.c | 1365 | // end of source file vobject.c |