3 commits - calendaring/calendaring.i calendaring/CMakeLists.txt calendaring/event.cpp calendaring/event.h calendaring/php CMakeLists.txt icalendar/CMakeLists.txt icalendar/php README tests/calendaringtest.cpp tests/calendaringtest.h tests/freebusytest.cpp
Christian Mollekopf
mollekopf at kolabsys.com
Fri Jul 20 02:14:53 CEST 2012
CMakeLists.txt | 3 ++
README | 19 ++++++++++++++++
calendaring/CMakeLists.txt | 7 +++++-
calendaring/calendaring.i | 4 +--
calendaring/event.cpp | 16 ++++++++++++++
calendaring/event.h | 16 ++++++++++++++
calendaring/php/CMakeLists.txt | 46 +++++++++++++++++++++++++++++++++++++++++
icalendar/CMakeLists.txt | 7 +++++-
icalendar/php/CMakeLists.txt | 46 +++++++++++++++++++++++++++++++++++++++++
tests/calendaringtest.cpp | 27 ++++++++++++++++++++++++
tests/calendaringtest.h | 2 +
tests/freebusytest.cpp | 2 +
12 files changed, 191 insertions(+), 4 deletions(-)
New commits:
commit 3e0b73548138ae1c6c1f895532cff9da3e24da55
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Jul 20 02:14:48 2012 +0200
PHP bindings
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c40fb3..fdd6f33 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -4,6 +4,7 @@ cmake_minimum_required(VERSION 2.6.4)
option( BUILD_TESTS "Build the tests" TRUE )
option( PYTHON_BINDINGS "Build bindings for python" FALSE )
+option( PHP_BINDINGS "Build bindings for php" FALSE )
option( USE_LIBCALENDARING "Use libcalendaring" FALSE )
set(Libkolab_MODULE_DIR ${Libkolab_SOURCE_DIR}/cmake/modules)
@@ -59,6 +60,8 @@ else()
find_package(KdepimLibs 4.8 REQUIRED)
endif()
+find_package(SWIG)
+
#Show summary of found libraries
macro_display_feature_log()
diff --git a/calendaring/CMakeLists.txt b/calendaring/CMakeLists.txt
index 28a4e97..395050c 100644
--- a/calendaring/CMakeLists.txt
+++ b/calendaring/CMakeLists.txt
@@ -6,4 +6,9 @@ set (CALENDARING_SRCS
if(PYTHON_BINDINGS)
message("building python bindings")
add_subdirectory(python)
-endif(PYTHON_BINDINGS)
\ No newline at end of file
+endif(PYTHON_BINDINGS)
+
+if(PHP_BINDINGS)
+ message("building php bindings")
+ add_subdirectory(php)
+endif(PHP_BINDINGS)
\ No newline at end of file
diff --git a/calendaring/calendaring.i b/calendaring/calendaring.i
index 4402f60..4f15de2 100644
--- a/calendaring/calendaring.i
+++ b/calendaring/calendaring.i
@@ -24,7 +24,7 @@ namespace std {
%rename(EventXML) Kolab::Event;
-%include "kolabcontainers.h"
-%include "kolabevent.h"
+%include <kolabcontainers.h>
+%include <kolabevent.h>
%include "../calendaring/calendaring.h"
%include "../calendaring/event.h"
diff --git a/calendaring/php/CMakeLists.txt b/calendaring/php/CMakeLists.txt
new file mode 100644
index 0000000..0644c13
--- /dev/null
+++ b/calendaring/php/CMakeLists.txt
@@ -0,0 +1,46 @@
+#Generate PHP wrapper
+include_directories(../)
+
+set(KOLAB_SWIG_PHP_SOURCE_FILE php_calendaring_wrapper.cpp)
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_PHP_SOURCE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/calendaring.php
+ COMMAND ${SWIG} -v -c++ -php -I${Libkolabxml_INCLUDES} -o ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_PHP_SOURCE_FILE} ../calendaring.i
+ COMMENT "Generating php bindings"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ../calendaring.i kolab
+ VERBATIM
+ )
+
+SET_SOURCE_FILES_PROPERTIES(${KOLAB_SWIG_PHP_SOURCE_FILE} PROPERTIES GENERATED 1)
+ADD_CUSTOM_TARGET(generate_calendaring_php_bindings ALL DEPENDS ${KOLAB_SWIG_PHP_SOURCE_FILE})
+
+
+#Compile PHP Bindings
+# Since there is no php library we can't compile with -Wl,--no-undefined
+set(CMAKE_SHARED_LINKER_FLAGS "")
+
+if (APPLE)
+ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flat_namespace -undefined suppress" )
+endif()
+
+find_package(PHP4 5.3 REQUIRED)
+
+if (PHP4_FOUND)
+ include_directories(${PHP4_INCLUDE_PATH})
+ add_library(calendaring_phpbindings SHARED ${KOLAB_SWIG_PHP_SOURCE_FILE})
+ target_link_libraries(calendaring_phpbindings kolab)
+ SET_TARGET_PROPERTIES(calendaring_phpbindings PROPERTIES OUTPUT_NAME "calendaring")
+ SET_TARGET_PROPERTIES(calendaring_phpbindings PROPERTIES PREFIX "")
+
+# configure_file(test.php ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
+
+ set(PHP_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/phpbindings" CACHE STRING "Install directory for php bindings.")
+
+ install(TARGETS calendaring_phpbindings LIBRARY DESTINATION ${PHP_INSTALL_DIR})
+
+ install( FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/calendaring.php
+ DESTINATION ${PHP_INSTALL_DIR}
+ )
+else(PHP4_FOUND)
+ message(WARNING "not building php bindings because php was not found")
+endif (PHP4_FOUND)
diff --git a/icalendar/CMakeLists.txt b/icalendar/CMakeLists.txt
index 7e0efd6..ee276d6 100644
--- a/icalendar/CMakeLists.txt
+++ b/icalendar/CMakeLists.txt
@@ -7,4 +7,9 @@ set (ICALENDAR_SRCS
if(PYTHON_BINDINGS)
message("building python bindings")
add_subdirectory(python)
-endif(PYTHON_BINDINGS)
\ No newline at end of file
+endif(PYTHON_BINDINGS)
+
+if(PHP_BINDINGS)
+ message("building php bindings")
+ add_subdirectory(php)
+endif(PHP_BINDINGS)
diff --git a/icalendar/php/CMakeLists.txt b/icalendar/php/CMakeLists.txt
new file mode 100644
index 0000000..fcdb5da
--- /dev/null
+++ b/icalendar/php/CMakeLists.txt
@@ -0,0 +1,46 @@
+#Generate PHP wrapper
+include_directories(../)
+
+set(KOLAB_SWIG_PHP_SOURCE_FILE php_icalendar_wrapper.cpp)
+add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_PHP_SOURCE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/icalendar.php
+ COMMAND ${SWIG} -v -c++ -php -o ${CMAKE_CURRENT_BINARY_DIR}/${KOLAB_SWIG_PHP_SOURCE_FILE} ../icalendar.i
+ COMMENT "Generating php bindings"
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ../icalendar.i kolab
+ VERBATIM
+ )
+
+SET_SOURCE_FILES_PROPERTIES(${KOLAB_SWIG_PHP_SOURCE_FILE} PROPERTIES GENERATED 1)
+ADD_CUSTOM_TARGET(generate_icalendar_php_bindings ALL DEPENDS ${KOLAB_SWIG_PHP_SOURCE_FILE})
+
+
+#Compile PHP Bindings
+# Since there is no php library we can't compile with -Wl,--no-undefined
+set(CMAKE_SHARED_LINKER_FLAGS "")
+
+if (APPLE)
+ set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flat_namespace -undefined suppress" )
+endif()
+
+find_package(PHP4 5.3 REQUIRED)
+
+if (PHP4_FOUND)
+ include_directories(${PHP4_INCLUDE_PATH})
+ add_library(icalendar_phpbindings SHARED ${KOLAB_SWIG_PHP_SOURCE_FILE})
+ target_link_libraries(icalendar_phpbindings kolab ${PHP_LIBRARIES})
+ SET_TARGET_PROPERTIES(icalendar_phpbindings PROPERTIES OUTPUT_NAME "icalendar")
+ SET_TARGET_PROPERTIES(icalendar_phpbindings PROPERTIES PREFIX "")
+
+# configure_file(test.php ${CMAKE_CURRENT_BINARY_DIR} COPYONLY)
+
+ set(PHP_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/phpbindings" CACHE STRING "Install directory for php bindings.")
+
+ install(TARGETS icalendar_phpbindings LIBRARY DESTINATION ${PHP_INSTALL_DIR})
+
+ install( FILES
+ ${CMAKE_CURRENT_BINARY_DIR}/icalendar.php
+ DESTINATION ${PHP_INSTALL_DIR}
+ )
+else(PHP4_FOUND)
+ message(WARNING "not building php bindings because php was not found")
+endif (PHP4_FOUND)
commit 9b3a1d544eb6d3bda77111153b95cd2ddd890dff
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Jul 20 00:34:28 2012 +0200
start of a readme
diff --git a/README b/README
new file mode 100644
index 0000000..fb7c7ed
--- /dev/null
+++ b/README
@@ -0,0 +1,19 @@
+= 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
commit 3e83624f788fc157d142db7b4ba139dd69830983
Author: Christian Mollekopf <mollekopf at kolabsys.com>
Date: Fri Jul 20 00:33:58 2012 +0200
Recurrence functions to loop through all occurences of an event.
diff --git a/calendaring/event.cpp b/calendaring/event.cpp
index f3bdce6..a4e7e84 100644
--- a/calendaring/event.cpp
+++ b/calendaring/event.cpp
@@ -200,7 +200,23 @@ Attendee Event::getAttendee(const std::string &s)
return Attendee();
}
+cDateTime Calendaring::Event::getNextOccurence(const cDateTime &date)
+{
+ KCalCore::Event::Ptr event = Kolab::Conversion::toKCalCore(*this);
+ if (!event->recurs()) {
+ return cDateTime();
+ }
+ const KDateTime nextDate = event->recurrence()->getNextDateTime(Kolab::Conversion::toDate(date));
+ return Kolab::Conversion::fromDate(nextDate);
+}
+cDateTime Calendaring::Event::getOccurenceEndDate(const cDateTime &startDate)
+{
+ KCalCore::Event::Ptr event = Kolab::Conversion::toKCalCore(*this);
+ const KDateTime start = Kolab::Conversion::toDate(startDate);
+ return Kolab::Conversion::fromDate(event->endDateForStart(start));
+}
+
};
};
diff --git a/calendaring/event.h b/calendaring/event.h
index 76efd7f..4657637 100644
--- a/calendaring/event.h
+++ b/calendaring/event.h
@@ -89,6 +89,22 @@ public:
* Get attendee by uid/email/name (in this order)
*/
Kolab::Attendee getAttendee(const std::string &);
+
+ /**
+ * Returns the next occurence for a recurring event.
+ *
+ * If the start date of the event is passed in, the second occurence is returned (so it can be used in a for loop to loop through all occurences).
+ *
+ * If there is no next occurence or the event is not recurring at all an invalid cDateTime is returned.
+ */
+ Kolab::cDateTime getNextOccurence(const Kolab::cDateTime &);
+
+ /**
+ * Returns the corresponding end date-time for a specific occurence.
+ * @param start is the start date of the occurence.
+ */
+ Kolab::cDateTime getOccurenceEndDate(const Kolab::cDateTime &start);
+
private:
Kolab::Attendee *getAttendee(const ContactReference &);
Kolab::ITipHandler mITipHandler;
diff --git a/tests/calendaringtest.cpp b/tests/calendaringtest.cpp
index 91b1b11..28aa0c6 100644
--- a/tests/calendaringtest.cpp
+++ b/tests/calendaringtest.cpp
@@ -367,6 +367,33 @@ void CalendaringTest::testIMip()
QCOMPARE(event.getSchedulingMethod(), Kolab::Calendaring::Event::iTIPRequest);
}
+void CalendaringTest::testRecurrence()
+{
+ Kolab::Calendaring::Event event;
+ event.setStart(Kolab::cDateTime(2011,1,1,1,1,1));
+ event.setEnd(Kolab::cDateTime(2011,1,1,2,1,1));
+ Kolab::RecurrenceRule rrule;
+ rrule.setFrequency(Kolab::RecurrenceRule::Daily);
+ rrule.setInterval(1);
+ rrule.setCount(10);
+ event.setRecurrenceRule(rrule);
+
+ Kolab::cDateTime previousDate = event.start();
+ for (int i = 0; i < 9; i++) {
+ const Kolab::cDateTime nextDate = event.getNextOccurence(previousDate);
+// qDebug() << QTest::toString(nextDate);
+ QCOMPARE(nextDate, Kolab::cDateTime(previousDate.year(), previousDate.month(), previousDate.day()+1, previousDate.hour(), previousDate.minute(), previousDate.second()));
+ const Kolab::cDateTime endDate = event.getOccurenceEndDate(nextDate);
+// qDebug() << QTest::toString(endDate);
+ QCOMPARE(endDate, Kolab::cDateTime(nextDate.year(), nextDate.month(), nextDate.day(), event.end().hour(), event.end().minute(), event.end().second()));
+ previousDate = nextDate;
+ }
+
+ Kolab::cDateTime outOfScopeDate = event.getNextOccurence(previousDate);
+ QVERIFY(!outOfScopeDate.isValid());
+
+}
+
QTEST_MAIN( CalendaringTest )
diff --git a/tests/calendaringtest.h b/tests/calendaringtest.h
index c3827de..0751d48 100644
--- a/tests/calendaringtest.h
+++ b/tests/calendaringtest.h
@@ -42,6 +42,8 @@ private slots:
void testMime();
void testICal();
void testIMip();
+
+ void testRecurrence();
};
#endif // CALENDARINGTEST_H
diff --git a/tests/freebusytest.cpp b/tests/freebusytest.cpp
index 0320ba1..26afe39 100644
--- a/tests/freebusytest.cpp
+++ b/tests/freebusytest.cpp
@@ -24,6 +24,8 @@
#include "freebusy/freebusy.h"
#include <kolabfreebusy.h>
+#include <iostream>
+
void FreebusyTest::testFB_data()
{
More information about the commits
mailing list