contentstorage/caclient/src/canotifier.cpp
changeset 73 4bc7b118b3df
parent 60 f62f87b200ec
child 80 397d00875918
--- a/contentstorage/caclient/src/canotifier.cpp	Mon May 03 12:48:45 2010 +0300
+++ b/contentstorage/caclient/src/canotifier.cpp	Fri May 14 16:10:06 2010 +0300
@@ -19,6 +19,7 @@
 #include "canotifier_p.h"
 #include "canotifierfilter.h"
 #include "caclientnotifierproxy.h"
+#include "caobserver.h"
 
 /*!
  \class CaNotifier.
@@ -89,6 +90,22 @@
  */
 
 /*!
+ \var CaNotifierPrivate::m_q
+ Points to the CaNotifier instance that uses
+ this private implementation.
+ */
+
+/*!
+ \var CaNotifierPrivate::mNotifierFilter
+ Own.
+ */
+
+/*!
+ \var CaNotifierPrivate::mNotifierProxy
+ Not own.
+ */
+
+/*!
  Constructor.
  \param entryPrivate pointer to private implementation.
  */
@@ -104,7 +121,14 @@
  */
 CaNotifier::~CaNotifier()
 {
-    m_d->makeDisconnect();
+    m_d->unregisterNotifier(
+                        CaNotifierPrivate::EntryChangedWithIdNotifierType);
+    m_d->unregisterNotifier(
+                        CaNotifierPrivate::EntryChangedWithEntryNotifierType);
+    m_d->unregisterNotifier(
+                        CaNotifierPrivate::EntryTouchedNotifierType);
+    m_d->unregisterNotifier(
+                        CaNotifierPrivate::GroupContentChangedNotifierType);
     delete m_d;
 }
 
@@ -193,11 +217,13 @@
  \param notifierFilter descrbies entries to observe.
  */
 CaNotifierPrivate::CaNotifierPrivate(
-    const CaNotifierFilter &notifierFilter) :
+    const CaNotifierFilter &notifierFilter, 
+    CaClientNotifierProxy *notifierProxy) :
     m_q(NULL),
-    mNotifierFilter(NULL),
-    mNotifierProxy(NULL)
+    mNotifierFilter(NULL), 
+    mObserver(NULL)
 {
+    mNotifierProxy = notifierProxy;
     mNotifierFilter = new CaNotifierFilter(notifierFilter);
 }
 
@@ -217,7 +243,6 @@
                                            GroupContentChangedNotifierType);
     }
     delete mNotifierFilter;
-    delete mNotifierProxy;
 }
 /*!
  Registers notifier
@@ -229,7 +254,7 @@
         return mNotifierProxy->registerNotifier(
                    mNotifierFilter,
                    notifierType,
-                   mNotifierProxy);
+                   mObserver);
     }
     return 0;
 }
@@ -251,48 +276,23 @@
 void CaNotifierPrivate::makeConnect()
 {
     if (m_q) {
-        if (!mNotifierProxy) {
-            mNotifierProxy = new CaClientNotifierProxy();
-        }
-        m_q->connect(mNotifierProxy,
+        mObserver = new CaObserver();
+        m_q->connect(mObserver,
                      SIGNAL(signalEntryChanged(int,ChangeType)),
                      m_q,
                      SIGNAL(entryChanged(int,ChangeType)));
-        m_q->connect(mNotifierProxy,
+        m_q->connect(mObserver,
                      SIGNAL(signalEntryChanged(const CaEntry &,ChangeType)),
                      m_q,
                      SIGNAL(entryChanged(const CaEntry &,ChangeType)));
-        m_q->connect(mNotifierProxy,
+        m_q->connect(mObserver,
                      SIGNAL(signalEntryTouched(int)),
                      m_q,
                      SIGNAL(entryTouched(int)));
-        m_q->connect(mNotifierProxy,
+        m_q->connect(mObserver,
                      SIGNAL(signalGroupContentChanged(int)),
                      m_q,
                      SIGNAL(groupContentChanged(int)));
     }
 }
-/*!
- Disconnects this Notifier
- */
-void CaNotifierPrivate::makeDisconnect()
-{
-    if (m_q && mNotifierProxy) {
-        m_q->disconnect(mNotifierProxy,
-                        SIGNAL(signalEntryChanged(int,ChangeType)),
-                        m_q,
-                        SIGNAL(entryChanged(int,ChangeType)));
-        m_q->disconnect(mNotifierProxy,
-                        SIGNAL(signalEntryChanged(const CaEntry &,ChangeType)),
-                        m_q,
-                        SIGNAL(entryChanged(const CaEntry &,ChangeType)));
-        m_q->disconnect(mNotifierProxy,
-                        SIGNAL(signalEntryTouched(int)),
-                        m_q,
-                        SIGNAL(entryTouched(int)));
-        m_q->disconnect(mNotifierProxy,
-                        SIGNAL(signalGroupContentChanged(int)),
-                        m_q,
-                        SIGNAL(groupContentChanged(int)));
-    }
-}
+