Commit c6a3dedf authored by Laurent Montel's avatar Laurent Montel 😁

Create own libpimkolab.

We decided to do it, for having more control on it.
So we will be able to debug, improve clean up it.

There was not improvement from age in official repo.
parent 8616ee44
remove_definitions(
-DQT_NO_CAST_FROM_ASCII
-DQT_NO_CAST_TO_ASCII
)
set(Libkolab_MODULE_DIR ${Libkolab_SOURCE_DIR}/cmake/modules)
set(CMAKE_MODULE_PATH ${Libkolab_MODULE_DIR})
# Versioning
# x.y.z scheme
# Development versions are only x.y
#
# i.e.
# 0.1 (0.1 development version towards 0.1.0)
# 0.1.0 (first release)
# 0.1.1 (patch release for 0.1.0)
# 0.2 (0.2 development version towards 0.2.0)
set(Libkolab_VERSION_MAJOR 1)
set(Libkolab_VERSION_MINOR 0)
# Enable the full x.y.z version only for release versions
set(Libkolab_VERSION_PATCH 2)
#set(Libkolab_VERSION ${Libkolab_VERSION_MAJOR}.${Libkolab_VERSION_MINOR}.${Libkolab_VERSION_PATCH})
set(Libkolab_VERSION ${Libkolab_VERSION_MAJOR}.${Libkolab_VERSION_MINOR})
set(Libkolab_VERSION_STRING ${CMAKE_PROJECT_NAME}-${Libkolab_VERSION})
# set up install directories.
set(LIB_INSTALL_DIR lib${LIB_SUFFIX} CACHE STRING "The directories where to install libraries to")
set(INCLUDE_INSTALL_DIR include CACHE STRING "The directory where to install headers to")
set(INCLUDE_INSTALL_DIR ${INCLUDE_INSTALL_DIR}/kolab)
set(CMAKECONFIG_INSTALL_DIR ${LIB_INSTALL_DIR}/cmake/Libkolab)
if (Qt5_POSITION_INDEPENDENT_CODE)
#Requires cmake 2.8.9 (same as -fPIC on gcc)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
# add_definitions(-DKDEPIMLIBS_VERSION=((${KdepimLibs_VERSION_MAJOR}<<16)|(${KdepimLibs_VERSION_MINOR}<<8)|(${KDEPIMLIBS_VERSION_PATCH})))
add_definitions(-DKDEPIMLIBS_VERSION_MAJOR=${KdepimLibs_VERSION_MAJOR})
add_definitions(-DKDEPIMLIBS_VERSION_MINOR=${KdepimLibs_VERSION_MINOR})
add_definitions(-DKDEPIMLIBS_VERSION_PATCH=${KdepimLibs_VERSION_PATCH})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wnon-virtual-dtor -Wno-long-long -ansi -Wundef -Wcast-align -Wchar-subscripts -Wall -W -Wpointer-arith -Wformat-security -fno-exceptions -DQT_NO_EXCEPTIONS -fno-common -Woverloaded-virtual -fno-threadsafe-statics -fvisibility=hidden -Werror=return-type -fvisibility-inlines-hidden -fexceptions -UQT_NO_EXCEPTIONS -fPIC -g -std=c++11")
# message("${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DQT_NO_DEBUG")
set(KDE_LIBRARIES
KF5::CalendarCore
KF5::CalendarUtils
KF5::Contacts
KF5::Mime
KF5::AkonadiCore
KF5::AkonadiNotes
KF5::Codecs
KF5::KDELibs4Support
)
find_package(Boost REQUIRED)
include_directories(
${Boost_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/kolabformatV2
${Libkolabxml_INCLUDES}
./
)
configure_file(libkolab-version.h.cmake "${CMAKE_CURRENT_BINARY_DIR}/libkolab-version.h" @ONLY)
add_subdirectory(kolabformatV2)
add_subdirectory(conversion)
add_subdirectory(calendaring)
add_subdirectory(icalendar)
add_subdirectory(freebusy)
add_subdirectory(utils)
QT5_WRAP_CPP(CALENDARING_MOC calendaring/event.h)
set(KOLAB_SRCS
kolabformat/kolabobject.cpp
kolabformat/xmlobject.cpp
kolabformat/formathelpers.cpp
kolabformat/errorhandler.cpp
kolabformat/v2helpers.cpp
kolabformat/mimeobject.cpp
mime/mimeutils.cpp
utils/porting.cpp
${CONVERSION_SRCS}
${kolabformatv2_SRCS}
${CALENDARING_SRCS}
${ICALENDAR_SRCS}
${CALENDARING_MOC}
${CONVERSION_MOC}
${FREEBUSY_SRCS}
)
set(KOLAB_LINK_LIBRARIES
${Libkolabxml_LIBRARIES}
${KDE_LIBRARIES}
Qt5::Core
Qt5::Xml
Qt5::Gui
Qt5::Widgets
)
if(BUILD_TESTS)
find_package(Qt5Test REQUIRED)
#for tests only
enable_testing()
add_library(kolab_static STATIC ${KOLAB_SRCS})
target_link_libraries(kolab_static ${KOLAB_LINK_LIBRARIES} Qt5::Test)
add_subdirectory(tests)
endif(BUILD_TESTS)
add_library(pimkolab STATIC ${KOLAB_SRCS})
target_link_libraries(pimkolab ${KOLAB_LINK_LIBRARIES})
set_target_properties(pimkolab PROPERTIES VERSION ${Libkolab_VERSION}
SOVERSION ${Libkolab_VERSION_MAJOR})
install(TARGETS pimkolab EXPORT LibkolabExport
RUNTIME DESTINATION ${BIN_INSTALL_DIR}
LIBRARY DESTINATION ${LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${LIB_INSTALL_DIR}
)
kolabformatV2/*: LGPLv2 or later
Everything else: LGPLv3 or later
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
= About =
Libkolab provides advanced calendaring functionality including:
* recurrence handling
* timezone handling
* iTip/iMip parsing/generating
* Freebusy generating
To implement most of the functionality, the kdepim libraries are used. The functionality of this library can be exposed via SWIG bindings to other languages.
Structure:
* kolabformatv2: Kolabformat v2 implementation from kdepim-runtime (moved here)
* kolabformat: Kolab object reading/writing (mime message + kolab-format). Handles v2/v3 transparently.
Currently this interface uses the KDE Containers, eventually we'd want one that uses the Kolab Containers and can be wrapped in SWIG bindings.
* conversion: Conversions from KDE to Kolab containers and vice verca.
* mime: Mime message handling used by kolabformat
* icalendar: Exposes iCalendar functionality: iCal reading/writing, iTip, iMip
* calendaring: Some general calendaring functions
* freebusy: Freebusy generating functions.
\ No newline at end of file
== Attention to Distributors ==
* 0.3: Headers are now installed into $INCLUDE_INSTALL_DIR/kolab
#!/bin/bash
dobuild=0
doprep=0
dotest=0
doinstall=0
srcdir=$(pwd)
while [ $# -gt 0 ]; do
case "$1" in
--build|-b)
dobuild=1
shift
;;
--prep|-p)
doprep=1
shift
;;
--test|-t)
dotest=1
shift
;;
--install|-i)
doinstall=1
shift
;;
esac
done
if [ ${dobuild} -eq 0 -a ${doprep} -eq 0 -a ${dotest} -eq 0 -a ${doinstall} -eq 0 ]; then
dobuild=1
doprep=1
dotest=1
doinstall=1
fi
version_major=`grep -E "^set\s*\(Libkolab_VERSION_MAJOR [0-9]+\)" CMakeLists.txt | sed -r -e 's/^set\s*\(Libkolab_VERSION_MAJOR ([0-9]+)\)/\1/g'`
version_minor=`grep -E "^set\s*\(Libkolab_VERSION_MINOR [0-9]+\)" CMakeLists.txt | sed -r -e 's/^set\s*\(Libkolab_VERSION_MINOR ([0-9]+)\)/\1/g'`
version_patch=`grep -E "^set\s*\(Libkolab_VERSION_PATCH [0-9]+\)" CMakeLists.txt | sed -r -e 's/^set\s*\(Libkolab_VERSION_PATCH ([0-9]+)\)/\1/g'`
if [ -z "${version_patch}" ]; then
version="${version_major}.${version_minor}"
else
version="${version_major}.${version_minor}.${version_patch}"
fi
# Rebuilds the entire foo in one go. One shot, one kill.
rm -rf build/
mkdir -p build
cd build
if [ ${doprep} -eq 1 ]; then
cmake \
-DCMAKE_VERBOSE_MAKEFILE=ON \
-DCMAKE_INSTALL_PREFIX=/usr \
-DLIB_INSTALL_DIR=/usr/lib64 \
-DINCLUDE_INSTALL_DIR=/usr/include \
-DUSE_LIBCALENDARING=ON \
-DPHP_BINDINGS=ON \
-DPHP_INSTALL_DIR=/usr/lib64/php/modules \
-DPYTHON_BINDINGS=ON \
-DCMAKE_BUILD_TYPE=Release \
..
fi
if [ ${dobuild} -eq 1 ]; then
make
fi
if [ ${dotest} -eq 1 ]; then
# Execute some tests?
pushd tests
unset DISPLAY
./benchmarktest
./calendaringtest
./formattest
./freebusytest
./icalendartest
./kcalconversiontest
./upgradetest
popd
fi
if [ ${doinstall} -eq 1 ]; then
make install DESTDIR=${TMPDIR:-/tmp}
fi
cd ..
rm -rf libkolab-${version}.tar.gz
git archive --prefix=libkolab-${version}/ HEAD | gzip -c > libkolab-${version}.tar.gz
rm -rf `rpm --eval='%{_sourcedir}'`/libkolab-${version}.tar.gz
cp libkolab-${version}.tar.gz `rpm --eval='%{_sourcedir}'`
set (CALENDARING_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/calendaring.cpp
${CMAKE_CURRENT_SOURCE_DIR}/event.cpp
${CMAKE_CURRENT_SOURCE_DIR}/datetimeutils.cpp
PARENT_SCOPE)
if(PYTHON_BINDINGS)
message("building python bindings")
add_subdirectory(python)
endif(PYTHON_BINDINGS)
if(PHP_BINDINGS)
message("building php bindings")
add_subdirectory(php)
endif(PHP_BINDINGS)
/*
* Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "calendaring.h"
#include <kcalcore/event.h>
#include <kcalcore/todo.h>
#include <qdebug.h>
#include <kolabevent.h>
#include <QDate>
#include <QTimeZone>
#include "conversion/kcalconversion.h"
#include "conversion/commonconversion.h"
namespace Kolab {
namespace Calendaring {
bool conflicts(const Kolab::Event &e1, const Kolab::Event &e2)
{
KCalCore::Event::Ptr k1 = Kolab::Conversion::toKCalCore(e1);
KCalCore::Event::Ptr k2 = Kolab::Conversion::toKCalCore(e2);
if (k2->dtEnd() < k1->dtStart()) {
return false;
} else if (k1->dtEnd() < k2->dtStart()) {
return false;
}
return true;
}
std::vector< std::vector< Event > > getConflictingSets(const std::vector< Event > &events, const std::vector< Event > &events2)
{
std::vector< std::vector< Kolab::Event > > ret;
for(std::size_t i = 0; i < events.size(); i++) {
std::vector<Kolab::Event> set;
const Kolab::Event &event = events.at(i);
set.push_back(event);
for(std::size_t q = i+1; q < events.size(); q++) {
const Kolab::Event &e2 = events.at(q);
if (conflicts(event, e2)) {
set.push_back(e2);
}
}
for(std::size_t m = 0; m < events2.size(); m++) {
const Kolab::Event &e2 = events2.at(m);
if (conflicts(event, e2)) {
set.push_back(e2);
}
}
if (set.size() > 1) {
ret.push_back(set);
}
}
return ret;
}
std::vector<Kolab::cDateTime> timeInInterval(const Kolab::Event &e, const Kolab::cDateTime &start, const Kolab::cDateTime &end)
{
KCalCore::Event::Ptr k = Kolab::Conversion::toKCalCore(e);
KCalCore::DateTimeList list = k->recurrence()->timesInInterval(Kolab::Conversion::toDate(start), Kolab::Conversion::toDate(end));
std::vector<Kolab::cDateTime> dtList;
foreach(const QDateTime &dt, list) {
dtList.push_back(Kolab::Conversion::fromDate(dt, start.isDateOnly()));
}
return dtList;
}
Calendar::Calendar()
: mCalendar(new KCalCore::MemoryCalendar(Kolab::Conversion::getTimeSpec(true, std::string()))) //Always utc as it doesn't change anything anyways
{
}
void Calendar::addEvent(const Kolab::Event &event)
{
KCalCore::Event::Ptr k = Kolab::Conversion::toKCalCore(event);
if (!mCalendar->addEvent(k)) {
qWarning() << "failed to add event";
}
}
std::vector<Kolab::Event> Calendar::getEvents(const Kolab::cDateTime& start, const Kolab::cDateTime& end, bool sort)
{
const QDateTime s = Kolab::Conversion::toDate(start);
const QDateTime e = Kolab::Conversion::toDate(end);
const QTimeZone tz = s.timeZone();
KCalCore::Event::List list = mCalendar->events(s.date(), e.date(), tz, true);
if (sort) {
list = mCalendar->sortEvents(list, KCalCore::EventSortStartDate, KCalCore::SortDirectionAscending);
}
std::vector<Kolab::Event> eventlist;
foreach (const KCalCore::Event::Ptr &event, list) {
//We have to filter the list by time
if (event->dtEnd() >= s && e >= event->dtStart()) {
eventlist.push_back(Kolab::Conversion::fromKCalCore(*event));
}
}
return eventlist;
}
} //Namespace
} //Namespace
/*
* Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KOLABCALENDARING_H
#define KOLABCALENDARING_H
#ifndef SWIG
#include "kolab_export.h"
#else
/* No export/import SWIG interface files */
#define KOLAB_EXPORT
#endif
#include <kcalcore/event.h>
#include <kcalcore/memorycalendar.h>
#include <boost/scoped_ptr.hpp>
#include <kolabevent.h>
namespace Kolab {
namespace Calendaring {
/**
* Returns true if the events conflict (overlap)
* Start and end date/time is inclusive.
*
* Does not take recurrences into account.
*/
KOLAB_EXPORT bool conflicts(const Kolab::Event &, const Kolab::Event &);
/**
* Returns sets of the events which are directly conflicting with each other.
* The same event may appear in multiple sets.
* Non-conflicting events are not returned.
* conflicts() is used for conflict detection.
*
* If the second list is given, each event from the first list is additionally checked against each event of the second set.
* Conflicts within the second list are not detected.
*
* The checked event from the first list comes always first in the returned set.
*/
KOLAB_EXPORT std::vector< std::vector<Kolab::Event> > getConflictingSets(const std::vector<Kolab::Event> &, const std::vector<Kolab::Event> & = std::vector<Kolab::Event>());
/**
* Returns the dates in which the event recurs within the specified timespan.
*/
KOLAB_EXPORT std::vector<Kolab::cDateTime> timeInInterval(const Kolab::Event &, const Kolab::cDateTime &start, const Kolab::cDateTime &end);
/**
* In-Memory Calendar Cache
*/
class KOLAB_EXPORT Calendar {
public:
explicit Calendar();
/**
* Add an event to the in-memory calendar.
*/
void addEvent(const Kolab::Event &);
/**
* Returns all events within the specified interval (start and end inclusive).
*
* @param sort controls if the resulting event set is sorted in ascending order according to the start date
*/
std::vector<Kolab::Event> getEvents(const Kolab::cDateTime &start, const Kolab::cDateTime &end, bool sort);
private:
Calendar(const Calendar &);
void operator=(const Calendar &);
boost::scoped_ptr<KCalCore::MemoryCalendar> mCalendar;
};
}; //Namespace
}; //Namespace
#endif
%{
/* This macro ensures that return vectors remain a vector also in python and are not converted to tuples */
#define SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS
#include "../calendaring/calendaring.h"
#include "../calendaring/event.h"
%}
%include "std_string.i"
%include "std_vector.i"
%import(module="kolabformat") <kolabevent.h>
%import "../shared.i"
%rename(EventCal) Kolab::Calendaring::Event;
%rename(KolabCalendar) Kolab::Calendaring::Calendar;
%include "../calendaring/calendaring.h"
%include "../calendaring/event.h"
/*
* Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "datetimeutils.h"
#include <qdebug.h>
#include <QTimeZone>
#include "conversion/commonconversion.h"
namespace Kolab {
namespace DateTimeUtils {
KOLAB_EXPORT std::string getLocalTimezone()
{
const QString tz = QTimeZone::systemTimeZoneId();
return tz.toStdString();
}
} //Namespace
} //Namespace
/*
* Copyright (C) 2012 Christian Mollekopf <mollekopf@kolabsys.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef KOLABDATETIMEUTILS_H
#define KOLABDATETIMEUTILS_H
#ifndef SWIG
#include "kolab_export.h"
#else
/* No export/import SWIG interface files */
#define KOLAB_EXPORT
#endif
#include <string>
namespace Kolab {
namespace DateTimeUtils {
KOLAB_EXPORT std::string getLocalTimezone();
}; //Namespace
}; //Namespace
#endif