// with Xestia Address Book. If not, see <http://www.gnu.org/licenses/>
#include "convert.h"
+#include "vcard/vcard.h"
ConvertResult ConvertContact(wxString InputFormat, wxString OutputFormat,
wxString InputFilename, wxString OutputFilename){
}
+ // Check that the input filename is not empty.
+
+ if (InputFilename.empty()){
+
+ return CONVERTRESULT_INPUTFILEEMPTY;
+
+ }
+
// Check that the input file given exists.
if (!wxFileExists(InputFilename)){
// Check that the output file can be opened.
+ bool OutputPipe = false;
wxFile OutputFile;
if (!OutputFilename.IsEmpty()){
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;