Skip to content

Commit

Permalink
[nemo-qml-plugin-calendar] Pass participation status on attendees. Co…
Browse files Browse the repository at this point in the history
…ntributes to JB#45994
  • Loading branch information
pvuorela committed Jun 11, 2019
1 parent 8df70d9 commit 85ef1c4
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 13 deletions.
2 changes: 1 addition & 1 deletion rpm/nemo-qml-plugin-calendar-qt5.spec
@@ -1,7 +1,7 @@
Name: nemo-qml-plugin-calendar-qt5

Summary: Calendar plugin for Nemo Mobile
Version: 0.4.5
Version: 0.5.1
Release: 1
Group: System/Libraries
License: BSD
Expand Down
17 changes: 15 additions & 2 deletions src/calendareventquery.h
Expand Up @@ -47,10 +47,12 @@ class Person : public QObject
{
Q_OBJECT
Q_ENUMS(AttendeeRole)
Q_ENUMS(ParticipationStatus)
Q_PROPERTY(QString name READ name CONSTANT FINAL)
Q_PROPERTY(QString email READ email CONSTANT FINAL)
Q_PROPERTY(bool isOrganizer READ isOrganizer CONSTANT FINAL)
Q_PROPERTY(int participationRole READ participationRole CONSTANT FINAL)
Q_PROPERTY(int participationStatus READ participationStatus CONSTANT FINAL)

public:
enum AttendeeRole {
Expand All @@ -60,21 +62,32 @@ class Person : public QObject
ChairParticipant
};

Person(const QString &aName, const QString &aEmail, bool aIsOrganizer, AttendeeRole aParticipationRole)
: m_name(aName), m_email(aEmail), m_isOrganizer(aIsOrganizer), m_participationRole(aParticipationRole)
enum ParticipationStatus {
UnknownParticipation,
AcceptedParticipation,
DeclinedParticipation,
TentativeParticipation
};

Person(const QString &aName, const QString &aEmail, bool aIsOrganizer, AttendeeRole aParticipationRole,
ParticipationStatus aStatus)
: m_name(aName), m_email(aEmail), m_isOrganizer(aIsOrganizer), m_participationRole(aParticipationRole),
m_participationStatus(aStatus)
{
}

QString name() const { return m_name; }
QString email() const { return m_email; }
bool isOrganizer() const { return m_isOrganizer; }
int participationRole() const { return m_participationRole; }
int participationStatus() const { return m_participationStatus; }

private:
QString m_name;
QString m_email;
bool m_isOrganizer;
int m_participationRole;
int m_participationStatus;
};

class CalendarEventQuery : public QObject, public QQmlParserStatus
Expand Down
3 changes: 1 addition & 2 deletions src/calendarimportevent.cpp
Expand Up @@ -127,8 +127,7 @@ QList<QObject *> CalendarImportEvent::attendees() const
if (!mEvent)
return QList<QObject *>();

// TODO: ownerEmail to be fixed later when invitation creation is done in calendar
return CalendarUtils::convertAttendeeList(CalendarUtils::getEventAttendees(mEvent, QString()));
return CalendarUtils::convertAttendeeList(CalendarUtils::getEventAttendees(mEvent));
}

CalendarEvent::Secrecy CalendarImportEvent::secrecy() const
Expand Down
25 changes: 20 additions & 5 deletions src/calendarutils.cpp
Expand Up @@ -112,7 +112,7 @@ int CalendarUtils::getReminder(const KCalCore::Event::Ptr &event)
return seconds;
}

QList<CalendarData::Attendee> CalendarUtils::getEventAttendees(const KCalCore::Event::Ptr &event, const QString &ownerEmail)
QList<CalendarData::Attendee> CalendarUtils::getEventAttendees(const KCalCore::Event::Ptr &event)
{
QList<CalendarData::Attendee> result;
KCalCore::Person::Ptr calOrganizer = event->organizer();
Expand All @@ -138,9 +138,8 @@ QList<CalendarData::Attendee> CalendarUtils::getEventAttendees(const KCalCore::E
// avoid duplicate info
continue;
}
if (attendee.email == ownerEmail) {
attendee.status = calAttendee->status();
}

attendee.status = calAttendee->status();
attendee.participationRole = calAttendee->role();
result.append(attendee);
}
Expand All @@ -167,7 +166,23 @@ QList<QObject *> CalendarUtils::convertAttendeeList(const QList<CalendarData::At
role = Person::NonParticipant;
break;
}
QObject *person = new Person(attendee.name, attendee.email, attendee.isOrganizer, role);

Person::ParticipationStatus status;
switch (attendee.status) {
case KCalCore::Attendee::Accepted:
status = Person::AcceptedParticipation;
break;
case KCalCore::Attendee::Declined:
status = Person::DeclinedParticipation;
break;
case KCalCore::Attendee::Tentative:
status = Person::TentativeParticipation;
break;
default:
status = Person::UnknownParticipation;
}

QObject *person = new Person(attendee.name, attendee.email, attendee.isOrganizer, role, status);
result.append(person);
}

Expand Down
2 changes: 1 addition & 1 deletion src/calendarutils.h
Expand Up @@ -45,7 +45,7 @@ namespace CalendarUtils {
CalendarEvent::Recur convertRecurrence(const KCalCore::Event::Ptr &event);
CalendarEvent::Secrecy convertSecrecy(const KCalCore::Event::Ptr &event);
int getReminder(const KCalCore::Event::Ptr &event);
QList<CalendarData::Attendee> getEventAttendees(const KCalCore::Event::Ptr &event, const QString &ownerEmail);
QList<CalendarData::Attendee> getEventAttendees(const KCalCore::Event::Ptr &event);
QList<QObject*> convertAttendeeList(const QList<CalendarData::Attendee> &list);
CalendarData::EventOccurrence getNextOccurrence(const KCalCore::Event::Ptr &event,
const QDateTime &start = QDateTime::currentDateTime());
Expand Down
3 changes: 1 addition & 2 deletions src/calendarworker.cpp
Expand Up @@ -899,8 +899,7 @@ QList<CalendarData::Attendee> CalendarWorker::getEventAttendees(const QString &u
return result;
}

const QString &ownerEmail = getNotebookAddress(event);
return CalendarUtils::getEventAttendees(event, ownerEmail);
return CalendarUtils::getEventAttendees(event);
}

void CalendarWorker::findMatchingEvent(const QString &invitationFile)
Expand Down

0 comments on commit 85ef1c4

Please sign in to comment.