properly resolve relative ../events/ path for Google
Added URI::resolve(), which is now used for Google default calendar if (and only if) starting with the "/user" or "/user/" URL.
This commit is contained in:
parent
d7c73d5aeb
commit
42e6307048
|
@ -69,6 +69,20 @@ URI URI::fromNeon(const ne_uri &uri)
|
|||
return res;
|
||||
}
|
||||
|
||||
URI URI::resolve(const std::string &path) const
|
||||
{
|
||||
ne_uri tmp[2];
|
||||
ne_uri full;
|
||||
memset(tmp, 0, sizeof(tmp));
|
||||
tmp[0].path = const_cast<char *>(m_path.c_str());
|
||||
tmp[1].path = const_cast<char *>(path.c_str());
|
||||
ne_uri_resolve(tmp + 0, tmp + 1, &full);
|
||||
URI res(*this);
|
||||
res.m_path = full.path;
|
||||
ne_uri_free(&full);
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string URI::toURL() const
|
||||
{
|
||||
return StringPrintf("%s://%s@%s:%u/%s#%s",
|
||||
|
|
|
@ -89,6 +89,12 @@ struct URI {
|
|||
|
||||
static URI fromNeon(const ne_uri &other);
|
||||
|
||||
/**
|
||||
* produce new URI from current path and new one (may be absolute
|
||||
* and relative)
|
||||
*/
|
||||
URI resolve(const std::string &path) const;
|
||||
|
||||
/** compose URL from parts */
|
||||
std::string toURL() const;
|
||||
};
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include <boost/bind.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
|
||||
SE_BEGIN_CXX
|
||||
|
||||
|
@ -81,8 +82,12 @@ void WebDAVSource::open()
|
|||
m_session->propfindProp(m_session->getURI().m_path, 0, caldav, callback);
|
||||
|
||||
// TODO: avoid hard-coded path to Google events
|
||||
std::string events = boost::replace_last_copy(m_session->getURI().m_path, "/user", "/events");
|
||||
m_session->propfindProp(events, 0, caldav, callback);
|
||||
m_calendar = m_session->getURI();
|
||||
if (boost::ends_with(m_calendar.m_path, "/user/") ||
|
||||
boost::ends_with(m_calendar.m_path, "/user")) {
|
||||
m_calendar = m_calendar.resolve("../events/");
|
||||
}
|
||||
m_session->propfindProp(m_calendar.m_path, 0, caldav, callback);
|
||||
}
|
||||
|
||||
void WebDAVSource::openPropCallback(const Neon::URI &uri,
|
||||
|
|
|
@ -48,6 +48,7 @@ class WebDAVSource : public TrackingSyncSource, private boost::noncopyable
|
|||
private:
|
||||
boost::shared_ptr<Neon::Settings> m_settings;
|
||||
boost::shared_ptr<Neon::Session> m_session;
|
||||
Neon::URI m_calendar;
|
||||
|
||||
void openPropCallback(const Neon::URI &uri,
|
||||
const ne_propname *prop,
|
||||
|
|
Loading…
Reference in a new issue