summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/backend/vobject.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/library/backend/vobject.cpp b/library/backend/vobject.cpp
index 592d116..28b8bae 100644
--- a/library/backend/vobject.cpp
+++ b/library/backend/vobject.cpp
@@ -1166,199 +1166,201 @@ static void writeAttrValue(OFile *fp, VObject *o)
1166 appendsOFileEncCs(fp); 1166 appendsOFileEncCs(fp);
1167 appendcOFile(fp,';'); 1167 appendcOFile(fp,';');
1168 appendsOFile(fp,NAME_OF(o)); 1168 appendsOFile(fp,NAME_OF(o));
1169 } else { 1169 } else {
1170 appendcOFile(fp,';'); 1170 appendcOFile(fp,';');
1171 } 1171 }
1172 if (VALUE_TYPE(o)) { 1172 if (VALUE_TYPE(o)) {
1173 appendcOFile(fp,'='); 1173 appendcOFile(fp,'=');
1174 writeValue(fp,o,0,TRUE); 1174 writeValue(fp,o,0,TRUE);
1175 } 1175 }
1176} 1176}
1177 1177
1178static void writeGroup(OFile *fp, VObject *o) 1178static void writeGroup(OFile *fp, VObject *o)
1179{ 1179{
1180 char buf1[256]; 1180 char buf1[256];
1181 char buf2[256]; 1181 char buf2[256];
1182 strcpy(buf1,NAME_OF(o)); 1182 strcpy(buf1,NAME_OF(o));
1183 while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) { 1183 while ((o=isAPropertyOf(o,VCGroupingProp)) != 0) {
1184 strcpy(buf2,STRINGZ_VALUE_OF(o)); 1184 strcpy(buf2,STRINGZ_VALUE_OF(o));
1185 strcat(buf2,"."); 1185 strcat(buf2,".");
1186 strcat(buf2,buf1); 1186 strcat(buf2,buf1);
1187 strcpy(buf1,buf2); 1187 strcpy(buf1,buf2);
1188 } 1188 }
1189 appendsOFile(fp,buf1); 1189 appendsOFile(fp,buf1);
1190} 1190}
1191 1191
1192static int inList(const char **list, const char *s) 1192static int inList(const char **list, const char *s)
1193{ 1193{
1194 if (list == 0) return 0; 1194 if (list == 0) return 0;
1195 while (*list) { 1195 while (*list) {
1196 if (qstricmp(*list,s) == 0) return 1; 1196 if (qstricmp(*list,s) == 0) return 1;
1197 list++; 1197 list++;
1198 } 1198 }
1199 return 0; 1199 return 0;
1200} 1200}
1201 1201
1202static void writeProp(OFile *fp, VObject *o) 1202static void writeProp(OFile *fp, VObject *o)
1203{ 1203{
1204 if (NAME_OF(o)) { 1204 if (NAME_OF(o)) {
1205 struct PreDefProp *pi; 1205 struct PreDefProp *pi;
1206 VObjectIterator t; 1206 VObjectIterator t;
1207 const char **fields_ = 0; 1207 const char **fields_ = 0;
1208 pi = lookupPropInfo(NAME_OF(o)); 1208 pi = lookupPropInfo(NAME_OF(o));
1209 if (pi && ((pi->flags & PD_BEGIN) != 0)) { 1209 if (pi && ((pi->flags & PD_BEGIN) != 0)) {
1210 writeVObject_(fp,o); 1210 writeVObject_(fp,o);
1211 return; 1211 return;
1212 } 1212 }
1213 if (isAPropertyOf(o,VCGroupingProp)) 1213 if (isAPropertyOf(o,VCGroupingProp))
1214 writeGroup(fp,o); 1214 writeGroup(fp,o);
1215 else 1215 else
1216 appendsOFile(fp,NAME_OF(o)); 1216 appendsOFile(fp,NAME_OF(o));
1217 if (pi) fields_ = pi->fields; 1217 if (pi) fields_ = pi->fields;
1218 initPropIterator(&t,o); 1218 initPropIterator(&t,o);
1219 while (moreIteration(&t)) { 1219 while (moreIteration(&t)) {
1220 const char *s; 1220 const char *s;
1221 VObject *eachProp = nextVObject(&t); 1221 VObject *eachProp = nextVObject(&t);
1222 s = NAME_OF(eachProp); 1222 s = NAME_OF(eachProp);
1223 if (qstricmp(VCGroupingProp,s) && !inList(fields_,s)) 1223 if (qstricmp(VCGroupingProp,s) && !inList(fields_,s))
1224 writeAttrValue(fp,eachProp); 1224 writeAttrValue(fp,eachProp);
1225 } 1225 }
1226 if (fields_) { 1226 if (fields_) {
1227 int i = 0, n = 0; 1227 int i = 0, n = 0;
1228 const char** fields = fields_; 1228 const char** fields = fields_;
1229 /* output prop as fields */ 1229 /* output prop as fields */
1230 bool printable = TRUE; 1230 bool printable = TRUE;
1231 while (*fields && printable) { 1231 while (*fields && printable) {
1232 VObject *t = isAPropertyOf(o,*fields); 1232 VObject *t = isAPropertyOf(o,*fields);
1233 if (includesUnprintable(t,TRUE)) 1233 if (includesUnprintable(t,TRUE))
1234 printable = FALSE; 1234 printable = FALSE;
1235 fields++; 1235 fields++;
1236 } 1236 }
1237 fields = fields_; 1237 fields = fields_;
1238 if (!printable) 1238 if (!printable)
1239 appendsOFileEncCs(fp); 1239 appendsOFileEncCs(fp);
1240 appendcOFile(fp,':'); 1240 appendcOFile(fp,':');
1241 while (*fields) { 1241 while (*fields) {
1242 VObject *t = isAPropertyOf(o,*fields); 1242 VObject *t = isAPropertyOf(o,*fields);
1243 i++; 1243 i++;
1244 if (t) n = i; 1244 if (t) n = i;
1245 fields++; 1245 fields++;
1246 } 1246 }
1247 fields = fields_; 1247 fields = fields_;
1248 for (i=0;i<n;i++) { 1248 for (i=0;i<n;i++) {
1249 writeValue(fp,isAPropertyOf(o,*fields),0,TRUE); 1249 writeValue(fp,isAPropertyOf(o,*fields),0,TRUE);
1250 fields++; 1250 fields++;
1251 if (i<(n-1)) appendcOFile(fp,';'); 1251 if (i<(n-1)) appendcOFile(fp,';');
1252 } 1252 }
1253 } 1253 }
1254 } 1254 }
1255 1255
1256 1256
1257 if (VALUE_TYPE(o)) { 1257 if (VALUE_TYPE(o)) {
1258 if ( includesUnprintable(o,FALSE) ) 1258 if ( includesUnprintable(o,FALSE) )
1259 appendsOFileEncCs(fp); 1259 appendsOFileEncCs(fp);
1260 unsigned long size = 0; 1260 unsigned long size = 0;
1261 VObject *p = isAPropertyOf(o,VCDataSizeProp); 1261 VObject *p = isAPropertyOf(o,VCDataSizeProp);
1262 if (p) size = LONG_VALUE_OF(p); 1262 if (p) size = LONG_VALUE_OF(p);
1263 appendcOFile(fp,':'); 1263 appendcOFile(fp,':');
1264 writeValue(fp,o,size,FALSE); 1264 writeValue(fp,o,size,FALSE);
1265 } 1265 }
1266 1266
1267 appendcOFile(fp,'\n'); 1267 appendcOFile(fp,'\n');
1268} 1268}
1269 1269
1270static void writeVObject_(OFile *fp, VObject *o) 1270static void writeVObject_(OFile *fp, VObject *o)
1271{ 1271{
1272 if (NAME_OF(o)) { 1272 if (NAME_OF(o)) {
1273 struct PreDefProp *pi; 1273 struct PreDefProp *pi;
1274 pi = lookupPropInfo(NAME_OF(o)); 1274 pi = lookupPropInfo(NAME_OF(o));
1275 1275
1276 if (pi && ((pi->flags & PD_BEGIN) != 0)) { 1276 if (pi && ((pi->flags & PD_BEGIN) != 0)) {
1277 VObjectIterator t; 1277 VObjectIterator t;
1278 const char *begin = NAME_OF(o); 1278 const char *begin = NAME_OF(o);
1279 appendsOFile(fp,"BEGIN:"); 1279 appendsOFile(fp,"BEGIN:");
1280 appendsOFile(fp,begin); 1280 appendsOFile(fp,begin);
1281 appendcOFile(fp,'\n'); 1281 appendcOFile(fp,'\n');
1282 initPropIterator(&t,o); 1282 initPropIterator(&t,o);
1283 while (moreIteration(&t)) { 1283 while (moreIteration(&t)) {
1284 VObject *eachProp = nextVObject(&t); 1284 VObject *eachProp = nextVObject(&t);
1285 writeProp(fp, eachProp); 1285 writeProp(fp, eachProp);
1286 } 1286 }
1287 appendsOFile(fp,"END:"); 1287 appendsOFile(fp,"END:");
1288 appendsOFile(fp,begin); 1288 appendsOFile(fp,begin);
1289 appendsOFile(fp,"\n\n"); 1289 appendsOFile(fp,"\n\n");
1290 } 1290 }
1291 } 1291 }
1292} 1292}
1293 1293
1294static void initVObjectEncoding() 1294static void initVObjectEncoding()
1295{ 1295{
1296 Config pimConfig( "Beam" ); 1296 Config pimConfig( "Beam" );
1297 pimConfig.setGroup("Send"); 1297 pimConfig.setGroup("Send");
1298 Config devcfg(pimConfig.readEntry("DeviceConfig"),Config::File); 1298 Config devcfg(pimConfig.readEntry("DeviceConfig"),Config::File);
1299 QString enc = "QP"; 1299 QString enc = "QP";
1300 QString cs = "UTF-8"; 1300 QString cs = "UTF-8";
1301 if ( devcfg.isValid() ) { 1301 if ( devcfg.isValid() ) {
1302 devcfg.setGroup("Send"); 1302 devcfg.setGroup("Send");
1303 enc = devcfg.readEntry("Encoding","QP"); 1303 enc = devcfg.readEntry("Encoding","QP");
1304 cs = devcfg.readEntry("CharSet","UTF-8"); 1304 cs = devcfg.readEntry("CharSet","UTF-8");
1305 } 1305 }
1306 strncpy(vobj_cs,cs.latin1(),10); 1306 strncpy(vobj_cs,cs.latin1(),10);
1307 if ( enc == "QP" ) { 1307 if ( enc == "QP" ) {
1308 vobj_enc = QuotedPrintable; 1308 vobj_enc = QuotedPrintable;
1309 vobj_enc_s = VCQuotedPrintableProp; 1309 vobj_enc_s = VCQuotedPrintableProp;
1310 } else if ( enc == "B64" ) { 1310 } else if ( enc == "B64" ) {
1311 vobj_enc = Base64; 1311 vobj_enc = Base64;
1312 vobj_enc_s = VCBase64Prop; 1312 vobj_enc_s = VCBase64Prop;
1313 } else { 1313 } else {
1314 vobj_enc = EightBit; 1314 vobj_enc = EightBit;
1315 vobj_enc_s = 0; 1315 vobj_enc_s = 0;
1316 } 1316 }
1317} 1317}
1318 1318
1319void writeVObject(FILE *fp, VObject *o) 1319void writeVObject(FILE *fp, VObject *o)
1320{ 1320{
1321 initVObjectEncoding(); 1321 initVObjectEncoding();
1322 1322
1323 OFile ofp; 1323 OFile ofp;
1324 // ##### 1324 // #####
1325 //_setmode(_fileno(fp), _O_BINARY); 1325 //_setmode(_fileno(fp), _O_BINARY);
1326 initOFile(&ofp,fp); 1326 initOFile(&ofp,fp);
1327 writeVObject_(&ofp,o); 1327 writeVObject_(&ofp,o);
1328} 1328}
1329 1329
1330DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o) 1330DLLEXPORT(void) writeVObjectToFile(char *fname, VObject *o)
1331{ 1331{
1332 QFileDirect f( fname); 1332 QFileDirect f( fname);
1333 if ( !f.open( IO_WriteOnly ) ) { 1333 if ( !f.open( IO_WriteOnly ) ) {
1334 qWarning("Unable to open vobject write %s", fname); 1334 qWarning("Unable to open vobject write %s", fname);
1335 return; 1335 return;
1336 } 1336 }
1337 1337
1338 writeVObject( f.directHandle(),o ); 1338 writeVObject( f.directHandle(),o );
1339} 1339}
1340 1340
1341DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list) 1341DLLEXPORT(void) writeVObjectsToFile(char *fname, VObject *list)
1342{ 1342{
1343 QFileDirect f( fname); 1343 QFileDirect f( fname);
1344 if ( !f.open( IO_WriteOnly ) ) { 1344 if ( !f.open( IO_WriteOnly ) ) {
1345 qWarning("Unable to open vobject write %s", fname); 1345 qWarning("Unable to open vobject write %s", fname);
1346 return; 1346 return;
1347 } 1347 }
1348 1348
1349 while (list) { 1349 while (list) {
1350 writeVObject(f.directHandle(),list); 1350 writeVObject(f.directHandle(),list);
1351 list = nextVObjectInList(list); 1351 list = nextVObjectInList(list);
1352 } 1352 }
1353} 1353}
1354 1354
1355DLLEXPORT(const char *) vObjectTypeInfo(VObject *o) 1355DLLEXPORT(const char *) vObjectTypeInfo(VObject *o)
1356{ 1356{
1357 const char *type = vObjectName( o ); 1357 const char *type = vObjectName( o );
1358 if ( strcmp( type, "TYPE" ) == 0 ) 1358 if ( strcmp( type, "type" ) == 0 ||
1359 type = vObjectStringZValue( o ); 1359 strcmp( type, "TYPE" ) == 0 ||
1360 strcmp( type, "Type" ) == 0 )
1361 type = vObjectStringZValue( o );
1360 return type; 1362 return type;
1361} 1363}
1362 1364
1363 1365
1364// end of source file vobject.c 1366// end of source file vobject.c