X-Git-Url: http://Server1/repobrowser/?a=blobdiff_plain;f=source%2Fconvert.cpp;h=ae0e4db81b30d0fa71659dc79c18d052855d715f;hb=6e5b70888b9a1bc4bb1c1d443402f9e7987e31d1;hp=2da7e4554972760b0007cd5369d1dc59c0d1c01c;hpb=0e3dcfcd57de79eac7dfce743447d81b5379e358;p=xestiaab%2F.git diff --git a/source/convert.cpp b/source/convert.cpp index 2da7e45..ae0e4db 100644 --- a/source/convert.cpp +++ b/source/convert.cpp @@ -17,6 +17,7 @@ // with Xestia Address Book. If not, see #include "convert.h" +#include "vcard/vcard.h" ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat, wxString InputFilename, wxString OutputFilename){ @@ -72,6 +73,14 @@ ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat, } + // Check that the input filename is not empty. + + if (InputFilename.empty()){ + + return CONVERTRESULT_INPUTFILEEMPTY; + + } + // Check that the input file given exists. if (!wxFileExists(InputFilename)){ @@ -92,6 +101,7 @@ ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat, // Check that the output file can be opened. + bool OutputPipe = false; wxFile OutputFile; if (!OutputFilename.IsEmpty()){ @@ -100,6 +110,44 @@ ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat, return CONVERTRESULT_OUTPUTFILEERROR; } + } else { + + OutputPipe = true; + + } + + // Check that the file has the correct file format. + + if (InputFormat == "vCard4"){ + + // Read from the file. + + wxString InputFileData; + InputFile.ReadAll(&InputFileData, wxConvAuto()); + + vCard InputvCard; + + InputvCard.LoadString(InputFileData); + + if (InputvCard.Get("VERSION") != "4.0"){ + return CONVERTRESULT_INPUTFILEINVALIDFORMAT; + } + + } else if (InputFormat == "vCard3"){ + + // Read from the file. + + wxString InputFileData; + InputFile.ReadAll(&InputFileData, wxConvAuto()); + + vCard InputvCard; + + InputvCard.LoadString(InputFileData); + + if (InputvCard.Get("VERSION") != "3.0"){ + return CONVERTRESULT_INPUTFILEINVALIDFORMAT; + } + } return CONVERTRESULT_OK;