[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdepim/libkdepim
From: David Faure <faure () kde ! org>
Date: 2004-05-18 17:41:37
Message-ID: 20040518174137.640329130 () office ! kde ! org
[Download RAW message or body]
CVS commit by faure:
Implemented DCOP-based notification between IdentityManagers - in the
same process (kontact) or in separate processes. This is a bit tricky because
it required:
1) separate dcopobject names for the 2 IdentityManager instances in the same process
2) sending the signal by hand (can't use the skel, since it would ship the dcopobject
name instead of a constant one, which is necessary for the connect)
3) shipping appId+objId in the signal to ignore the signal in the emitter
(I saw that dcopserver has a bool excludeSelf, but it's never true :)
Missing dcopserver feature? OTOH the skel-based approach wouldn't allow
passing a bool excludeSelf there... And excluding self based on objId
would fail in this particular case anyway.
M +38 -2 identitymanager.cpp 1.34
M +6 -2 identitymanager.h 1.14
--- kdepim/libkdepim/identitymanager.cpp #1.33:1.34
@@ -48,4 +48,5 @@ static const char configKeyDefaultIdenti
#include <kconfig.h>
#include <kuser.h>
+#include <dcopclient.h>
#include <qregexp.h>
@@ -55,6 +56,17 @@ static const char configKeyDefaultIdenti
using namespace KPIM;
+static QCString newDCOPObjectName()
+{
+ static int s_count = 0;
+ QCString name( "KPIM::IdentityManager" );
+ if ( s_count++ ) {
+ name += '-';
+ name += QCString().setNum( s_count );
+ }
+ return name;
+}
+
IdentityManager::IdentityManager( bool readonly, QObject * parent, const char * name \
)
- : ConfigManager( parent, name ), DCOPObject( "KPIM::IdentityManager" )
+ : ConfigManager( parent, name ), DCOPObject( newDCOPObjectName() )
{
mReadOnly = readonly;
@@ -79,4 +91,9 @@ IdentityManager::IdentityManager( bool r
writeConfig();
}
+
+ // The emitter is always called KPIM::IdentityManager even if we are not
+ if ( !connectDCOPSignal( 0, "KPIM::IdentityManager", \
"identitiesChanged(QCString,QCString)", + \
"slotIdentitiesChanged(QCString,QCString)", false ) ) + kdError(5650) << \
"IdentityManager: connection to identitiesChanged failed" << endl; }
@@ -127,5 +144,13 @@ void IdentityManager::commit()
mIdentities = mShadowIdentities;
writeConfig();
- emit ConfigManager::changed();
+ emit ConfigManager::changed(); // normal signal
+
+ // DCOP signal for other IdentityManager instances
+ // The emitter is always set to KPIM::IdentityManager, so that the connect works
+ // This is why we can't use k_dcop_signals here, but need to use emitDCOPSignal
+ QByteArray data; QDataStream arg( data, IO_WriteOnly );
+ arg << kapp->dcopClient()->appId();
+ arg << DCOPObject::objId(); // the real objId, for checking in \
slotIdentitiesChanged + kapp->dcopClient()->emitDCOPSignal( "KPIM::IdentityManager", \
"identitiesChanged(QCString,QCString)", data ); }
@@ -470,3 +495,14 @@ QStringList KPIM::IdentityManager::allEm
}
+void KPIM::IdentityManager::slotIdentitiesChanged( QCString appId, QCString objId )
+{
+ // From standalone kmail to standalone korganizer, the appId will differ
+ // From kontact the appId will match, so we need to test the objId
+ if ( kapp->dcopClient()->appId() != appId || DCOPObject::objId() != objId ) {
+ mConfig->reparseConfiguration();
+ Q_ASSERT( !hasPendingChanges() );
+ readConfig( mConfig );
+ }
+}
+
#include "identitymanager.moc"
--- kdepim/libkdepim/identitymanager.h #1.13:1.14
@@ -212,6 +212,10 @@ protected:
QValueList<Identity> mShadowIdentities;
-k_dcop_signals:
- void identitiesChanged();
+//k_dcop_signals:
+// void identitiesChanged( QCString appId, QCString objId );
+
+k_dcop:
+ // Connected to the DCOP signal
+ void slotIdentitiesChanged( QCString appId, QCString objId );
private:
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic