[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/kdepim/enterprise/kdepim/kresources/kolab/kcal
From: Sergio Luis Martins <iamsergio () gmail ! com>
Date: 2010-08-04 11:22:39
Message-ID: 20100804112239.BF126AC7BC () svn ! kde ! org
[Download RAW message or body]
SVN commit 1159095 by smartins:
Don't send incidence updates twice to kmail. Explanations inside.
MERGE: must look in trunk what's going on.
Part of kolab/issue2109
M +35 -2 resourcekolab.cpp
M +12 -0 resourcekolab.h
--- branches/kdepim/enterprise/kdepim/kresources/kolab/kcal/resourcekolab.cpp #1159094:1159095
@@ -319,6 +319,40 @@
return;
}
+ { // start optimization
+ /**
+ KOrganizer and libkcal like calling two Incidence::updated()
+ for only one user change. That's because after a change,
+ IncidenceChanger calls incidence->setRevision( rev++ );
+ which also calls Incidence::updated().
+
+ Lets ignore the first updated() and only send to kmail
+ the second. This makes things faster.
+ */
+
+ //IncidenceBase doesn't have revision(), downcast needed.
+ Incidence *i = dynamic_cast<Incidence*>( incidencebase );
+
+ if ( i ) {
+ bool ignoreThisUpdate = false;
+
+ if ( !mLastKnownRevisions.contains( uid ) ) {
+ mLastKnownRevisions[uid] = i->revision();
+ }
+
+ // update the last known revision
+ if ( mLastKnownRevisions[uid] < i->revision() ) {
+ mLastKnownRevisions[uid] = i->revision();
+ } else {
+ ignoreThisUpdate = true;
+ }
+
+ if ( ignoreThisUpdate ) {
+ return;
+ }
+ }
+ } // end optimization
+
QString subResource;
Q_UINT32 sernum = 0;
if ( mUidMap.contains( uid ) ) {
@@ -326,8 +360,8 @@
sernum = mUidMap[ uid ].serialNumber();
mUidsPendingUpdate.append( uid );
}
+
sendKMailUpdate( incidencebase, subResource, sernum );
-
}
void ResourceKolab::incidenceUpdated( KCal::IncidenceBase* incidencebase )
{
@@ -525,7 +559,6 @@
Q_UINT32 sernum )
{
Q_ASSERT( incidence );
-
if ( !incidence ) {
return false;
}
--- branches/kdepim/enterprise/kdepim/kresources/kolab/kcal/resourcekolab.h #1159094:1159095
@@ -249,6 +249,18 @@
bool mBatchAddingInProgress;
QMap<Kolab::ResourceType,QString> mLastUsedResources;
+
+ /**
+ Indexed by uid, it holds the last known revision of an incidence.
+ If we receive an update where the incidence still has the same
+ revision as the last known, we ignore it and don't send it to kmail,
+ because shortly after, IncidenceChanger will increment the revision
+ and that will trigger another update.
+
+ If we didn't discard the first update, kmail would have been updated twice.
+ */
+ QMap<QString,int> mLastKnownRevisions;
+
};
struct TemporarySilencer {
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic