author | eilers <eilers> | 2003-03-27 16:17:48 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-03-27 16:17:48 (UTC) |
commit | 390a5a0c332c8c6fb380c1ed4cd6adae3e544a08 (patch) (unidiff) | |
tree | 7ad6266be3d78d25ae061a0be067f82f8d666246 | |
parent | ff43585778968407bb08473e45ddd1d942f8d8c8 (diff) | |
download | opie-390a5a0c332c8c6fb380c1ed4cd6adae3e544a08.zip opie-390a5a0c332c8c6fb380c1ed4cd6adae3e544a08.tar.gz opie-390a5a0c332c8c6fb380c1ed4cd6adae3e544a08.tar.bz2 |
using releases from qtopia-free-1.6.0-snapshot-20030324 which fixes the
following bugs #776 and #490:
Now, we could successfully parse vcards from palm 4 + 5 and
quoted-printable encoded lines .. !
-rw-r--r-- | library/backend/vcc.y | 22 | ||||
-rw-r--r-- | library/backend/vcc_yacc.cpp | 127 | ||||
-rw-r--r-- | library/backend/vobject.cpp | 163 | ||||
-rw-r--r-- | library/backend/vobject_p.h | 29 |
4 files changed, 189 insertions, 152 deletions
diff --git a/library/backend/vcc.y b/library/backend/vcc.y index 6781312..94a8fea 100644 --- a/library/backend/vcc.y +++ b/library/backend/vcc.y | |||
@@ -121,9 +121,9 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | |||
121 | 121 | ||
122 | //#ifdef PALMTOPCENTER | 122 | //#ifdef PALMTOPCENTER |
123 | //#include <qpe/vobject_p.h> | 123 | //#include <qpe/vobject_p.h> |
124 | //#else | 124 | //#else |
125 | #include <qtopia/private/vobject_p.h> | 125 | #include "vobject_p.h" |
126 | //#endif | 126 | //#endif |
127 | 127 | ||
128 | /**** Types, Constants ****/ | 128 | /**** Types, Constants ****/ |
129 | 129 | ||
@@ -722,18 +722,24 @@ static char* lexGet1Value() { | |||
722 | int c; | 722 | int c; |
723 | lexSkipWhite(); | 723 | lexSkipWhite(); |
724 | c = lexLookahead(); | 724 | c = lexLookahead(); |
725 | lexClearToken(); | 725 | lexClearToken(); |
726 | while (c != EOF && c != ';') { | 726 | while (c != EOF && (c != ';' || !fieldedProp)) { |
727 | if (c == '\\' ) { | 727 | if (c == '\\' ) { |
728 | int a; | 728 | int a; |
729 | lexSkipLookahead(); | 729 | lexSkipLookahead(); |
730 | a = lexLookahead(); | 730 | a = lexLookahead(); |
731 | if ( a != ';' ) { | 731 | if ( a == ';' ) { |
732 | lexAppendc('\\'); | ||
733 | } else { | ||
734 | lexAppendc( ';' ); | 732 | lexAppendc( ';' ); |
735 | lexSkipLookahead(); | 733 | lexSkipLookahead(); |
734 | } else if ( a == '\n' ) { | ||
735 | lexAppendc( '\n' ); | ||
736 | lexSkipLookahead(); | ||
737 | } else if ( a == '\\' ) { | ||
738 | lexAppendc( '\\' ); | ||
739 | lexSkipLookahead(); | ||
740 | } else { | ||
741 | lexAppendc('\\'); | ||
736 | } | 742 | } |
737 | } else if (c == '\n') { | 743 | } else if (c == '\n') { |
738 | int a; | 744 | int a; |
739 | lexSkipLookahead(); | 745 | lexSkipLookahead(); |
@@ -960,8 +966,9 @@ static char* lexGetQuotedPrintable() | |||
960 | } else { | 966 | } else { |
961 | // we have been sent buggy stuff. doesn't matter | 967 | // we have been sent buggy stuff. doesn't matter |
962 | // what we do so long as we keep going. | 968 | // what we do so long as we keep going. |
963 | // should probably spit an error here | 969 | // should probably spit an error here |
970 | lexSkipLookahead(); | ||
964 | c = lexLookahead(); | 971 | c = lexLookahead(); |
965 | continue; | 972 | continue; |
966 | } | 973 | } |
967 | 974 | ||
@@ -977,8 +984,9 @@ static char* lexGetQuotedPrintable() | |||
977 | } else { | 984 | } else { |
978 | // we have been sent buggy stuff. doesn't matter | 985 | // we have been sent buggy stuff. doesn't matter |
979 | // what we do so long as we keep going. | 986 | // what we do so long as we keep going. |
980 | // should probably spit an error here | 987 | // should probably spit an error here |
988 | lexSkipLookahead(); | ||
981 | c = lexLookahead(); | 989 | c = lexLookahead(); |
982 | continue; | 990 | continue; |
983 | } | 991 | } |
984 | 992 | ||
@@ -999,9 +1007,9 @@ static int yylex() { | |||
999 | 1007 | ||
1000 | int lexmode = LEXMODE(); | 1008 | int lexmode = LEXMODE(); |
1001 | if (lexmode == L_VALUES) { | 1009 | if (lexmode == L_VALUES) { |
1002 | int c = lexGetc(); | 1010 | int c = lexGetc(); |
1003 | if (c == ';') { | 1011 | if (c == ';' && fieldedProp) { |
1004 | DBG_(("db: SEMICOLON\n")); | 1012 | DBG_(("db: SEMICOLON\n")); |
1005 | lexPushLookaheadc(c); | 1013 | lexPushLookaheadc(c); |
1006 | handleMoreRFC822LineBreak(c); | 1014 | handleMoreRFC822LineBreak(c); |
1007 | lexSkipLookahead(); | 1015 | lexSkipLookahead(); |
@@ -1053,14 +1061,16 @@ static int yylex() { | |||
1053 | switch(c) { | 1061 | switch(c) { |
1054 | case ':': { | 1062 | case ':': { |
1055 | /* consume all line separator(s) adjacent to each other */ | 1063 | /* consume all line separator(s) adjacent to each other */ |
1056 | /* ignoring linesep immediately after colon. */ | 1064 | /* ignoring linesep immediately after colon. */ |
1065 | /* I don't see this in the spec, and it breaks null values -- WA | ||
1057 | c = lexLookahead(); | 1066 | c = lexLookahead(); |
1058 | while (strchr("\n",c)) { | 1067 | while (strchr("\n",c)) { |
1059 | lexSkipLookahead(); | 1068 | lexSkipLookahead(); |
1060 | c = lexLookahead(); | 1069 | c = lexLookahead(); |
1061 | ++mime_lineNum; | 1070 | ++mime_lineNum; |
1062 | } | 1071 | } |
1072 | */ | ||
1063 | DBG_(("db: COLON\n")); | 1073 | DBG_(("db: COLON\n")); |
1064 | return COLON; | 1074 | return COLON; |
1065 | } | 1075 | } |
1066 | case ';': | 1076 | case ';': |
diff --git a/library/backend/vcc_yacc.cpp b/library/backend/vcc_yacc.cpp index b2b0c14..5649522 100644 --- a/library/backend/vcc_yacc.cpp +++ b/library/backend/vcc_yacc.cpp | |||
@@ -157,9 +157,9 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | |||
157 | 157 | ||
158 | /*#ifdef PALMTOPCENTER */ | 158 | /*#ifdef PALMTOPCENTER */ |
159 | /*#include <qpe/vobject_p.h> */ | 159 | /*#include <qpe/vobject_p.h> */ |
160 | /*#else */ | 160 | /*#else */ |
161 | #include <qtopia/private/vobject_p.h> | 161 | #include "vobject_p.h" |
162 | /*#endif */ | 162 | /*#endif */ |
163 | 163 | ||
164 | /**** Types, Constants ****/ | 164 | /**** Types, Constants ****/ |
165 | 165 | ||
@@ -742,18 +742,24 @@ static char* lexGet1Value() { | |||
742 | int c; | 742 | int c; |
743 | lexSkipWhite(); | 743 | lexSkipWhite(); |
744 | c = lexLookahead(); | 744 | c = lexLookahead(); |
745 | lexClearToken(); | 745 | lexClearToken(); |
746 | while (c != EOF && c != ';') { | 746 | while (c != EOF && (c != ';' || !fieldedProp)) { |
747 | if (c == '\\' ) { | 747 | if (c == '\\' ) { |
748 | int a; | 748 | int a; |
749 | lexSkipLookahead(); | 749 | lexSkipLookahead(); |
750 | a = lexLookahead(); | 750 | a = lexLookahead(); |
751 | if ( a != ';' ) { | 751 | if ( a == ';' ) { |
752 | lexAppendc('\\'); | ||
753 | } else { | ||
754 | lexAppendc( ';' ); | 752 | lexAppendc( ';' ); |
755 | lexSkipLookahead(); | 753 | lexSkipLookahead(); |
754 | } else if ( a == '\n' ) { | ||
755 | lexAppendc( '\n' ); | ||
756 | lexSkipLookahead(); | ||
757 | } else if ( a == '\\' ) { | ||
758 | lexAppendc( '\\' ); | ||
759 | lexSkipLookahead(); | ||
760 | } else { | ||
761 | lexAppendc('\\'); | ||
756 | } | 762 | } |
757 | } else if (c == '\n') { | 763 | } else if (c == '\n') { |
758 | int a; | 764 | int a; |
759 | lexSkipLookahead(); | 765 | lexSkipLookahead(); |
@@ -950,69 +956,80 @@ static int match_begin_end_name(int end) { | |||
950 | } | 956 | } |
951 | 957 | ||
952 | static char* lexGetQuotedPrintable() | 958 | static char* lexGetQuotedPrintable() |
953 | { | 959 | { |
954 | int cur; | 960 | int c; |
955 | 961 | lexSkipWhite(); | |
962 | c = lexLookahead(); | ||
956 | lexClearToken(); | 963 | lexClearToken(); |
957 | do { | 964 | |
958 | cur = lexGetc(); | 965 | while (c != EOF && c != ';') { |
959 | switch (cur) { | 966 | if (c == '\n') { |
960 | case '=': { | 967 | // break, leave '\n' on remaining chars. |
961 | int c = 0; | ||
962 | int next[2]; | ||
963 | int i; | ||
964 | for (i = 0; i < 2; i++) { | ||
965 | next[i] = lexGetc(); | ||
966 | if (next[i] >= '0' && next[i] <= '9') | ||
967 | c = c * 16 + next[i] - '0'; | ||
968 | else if (next[i] >= 'A' && next[i] <= 'F') | ||
969 | c = c * 16 + next[i] - 'A' + 10; | ||
970 | else | ||
971 | break; | 968 | break; |
969 | } else if (c == '=') { | ||
970 | int cur = 0; | ||
971 | int next; | ||
972 | |||
973 | lexSkipLookahead(); // skip '=' | ||
974 | next = lexLookahead(); | ||
975 | |||
976 | if (next == '\n') { | ||
977 | // skip and only skip the \n | ||
978 | lexSkipLookahead(); | ||
979 | c = lexLookahead(); | ||
980 | ++mime_lineNum; // aid in error reporting | ||
981 | continue; | ||
982 | } else if (next >= '0' && next <= '9') { | ||
983 | cur = next - '0'; | ||
984 | } else if (next >= 'A' && next <= 'F') { | ||
985 | cur = next - 'A' + 10; | ||
986 | } else { | ||
987 | // we have been sent buggy stuff. doesn't matter | ||
988 | // what we do so long as we keep going. | ||
989 | // should probably spit an error here | ||
990 | lexSkipLookahead(); | ||
991 | c = lexLookahead(); | ||
992 | continue; | ||
972 | } | 993 | } |
973 | if (i == 0) { | 994 | |
974 | /* single '=' follow by LINESEP is continuation sign? */ | 995 | lexSkipLookahead(); // skip A-Z0-9 |
975 | if (next[0] == '\n') { | 996 | next = lexLookahead(); |
976 | ++mime_lineNum; | 997 | |
977 | } | 998 | cur = cur * 16; |
978 | else { | 999 | // this time really just expecting 0-9A-F |
979 | lexPushLookaheadc('='); | 1000 | if (next >= '0' && next <= '9') { |
980 | goto EndString; | 1001 | cur += next - '0'; |
981 | } | 1002 | } else if (next >= 'A' && next <= 'F') { |
1003 | cur += next - 'A' + 10; | ||
1004 | } else { | ||
1005 | // we have been sent buggy stuff. doesn't matter | ||
1006 | // what we do so long as we keep going. | ||
1007 | // should probably spit an error here | ||
1008 | lexSkipLookahead(); | ||
1009 | c = lexLookahead(); | ||
1010 | continue; | ||
982 | } | 1011 | } |
983 | else if (i == 1) { | 1012 | |
984 | lexPushLookaheadc(next[1]); | 1013 | // got a valid escaped =. append it. |
985 | lexPushLookaheadc(next[0]); | 1014 | lexSkipLookahead(); // skip second 0-9A-F |
986 | lexAppendc('='); | 1015 | lexAppendc(cur); |
987 | } else { | 1016 | } else { |
988 | lexAppendc(c); | 1017 | lexSkipLookahead(); // skip whatever we just read. |
1018 | lexAppendc(c); // and append it. | ||
989 | } | 1019 | } |
990 | break; | 1020 | c = lexLookahead(); |
991 | } /* '=' */ | ||
992 | case '\n': { | ||
993 | lexPushLookaheadc('\n'); | ||
994 | goto EndString; | ||
995 | } | 1021 | } |
996 | case (int)EOF: | ||
997 | break; | ||
998 | default: | ||
999 | lexAppendc(cur); | ||
1000 | break; | ||
1001 | } /* switch */ | ||
1002 | } while (cur != (int)EOF); | ||
1003 | |||
1004 | EndString: | ||
1005 | lexAppendc(0); | 1022 | lexAppendc(0); |
1006 | return lexStr(); | 1023 | return c==EOF?0:lexStr(); |
1007 | } /* LexQuotedPrintable */ | 1024 | } |
1008 | 1025 | ||
1009 | static int yylex() { | 1026 | static int yylex() { |
1010 | 1027 | ||
1011 | int lexmode = LEXMODE(); | 1028 | int lexmode = LEXMODE(); |
1012 | if (lexmode == L_VALUES) { | 1029 | if (lexmode == L_VALUES) { |
1013 | int c = lexGetc(); | 1030 | int c = lexGetc(); |
1014 | if (c == ';') { | 1031 | if (c == ';' && fieldedProp) { |
1015 | DBG_(("db: SEMICOLON\n")); | 1032 | DBG_(("db: SEMICOLON\n")); |
1016 | lexPushLookaheadc(c); | 1033 | lexPushLookaheadc(c); |
1017 | handleMoreRFC822LineBreak(c); | 1034 | handleMoreRFC822LineBreak(c); |
1018 | lexSkipLookahead(); | 1035 | lexSkipLookahead(); |
@@ -1064,14 +1081,16 @@ static int yylex() { | |||
1064 | switch(c) { | 1081 | switch(c) { |
1065 | case ':': { | 1082 | case ':': { |
1066 | /* consume all line separator(s) adjacent to each other */ | 1083 | /* consume all line separator(s) adjacent to each other */ |
1067 | /* ignoring linesep immediately after colon. */ | 1084 | /* ignoring linesep immediately after colon. */ |
1085 | /* I don't see this in the spec, and it breaks null values -- WA | ||
1068 | c = lexLookahead(); | 1086 | c = lexLookahead(); |
1069 | while (strchr("\n",c)) { | 1087 | while (strchr("\n",c)) { |
1070 | lexSkipLookahead(); | 1088 | lexSkipLookahead(); |
1071 | c = lexLookahead(); | 1089 | c = lexLookahead(); |
1072 | ++mime_lineNum; | 1090 | ++mime_lineNum; |
1073 | } | 1091 | } |
1092 | */ | ||
1074 | DBG_(("db: COLON\n")); | 1093 | DBG_(("db: COLON\n")); |
1075 | return COLON; | 1094 | return COLON; |
1076 | } | 1095 | } |
1077 | case ';': | 1096 | case ';': |
@@ -1216,9 +1235,9 @@ void mime_error_(char *s) | |||
1216 | mimeErrorHandler(s); | 1235 | mimeErrorHandler(s); |
1217 | } | 1236 | } |
1218 | } | 1237 | } |
1219 | 1238 | ||
1220 | #line 1221 "y.tab.c" | 1239 | #line 1240 "y.tab.c" |
1221 | #define YYABORT goto yyabort | 1240 | #define YYABORT goto yyabort |
1222 | #define YYREJECT goto yyabort | 1241 | #define YYREJECT goto yyabort |
1223 | #define YYACCEPT goto yyaccept | 1242 | #define YYACCEPT goto yyaccept |
1224 | #define YYERROR goto yyerrlab | 1243 | #define YYERROR goto yyerrlab |
@@ -1516,9 +1535,9 @@ case 45: | |||
1516 | lexPopMode(0); | 1535 | lexPopMode(0); |
1517 | popVObject(); | 1536 | popVObject(); |
1518 | } | 1537 | } |
1519 | break; | 1538 | break; |
1520 | #line 1521 "y.tab.c" | 1539 | #line 1540 "y.tab.c" |
1521 | } | 1540 | } |
1522 | yyssp -= yym; | 1541 | yyssp -= yym; |
1523 | yystate = *yyssp; | 1542 | yystate = *yyssp; |
1524 | yyvsp -= yym; | 1543 | yyvsp -= yym; |
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 | |||
@@ -45,10 +45,11 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | |||
45 | #ifndef MWERKS | 45 | #ifndef MWERKS |
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> |
54 | //#include <io.h> | 55 | //#include <io.h> |
@@ -61,8 +62,12 @@ DFARS 252.227-7013 or 48 CFR 52.227-19, as applicable. | |||
61 | #define LONG_VALUE_OF(o) o->val.l | 62 | #define LONG_VALUE_OF(o) o->val.l |
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; |
68 | unsigned long l; | 73 | unsigned long l; |
@@ -85,9 +90,9 @@ struct StrItem { | |||
85 | const char *s; | 90 | const char *s; |
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 | ||
93 | /*---------------------------------------------------------------------- | 98 | /*---------------------------------------------------------------------- |
@@ -952,8 +957,19 @@ static void appendsOFile(OFile *fp, const char *s) | |||
952 | } | 957 | } |
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; |
959 | fp->s = 0; | 975 | fp->s = 0; |
@@ -1004,43 +1020,22 @@ static int writeBase64(OFile *fp, unsigned char *s, long len) | |||
1004 | 1020 | ||
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 | || | 1031 | || |
1017 | (c >= '0' && c <= '9') | 1032 | (c >= 62 && c <= 126) |
1018 | || | 1033 | ) |
1019 | (c >= '\'' && c <= ')') | ||
1020 | || | ||
1021 | (c >= '+' && c <= '-') | ||
1022 | || | ||
1023 | (c == '/') | ||
1024 | || | ||
1025 | (c == '?') | ||
1026 | || | ||
1027 | (c == ' ')) | ||
1028 | { | 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'; |
1046 | int rem = c % 16; | 1041 | int rem = c % 16; |
@@ -1056,12 +1051,11 @@ static const char *replaceChar(unsigned char c) | |||
1056 | else | 1051 | else |
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) |
@@ -1078,57 +1072,66 @@ static void writeQPString(OFile *fp, const char *s) | |||
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; |
1076 | switch ( vobj_enc ) { | ||
1077 | case EightBit: | ||
1078 | while (*p) { | ||
1079 | if ( *p == '\n' || nosemi && ( *p == '\\' || *p == ';' ) ) | ||
1080 | appendcOFile(fp, '\\'); | ||
1081 | appendcOFile(fp, *p); | ||
1082 | p++; | ||
1083 | } | ||
1084 | break; | ||
1085 | case QuotedPrintable: | ||
1082 | while (*p) { | 1086 | while (*p) { |
1083 | const char *rep = replaceChar(*p); | 1087 | const char *rep = qpReplaceChar(*p); |
1084 | if (rep) | 1088 | if (rep) |
1085 | appendsOFile(fp, 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"); | ||
1086 | else | 1095 | else |
1087 | appendcOFile(fp, *p); | 1096 | appendcOFile(fp, *p); |
1097 | } else | ||
1098 | appendcOFile(fp, *p); | ||
1088 | p++; | 1099 | p++; |
1089 | } | 1100 | } |
1101 | break; | ||
1102 | case Base64: | ||
1103 | writeBase64(fp, (unsigned char*)p, strlen(p)); | ||
1104 | break; | ||
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: { |
1134 | char buf[16]; | 1137 | char buf[16]; |
@@ -1159,20 +1162,18 @@ static void writeAttrValue(OFile *fp, VObject *o) | |||
1159 | if (NAME_OF(o)) { | 1162 | if (NAME_OF(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) |
@@ -1234,12 +1235,10 @@ static void writeProp(OFile *fp, VObject *o) | |||
1234 | printable = FALSE; | 1235 | printable = FALSE; |
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); |
1245 | i++; | 1244 | i++; |
@@ -1247,26 +1246,24 @@ static void writeProp(OFile *fp, VObject *o) | |||
1247 | fields++; | 1246 | fields++; |
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'); |
1272 | } | 1269 | } |
@@ -1294,10 +1291,37 @@ static void writeVObject_(OFile *fp, VObject *o) | |||
1294 | } | 1291 | } |
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); |
1303 | initOFile(&ofp,fp); | 1327 | initOFile(&ofp,fp); |
@@ -1328,19 +1352,14 @@ DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) | |||
1328 | list = nextVObjectInList(list); | 1352 | list = nextVObjectInList(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 ); |
1340 | if ( strcmp( type, "TYPE" ) == 0 ) | 1359 | if ( strcmp( type, "TYPE" ) == 0 ) |
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 |
diff --git a/library/backend/vobject_p.h b/library/backend/vobject_p.h index bab22bb..f969898 100644 --- a/library/backend/vobject_p.h +++ b/library/backend/vobject_p.h | |||
@@ -98,11 +98,15 @@ For example: | |||
98 | #define vCardMimeType "text/x-vCard" | 98 | #define vCardMimeType "text/x-vCard" |
99 | #define vCalendarMimeType"text/x-vCalendar" | 99 | #define vCalendarMimeType"text/x-vCalendar" |
100 | 100 | ||
101 | #undef DLLEXPORT | 101 | #undef DLLEXPORT |
102 | //#include <qtopia/qpeglobal.h> | ||
102 | #include <qglobal.h> | 103 | #include <qglobal.h> |
103 | #if defined(Q_WS_WIN) | 104 | |
105 | #if defined(QTOPIA_MAKEDLL) | ||
104 | #define DLLEXPORT(t) __declspec(dllexport) t | 106 | #define DLLEXPORT(t) __declspec(dllexport) t |
107 | #elif defined(QTOPIA_DLL) | ||
108 | #define DLLEXPORT(t) __declspec(dllimport) t | ||
105 | #else | 109 | #else |
106 | #define DLLEXPORT(t) t | 110 | #define DLLEXPORT(t) t |
107 | #endif | 111 | #endif |
108 | 112 | ||
@@ -350,9 +354,9 @@ extern DLLEXPORT(int) vObjectValueType(VObject *o); | |||
350 | /* if the VObject has value set by setVObjectAnyValue. */ | 354 | /* if the VObject has value set by setVObjectAnyValue. */ |
351 | #define VCVT_VOBJECT5 | 355 | #define VCVT_VOBJECT5 |
352 | /* if the VObject has value set by setVObjectVObjectValue. */ | 356 | /* if the VObject has value set by setVObjectVObjectValue. */ |
353 | 357 | ||
354 | extern const char** fieldedProp; | 358 | extern DLLEXPORT(const char**) fieldedProp; |
355 | 359 | ||
356 | /*************************************************** | 360 | /*************************************************** |
357 | * The methods below are implemented in vcc.c (generated from vcc.y ) | 361 | * The methods below are implemented in vcc.c (generated from vcc.y ) |
358 | ***************************************************/ | 362 | ***************************************************/ |
@@ -367,9 +371,9 @@ to memory. However, if you are linking this code into | |||
367 | your build directly then you may find them a more convenient API | 371 | your build directly then you may find them a more convenient API |
368 | and you can go ahead and use them. If you try to use them with | 372 | and you can go ahead and use them. If you try to use them with |
369 | the DLL LIB you will get a link error. | 373 | the DLL LIB you will get a link error. |
370 | */ | 374 | */ |
371 | extern void writeVObject(FILE *fp, VObject *o); | 375 | extern DLLEXPORT(void) writeVObject(FILE *fp, VObject *o); |
372 | 376 | ||
373 | 377 | ||
374 | 378 | ||
375 | typedef void (*MimeErrorHandler)(char *); | 379 | typedef void (*MimeErrorHandler)(char *); |
@@ -392,30 +396,15 @@ will get a link error. | |||
392 | */ | 396 | */ |
393 | 397 | ||
394 | 398 | ||
395 | #if INCLUDEMFC | 399 | #if INCLUDEMFC |
396 | extern VObject* Parse_MIME_FromFile(CFile *file); | 400 | extern DLLEXPORT(VObject*) Parse_MIME_FromFile(CFile *file); |
397 | #else | 401 | #else |
398 | extern VObject* Parse_MIME_FromFile(FILE *file); | 402 | extern DLLEXPORT(VObject*) Parse_MIME_FromFile(FILE *file); |
399 | #endif | 403 | #endif |
400 | 404 | ||
401 | #define __SHARP_COMP_ | ||
402 | |||
403 | #ifndef __SHARP_COMP_ | ||
404 | extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o); | 405 | extern DLLEXPORT(const char *) vObjectTypeInfo(VObject *o); |
405 | 406 | ||
406 | #else | ||
407 | // This function is not available in the Sharp ROM for SL 5500 ! | ||
408 | // Therefore I have to move it into the header file.. (se) | ||
409 | |||
410 | inline const char* vObjectTypeInfo(VObject *o) | ||
411 | { | ||
412 | const char *type = vObjectName( o ); | ||
413 | if ( strcmp( type, "TYPE" ) == 0 ) | ||
414 | type = vObjectStringZValue( o ); | ||
415 | return type; | ||
416 | } | ||
417 | #endif | ||
418 | 407 | ||
419 | #endif /* __VOBJECT_H__ */ | 408 | #endif /* __VOBJECT_H__ */ |
420 | 409 | ||
421 | 410 | ||