Page MenuHomePhorge

No OneTemporary

Authored By
Unknown
Size
3 KB
Referenced Files
None
Subscribers
None
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
@@ -1,97 +1,80 @@
#include <boost/program_options.hpp>
#include <iostream>
#include <string>
#include <vector>
#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;
using namespace Kolab;
int main(int argc, char *argv[])
{
// Declare the supported options.
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
("input-file", po::value<std::vector<std::string> >(), "input files")
;
po::positional_options_description p;
p.add("input-file", -1);
po::variables_map vm;
po::store(po::command_line_parser(argc, argv).
options(desc).positional(p).run(), vm);
po::notify(vm);
if (vm.count("help")) {
cout << desc << "\n";
return 1;
}
vector<string> inputFiles;
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;
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Apr 24, 10:00 AM (6 d, 21 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18842481
Default Alt Text
(3 KB)

Event Timeline