Initial submission of Akonadi EWS Resource to KDE PIM
ClosedPublic

Authored by nowicki on Sep 11 2017, 8:43 PM.

Details

Summary

This change adds the Akonadi EWS resource, which allows connecting to a Microsoft Exchange mailbox using the Exchange Web Services (EWS) protocol. The resource has been developed on GitHub. In its current state it is able to:

  • Send and receive e-mail
  • Provide read-only access to the calendar (with some known issues related to timezone conversion).
  • Provide read-only access to the personal address book.

From day one I have developed this resource with future inclusion into KDE in mind, however the original idea was to have it more feature complete before that. Given the demand for a working Exchange solution I have decided to make an attempt to submit it now in hope to be able to gain more traction.

The submitted code is a flat copy of the latest GitHub master with necessary integration changes. Full history (including the adaptation changes) can be examined on the for-kdepim-runtime branch.

Diff Detail

Repository
R44 KDE PIM Runtime
Lint
Lint Skipped
Unit
Unit Tests Skipped
nowicki created this revision.Sep 11 2017, 8:43 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptSep 11 2017, 8:43 PM
mlaurent requested changes to this revision.Sep 12 2017, 4:40 AM

I can't see a Messages.sh file for extracting i18n

This revision now requires changes to proceed.Sep 12 2017, 4:40 AM
mlaurent added inline comments.Sep 12 2017, 5:04 AM
resources/ews/abchperson/ewsabchpersonhandler.h
34

could you rename all Q_DECL_OVERRIDE to override please ?

resources/ews/abchperson/ewscreateabchpersonjob.cpp
45

could you add EWSRES_LOG to kdepim-runtime.categories please ? so we can load this info in kdebugsettings thanks

resources/ews/calendar/ewsfetchcalendardetailjob.cpp
187

i18n ? setErrorText is displaying in a messagebox no ?

resources/ews/configdialog.cpp
54

could you replace Q_NULLPTR by nullptr thanks :)

resources/ews/contact/ewscreatecontactjob.h
30

coding style EwsClient &client

resources/ews/ewsautodiscoveryjob.cpp
94

i18n ?

resources/ews/ewsclient/CMakeLists.txt
62

debug file is not autogenerated ? see ecm_qt_declare_logging_category(kolabresource_SRCS HEADER kolabresource_debug.h IDENTIFIER KOLABRESOURCE_LOG CATEGORY_NAME org.kde.pim.kolabresource)

resources/ews/ewsclient/ewsattachment.h
50

const here ?

resources/ews/ewsclient/ewsattendee.h
40

const QXmlStreamReader

resources/ews/ewsclient/ewsclient.h
35

replace = 0 to nullptr ?

38

const QString &

43

const/ref

resources/ews/ewsclient/ewscreatefolderrequest.cpp
102

i18n ?

resources/ews/ewsclient/ewscreateitemrequest.h
43

const QXmk... &

resources/ews/ewsclient/ewseventrequestbase.cpp
205

why not using evName for each if(...) ?

resources/ews/ewsclient/ewsitem.cpp
427

cache reader.name() value

resources/ews/ewsclient/ewsjob.cpp
43

const QString &

resources/ews/ewsclient/ewssubscriberequest.h
64

const ... &

resources/ews/ewsmtaresource.cpp
39

Remove debug here no ?

resources/ews/mail/ewsmailhandler.cpp
83

qCDebug

resources/ews/test/basictest.cpp
39

nullptr + explicit

resources/ews/test/fakeserver/fakeewsserverthread.h
33

nullptr

resources/ews/test/isolatedtestbase.h
66

nullptr

no update ?:)

no update ?:)

I'm working on it :)

Mostly sed work, but a few things need a little thought to get right.

nowicki added inline comments.Sep 14 2017, 5:54 PM
resources/ews/ewsclient/ewsattachment.h
50

The implementation calls QXmlStreamReader::readNextStartElement(), which is a non-const member.

resources/ews/ewsclient/ewsattendee.h
40

The implementation calls QXmlStreamReader::readNextStartElement(), which is a non-const member.

resources/ews/ewsclient/ewscreateitemrequest.h
43

The implementation calls QXmlStreamReader::readNextStartElement(), which is a non-const member.

mlaurent added inline comments.Sep 15 2017, 4:49 AM
resources/ews/ewsclient/ewscreateitemrequest.h
43

ok

I saw that the KDateTime removal changes landed, so I'll have to check what popped in the calendar interface.

The KDateTime removal might be a bit more digging.

The current calendar code downloads the calendar event from Exchange in form of a vCal event. While this is not ideal (the Exchange's vCal exporter is not perfect) it is good enough for a start. On the Akonadi EWS side I feed it to a memory calendar in order to get an event. Previously the importer just created a KDateTime and didn't attempt to parse the timezone (it was just provided as a name). This was fine when the timezone name was an IANA name as it was then parsed correctly. Unfortunately the Window$ world has it's own standards and the timezone names are often different (either MS timezone names of even some non-standard ones). These I need to attempt to parse.

After the changes I get a QDateTime, which has an already parsed QTimeZone. I assume the parsing is done in KCalCore. The question is what happens when it occurs some non-IANA timezone name.

I'll need to dig into the code a bit more.

QTimeZone does not allow custom time zones, unlike KTimeZone. KCalCore thus has to perform mapping from the provided VTIMEZONE to a known IANA timezone that it supports.

To simplify, KCalCore will parse the standard and DTS offsets from VTIMEZONE and will try to find an IANA timezone that has the closest match to the specified VTIMEZONE - the actual code is here: https://cgit.kde.org/kcalcore.git/tree/src/icaltimezones.cpp#n466

As such, you should no longer need a code to deal with mapping Windows to IANA yourself but KCalCore will do the magic for you :-)

As such, you should no longer need a code to deal with mapping Windows to IANA yourself but KCalCore will do the magic for you :-)

Which is what I'm very happy to hear - one piece of crappy code less to maintain :)

nowicki updated this revision to Diff 20201.Oct 1 2017, 7:23 PM

It took a while, but it's there. I've addressed the comments raised by Laurent.

nowicki updated this revision to Diff 20202.Oct 1 2017, 7:27 PM

Oops, missed one comment.

dvratil added inline comments.Oct 1 2017, 7:51 PM
resources/ews/calendar/ewsfetchcalendardetailjob.cpp
123

This looks unused now?

Does the EWSItem contain actual information regarding the timezone, except for its name, like UTC offset and DST transitions?

I know realize KCalCore may not have the API you might need to get this working properly, but I don't know how much information you actually have available for EWS events

178

If the errorText of the job is passed to Akonadi::ResourceBase::cancelTask() at some point, it should be localized (and probably less technical, that's what debug output is for)

nowicki added inline comments.Oct 1 2017, 8:19 PM
resources/ews/calendar/ewsfetchcalendardetailjob.cpp
123

You're right - I missed that when converting to QDateTime.

In the current form the data downloaded from Exchange contains full vCalendar payload including the timezone specification. This I believe is handled by the updated KCalCore code, that I asked about in one of the previous comments.

This implementation is however temporary as it doesn't provide room to implement calendar modifications. To do that I'll need to download the events piece by piece including the timezone. The Exchange server provides the timezone name as well as offset information, so it will be enough to do proper conversion. This is the moment I'll need to hook up to KCalCore's timezone processing code, but I'm not too worried about it ATM.

178

This used to be like that in the beginning, but after addressing Laurent's comments I have changed this behaviour - the exact message is only printed to the log and the user is presented with a more generic message that item retrieval has failed (see ewsresource.cpp:608)

Great, thanks! In that case, please clear up the unused variables (check for others, possibly) and I think we are good to go unless @mlaurent has any more issues?

nowicki updated this revision to Diff 20210.Oct 1 2017, 8:26 PM

Fix leftovers from KCalCore conversion found by Dan.

mlaurent added inline comments.Oct 2 2017, 4:57 AM
resources/ews/CMakeLists.txt
32

could you rename it as config-ews.h.cmake ... config-ews.h ?
It avoid to have a lot file with same name.
Thanks

resources/ews/abchperson/ewsabchpersonhandler.h
43

not necessary

resources/ews/abchperson/ewscreateabchpersonjob.h
35

remove virtual keyword

resources/ews/abchperson/ewsfetchabchpersondetailjob.h
33

Remove all virtual keyword when you have override thanks

resources/ews/configdialog.cpp
60

Add parent to QDialogButtonBox it can create a bug where default button is not correct (for example it can select cancel and not ok in some case)
thanks

resources/ews/ewsautodiscoveryjob.h
41

pedantic no .? we don't need ";"
Same for all other methods

resources/ews/ewsclient/ewscreatefolderrequest.h
44

pedantic

resources/ews/ewsclient/ewsjob.h
34

const QString &msg

resources/ews/ewsclient/ewsrecurrence.cpp
85

cache reader.name() seems better

resources/ews/ewsclient/ewsupdateitemrequest.cpp
215

const QSharedPointer &upd

resources/ews/ewsmtaresource.h
49

I think that you remove check

nowicki updated this revision to Diff 20262.Oct 2 2017, 7:37 PM

Another round of fixes in response to Larent's comments.

mlaurent accepted this revision.Oct 2 2017, 9:14 PM

Seems ok for me.
Thanks :)

This revision is now accepted and ready to land.Oct 2 2017, 9:14 PM

Could you close it please ?:)

nowicki closed this revision.Oct 11 2017, 8:34 PM