summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorSofia Balicka <balicka@kolabsys.com>2012-12-03 12:08:08 (GMT)
committerSofia Balicka <balicka@kolabsys.com>2012-12-03 12:08:08 (GMT)
commit13269ae66fadc484b1b4ba68f44298cf95d818dc (patch)
treee5f420a679a7db95857277cc6cebff9d727b2198 /utils
parentc0701e95450905fc0062f748c76444f7b422c830 (diff)
downloadlibkolab-13269ae66fadc484b1b4ba68f44298cf95d818dc.tar.gz
Formatchecker rewritten
Diffstat (limited to 'utils')
-rw-r--r--utils/CMakeLists.txt5
-rw-r--r--utils/kolabformatchecker.cpp65
2 files changed, 29 insertions, 41 deletions
diff --git a/utils/CMakeLists.txt b/utils/CMakeLists.txt
new file mode 100644
index 0000000..19d34d1
--- /dev/null
+++ b/utils/CMakeLists.txt
@@ -0,0 +1,5 @@
+
+find_package(Boost REQUIRED COMPONENTS program_options)
+
+add_executable(kolabformatchecker kolabformatchecker.cpp)
+target_link_libraries(kolabformatchecker kolab ${Boost_LIBRARIES})
diff --git a/utils/kolabformatchecker.cpp b/utils/kolabformatchecker.cpp
index f13a08c..af5a0ed 100644
--- a/utils/kolabformatchecker.cpp
+++ b/utils/kolabformatchecker.cpp
@@ -5,8 +5,8 @@
#include <kolabformat.h>
#include "tests/testutils.h"
#include "kolabformat/kolabobject.h"
-#include "qstring.h"
#include "kolabformat/errorhandler.h"
+#include "qstring.h"
namespace po = boost::program_options;
using namespace std;
@@ -38,60 +38,43 @@ int main(int argc, char *argv[])
if (vm.count("input-file")) {
inputFiles = vm["input-file"].as< vector<string> >();
} else {
- cout << "Specify input-file";
+ cout << "Specify input-file\n";
return -1;
}
+ ErrorHandler::handleLibkolabxmlErrors();
+
+ bool faildToOpen=false;
+
+ cout << endl;
+
for(vector<string>::const_iterator it = inputFiles.begin();
it != inputFiles.end(); it++){
- ErrorHandler::clearErrors();
+ cout << "File: " << *it << endl;
+
bool ok;
KMime::Message::Ptr message = readMimeFile( QString::fromStdString(*it), ok);
- if(!ok) continue;
-
- Kolab::KolabObjectReader reader(message);
- ObjectType type = reader.getType();
-
- switch (type){
- case ContactObject:
- reader.getContact();
- break;
- case DistlistObject:
- reader.getDistlist();
- break;
- case EventObject:
- reader.getEvent();
- break;
- case TodoObject:
- reader.getTodo();
- break;
- case JournalObject:
- reader.getJournal();
- break;
- case FreebusyObject:
- reader.getFreebusy();
- break;
- case NoteObject:
- reader.getNote();
- break;
- //case DictionaryConfigurationObject:
- // break;
+ if(!ok){
+ faildToOpen=true;
+ cout << endl;
+ continue;
}
- cout << "File: " << *it << endl;
-
- if (error()) {
- cout << "Error: " << errorMessage() << endl;
- } else if (ErrorHandler::errorOccured() || type == InvalidObject){
- //was machen?
- cout << "error..." << endl;
- } else {
+ Kolab::KolabObjectReader reader(message);
+
+ if (!error()) {
cout << "Parsed message without error." << endl;
}
-
+
+ cout << endl;
}
+
+ if (ErrorHandler::errorOccured() || faildToOpen){
+ return -1;
+ }
+
return 0;
}