Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
KDE Pim
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Unmaintained
KDE Pim
Commits
3feced60
Commit
3feced60
authored
Jun 16, 2016
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
We don't want to check all the time. Reveify check each 7 days
parent
993ecffe
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
20 deletions
+44
-20
kmail/src/search/checkindexingjob.cpp
kmail/src/search/checkindexingjob.cpp
+7
-7
kmail/src/search/checkindexingjob.h
kmail/src/search/checkindexingjob.h
+2
-2
kmail/src/search/checkindexingmanager.cpp
kmail/src/search/checkindexingmanager.cpp
+33
-10
kmail/src/search/checkindexingmanager.h
kmail/src/search/checkindexingmanager.h
+2
-1
No files found.
kmail/src/search/checkindexingjob.cpp
View file @
3feced60
...
...
@@ -40,10 +40,10 @@ CheckIndexingJob::~CheckIndexingJob()
}
void
CheckIndexingJob
::
askForNextCheck
()
void
CheckIndexingJob
::
askForNextCheck
(
quint64
id
)
{
deleteLater
();
Q_EMIT
finished
();
Q_EMIT
finished
(
id
);
}
void
CheckIndexingJob
::
setCollection
(
const
Akonadi
::
Collection
&
col
)
...
...
@@ -60,7 +60,7 @@ void CheckIndexingJob::start()
connect
(
fetch
,
&
KJob
::
result
,
this
,
&
CheckIndexingJob
::
slotCollectionPropertiesFinished
);
}
else
{
qCWarning
(
KMAIL_LOG
)
<<
"Collection was not valid"
;
askForNextCheck
();
askForNextCheck
(
-
1
);
}
}
...
...
@@ -70,7 +70,7 @@ void CheckIndexingJob::slotCollectionPropertiesFinished(KJob *job)
Q_ASSERT
(
fetch
);
if
(
fetch
->
collections
().
isEmpty
())
{
qCWarning
(
KMAIL_LOG
)
<<
"No collection fetched"
;
askForNextCheck
();
askForNextCheck
(
-
1
);
return
;
}
...
...
@@ -84,7 +84,7 @@ void CheckIndexingJob::indexerStatsFetchFinished(KJob* job)
{
if
(
job
->
error
())
{
qCWarning
(
KMAIL_LOG
)
<<
"CheckIndexingJob::indexerStatsFetchFinished error :"
<<
job
->
errorString
();
askForNextCheck
();
askForNextCheck
(
-
1
);
return
;
}
...
...
@@ -92,11 +92,11 @@ void CheckIndexingJob::indexerStatsFetchFinished(KJob* job)
//qDebug()<<" stats "<< stats;
qCDebug
(
KMAIL_LOG
)
<<
" mCollection.statistics().count() "
<<
mCollection
.
statistics
().
count
()
<<
"stats.value(mCollection.id())"
<<
stats
.
value
(
mCollection
.
id
());
if
(
mCollection
.
statistics
().
count
()
!=
stats
.
value
(
mCollection
.
id
()))
{
QDBusInterface
interfaceBalooIndexer
(
QStringLiteral
(
"org.freedesktop.Akonadi.Agent.akonadi_indexing_agent"
),
QStringLiteral
(
"/"
),
QStringLiteral
(
"org.freedesktop.Akonadi.Indexer"
));
QDBusInterface
interfaceBalooIndexer
(
PimCommon
::
indexerServiceName
(
),
QStringLiteral
(
"/"
),
QStringLiteral
(
"org.freedesktop.Akonadi.Indexer"
));
if
(
interfaceBalooIndexer
.
isValid
())
{
qCDebug
(
KMAIL_LOG
)
<<
"Reindex collection :"
<<
mCollection
.
id
()
<<
"name :"
<<
mCollection
.
name
();
interfaceBalooIndexer
.
call
(
QStringLiteral
(
"reindexCollection"
),
(
qlonglong
)
mCollection
.
id
());
}
}
askForNextCheck
();
askForNextCheck
(
mCollection
.
id
()
);
}
kmail/src/search/checkindexingjob.h
View file @
3feced60
...
...
@@ -35,13 +35,13 @@ public:
void
start
();
Q_SIGNALS:
void
finished
();
void
finished
(
Akonadi
::
Collection
::
Id
id
);
private
Q_SLOTS
:
void
slotCollectionPropertiesFinished
(
KJob
*
job
);
void
indexerStatsFetchFinished
(
KJob
*
job
);
private:
void
askForNextCheck
();
void
askForNextCheck
(
quint64
id
);
Akonadi
::
Collection
mCollection
;
};
...
...
kmail/src/search/checkindexingmanager.cpp
View file @
3feced60
...
...
@@ -23,6 +23,8 @@
#include "checkindexingjob.h"
#include <AkonadiCore/EntityTreeModel>
#include <AkonadiCore/CachePolicy>
#include <KSharedConfig>
#include <KConfigGroup>
#include <MailCommon/MailUtil>
#include <PimCommon/PimUtil>
#include <QTimer>
...
...
@@ -41,7 +43,9 @@ CheckIndexingManager::CheckIndexingManager(QObject *parent)
CheckIndexingManager
::~
CheckIndexingManager
()
{
const
KSharedConfig
::
Ptr
cfg
=
KSharedConfig
::
openConfig
(
QStringLiteral
(
"kmailsearchindexingrc"
));
KConfigGroup
grp
=
cfg
->
group
(
QStringLiteral
(
"General"
));
grp
.
writeEntry
(
QStringLiteral
(
"collectionsIndexed"
),
mCollectionsIndexed
);
}
void
CheckIndexingManager
::
start
(
QAbstractItemModel
*
collectionModel
)
...
...
@@ -49,12 +53,20 @@ void CheckIndexingManager::start(QAbstractItemModel *collectionModel)
if
(
mIsReady
)
{
mIndex
=
0
;
mListCollection
.
clear
();
if
(
collectionModel
)
{
initializeCollectionList
(
collectionModel
);
if
(
!
mListCollection
.
isEmpty
())
{
qCDebug
(
KMAIL_LOG
)
<<
"Number of collection to check "
<<
mListCollection
.
count
();
mIsReady
=
false
;
mTimer
->
start
();
const
KSharedConfig
::
Ptr
cfg
=
KSharedConfig
::
openConfig
(
QStringLiteral
(
"kmailsearchindexingrc"
));
KConfigGroup
grp
=
cfg
->
group
(
QStringLiteral
(
"General"
));
const
QDateTime
lastDateTime
=
grp
.
readEntry
(
QStringLiteral
(
"lastCheck"
),
QDateTime
());
//Check each 7 days
QDateTime
today
=
QDateTime
::
currentDateTime
();
if
(
lastDateTime
.
isValid
()
||
today
>
lastDateTime
.
addDays
(
7
))
{
mCollectionsIndexed
=
grp
.
readEntry
(
QStringLiteral
(
"collectionsIndexed"
),
QList
<
qint64
>
());
if
(
collectionModel
)
{
initializeCollectionList
(
collectionModel
);
if
(
!
mListCollection
.
isEmpty
())
{
qCDebug
(
KMAIL_LOG
)
<<
"Number of collection to check "
<<
mListCollection
.
count
();
mIsReady
=
false
;
mTimer
->
start
();
}
}
}
}
...
...
@@ -64,7 +76,7 @@ void CheckIndexingManager::createJob()
{
CheckIndexingJob
*
job
=
new
CheckIndexingJob
(
this
);
job
->
setCollection
(
mListCollection
.
at
(
mIndex
));
connect
(
job
,
&
CheckIndexingJob
::
finished
,
this
,
&
CheckIndexingManager
::
slotRestartTimer
);
connect
(
job
,
&
CheckIndexingJob
::
finished
,
this
,
&
CheckIndexingManager
::
indexingFinished
);
job
->
start
();
}
...
...
@@ -75,8 +87,13 @@ void CheckIndexingManager::checkNextCollection()
}
}
void
CheckIndexingManager
::
slotRestartTimer
(
)
void
CheckIndexingManager
::
indexingFinished
(
qint64
index
)
{
if
(
index
!=
-
1
)
{
if
(
!
mCollectionsIndexed
.
contains
(
index
))
{
mCollectionsIndexed
.
append
(
index
);
}
}
mIndex
++
;
if
(
mIndex
<
mListCollection
.
count
())
{
mTimer
->
start
();
...
...
@@ -84,6 +101,10 @@ void CheckIndexingManager::slotRestartTimer()
mIsReady
=
true
;
mIndex
=
0
;
mListCollection
.
clear
();
const
KSharedConfig
::
Ptr
cfg
=
KSharedConfig
::
openConfig
(
QStringLiteral
(
"kmailsearchindexingrc"
));
KConfigGroup
grp
=
cfg
->
group
(
QStringLiteral
(
"General"
));
grp
.
writeEntry
(
QStringLiteral
(
"lastCheck"
),
QDateTime
::
currentDateTime
());
grp
.
deleteEntry
(
QStringLiteral
(
"collectionsIndexed"
));
}
}
...
...
@@ -111,7 +132,9 @@ void CheckIndexingManager::initializeCollectionList(QAbstractItemModel *model, c
if
(
PimCommon
::
Util
::
isImapResource
(
collection
.
resource
())
&&
!
collection
.
cachePolicy
().
localParts
().
contains
(
QLatin1String
(
"RFC822"
)))
{
continue
;
}
mListCollection
.
append
(
collection
);
if
(
!
mCollectionsIndexed
.
contains
(
collection
.
id
()))
{
mListCollection
.
append
(
collection
);
}
if
(
model
->
rowCount
(
index
)
>
0
)
{
initializeCollectionList
(
model
,
index
);
}
...
...
kmail/src/search/checkindexingmanager.h
View file @
3feced60
...
...
@@ -38,13 +38,14 @@ public:
private
Q_SLOTS
:
void
checkNextCollection
();
void
slotRestartTimer
(
);
void
indexingFinished
(
qint64
index
);
private:
void
initializeCollectionList
(
QAbstractItemModel
*
model
,
const
QModelIndex
&
parentIndex
=
QModelIndex
());
void
createJob
();
Akonadi
::
Collection
::
List
mListCollection
;
QTimer
*
mTimer
;
QList
<
qint64
>
mCollectionsIndexed
;
int
mIndex
;
bool
mIsReady
;
};
...
...
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