Skip to content
This repository was archived by the owner on Sep 4, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/pim.calendar/CalendarEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ CalendarEvent.prototype.save = function (onSaveSuccess, onSaveError) {
args._eventId = utils.guid();

saveCallback = function (args) {
var result = JSON.parse(unescape(args.result)),
var result = JSON.parse(unescape(decodeURIComponent(args.result))),
errorObj,
newEvent;

Expand Down Expand Up @@ -219,7 +219,7 @@ CalendarEvent.prototype.remove = function (onRemoveSuccess, onRemoveError, remov
}

removeCallback = function (args) {
var result = JSON.parse(unescape(args.result)),
var result = JSON.parse(unescape(decodeURIComponent(args.result))),
errorObj;

if (result._success) {
Expand Down
2 changes: 1 addition & 1 deletion ext/pim.calendar/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ _self.findEvents = function (findOptions, onFindSuccess, onFindError) {
realEvents = [];

try {
tmp = unescape(args.result);
tmp = unescape(decodeURIComponent(args.result));
result = JSON.parse(tmp);
events = result.events;
} catch (e) {
Expand Down
36 changes: 23 additions & 13 deletions ext/pim.calendar/native/pim_calendar_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ bool PimCalendarQt::getSearchParams(bbpim::EventSearchParameters& searchParams,

// filter - substring - optional
if (filter.isMember("substring") && filter["substring"].isString()) {
searchParams.setPrefix(QString(filter["substring"].asCString()));
searchParams.setPrefix(toQString(filter["substring"].asString()));
}

// detail - optional - defaults to Agenda if not set
Expand Down Expand Up @@ -599,15 +599,15 @@ QList<QDateTime> PimCalendarQt::setEventFields(bbpim::CalendarEvent& ev, const J
}

if (args.isMember("summary") && args["summary"].isString()) {
ev.setSubject(args["summary"].asCString());
ev.setSubject(toQString(args["summary"].asString()));
}

if (args.isMember("location") && args["location"].isString()) {
ev.setLocation(args["location"].asCString());
ev.setLocation(toQString(args["location"].asString()));
}

if (args.isMember("description") && args["description"].isString()) {
ev.setBody(args["description"].asCString());
ev.setBody(toQString(args["description"].asString()));
}

if (args.isMember("transparency") && args["transparency"].isInt()) {
Expand All @@ -627,7 +627,7 @@ QList<QDateTime> PimCalendarQt::setEventFields(bbpim::CalendarEvent& ev, const J
}

if (args.isMember("url") && args["url"].isString()) {
ev.setUrl(args["url"].asCString());
ev.setUrl(toQString(args["url"].asString()));
}

if (args.isMember("recurrence") && !args["recurrence"].isNull()) {
Expand Down Expand Up @@ -673,8 +673,8 @@ QList<QDateTime> PimCalendarQt::setEventFields(bbpim::CalendarEvent& ev, const J
bbpim::Attendee attendee;
Json::Value attArgs = args["attendees"][i];

attendee.setName(QString(attArgs.get("name", "").asCString()));
attendee.setEmail(QString(attArgs.get("email", "").asCString()));
attendee.setName(toQString(attArgs.get("name", "").asString()));
attendee.setEmail(toQString(attArgs.get("email", "").asString()));
attendee.setType((bbpim::Attendee::Type)(attArgs.get("type", bbpim::Attendee::Host).asInt()));
attendee.setRole((bbpim::AttendeeRole::Type)(attArgs.get("role", bbpim::AttendeeRole::Chair).asInt()));
attendee.setStatus((bbpim::AttendeeStatus::Type)(attArgs.get("status", bbpim::AttendeeStatus::Unknown).asInt()));
Expand Down Expand Up @@ -708,6 +708,16 @@ QList<QDateTime> PimCalendarQt::setEventFields(bbpim::CalendarEvent& ev, const J
/****************************************************************
* Helper functions shared by Find and Save
****************************************************************/
QString PimCalendarQt::toQString(std::string const &s)
{
return QString::fromUtf8(s.c_str());
}

std::string PimCalendarQt::fromQString(QString const &s)
{
return std::string(s.toUtf8().data());
}

bbpim::CalendarService* PimCalendarQt::getCalendarService() {
return m_provider.GetCalendarService();
}
Expand Down Expand Up @@ -761,11 +771,11 @@ Json::Value PimCalendarQt::eventToJson(const bbpim::CalendarEvent& event)
jsonEvent["accountId"] = Utils::intToStr(event.accountId());
jsonEvent["start"] = QString::number(event.startTime().toUTC().toMSecsSinceEpoch()).toStdString();
jsonEvent["end"] = QString::number(event.endTime().toUTC().toMSecsSinceEpoch()).toStdString();
jsonEvent["description"] = getSafeString(event.body().toStdString());
jsonEvent["summary"] = getSafeString(event.subject().toStdString());
jsonEvent["location"] = getSafeString(event.location().toStdString());
jsonEvent["description"] = getSafeString(fromQString(event.body()));
jsonEvent["summary"] = getSafeString(fromQString(event.subject()));
jsonEvent["location"] = getSafeString(fromQString(event.location()));
jsonEvent["timezone"] = event.timezone().toStdString();
jsonEvent["url"] = event.url().toStdString();
jsonEvent["url"] = fromQString(event.url());

if (event.recurrence().isValid()) {
jsonEvent["recurrence"] = Json::Value();
Expand All @@ -791,8 +801,8 @@ Json::Value PimCalendarQt::eventToJson(const bbpim::CalendarEvent& event)

for (QList<bbpim::Attendee>::const_iterator i = event.attendees().constBegin(); i != event.attendees().constEnd(); ++i) {
Json::Value jsonAttendee;
jsonAttendee["email"] = getSafeString(i->email().toStdString());
jsonAttendee["name"] = getSafeString(i->name().toStdString());
jsonAttendee["email"] = getSafeString(fromQString(i->email()));
jsonAttendee["name"] = getSafeString(fromQString(i->name()));
jsonAttendee["type"] = i->type();
jsonAttendee["role"] = i->role();
jsonAttendee["id"] = Utils::intToStr(i->id());
Expand Down
2 changes: 2 additions & 0 deletions ext/pim.calendar/native/pim_calendar_qt.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ class PimCalendarQt : public ThreadSync {
static Json::Value GetDefaultCalendarAccount();

private:
static QString toQString(std::string const& s);
static std::string fromQString(QString const& s);
static QDateTime getDate(const Json::Value& arg);
static QVariant getFromMap(QMap<QString, QVariant> map, QStringList keys);
static std::string getSafeString(const std::string& s);
Expand Down