WebDAV: allow compilation on older distros (Ubuntu Hardy)
libneon 0.27 doesn't have ne_options2() and ne_session_system_proxy(). ne_options2() is purely for debugging, disabled in builds on old distros. ne_session_system_proxy() is needed to enable the use of the system proxy settings. If a recent enough libneon.so.27 is found at runtime (= one which has the function), then it is called. libical was contained in libecal in Ubuntu Hardy, at least the way how SyncEvolution is compiled there. Thus use libecal-1.2 when libical is not found. Also handle the different ical string allocation semantic via the icalstrdup() wrapper.
This commit is contained in:
parent
17eefc106b
commit
9b70dc2e03
|
@ -2,18 +2,21 @@
|
|||
* Copyright (C) 2010 Intel Corporation
|
||||
*/
|
||||
|
||||
#include "CalDAVSource.h"
|
||||
#include "config.h"
|
||||
|
||||
#ifdef ENABLE_DAV
|
||||
|
||||
// include first, it sets HANDLE_LIBICAL_MEMORY for us
|
||||
#include <syncevo/icalstrdup.h>
|
||||
|
||||
#include "CalDAVSource.h"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
#include <syncevo/declarations.h>
|
||||
SE_BEGIN_CXX
|
||||
|
||||
// TODO: use EDS backend icalstrdup.c
|
||||
#define ical_strdup(_x) (_x)
|
||||
|
||||
CalDAVSource::CalDAVSource(const SyncSourceParams ¶ms,
|
||||
const boost::shared_ptr<Neon::Settings> &settings) :
|
||||
|
@ -83,7 +86,7 @@ int CalDAVSource::appendItem(SubRevisionMap_t &revisions,
|
|||
std::string &data)
|
||||
{
|
||||
Event::unescapeRecurrenceID(data);
|
||||
eptr<icalcomponent> calendar(icalcomponent_new_from_string(data.c_str()),
|
||||
eptr<icalcomponent> calendar(icalcomponent_new_from_string((char *)data.c_str()), // cast is a hack for broken definition in old libical
|
||||
"iCalendar 2.0");
|
||||
std::string davLUID = path2luid(Neon::URI::parse(href).m_path);
|
||||
pair<string, set<string> > &rev = revisions[davLUID];
|
||||
|
@ -614,7 +617,7 @@ CalDAVSource::Event &CalDAVSource::loadItem(Event &event)
|
|||
}
|
||||
}
|
||||
Event::unescapeRecurrenceID(item);
|
||||
event.m_calendar.set(icalcomponent_new_from_string(item.c_str()),
|
||||
event.m_calendar.set(icalcomponent_new_from_string((char *)item.c_str()), // hack for old libical
|
||||
"parsing iCalendar 2.0");
|
||||
// sequence number might have been increased by last save,
|
||||
// so check it again
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include <syncevo/LogRedirect.h>
|
||||
#include <syncevo/SmartPtr.h>
|
||||
|
||||
#include <dlfcn.h>
|
||||
|
||||
#include <syncevo/declarations.h>
|
||||
SE_BEGIN_CXX
|
||||
|
||||
|
@ -196,7 +198,18 @@ Session::Session(const boost::shared_ptr<Settings> &settings) :
|
|||
|
||||
m_proxyURL = settings->proxy();
|
||||
if (m_proxyURL.empty()) {
|
||||
#ifdef HAVE_LIBNEON_SYSTEM_PROXY
|
||||
// hard compile-time dependency
|
||||
ne_session_system_proxy(m_session, 0);
|
||||
#else
|
||||
// compiled against older libneon, but might run with more recent neon
|
||||
typedef void (*session_system_proxy_t)(ne_session *sess, unsigned int flags);
|
||||
session_system_proxy_t session_system_proxy =
|
||||
(session_system_proxy_t)dlsym(RTLD_DEFAULT, "ne_session_system_proxy");
|
||||
if (session_system_proxy) {
|
||||
session_system_proxy(m_session, 0);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
URI proxyuri = URI::parse(m_proxyURL);
|
||||
ne_session_proxy(m_session, proxyuri.m_host.c_str(), proxyuri.m_port);
|
||||
|
@ -317,12 +330,14 @@ int Session::sslVerify(void *userdata, int failures, const ne_ssl_certificate *c
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBNEON_OPTIONS
|
||||
unsigned int Session::options(const std::string &path)
|
||||
{
|
||||
unsigned int caps;
|
||||
check(ne_options2(m_session, path.c_str(), &caps));
|
||||
return caps;
|
||||
}
|
||||
#endif // HAVE_LIBNEON_OPTIONS
|
||||
|
||||
void Session::propfindURI(const std::string &path, int depth,
|
||||
const ne_propname *props,
|
||||
|
|
|
@ -181,8 +181,10 @@ class Session {
|
|||
static boost::shared_ptr<Session> create(const boost::shared_ptr<Settings> &settings);
|
||||
~Session();
|
||||
|
||||
#ifdef HAVE_LIBNEON_OPTIONS
|
||||
/** ne_options2() for a specific path*/
|
||||
unsigned int options(const std::string &path);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* called with URI and complete result set; exceptions are logged, but ignored
|
||||
|
|
|
@ -540,6 +540,7 @@ void WebDAVSource::open()
|
|||
SE_LOG_DEBUG(NULL, NULL, "picked final path %s", m_calendar.m_path.c_str());
|
||||
|
||||
// Check some server capabilities. Purely informational at this point.
|
||||
#ifdef HAVE_LIBNEON_OPTIONS
|
||||
if (LoggerBase::instance().getLevel() >= Logger::DEV) {
|
||||
SE_LOG_DEBUG(NULL, NULL, "read capabilities of %s", m_calendar.toURL().c_str());
|
||||
int caps = m_session->options(path);
|
||||
|
@ -566,6 +567,7 @@ void WebDAVSource::open()
|
|||
m_session->getURL().c_str(),
|
||||
Flags2String(caps, descr).c_str());
|
||||
}
|
||||
#endif // HAVE_LIBNEON_OPTIONS
|
||||
}
|
||||
|
||||
void WebDAVSource::openPropCallback(const Neon::URI &uri,
|
||||
|
|
|
@ -10,9 +10,15 @@ AC_ARG_ENABLE_BACKEND(dav,
|
|||
)
|
||||
|
||||
if test "$enable_dav" = "yes"; then
|
||||
PKG_CHECK_MODULES(LIBICAL, libical)
|
||||
PKG_CHECK_MODULES(NEON, neon >= 0.29)
|
||||
PKG_CHECK_MODULES(LIBICAL, libical,
|
||||
[true],
|
||||
[PKG_CHECK_MODULES(LIBICAL, libecal-1.2)])
|
||||
PKG_CHECK_MODULES(NEON, neon >= 0.29,
|
||||
[AC_DEFINE(HAVE_LIBNEON_SYSTEM_PROXY, 1, [ne_session_system_proxy() available])
|
||||
AC_DEFINE(HAVE_LIBNEON_OPTIONS, 1, [ne_options2() and NE_CAP_* defines available])],
|
||||
[PKG_CHECK_MODULES(NEON, neon >= 0.27)])
|
||||
AC_DEFINE(ENABLE_DAV, 1, [DAV available])
|
||||
AC_DEFINE(ENABLE_ICAL, 1, [libical in use])
|
||||
BACKEND_CPPFLAGS="$BACKEND_CPPFLAGS $NEON_CFLAGS"
|
||||
fi
|
||||
AM_CONDITIONAL([ENABLE_ICAL], [test "$enable_dav" = "yes"])
|
||||
|
|
Loading…
Reference in a new issue