X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fconvert.cpp;h=0cfaa9f352e8c4ef153aa37d62c4d48f3c24c9f7;hb=0177e3dca8765fcab7ca524f3ba0f243a972fdfb;hp=ae0e4db81b30d0fa71659dc79c18d052855d715f;hpb=6d8adc7cd79ec1ce66dbd087710d069353dd5284;p=xestiaab%2F.git diff --git a/source/convert.cpp b/source/convert.cpp index ae0e4db..0cfaa9f 100644 --- a/source/convert.cpp +++ b/source/convert.cpp @@ -18,6 +18,7 @@ #include "convert.h" #include "vcard/vcard.h" +#include "vcard/vcard34conv.h" ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat, wxString InputFilename, wxString OutputFilename){ @@ -118,6 +119,9 @@ ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat, // Check that the file has the correct file format. + vCard vCard4Format; + wxString FinalData; + if (InputFormat == "vCard4"){ // Read from the file. @@ -125,13 +129,16 @@ ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat, wxString InputFileData; InputFile.ReadAll(&InputFileData, wxConvAuto()); - vCard InputvCard; + vCard vCard4Format; - InputvCard.LoadString(InputFileData); + vCard4Format.LoadString(InputFileData); - if (InputvCard.Get("VERSION") != "4.0"){ + if (vCard4Format.Get("VERSION") != "4.0"){ return CONVERTRESULT_INPUTFILEINVALIDFORMAT; } + + // No conversion needs to be as the card is already + // in the vCard 4.0 format. } else if (InputFormat == "vCard3"){ @@ -150,6 +157,42 @@ ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat, } + // Convert the vCard into the required format and + // get the string value. + + if (OutputFormat == "vCard4"){ + + // Do nothing as the vCard is already in the vCard 4.0 + // format. + + } else if (OutputFormat == "vCard3"){ + + // Convert the vCard to vCard 3.0. + + vCard34Conv vCard34ConvObj; + + vCard vCard3Format; + + vCard34ConvObj.ConvertToV3(InputFilename, &FinalData); + + } + + // Check if we are outputting to console or to file. + + if (OutputPipe == false){ + + // We are outputting to a file. + + OutputFile.Write(FinalData, wxConvUTF8); + + } else { + + // Write out the data to the console. + + std::cout << FinalData << std::endl; + + } + return CONVERTRESULT_OK; } \ No newline at end of file