contentstorage/caclient/src/canotifier.cpp
author hgs
Fri, 11 Jun 2010 16:13:51 +0300
changeset 98 d2f833ab7940
parent 94 dbb8300717f7
permissions -rw-r--r--
201023
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
85
7feec50967db 201003_02
hgs
parents:
diff changeset
     1
/*
7feec50967db 201003_02
hgs
parents:
diff changeset
     2
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
7feec50967db 201003_02
hgs
parents:
diff changeset
     3
 * All rights reserved.
7feec50967db 201003_02
hgs
parents:
diff changeset
     4
 * This component and the accompanying materials are made available
7feec50967db 201003_02
hgs
parents:
diff changeset
     5
 * under the terms of "Eclipse Public License v1.0"
7feec50967db 201003_02
hgs
parents:
diff changeset
     6
 * which accompanies this distribution, and is available
7feec50967db 201003_02
hgs
parents:
diff changeset
     7
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
7feec50967db 201003_02
hgs
parents:
diff changeset
     8
 *
7feec50967db 201003_02
hgs
parents:
diff changeset
     9
 * Initial Contributors:
7feec50967db 201003_02
hgs
parents:
diff changeset
    10
 * Nokia Corporation - initial contribution.
7feec50967db 201003_02
hgs
parents:
diff changeset
    11
 *
7feec50967db 201003_02
hgs
parents:
diff changeset
    12
 * Contributors:
7feec50967db 201003_02
hgs
parents:
diff changeset
    13
 *
7feec50967db 201003_02
hgs
parents:
diff changeset
    14
 * Description: canotifier.cpp
7feec50967db 201003_02
hgs
parents:
diff changeset
    15
 *
7feec50967db 201003_02
hgs
parents:
diff changeset
    16
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
    17
94
hgs
parents: 93
diff changeset
    18
#include <caservice.h>
hgs
parents: 93
diff changeset
    19
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    20
#include "canotifier.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    21
#include "canotifier_p.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    22
#include "canotifierfilter.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    23
#include "caclientnotifierproxy.h"
93
hgs
parents: 87
diff changeset
    24
#include "caobserver.h"
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    25
7feec50967db 201003_02
hgs
parents:
diff changeset
    26
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
    27
 \class CaNotifier.
7feec50967db 201003_02
hgs
parents:
diff changeset
    28
 \brief This class describes notifier.
7feec50967db 201003_02
hgs
parents:
diff changeset
    29
7feec50967db 201003_02
hgs
parents:
diff changeset
    30
 \example
7feec50967db 201003_02
hgs
parents:
diff changeset
    31
 It's example how client can be notified about changes on data specified by client's filter
7feec50967db 201003_02
hgs
parents:
diff changeset
    32
7feec50967db 201003_02
hgs
parents:
diff changeset
    33
 \code
7feec50967db 201003_02
hgs
parents:
diff changeset
    34
 // example Client class which wants to be notified about changes
7feec50967db 201003_02
hgs
parents:
diff changeset
    35
7feec50967db 201003_02
hgs
parents:
diff changeset
    36
 class Client: public QObject
7feec50967db 201003_02
hgs
parents:
diff changeset
    37
 {
7feec50967db 201003_02
hgs
parents:
diff changeset
    38
 Q_OBJECT
7feec50967db 201003_02
hgs
parents:
diff changeset
    39
 ...
7feec50967db 201003_02
hgs
parents:
diff changeset
    40
 public slots:
7feec50967db 201003_02
hgs
parents:
diff changeset
    41
7feec50967db 201003_02
hgs
parents:
diff changeset
    42
 updateModelForEntryChanged(int,ChangeType);
7feec50967db 201003_02
hgs
parents:
diff changeset
    43
 updateModelForEntryChanged(const CaEntry &,ChangeType);
7feec50967db 201003_02
hgs
parents:
diff changeset
    44
 updateModelForEntryTouched(int);
7feec50967db 201003_02
hgs
parents:
diff changeset
    45
 updateModelForgroupContentChanged(int);
7feec50967db 201003_02
hgs
parents:
diff changeset
    46
 ...
7feec50967db 201003_02
hgs
parents:
diff changeset
    47
 };
7feec50967db 201003_02
hgs
parents:
diff changeset
    48
 \endcode
7feec50967db 201003_02
hgs
parents:
diff changeset
    49
7feec50967db 201003_02
hgs
parents:
diff changeset
    50
 \code
7feec50967db 201003_02
hgs
parents:
diff changeset
    51
 // example code showed how to register for notifications
7feec50967db 201003_02
hgs
parents:
diff changeset
    52
 Client * client;
7feec50967db 201003_02
hgs
parents:
diff changeset
    53
 ...
7feec50967db 201003_02
hgs
parents:
diff changeset
    54
 QSharedPointer<CaService> service = CaService::instance();
7feec50967db 201003_02
hgs
parents:
diff changeset
    55
 CaNotifierFilter notifierFilter();
7feec50967db 201003_02
hgs
parents:
diff changeset
    56
 CaNotifier * notifier = service->createNotifier(notifierfilter);
7feec50967db 201003_02
hgs
parents:
diff changeset
    57
94
hgs
parents: 93
diff changeset
    58
CaService instance is a singleton and is deleted when nothing references
hgs
parents: 93
diff changeset
    59
it but CaNotifier contains a member referencing it,
hgs
parents: 93
diff changeset
    60
so, CaService instance is not deleted before notifier is deleted.
hgs
parents: 93
diff changeset
    61
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    62
 // Connections cause that notifier is registered to server distributed
7feec50967db 201003_02
hgs
parents:
diff changeset
    63
 // notifications while data changes.
7feec50967db 201003_02
hgs
parents:
diff changeset
    64
 if( notifier )
7feec50967db 201003_02
hgs
parents:
diff changeset
    65
 {
7feec50967db 201003_02
hgs
parents:
diff changeset
    66
 connect( notifier, SIGNAL(entryChanged(int,ChangeType)),
7feec50967db 201003_02
hgs
parents:
diff changeset
    67
 client, SLOT(updateModelForEntryChanged(int,ChangeType)) );
7feec50967db 201003_02
hgs
parents:
diff changeset
    68
 connect( notifier, SIGNAL(entryChanged(CaEntry,ChangeType)),
7feec50967db 201003_02
hgs
parents:
diff changeset
    69
 client, SLOT(updateModelForEntryChanged(CaEntry,ChangeType)) );
7feec50967db 201003_02
hgs
parents:
diff changeset
    70
 connect( notifier, SIGNAL(entryTouched(int)),
7feec50967db 201003_02
hgs
parents:
diff changeset
    71
 client, SLOT(updateModelForEntryTouched(int)) );
7feec50967db 201003_02
hgs
parents:
diff changeset
    72
 connect( notifier, SIGNAL(groupContentChanged(int)),
7feec50967db 201003_02
hgs
parents:
diff changeset
    73
 client, SLOT(updateModelForgroupContentChanged(int)) );
7feec50967db 201003_02
hgs
parents:
diff changeset
    74
 }
7feec50967db 201003_02
hgs
parents:
diff changeset
    75
 ...
7feec50967db 201003_02
hgs
parents:
diff changeset
    76
 // creation new entry causes sent notification to the client
7feec50967db 201003_02
hgs
parents:
diff changeset
    77
 CaEntry entry;
7feec50967db 201003_02
hgs
parents:
diff changeset
    78
 entry.setText( "Text" );
7feec50967db 201003_02
hgs
parents:
diff changeset
    79
 entry.setTypeName( "TypeName" );
7feec50967db 201003_02
hgs
parents:
diff changeset
    80
 CaEntry * newEntry = service->createEntry( entry );
7feec50967db 201003_02
hgs
parents:
diff changeset
    81
 ...
7feec50967db 201003_02
hgs
parents:
diff changeset
    82
 \endcode
7feec50967db 201003_02
hgs
parents:
diff changeset
    83
7feec50967db 201003_02
hgs
parents:
diff changeset
    84
 \code
7feec50967db 201003_02
hgs
parents:
diff changeset
    85
 // here client is being get notifications new entry was created
7feec50967db 201003_02
hgs
parents:
diff changeset
    86
 ...
7feec50967db 201003_02
hgs
parents:
diff changeset
    87
 Client::updateModelForEntryChanged(int entryId ,ChangeType changeType)
7feec50967db 201003_02
hgs
parents:
diff changeset
    88
 {
7feec50967db 201003_02
hgs
parents:
diff changeset
    89
 ...
7feec50967db 201003_02
hgs
parents:
diff changeset
    90
 changeType == AddChangeType;
7feec50967db 201003_02
hgs
parents:
diff changeset
    91
 ...
7feec50967db 201003_02
hgs
parents:
diff changeset
    92
 }
7feec50967db 201003_02
hgs
parents:
diff changeset
    93
7feec50967db 201003_02
hgs
parents:
diff changeset
    94
 \endcode
7feec50967db 201003_02
hgs
parents:
diff changeset
    95
7feec50967db 201003_02
hgs
parents:
diff changeset
    96
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
    97
7feec50967db 201003_02
hgs
parents:
diff changeset
    98
/*!
93
hgs
parents: 87
diff changeset
    99
 \var CaNotifierPrivate::m_q
hgs
parents: 87
diff changeset
   100
 Points to the CaNotifier instance that uses
hgs
parents: 87
diff changeset
   101
 this private implementation.
hgs
parents: 87
diff changeset
   102
 */
hgs
parents: 87
diff changeset
   103
hgs
parents: 87
diff changeset
   104
/*!
hgs
parents: 87
diff changeset
   105
 \var CaNotifierPrivate::mNotifierFilter
hgs
parents: 87
diff changeset
   106
 Own.
hgs
parents: 87
diff changeset
   107
 */
hgs
parents: 87
diff changeset
   108
hgs
parents: 87
diff changeset
   109
/*!
hgs
parents: 87
diff changeset
   110
 \var CaNotifierPrivate::mNotifierProxy
hgs
parents: 87
diff changeset
   111
 Not own.
hgs
parents: 87
diff changeset
   112
 */
hgs
parents: 87
diff changeset
   113
hgs
parents: 87
diff changeset
   114
/*!
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   115
 Constructor.
7feec50967db 201003_02
hgs
parents:
diff changeset
   116
 \param entryPrivate pointer to private implementation.
7feec50967db 201003_02
hgs
parents:
diff changeset
   117
 */
87
hgs
parents: 85
diff changeset
   118
CaNotifier::CaNotifier(CaNotifierPrivate *const notifierPrivate) :
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   119
    QObject(0), m_d(notifierPrivate)
7feec50967db 201003_02
hgs
parents:
diff changeset
   120
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   121
    m_d->m_q = this;
7feec50967db 201003_02
hgs
parents:
diff changeset
   122
    m_d->makeConnect();
7feec50967db 201003_02
hgs
parents:
diff changeset
   123
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   124
7feec50967db 201003_02
hgs
parents:
diff changeset
   125
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   126
 Destructor.
7feec50967db 201003_02
hgs
parents:
diff changeset
   127
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
   128
CaNotifier::~CaNotifier()
7feec50967db 201003_02
hgs
parents:
diff changeset
   129
{
93
hgs
parents: 87
diff changeset
   130
    m_d->unregisterNotifier(
hgs
parents: 87
diff changeset
   131
                        CaNotifierPrivate::EntryChangedWithIdNotifierType);
hgs
parents: 87
diff changeset
   132
    m_d->unregisterNotifier(
hgs
parents: 87
diff changeset
   133
                        CaNotifierPrivate::EntryChangedWithEntryNotifierType);
hgs
parents: 87
diff changeset
   134
    m_d->unregisterNotifier(
hgs
parents: 87
diff changeset
   135
                        CaNotifierPrivate::EntryTouchedNotifierType);
hgs
parents: 87
diff changeset
   136
    m_d->unregisterNotifier(
hgs
parents: 87
diff changeset
   137
                        CaNotifierPrivate::GroupContentChangedNotifierType);
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   138
    delete m_d;
7feec50967db 201003_02
hgs
parents:
diff changeset
   139
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   140
7feec50967db 201003_02
hgs
parents:
diff changeset
   141
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   142
    This method is called when something has been
7feec50967db 201003_02
hgs
parents:
diff changeset
   143
    connected to signal in this object.
7feec50967db 201003_02
hgs
parents:
diff changeset
   144
    \param signal which is used to register an appropriate notifier.
7feec50967db 201003_02
hgs
parents:
diff changeset
   145
*/
7feec50967db 201003_02
hgs
parents:
diff changeset
   146
void CaNotifier::connectNotify(const char *signal)
7feec50967db 201003_02
hgs
parents:
diff changeset
   147
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   148
    qDebug("CaNotifier::connectNotify");
7feec50967db 201003_02
hgs
parents:
diff changeset
   149
    qDebug("\tsignal: %s", signal);
7feec50967db 201003_02
hgs
parents:
diff changeset
   150
    if (QLatin1String(signal)
87
hgs
parents: 85
diff changeset
   151
            == SIGNAL(entryChanged(int,ChangeType))) {
hgs
parents: 85
diff changeset
   152
        // signal is entryChanged(int, ChangeType)
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   153
        if (receivers(SIGNAL(entryChanged(int,ChangeType))) == 1) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   154
            m_d->registerNotifier(
7feec50967db 201003_02
hgs
parents:
diff changeset
   155
                CaNotifierPrivate::EntryChangedWithIdNotifierType);
7feec50967db 201003_02
hgs
parents:
diff changeset
   156
        }
87
hgs
parents: 85
diff changeset
   157
    } else if (QLatin1String(signal)
hgs
parents: 85
diff changeset
   158
               == SIGNAL(entryChanged(CaEntry,ChangeType))) {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   159
        // signal is entryChanged(const CaEntry &, ChangeType)
7feec50967db 201003_02
hgs
parents:
diff changeset
   160
        if (receivers(SIGNAL(entryChanged(const CaEntry &,ChangeType))) == 1) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   161
            m_d->registerNotifier(
7feec50967db 201003_02
hgs
parents:
diff changeset
   162
                CaNotifierPrivate::EntryChangedWithEntryNotifierType);
7feec50967db 201003_02
hgs
parents:
diff changeset
   163
        }
87
hgs
parents: 85
diff changeset
   164
    } else if (QLatin1String(signal)
hgs
parents: 85
diff changeset
   165
               == SIGNAL(entryTouched(int))) {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   166
        // signal is entryTouched(int)
7feec50967db 201003_02
hgs
parents:
diff changeset
   167
        if (receivers(SIGNAL(entryTouched(int)))) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   168
            m_d->registerNotifier(
7feec50967db 201003_02
hgs
parents:
diff changeset
   169
                CaNotifierPrivate::EntryTouchedNotifierType);
7feec50967db 201003_02
hgs
parents:
diff changeset
   170
        }
87
hgs
parents: 85
diff changeset
   171
    } else if (QLatin1String(signal)
hgs
parents: 85
diff changeset
   172
               == SIGNAL(groupContentChanged(int))) {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   173
        // signal is groupContentChanged(int)
7feec50967db 201003_02
hgs
parents:
diff changeset
   174
        if (receivers(SIGNAL(groupContentChanged(int)))) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   175
            m_d->registerNotifier(
7feec50967db 201003_02
hgs
parents:
diff changeset
   176
                CaNotifierPrivate::GroupContentChangedNotifierType);
7feec50967db 201003_02
hgs
parents:
diff changeset
   177
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   178
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   179
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   180
7feec50967db 201003_02
hgs
parents:
diff changeset
   181
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   182
    This method is called when something has been
7feec50967db 201003_02
hgs
parents:
diff changeset
   183
    disconnected from signal in this object.
7feec50967db 201003_02
hgs
parents:
diff changeset
   184
    \param signal which is used to unregister an appropriate notifier.
7feec50967db 201003_02
hgs
parents:
diff changeset
   185
*/
7feec50967db 201003_02
hgs
parents:
diff changeset
   186
void CaNotifier::disconnectNotify(const char *signal)
7feec50967db 201003_02
hgs
parents:
diff changeset
   187
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   188
    qDebug("CaNotifier::disconnectNotify");
7feec50967db 201003_02
hgs
parents:
diff changeset
   189
    qDebug("\tsignal: %s", signal);
7feec50967db 201003_02
hgs
parents:
diff changeset
   190
    if (QLatin1String(signal)
87
hgs
parents: 85
diff changeset
   191
            == SIGNAL(entryChanged(int,ChangeType))) {
hgs
parents: 85
diff changeset
   192
        // signal is entryChanged(int, ChangeType)
hgs
parents: 85
diff changeset
   193
        if (receivers(SIGNAL(entryChanged(int,ChangeType)))==0) {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   194
            m_d->unregisterNotifier(
7feec50967db 201003_02
hgs
parents:
diff changeset
   195
                CaNotifierPrivate::EntryChangedWithIdNotifierType);
7feec50967db 201003_02
hgs
parents:
diff changeset
   196
        }
87
hgs
parents: 85
diff changeset
   197
    } else if (QLatin1String(signal)
hgs
parents: 85
diff changeset
   198
               == SIGNAL(entryChanged(CaEntry,ChangeType))) {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   199
        // signal is entryChanged(const CaEntry &, ChangeType)
7feec50967db 201003_02
hgs
parents:
diff changeset
   200
        if (receivers(SIGNAL(entryChanged(const CaEntry &,ChangeType)))==0) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   201
            m_d->unregisterNotifier(
7feec50967db 201003_02
hgs
parents:
diff changeset
   202
                CaNotifierPrivate::EntryChangedWithEntryNotifierType);
7feec50967db 201003_02
hgs
parents:
diff changeset
   203
        }
87
hgs
parents: 85
diff changeset
   204
    } else if (QLatin1String(signal)
hgs
parents: 85
diff changeset
   205
               == SIGNAL(entryTouched(int))) {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   206
        // signal is entryTouched(int)
7feec50967db 201003_02
hgs
parents:
diff changeset
   207
        if (receivers(SIGNAL(entryTouched(int))) == 0) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   208
            m_d->unregisterNotifier(
7feec50967db 201003_02
hgs
parents:
diff changeset
   209
                CaNotifierPrivate::EntryTouchedNotifierType);
7feec50967db 201003_02
hgs
parents:
diff changeset
   210
        }
87
hgs
parents: 85
diff changeset
   211
    } else if (QLatin1String(signal)
hgs
parents: 85
diff changeset
   212
               == SIGNAL(groupContentChanged(int))) {
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   213
        // signal is groupContentChanged(int)
7feec50967db 201003_02
hgs
parents:
diff changeset
   214
        if (receivers(SIGNAL(groupContentChanged(int))) == 0) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   215
            m_d->unregisterNotifier(
7feec50967db 201003_02
hgs
parents:
diff changeset
   216
                CaNotifierPrivate::GroupContentChangedNotifierType);
7feec50967db 201003_02
hgs
parents:
diff changeset
   217
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   218
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   219
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   220
7feec50967db 201003_02
hgs
parents:
diff changeset
   221
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   222
 Constructor.
7feec50967db 201003_02
hgs
parents:
diff changeset
   223
 \param notifierFilter descrbies entries to observe.
7feec50967db 201003_02
hgs
parents:
diff changeset
   224
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
   225
CaNotifierPrivate::CaNotifierPrivate(
93
hgs
parents: 87
diff changeset
   226
    const CaNotifierFilter &notifierFilter, 
hgs
parents: 87
diff changeset
   227
    CaClientNotifierProxy *notifierProxy) :
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   228
    m_q(NULL),
93
hgs
parents: 87
diff changeset
   229
    mNotifierFilter(NULL), 
94
hgs
parents: 93
diff changeset
   230
    mObserver(NULL),
hgs
parents: 93
diff changeset
   231
    mCaService(CaService::instance())
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   232
{
93
hgs
parents: 87
diff changeset
   233
    mNotifierProxy = notifierProxy;
87
hgs
parents: 85
diff changeset
   234
    mNotifierFilter = new CaNotifierFilter(notifierFilter);
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   235
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   236
7feec50967db 201003_02
hgs
parents:
diff changeset
   237
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   238
 Destructor.
7feec50967db 201003_02
hgs
parents:
diff changeset
   239
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
   240
CaNotifierPrivate::~CaNotifierPrivate()
7feec50967db 201003_02
hgs
parents:
diff changeset
   241
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   242
    if (mNotifierProxy) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   243
        mNotifierProxy->unregisterNotifier(*mNotifierFilter,
87
hgs
parents: 85
diff changeset
   244
                                           EntryChangedWithIdNotifierType);
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   245
        mNotifierProxy->unregisterNotifier(*mNotifierFilter,
87
hgs
parents: 85
diff changeset
   246
                                           EntryChangedWithEntryNotifierType);
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   247
        mNotifierProxy->unregisterNotifier(*mNotifierFilter,
87
hgs
parents: 85
diff changeset
   248
                                           EntryTouchedNotifierType);
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   249
        mNotifierProxy->unregisterNotifier(*mNotifierFilter,
87
hgs
parents: 85
diff changeset
   250
                                           GroupContentChangedNotifierType);
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   251
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   252
    delete mNotifierFilter;
7feec50967db 201003_02
hgs
parents:
diff changeset
   253
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   254
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   255
 Registers notifier
7feec50967db 201003_02
hgs
parents:
diff changeset
   256
 \param notifierType type of notifier to register (class of events to listen)
7feec50967db 201003_02
hgs
parents:
diff changeset
   257
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
   258
int CaNotifierPrivate::registerNotifier(NotifierType notifierType)
7feec50967db 201003_02
hgs
parents:
diff changeset
   259
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   260
    if (mNotifierProxy) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   261
        return mNotifierProxy->registerNotifier(
87
hgs
parents: 85
diff changeset
   262
                   mNotifierFilter,
hgs
parents: 85
diff changeset
   263
                   notifierType,
93
hgs
parents: 87
diff changeset
   264
                   mObserver);
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   265
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   266
    return 0;
7feec50967db 201003_02
hgs
parents:
diff changeset
   267
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   268
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   269
 Unregisters notifier
7feec50967db 201003_02
hgs
parents:
diff changeset
   270
 \param notifierType type of notifier event type to unregister
7feec50967db 201003_02
hgs
parents:
diff changeset
   271
     (class of events to listen)
7feec50967db 201003_02
hgs
parents:
diff changeset
   272
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
   273
void CaNotifierPrivate::unregisterNotifier(NotifierType notifierType)
7feec50967db 201003_02
hgs
parents:
diff changeset
   274
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   275
    if (mNotifierProxy) {
7feec50967db 201003_02
hgs
parents:
diff changeset
   276
        mNotifierProxy->unregisterNotifier(*mNotifierFilter, notifierType);
7feec50967db 201003_02
hgs
parents:
diff changeset
   277
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   278
}
7feec50967db 201003_02
hgs
parents:
diff changeset
   279
7feec50967db 201003_02
hgs
parents:
diff changeset
   280
/*!
7feec50967db 201003_02
hgs
parents:
diff changeset
   281
 Connects this Notifier
7feec50967db 201003_02
hgs
parents:
diff changeset
   282
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
   283
void CaNotifierPrivate::makeConnect()
7feec50967db 201003_02
hgs
parents:
diff changeset
   284
{
7feec50967db 201003_02
hgs
parents:
diff changeset
   285
    if (m_q) {
93
hgs
parents: 87
diff changeset
   286
        mObserver = new CaObserver();
hgs
parents: 87
diff changeset
   287
        m_q->connect(mObserver,
87
hgs
parents: 85
diff changeset
   288
                     SIGNAL(signalEntryChanged(int,ChangeType)),
hgs
parents: 85
diff changeset
   289
                     m_q,
hgs
parents: 85
diff changeset
   290
                     SIGNAL(entryChanged(int,ChangeType)));
93
hgs
parents: 87
diff changeset
   291
        m_q->connect(mObserver,
87
hgs
parents: 85
diff changeset
   292
                     SIGNAL(signalEntryChanged(const CaEntry &,ChangeType)),
hgs
parents: 85
diff changeset
   293
                     m_q,
hgs
parents: 85
diff changeset
   294
                     SIGNAL(entryChanged(const CaEntry &,ChangeType)));
93
hgs
parents: 87
diff changeset
   295
        m_q->connect(mObserver,
87
hgs
parents: 85
diff changeset
   296
                     SIGNAL(signalEntryTouched(int)),
hgs
parents: 85
diff changeset
   297
                     m_q,
hgs
parents: 85
diff changeset
   298
                     SIGNAL(entryTouched(int)));
93
hgs
parents: 87
diff changeset
   299
        m_q->connect(mObserver,
87
hgs
parents: 85
diff changeset
   300
                     SIGNAL(signalGroupContentChanged(int)),
hgs
parents: 85
diff changeset
   301
                     m_q,
hgs
parents: 85
diff changeset
   302
                     SIGNAL(groupContentChanged(int)));
85
7feec50967db 201003_02
hgs
parents:
diff changeset
   303
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   304
}
93
hgs
parents: 87
diff changeset
   305