contentstorage/srvsrc/casrvnotifier.cpp
author hgs
Fri, 28 May 2010 16:17:03 +0300
changeset 96 5d243a69bdda
parent 86 e492551a0d54
child 98 d2f833ab7940
permissions -rw-r--r--
201021
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) 2008 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:  ?Description
7feec50967db 201003_02
hgs
parents:
diff changeset
    15
 *
7feec50967db 201003_02
hgs
parents:
diff changeset
    16
 */
7feec50967db 201003_02
hgs
parents:
diff changeset
    17
86
hgs
parents: 85
diff changeset
    18
#include <badesca.h>
85
7feec50967db 201003_02
hgs
parents:
diff changeset
    19
#include "casrvnotifier.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    20
#include "cainnernotifierfilter.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    21
#include "cainnerentry.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    22
#include "casrvdef.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    23
#include "cautils.h"
7feec50967db 201003_02
hgs
parents:
diff changeset
    24
#include "caarraycleanup.inl"
7feec50967db 201003_02
hgs
parents:
diff changeset
    25
7feec50967db 201003_02
hgs
parents:
diff changeset
    26
// ================= MEMBER FUNCTIONS =======================
7feec50967db 201003_02
hgs
parents:
diff changeset
    27
7feec50967db 201003_02
hgs
parents:
diff changeset
    28
7feec50967db 201003_02
hgs
parents:
diff changeset
    29
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    30
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
    31
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    32
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    33
CCaSrvNotifier::~CCaSrvNotifier()
7feec50967db 201003_02
hgs
parents:
diff changeset
    34
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
    35
    Complete( KErrCancel );
7feec50967db 201003_02
hgs
parents:
diff changeset
    36
    iBufArrayInfo.ResetAndDestroy();
7feec50967db 201003_02
hgs
parents:
diff changeset
    37
    iArrayChangeType.Close();
7feec50967db 201003_02
hgs
parents:
diff changeset
    38
    delete iFilter;
7feec50967db 201003_02
hgs
parents:
diff changeset
    39
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
    40
7feec50967db 201003_02
hgs
parents:
diff changeset
    41
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    42
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
    43
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    44
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    45
CCaSrvNotifier* CCaSrvNotifier::NewL()
7feec50967db 201003_02
hgs
parents:
diff changeset
    46
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
    47
    CCaSrvNotifier* self = CCaSrvNotifier::NewLC();
7feec50967db 201003_02
hgs
parents:
diff changeset
    48
    CleanupStack::Pop();
7feec50967db 201003_02
hgs
parents:
diff changeset
    49
    return self;
7feec50967db 201003_02
hgs
parents:
diff changeset
    50
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
    51
7feec50967db 201003_02
hgs
parents:
diff changeset
    52
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    53
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
    54
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    55
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    56
CCaSrvNotifier* CCaSrvNotifier::NewLC()
7feec50967db 201003_02
hgs
parents:
diff changeset
    57
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
    58
    CCaSrvNotifier* self = new ( ELeave ) CCaSrvNotifier();
7feec50967db 201003_02
hgs
parents:
diff changeset
    59
    CleanupStack::PushL( self );
7feec50967db 201003_02
hgs
parents:
diff changeset
    60
    self->ConstructL();
7feec50967db 201003_02
hgs
parents:
diff changeset
    61
    return self;
7feec50967db 201003_02
hgs
parents:
diff changeset
    62
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
    63
7feec50967db 201003_02
hgs
parents:
diff changeset
    64
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    65
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
    66
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    67
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    68
CCaSrvNotifier::CCaSrvNotifier()
7feec50967db 201003_02
hgs
parents:
diff changeset
    69
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
    70
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
    71
7feec50967db 201003_02
hgs
parents:
diff changeset
    72
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    73
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
    74
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    75
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    76
void CCaSrvNotifier::ConstructL()
7feec50967db 201003_02
hgs
parents:
diff changeset
    77
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
    78
    iFilter = CCaInnerNotifierFilter::NewL(
7feec50967db 201003_02
hgs
parents:
diff changeset
    79
            CCaInnerNotifierFilter::EEntryChangedWithId );
7feec50967db 201003_02
hgs
parents:
diff changeset
    80
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
    81
7feec50967db 201003_02
hgs
parents:
diff changeset
    82
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    83
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
    84
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    85
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    86
void CCaSrvNotifier::NotifyL( const RMessage2& aMessage )
7feec50967db 201003_02
hgs
parents:
diff changeset
    87
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
    88
    PanicIfPendingL( aMessage );
7feec50967db 201003_02
hgs
parents:
diff changeset
    89
    SetPendingL( aMessage ); // No leaving after this!
7feec50967db 201003_02
hgs
parents:
diff changeset
    90
    }
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
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
    95
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
    96
//
7feec50967db 201003_02
hgs
parents:
diff changeset
    97
void CCaSrvNotifier::Cancel()
7feec50967db 201003_02
hgs
parents:
diff changeset
    98
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
    99
    Complete( KErrCancel );
7feec50967db 201003_02
hgs
parents:
diff changeset
   100
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   101
7feec50967db 201003_02
hgs
parents:
diff changeset
   102
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   103
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
   104
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   105
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   106
void CCaSrvNotifier::SetPendingL( const RMessage2 &aMessage )
7feec50967db 201003_02
hgs
parents:
diff changeset
   107
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   108
    __ASSERT_DEBUG( !iPending, User::Invariant() );
7feec50967db 201003_02
hgs
parents:
diff changeset
   109
    iMessage = aMessage;
7feec50967db 201003_02
hgs
parents:
diff changeset
   110
    iPending = ETrue;
7feec50967db 201003_02
hgs
parents:
diff changeset
   111
    if( iBufArrayInfo.Count() > 0 )
7feec50967db 201003_02
hgs
parents:
diff changeset
   112
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   113
        Complete();
7feec50967db 201003_02
hgs
parents:
diff changeset
   114
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   115
    else
7feec50967db 201003_02
hgs
parents:
diff changeset
   116
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   117
        MenuUtils::InternalizeObjectL( aMessage, *iFilter );
7feec50967db 201003_02
hgs
parents:
diff changeset
   118
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   119
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   120
7feec50967db 201003_02
hgs
parents:
diff changeset
   121
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   122
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
   123
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   124
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   125
void CCaSrvNotifier::PanicIfPendingL( const RMessage2& aMessage )
7feec50967db 201003_02
hgs
parents:
diff changeset
   126
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   127
    if( iPending )
7feec50967db 201003_02
hgs
parents:
diff changeset
   128
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   129
        // Another message is already being served.
7feec50967db 201003_02
hgs
parents:
diff changeset
   130
        aMessage.Panic( KCaSrvName, KErrInUse );
7feec50967db 201003_02
hgs
parents:
diff changeset
   131
        User::Leave( KErrInUse );
7feec50967db 201003_02
hgs
parents:
diff changeset
   132
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   133
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   134
7feec50967db 201003_02
hgs
parents:
diff changeset
   135
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   136
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
   137
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   138
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   139
void CCaSrvNotifier::Complete( TInt aReason )
7feec50967db 201003_02
hgs
parents:
diff changeset
   140
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   141
    if( iPending )
7feec50967db 201003_02
hgs
parents:
diff changeset
   142
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   143
        if( aReason != KErrNone )
7feec50967db 201003_02
hgs
parents:
diff changeset
   144
            {
7feec50967db 201003_02
hgs
parents:
diff changeset
   145
            iMessage.Complete( aReason );
7feec50967db 201003_02
hgs
parents:
diff changeset
   146
            iBufArrayInfo.ResetAndDestroy();
7feec50967db 201003_02
hgs
parents:
diff changeset
   147
            iArrayChangeType.Close();
7feec50967db 201003_02
hgs
parents:
diff changeset
   148
            }
7feec50967db 201003_02
hgs
parents:
diff changeset
   149
        else
7feec50967db 201003_02
hgs
parents:
diff changeset
   150
            {
7feec50967db 201003_02
hgs
parents:
diff changeset
   151
            if( iBufArrayInfo.Count() > 0 )
7feec50967db 201003_02
hgs
parents:
diff changeset
   152
                {
7feec50967db 201003_02
hgs
parents:
diff changeset
   153
                TPckgBuf<TInt> sizeDes( iBufArrayInfo[0]->Size() );
7feec50967db 201003_02
hgs
parents:
diff changeset
   154
                iMessage.Write( KOutputPosition, sizeDes );
7feec50967db 201003_02
hgs
parents:
diff changeset
   155
                }
7feec50967db 201003_02
hgs
parents:
diff changeset
   156
            iMessage.Complete( KErrNone );
7feec50967db 201003_02
hgs
parents:
diff changeset
   157
            }
7feec50967db 201003_02
hgs
parents:
diff changeset
   158
        iPending = EFalse;
7feec50967db 201003_02
hgs
parents:
diff changeset
   159
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   160
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   161
7feec50967db 201003_02
hgs
parents:
diff changeset
   162
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   163
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
   164
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   165
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   166
void CCaSrvNotifier::EntryChangedL( const CCaInnerEntry* aEntry,
7feec50967db 201003_02
hgs
parents:
diff changeset
   167
        TChangeType aChangeType, const RArray<TInt>& aParentIds )
7feec50967db 201003_02
hgs
parents:
diff changeset
   168
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   169
    if( iFilter && CheckFilterForEntry( aEntry, aParentIds ) )
7feec50967db 201003_02
hgs
parents:
diff changeset
   170
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   171
        if( iFilter->GetNotifierType()
7feec50967db 201003_02
hgs
parents:
diff changeset
   172
                == CCaInnerNotifierFilter::EEntryChangedWithEntry )
7feec50967db 201003_02
hgs
parents:
diff changeset
   173
            {
7feec50967db 201003_02
hgs
parents:
diff changeset
   174
            HBufC8* bufInfo = MenuUtils::MarshalDataL( 
7feec50967db 201003_02
hgs
parents:
diff changeset
   175
                    *aEntry, KDefaultExpandSize );
7feec50967db 201003_02
hgs
parents:
diff changeset
   176
            CleanupStack::PushL( bufInfo );
7feec50967db 201003_02
hgs
parents:
diff changeset
   177
            iBufArrayInfo.AppendL( bufInfo );
7feec50967db 201003_02
hgs
parents:
diff changeset
   178
            CleanupStack::Pop( bufInfo );
7feec50967db 201003_02
hgs
parents:
diff changeset
   179
            iArrayChangeType.AppendL( aChangeType );
7feec50967db 201003_02
hgs
parents:
diff changeset
   180
            Complete();
7feec50967db 201003_02
hgs
parents:
diff changeset
   181
            }
7feec50967db 201003_02
hgs
parents:
diff changeset
   182
        else if( iFilter->GetNotifierType()
7feec50967db 201003_02
hgs
parents:
diff changeset
   183
                == CCaInnerNotifierFilter::EEntryChangedWithId )
7feec50967db 201003_02
hgs
parents:
diff changeset
   184
            {
7feec50967db 201003_02
hgs
parents:
diff changeset
   185
            AddEntryWithIdL( aEntry->GetId() );
7feec50967db 201003_02
hgs
parents:
diff changeset
   186
            iArrayChangeType.AppendL( aChangeType );
7feec50967db 201003_02
hgs
parents:
diff changeset
   187
            Complete();
7feec50967db 201003_02
hgs
parents:
diff changeset
   188
            }
7feec50967db 201003_02
hgs
parents:
diff changeset
   189
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   190
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   191
7feec50967db 201003_02
hgs
parents:
diff changeset
   192
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   193
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
   194
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   195
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   196
void CCaSrvNotifier::EntryTouchedL( TInt aId )
7feec50967db 201003_02
hgs
parents:
diff changeset
   197
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   198
    if( iFilter && iFilter->GetNotifierType()
7feec50967db 201003_02
hgs
parents:
diff changeset
   199
            == CCaInnerNotifierFilter::EEntryTouched && CheckIds(
7feec50967db 201003_02
hgs
parents:
diff changeset
   200
            iFilter->GetIds(), aId ) )
7feec50967db 201003_02
hgs
parents:
diff changeset
   201
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   202
        AddEntryWithIdL( aId );
7feec50967db 201003_02
hgs
parents:
diff changeset
   203
        Complete();
7feec50967db 201003_02
hgs
parents:
diff changeset
   204
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   205
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   206
7feec50967db 201003_02
hgs
parents:
diff changeset
   207
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   208
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
   209
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   210
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   211
void CCaSrvNotifier::GroupContentChangedL( const RArray<TInt>& aParentIds )
7feec50967db 201003_02
hgs
parents:
diff changeset
   212
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   213
    if( iFilter && iFilter->GetNotifierType()
7feec50967db 201003_02
hgs
parents:
diff changeset
   214
            == CCaInnerNotifierFilter::EGroupContentChanged )
7feec50967db 201003_02
hgs
parents:
diff changeset
   215
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   216
        if( iFilter->GetParentId() == 0 && aParentIds.Count() > 0 )
7feec50967db 201003_02
hgs
parents:
diff changeset
   217
            {
7feec50967db 201003_02
hgs
parents:
diff changeset
   218
            for( TInt i( 0 ); i < aParentIds.Count(); i++ )
7feec50967db 201003_02
hgs
parents:
diff changeset
   219
                {
7feec50967db 201003_02
hgs
parents:
diff changeset
   220
                AddEntryWithIdL( aParentIds[i] );
7feec50967db 201003_02
hgs
parents:
diff changeset
   221
                }
7feec50967db 201003_02
hgs
parents:
diff changeset
   222
            Complete();
7feec50967db 201003_02
hgs
parents:
diff changeset
   223
            }
7feec50967db 201003_02
hgs
parents:
diff changeset
   224
        else if( aParentIds.Find( iFilter->GetParentId() ) != KErrNotFound )
7feec50967db 201003_02
hgs
parents:
diff changeset
   225
            {
7feec50967db 201003_02
hgs
parents:
diff changeset
   226
            AddEntryWithIdL( iFilter->GetParentId() );
7feec50967db 201003_02
hgs
parents:
diff changeset
   227
            Complete();
7feec50967db 201003_02
hgs
parents:
diff changeset
   228
            }
7feec50967db 201003_02
hgs
parents:
diff changeset
   229
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   230
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   231
7feec50967db 201003_02
hgs
parents:
diff changeset
   232
// ---------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   233
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
   234
// ---------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   235
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   236
void CCaSrvNotifier::GetChangeInfoL( const RMessage2& aMessage )
7feec50967db 201003_02
hgs
parents:
diff changeset
   237
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   238
    if( iBufArrayInfo.Count() > 0 )
7feec50967db 201003_02
hgs
parents:
diff changeset
   239
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   240
        aMessage.WriteL( KInputPosition1, iBufArrayInfo[0]->Des() );
7feec50967db 201003_02
hgs
parents:
diff changeset
   241
        if( iArrayChangeType.Count() > 0 )
7feec50967db 201003_02
hgs
parents:
diff changeset
   242
            {
7feec50967db 201003_02
hgs
parents:
diff changeset
   243
            TPckg<TChangeType> changeTypePckg( iArrayChangeType[0] );
7feec50967db 201003_02
hgs
parents:
diff changeset
   244
            aMessage.WriteL( KInputPosition2, changeTypePckg );
7feec50967db 201003_02
hgs
parents:
diff changeset
   245
            iArrayChangeType.Remove( 0 );
7feec50967db 201003_02
hgs
parents:
diff changeset
   246
            }
7feec50967db 201003_02
hgs
parents:
diff changeset
   247
        delete iBufArrayInfo[0];
7feec50967db 201003_02
hgs
parents:
diff changeset
   248
        iBufArrayInfo.Remove( 0 );
7feec50967db 201003_02
hgs
parents:
diff changeset
   249
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   250
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   251
7feec50967db 201003_02
hgs
parents:
diff changeset
   252
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   253
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
   254
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   255
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   256
TBool CCaSrvNotifier::CheckFilterForEntry( const CCaInnerEntry* aEntry,
7feec50967db 201003_02
hgs
parents:
diff changeset
   257
        const RArray<TInt>& aParentIds )
7feec50967db 201003_02
hgs
parents:
diff changeset
   258
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   259
    TBool filterCorrect = CheckIds( iFilter->GetIds(), aEntry->GetId() );
7feec50967db 201003_02
hgs
parents:
diff changeset
   260
    if( filterCorrect )
7feec50967db 201003_02
hgs
parents:
diff changeset
   261
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   262
        filterCorrect = ( static_cast<TUint> ( iFilter->GetEntryRole() )
7feec50967db 201003_02
hgs
parents:
diff changeset
   263
                == ENoneEntryRole
7feec50967db 201003_02
hgs
parents:
diff changeset
   264
                || static_cast<TUint> ( iFilter->GetEntryRole() )
7feec50967db 201003_02
hgs
parents:
diff changeset
   265
                        == aEntry->GetRole() );
7feec50967db 201003_02
hgs
parents:
diff changeset
   266
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   267
    if( filterCorrect )
7feec50967db 201003_02
hgs
parents:
diff changeset
   268
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   269
        filterCorrect = CheckTypeName( iFilter->GetTypeNames(),
7feec50967db 201003_02
hgs
parents:
diff changeset
   270
                aEntry->GetEntryTypeName() );
7feec50967db 201003_02
hgs
parents:
diff changeset
   271
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   272
    if( filterCorrect && iFilter->GetParentId() > 0 )
7feec50967db 201003_02
hgs
parents:
diff changeset
   273
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   274
        filterCorrect = ( iFilter->GetParentId() == aEntry->GetId()
7feec50967db 201003_02
hgs
parents:
diff changeset
   275
                || aParentIds.Find( iFilter->GetParentId() )
7feec50967db 201003_02
hgs
parents:
diff changeset
   276
                        != KErrNotFound );
7feec50967db 201003_02
hgs
parents:
diff changeset
   277
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   278
    return filterCorrect;
7feec50967db 201003_02
hgs
parents:
diff changeset
   279
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   280
7feec50967db 201003_02
hgs
parents:
diff changeset
   281
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   282
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
   283
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   284
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   285
void CCaSrvNotifier::AddEntryWithIdL( TInt aId )
7feec50967db 201003_02
hgs
parents:
diff changeset
   286
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   287
    CCaInnerEntry* entry = CCaInnerEntry::NewLC();
7feec50967db 201003_02
hgs
parents:
diff changeset
   288
    entry->SetId( aId );
7feec50967db 201003_02
hgs
parents:
diff changeset
   289
    HBufC8* bufInfo = MenuUtils::MarshalDataL( *entry, KDefaultExpandSize );
7feec50967db 201003_02
hgs
parents:
diff changeset
   290
    CleanupStack::PushL( bufInfo );
7feec50967db 201003_02
hgs
parents:
diff changeset
   291
    iBufArrayInfo.AppendL( bufInfo );
7feec50967db 201003_02
hgs
parents:
diff changeset
   292
    CleanupStack::Pop( bufInfo );
7feec50967db 201003_02
hgs
parents:
diff changeset
   293
    CleanupStack::PopAndDestroy( entry );
7feec50967db 201003_02
hgs
parents:
diff changeset
   294
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   295
7feec50967db 201003_02
hgs
parents:
diff changeset
   296
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   297
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
   298
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   299
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   300
TBool CCaSrvNotifier::CheckIds( const RArray<TInt>& aIds, TInt aId )
7feec50967db 201003_02
hgs
parents:
diff changeset
   301
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   302
    TBool result( ETrue );
7feec50967db 201003_02
hgs
parents:
diff changeset
   303
    if( aIds.Count() > 0 && aIds.Find( aId ) == KErrNotFound )
7feec50967db 201003_02
hgs
parents:
diff changeset
   304
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   305
        result = EFalse;
7feec50967db 201003_02
hgs
parents:
diff changeset
   306
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   307
    return result;
7feec50967db 201003_02
hgs
parents:
diff changeset
   308
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   309
7feec50967db 201003_02
hgs
parents:
diff changeset
   310
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   311
// 
7feec50967db 201003_02
hgs
parents:
diff changeset
   312
// -----------------------------------------------------------------------------
7feec50967db 201003_02
hgs
parents:
diff changeset
   313
//
7feec50967db 201003_02
hgs
parents:
diff changeset
   314
TBool CCaSrvNotifier::CheckTypeName( const CDesC16ArrayFlat* aTypeNames,
7feec50967db 201003_02
hgs
parents:
diff changeset
   315
        const RBuf& aTypeName )
7feec50967db 201003_02
hgs
parents:
diff changeset
   316
    {
7feec50967db 201003_02
hgs
parents:
diff changeset
   317
    TBool result( ETrue );
7feec50967db 201003_02
hgs
parents:
diff changeset
   318
    TInt position( 0 );
7feec50967db 201003_02
hgs
parents:
diff changeset
   319
    if( aTypeNames->Count() > 0 && aTypeNames->Find( aTypeName, position )
7feec50967db 201003_02
hgs
parents:
diff changeset
   320
            != KErrNone )
7feec50967db 201003_02
hgs
parents:
diff changeset
   321
        {
7feec50967db 201003_02
hgs
parents:
diff changeset
   322
        result = EFalse;
7feec50967db 201003_02
hgs
parents:
diff changeset
   323
        }
7feec50967db 201003_02
hgs
parents:
diff changeset
   324
    return result;
7feec50967db 201003_02
hgs
parents:
diff changeset
   325
    }
7feec50967db 201003_02
hgs
parents:
diff changeset
   326