Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KDE PIM Runtime
Commits
73d2f3f6
Commit
73d2f3f6
authored
Aug 12, 2020
by
Shashwat Jolly
Browse files
Minor changes - resolved some PR comments
parent
f7dcfa5b
Changes
5
Hide whitespace changes
Inline
Side-by-side
resources/etesync/calendartaskbasehandler.cpp
View file @
73d2f3f6
...
...
@@ -63,7 +63,7 @@ void CalendarTaskBaseHandler::getItemListFromEntries(EteSyncEntry **entries, Ite
item
.
setMimeType
(
mimeType
());
item
.
setParentCollection
(
collection
);
item
.
setRemoteId
(
incidence
->
uid
());
removedItems
<<
item
;
removedItems
.
push_back
(
item
)
;
deleteLocalCalendar
(
incidence
);
}
...
...
@@ -80,7 +80,7 @@ void CalendarTaskBaseHandler::getItemListFromEntries(EteSyncEntry **entries, Ite
item
.
setParentCollection
(
collection
);
item
.
setRemoteId
(
it
.
key
());
item
.
setPayload
<
KCalendarCore
::
Incidence
::
Ptr
>
(
it
.
value
());
changedItems
<<
item
;
changedItems
.
push_back
(
item
)
;
updateLocalCalendar
(
it
.
value
());
}
...
...
resources/etesync/contacthandler.cpp
View file @
73d2f3f6
...
...
@@ -71,7 +71,7 @@ void ContactHandler::getItemListFromEntries(EteSyncEntry **entries, Item::List &
item
.
setMimeType
(
mimeType
());
item
.
setParentCollection
(
collection
);
item
.
setRemoteId
(
contact
.
uid
());
removedItems
<<
item
;
removedItems
.
push_back
(
item
)
;
deleteLocalContact
(
contact
);
}
...
...
@@ -88,7 +88,7 @@ void ContactHandler::getItemListFromEntries(EteSyncEntry **entries, Item::List &
item
.
setParentCollection
(
collection
);
item
.
setRemoteId
(
it
.
key
());
item
.
setPayload
<
KContacts
::
Addressee
>
(
it
.
value
());
changedItems
<<
item
;
changedItems
.
push_back
(
item
)
;
updateLocalContact
(
it
.
value
());
}
...
...
resources/etesync/etesyncclientstate.h
View file @
73d2f3f6
...
...
@@ -68,12 +68,12 @@ Q_SIGNALS:
void
tokenRefreshed
();
private:
EteSyncPtr
mClient
=
nullptr
;
EteSyncPtr
mClient
;
QString
mDerived
;
QString
mToken
;
EteSyncJournalManagerPtr
mJournalManager
=
nullptr
;
EteSyncUserInfoPtr
mUserInfo
=
nullptr
;
EteSyncAsymmetricKeyPairPtr
mKeypair
=
nullptr
;
EteSyncJournalManagerPtr
mJournalManager
;
EteSyncUserInfoPtr
mUserInfo
;
EteSyncAsymmetricKeyPairPtr
mKeypair
;
QString
mUsername
;
QString
mPassword
;
QString
mServerUrl
;
...
...
resources/etesync/etesyncresource.cpp
View file @
73d2f3f6
...
...
@@ -114,30 +114,35 @@ void EteSyncResource::configure(WId windowId)
void
EteSyncResource
::
retrieveCollections
()
{
setCollectionStreamingEnabled
(
true
);
// Set up root collection for resource
mResourceCollection
=
Collection
();
mResourceCollection
.
setContentMimeTypes
({
Collection
::
mimeType
()});
mResourceCollection
.
setName
(
mClientState
->
username
());
mResourceCollection
.
setRemoteId
(
ROOT_COLLECTION_REMOTEID
);
mResourceCollection
.
setParentCollection
(
Collection
::
root
());
mResourceCollection
.
setRights
(
Collection
::
CanCreateCollection
);
auto
job
=
new
JournalsFetchJob
(
mClientState
->
client
(),
this
);
connect
(
job
,
&
JournalsFetchJob
::
finished
,
this
,
&
EteSyncResource
::
slotCollectionsRetrieved
);
job
->
start
();
}
Collection
EteSyncResource
::
createRootCollection
()
{
Collection
rootCollection
=
Collection
();
rootCollection
.
setContentMimeTypes
({
Collection
::
mimeType
()});
rootCollection
.
setName
(
mClientState
->
username
());
rootCollection
.
setRemoteId
(
ROOT_COLLECTION_REMOTEID
);
rootCollection
.
setParentCollection
(
Collection
::
root
());
rootCollection
.
setRights
(
Collection
::
CanCreateCollection
);
Akonadi
::
CachePolicy
cachePolicy
;
cachePolicy
.
setInheritFromParent
(
false
);
cachePolicy
.
setSyncOnDemand
(
false
);
cachePolicy
.
setCacheTimeout
(
-
1
);
cachePolicy
.
setIntervalCheckTime
(
5
);
mResource
Collection
.
setCachePolicy
(
cachePolicy
);
root
Collection
.
setCachePolicy
(
cachePolicy
);
EntityDisplayAttribute
*
attr
=
mResource
Collection
.
attribute
<
EntityDisplayAttribute
>
(
Collection
::
AddIfMissing
);
EntityDisplayAttribute
*
attr
=
root
Collection
.
attribute
<
EntityDisplayAttribute
>
(
Collection
::
AddIfMissing
);
attr
->
setDisplayName
(
mClientState
->
username
());
attr
->
setIconName
(
QStringLiteral
(
"akonadi-etesync"
));
collectionsRetrieved
({
mResource
Collection
});
collectionsRetrieved
({
root
Collection
});
auto
job
=
new
JournalsFetchJob
(
mClientState
->
client
(),
this
);
connect
(
job
,
&
JournalsFetchJob
::
finished
,
this
,
&
EteSyncResource
::
slotCollectionsRetrieved
);
job
->
start
();
return
rootCollection
;
}
void
EteSyncResource
::
slotCollectionsRetrieved
(
KJob
*
job
)
...
...
@@ -149,13 +154,14 @@ void EteSyncResource::slotCollectionsRetrieved(KJob *job)
return
;
}
qCDebug
(
ETESYNC_LOG
)
<<
"Retrieving collections"
;
const
Collection
&
rootCollection
=
createRootCollection
();
EteSyncJournal
**
journals
=
qobject_cast
<
JournalsFetchJob
*>
(
job
)
->
journals
();
Collection
::
List
list
;
for
(
EteSyncJournal
**
iter
=
journals
;
*
iter
;
iter
++
)
{
Collection
collection
;
collection
.
setParentCollection
(
mResource
Collection
);
collection
.
setParentCollection
(
root
Collection
);
setupCollection
(
collection
,
*
iter
);
list
<<
collection
;
list
.
push_back
(
collection
)
;
}
free
(
journals
);
collectionsRetrieved
(
list
);
...
...
@@ -187,13 +193,13 @@ void EteSyncResource::setupCollection(Collection &collection, EteSyncJournal *jo
auto
attr
=
collection
.
attribute
<
EntityDisplayAttribute
>
(
Collection
::
AddIfMissing
);
if
(
type
==
QStringLiteral
(
ETESYNC_COLLECTION_TYPE_ADDRESS_BOOK
))
{
mimeTypes
<<
KContacts
::
Addressee
::
mimeType
();
mimeTypes
.
push_back
(
KContacts
::
Addressee
::
mimeType
()
)
;
attr
->
setIconName
(
QStringLiteral
(
"view-pim-contacts"
));
}
else
if
(
type
==
QStringLiteral
(
ETESYNC_COLLECTION_TYPE_CALENDAR
))
{
mimeTypes
<<
KCalendarCore
::
Event
::
eventMimeType
();
mimeTypes
.
push_back
(
KCalendarCore
::
Event
::
eventMimeType
()
)
;
attr
->
setIconName
(
QStringLiteral
(
"view-calendar"
));
}
else
if
(
type
==
QStringLiteral
(
ETESYNC_COLLECTION_TYPE_TASKS
))
{
mimeTypes
<<
KCalendarCore
::
Todo
::
todoMimeType
();
mimeTypes
.
push_back
(
KCalendarCore
::
Todo
::
todoMimeType
()
)
;
attr
->
setIconName
(
QStringLiteral
(
"view-pim-tasks"
));
}
else
{
qCWarning
(
ETESYNC_LOG
)
<<
"Unknown journal type. Cannot set collection mime type."
;
...
...
resources/etesync/etesyncresource.h
View file @
73d2f3f6
...
...
@@ -64,6 +64,8 @@ protected:
void
setupCollection
(
Akonadi
::
Collection
&
collection
,
EteSyncJournal
*
journal
);
Collection
createRootCollection
();
void
initialiseDirectory
(
const
QString
&
path
)
const
;
QString
baseDirectoryPath
()
const
;
...
...
@@ -82,15 +84,14 @@ private Q_SLOTS:
void
slotCollectionsRetrieved
(
KJob
*
job
);
private:
Akonadi
::
Collection
mResourceCollection
;
EteSyncClientState
*
mClientState
=
nullptr
;
std
::
vector
<
BaseHandler
::
Ptr
>
mHandlers
;
std
::
map
<
QString
,
EteSyncJournalPtr
>
mJournalsCache
;
QDateTime
mJournalsCacheUpdateTime
;
ContactHandler
::
Ptr
mContactHandler
=
nullptr
;
CalendarHandler
::
Ptr
mCalendarHandler
=
nullptr
;
TaskHandler
::
Ptr
mTaskHandler
=
nullptr
;
ContactHandler
::
Ptr
mContactHandler
;
CalendarHandler
::
Ptr
mCalendarHandler
;
TaskHandler
::
Ptr
mTaskHandler
;
friend
class
ContactHandler
;
friend
class
CalendarTaskBaseHandler
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment