summaryrefslogtreecommitdiff
authoreilers <eilers>2004-11-19 11:05:19 (UTC)
committer eilers <eilers>2004-11-19 11:05:19 (UTC)
commit362e353e4ee43a5aa37fd4c264ad0b40bbd0098b (patch) (unidiff)
tree52de09cbe81e5105cfdef9b606c10e4239cef814
parent6b1a6e3bf5d012e517c9668501f030d8c660b537 (diff)
downloadopie-362e353e4ee43a5aa37fd4c264ad0b40bbd0098b.zip
opie-362e353e4ee43a5aa37fd4c264ad0b40bbd0098b.tar.gz
opie-362e353e4ee43a5aa37fd4c264ad0b40bbd0098b.tar.bz2
Don't just allow "TYPE=<value>".. This makes the vcard import filter more
robust against unexpected typos..
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
@@ -1262,103 +1262,105 @@ static void writeProp(OFile *fp, VObject *o)
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