contentstorage/caclient/src/canotifier.cpp
changeset 73 4bc7b118b3df
parent 60 f62f87b200ec
child 80 397d00875918
equal deleted inserted replaced
66:32469d7d46ff 73:4bc7b118b3df
    17 
    17 
    18 #include "canotifier.h"
    18 #include "canotifier.h"
    19 #include "canotifier_p.h"
    19 #include "canotifier_p.h"
    20 #include "canotifierfilter.h"
    20 #include "canotifierfilter.h"
    21 #include "caclientnotifierproxy.h"
    21 #include "caclientnotifierproxy.h"
       
    22 #include "caobserver.h"
    22 
    23 
    23 /*!
    24 /*!
    24  \class CaNotifier.
    25  \class CaNotifier.
    25  \brief This class describes notifier.
    26  \brief This class describes notifier.
    26 
    27 
    87  \endcode
    88  \endcode
    88 
    89 
    89  */
    90  */
    90 
    91 
    91 /*!
    92 /*!
       
    93  \var CaNotifierPrivate::m_q
       
    94  Points to the CaNotifier instance that uses
       
    95  this private implementation.
       
    96  */
       
    97 
       
    98 /*!
       
    99  \var CaNotifierPrivate::mNotifierFilter
       
   100  Own.
       
   101  */
       
   102 
       
   103 /*!
       
   104  \var CaNotifierPrivate::mNotifierProxy
       
   105  Not own.
       
   106  */
       
   107 
       
   108 /*!
    92  Constructor.
   109  Constructor.
    93  \param entryPrivate pointer to private implementation.
   110  \param entryPrivate pointer to private implementation.
    94  */
   111  */
    95 CaNotifier::CaNotifier(CaNotifierPrivate *const notifierPrivate) :
   112 CaNotifier::CaNotifier(CaNotifierPrivate *const notifierPrivate) :
    96     QObject(0), m_d(notifierPrivate)
   113     QObject(0), m_d(notifierPrivate)
   102 /*!
   119 /*!
   103  Destructor.
   120  Destructor.
   104  */
   121  */
   105 CaNotifier::~CaNotifier()
   122 CaNotifier::~CaNotifier()
   106 {
   123 {
   107     m_d->makeDisconnect();
   124     m_d->unregisterNotifier(
       
   125                         CaNotifierPrivate::EntryChangedWithIdNotifierType);
       
   126     m_d->unregisterNotifier(
       
   127                         CaNotifierPrivate::EntryChangedWithEntryNotifierType);
       
   128     m_d->unregisterNotifier(
       
   129                         CaNotifierPrivate::EntryTouchedNotifierType);
       
   130     m_d->unregisterNotifier(
       
   131                         CaNotifierPrivate::GroupContentChangedNotifierType);
   108     delete m_d;
   132     delete m_d;
   109 }
   133 }
   110 
   134 
   111 /*!
   135 /*!
   112     This method is called when something has been
   136     This method is called when something has been
   191 /*!
   215 /*!
   192  Constructor.
   216  Constructor.
   193  \param notifierFilter descrbies entries to observe.
   217  \param notifierFilter descrbies entries to observe.
   194  */
   218  */
   195 CaNotifierPrivate::CaNotifierPrivate(
   219 CaNotifierPrivate::CaNotifierPrivate(
   196     const CaNotifierFilter &notifierFilter) :
   220     const CaNotifierFilter &notifierFilter, 
       
   221     CaClientNotifierProxy *notifierProxy) :
   197     m_q(NULL),
   222     m_q(NULL),
   198     mNotifierFilter(NULL),
   223     mNotifierFilter(NULL), 
   199     mNotifierProxy(NULL)
   224     mObserver(NULL)
   200 {
   225 {
       
   226     mNotifierProxy = notifierProxy;
   201     mNotifierFilter = new CaNotifierFilter(notifierFilter);
   227     mNotifierFilter = new CaNotifierFilter(notifierFilter);
   202 }
   228 }
   203 
   229 
   204 /*!
   230 /*!
   205  Destructor.
   231  Destructor.
   215                                            EntryTouchedNotifierType);
   241                                            EntryTouchedNotifierType);
   216         mNotifierProxy->unregisterNotifier(*mNotifierFilter,
   242         mNotifierProxy->unregisterNotifier(*mNotifierFilter,
   217                                            GroupContentChangedNotifierType);
   243                                            GroupContentChangedNotifierType);
   218     }
   244     }
   219     delete mNotifierFilter;
   245     delete mNotifierFilter;
   220     delete mNotifierProxy;
       
   221 }
   246 }
   222 /*!
   247 /*!
   223  Registers notifier
   248  Registers notifier
   224  \param notifierType type of notifier to register (class of events to listen)
   249  \param notifierType type of notifier to register (class of events to listen)
   225  */
   250  */
   227 {
   252 {
   228     if (mNotifierProxy) {
   253     if (mNotifierProxy) {
   229         return mNotifierProxy->registerNotifier(
   254         return mNotifierProxy->registerNotifier(
   230                    mNotifierFilter,
   255                    mNotifierFilter,
   231                    notifierType,
   256                    notifierType,
   232                    mNotifierProxy);
   257                    mObserver);
   233     }
   258     }
   234     return 0;
   259     return 0;
   235 }
   260 }
   236 /*!
   261 /*!
   237  Unregisters notifier
   262  Unregisters notifier
   249  Connects this Notifier
   274  Connects this Notifier
   250  */
   275  */
   251 void CaNotifierPrivate::makeConnect()
   276 void CaNotifierPrivate::makeConnect()
   252 {
   277 {
   253     if (m_q) {
   278     if (m_q) {
   254         if (!mNotifierProxy) {
   279         mObserver = new CaObserver();
   255             mNotifierProxy = new CaClientNotifierProxy();
   280         m_q->connect(mObserver,
   256         }
       
   257         m_q->connect(mNotifierProxy,
       
   258                      SIGNAL(signalEntryChanged(int,ChangeType)),
   281                      SIGNAL(signalEntryChanged(int,ChangeType)),
   259                      m_q,
   282                      m_q,
   260                      SIGNAL(entryChanged(int,ChangeType)));
   283                      SIGNAL(entryChanged(int,ChangeType)));
   261         m_q->connect(mNotifierProxy,
   284         m_q->connect(mObserver,
   262                      SIGNAL(signalEntryChanged(const CaEntry &,ChangeType)),
   285                      SIGNAL(signalEntryChanged(const CaEntry &,ChangeType)),
   263                      m_q,
   286                      m_q,
   264                      SIGNAL(entryChanged(const CaEntry &,ChangeType)));
   287                      SIGNAL(entryChanged(const CaEntry &,ChangeType)));
   265         m_q->connect(mNotifierProxy,
   288         m_q->connect(mObserver,
   266                      SIGNAL(signalEntryTouched(int)),
   289                      SIGNAL(signalEntryTouched(int)),
   267                      m_q,
   290                      m_q,
   268                      SIGNAL(entryTouched(int)));
   291                      SIGNAL(entryTouched(int)));
   269         m_q->connect(mNotifierProxy,
   292         m_q->connect(mObserver,
   270                      SIGNAL(signalGroupContentChanged(int)),
   293                      SIGNAL(signalGroupContentChanged(int)),
   271                      m_q,
   294                      m_q,
   272                      SIGNAL(groupContentChanged(int)));
   295                      SIGNAL(groupContentChanged(int)));
   273     }
   296     }
   274 }
   297 }
   275 /*!
   298 
   276  Disconnects this Notifier
       
   277  */
       
   278 void CaNotifierPrivate::makeDisconnect()
       
   279 {
       
   280     if (m_q && mNotifierProxy) {
       
   281         m_q->disconnect(mNotifierProxy,
       
   282                         SIGNAL(signalEntryChanged(int,ChangeType)),
       
   283                         m_q,
       
   284                         SIGNAL(entryChanged(int,ChangeType)));
       
   285         m_q->disconnect(mNotifierProxy,
       
   286                         SIGNAL(signalEntryChanged(const CaEntry &,ChangeType)),
       
   287                         m_q,
       
   288                         SIGNAL(entryChanged(const CaEntry &,ChangeType)));
       
   289         m_q->disconnect(mNotifierProxy,
       
   290                         SIGNAL(signalEntryTouched(int)),
       
   291                         m_q,
       
   292                         SIGNAL(entryTouched(int)));
       
   293         m_q->disconnect(mNotifierProxy,
       
   294                         SIGNAL(signalGroupContentChanged(int)),
       
   295                         m_q,
       
   296                         SIGNAL(groupContentChanged(int)));
       
   297     }
       
   298 }