ncdengine/provider/client/src/ncdsearchnodebundleproxy.cpp
changeset 0 ba25891c3a9e
equal deleted inserted replaced
-1:000000000000 0:ba25891c3a9e
       
     1 /*
       
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:   Contains CNcdSearchNodeFolder class implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdsearchnodebundleproxy.h"
       
    20 #include "ncdoperationmanagerproxy.h"
       
    21 #include "ncdloadnodeoperationproxy.h"
       
    22 #include "catalogsinterfaceidentifier.h"
       
    23 #include "catalogsdebug.h"
       
    24 #include "catalogsutils.h"
       
    25 #include "ncdchildentity.h"
       
    26 #include "ncdnodemanagerproxy.h"
       
    27 #include "ncdchildloadmode.h"
       
    28 #include "ncdcapabilities.h"
       
    29 
       
    30 CNcdSearchNodeBundleProxy* CNcdSearchNodeBundleProxy::NewL(
       
    31     MCatalogsClientServer& aSession, 
       
    32     TInt aHandle,
       
    33     CNcdNodeManagerProxy& aNodeManager,
       
    34     CNcdOperationManagerProxy& aOperationManager,
       
    35     CNcdFavoriteManagerProxy& aFavoriteManager ) 
       
    36     {
       
    37     DLTRACEIN((""));
       
    38     CNcdSearchNodeBundleProxy* self = NewLC(
       
    39         aSession, aHandle, aNodeManager, aOperationManager, aFavoriteManager );
       
    40     CleanupStack::Pop( self );
       
    41     return self;
       
    42     }
       
    43 
       
    44 CNcdSearchNodeBundleProxy* CNcdSearchNodeBundleProxy::NewLC(
       
    45     MCatalogsClientServer& aSession, 
       
    46     TInt aHandle,
       
    47     CNcdNodeManagerProxy& aNodeManager,
       
    48     CNcdOperationManagerProxy& aOperationManager,
       
    49     CNcdFavoriteManagerProxy& aFavoriteManager ) 
       
    50     {
       
    51     DLTRACEIN((""));
       
    52     CNcdSearchNodeBundleProxy* self = new ( ELeave ) CNcdSearchNodeBundleProxy(
       
    53         aSession, aHandle, aNodeManager, aOperationManager, aFavoriteManager );
       
    54     // Using PushL because the object does not have any references yet
       
    55     CleanupStack::PushL( self );
       
    56 
       
    57     self->ConstructL();
       
    58     return self;
       
    59     }
       
    60 
       
    61 CNcdSearchNodeBundleProxy::CNcdSearchNodeBundleProxy(
       
    62     MCatalogsClientServer& aSession,
       
    63     TInt aHandle,
       
    64     CNcdNodeManagerProxy& aNodeManager,
       
    65     CNcdOperationManagerProxy& aOperationManager,
       
    66     CNcdFavoriteManagerProxy& aFavoriteManager )
       
    67 : CNcdSearchNodeFolderProxy( aSession, aHandle, aNodeManager,
       
    68                        aOperationManager, aFavoriteManager ) 
       
    69     {
       
    70     }
       
    71     
       
    72 CNcdSearchNodeBundleProxy::~CNcdSearchNodeBundleProxy()  
       
    73     {
       
    74     }
       
    75 
       
    76 TInt CNcdSearchNodeBundleProxy::ChildCount() const
       
    77     {
       
    78     return iChildren.Count();
       
    79     }
       
    80 
       
    81 
       
    82 MNcdNode* CNcdSearchNodeBundleProxy::ChildL( TInt aIndex )
       
    83     {
       
    84     DLTRACEIN(( _L("This parent: %S, %S"), &Namespace(), &Id() ));
       
    85 
       
    86            
       
    87     if ( aIndex < 0 || aIndex >= iChildren.Count() )
       
    88         {
       
    89         // Nothing to be done 
       
    90         DLERROR(( "Index error. child count: %d Given index: %d", 
       
    91                   iChildren.Count(), aIndex ));
       
    92         DASSERT( EFalse );
       
    93         User::Leave( KErrArgument );
       
    94         }
       
    95         
       
    96     const CNcdNodeIdentifier* child = &iChildren[aIndex]->Identifier();
       
    97         
       
    98     MNcdNode* node( NULL );
       
    99     
       
   100     TRAPD( err, node = &NodeManager().NodeL( *child ) );
       
   101     
       
   102     if ( err == KErrNotFound ) 
       
   103         {
       
   104         return NULL;
       
   105         }
       
   106         
       
   107     User::LeaveIfError( err );
       
   108     
       
   109     // Increase the reference counter by one
       
   110     node->AddRef();
       
   111     
       
   112     DLTRACEOUT((""));
       
   113 
       
   114     return node;
       
   115     }
       
   116     
       
   117 
       
   118 MNcdLoadNodeOperation* CNcdSearchNodeBundleProxy::LoadChildrenL( TInt aIndex, 
       
   119                                                            TInt aSize,
       
   120                                                            TNcdChildLoadMode aMode,
       
   121                                                            MNcdLoadNodeOperationObserver& aObserver )
       
   122     {
       
   123     DLTRACEIN((("this: %X"), this));
       
   124     DASSERT( iSearchFilter );
       
   125         
       
   126     if( aSize < 1 || aIndex < 0 || ( aMode == ELoadMetadata && aIndex + aSize > ChildCount() ))
       
   127         {
       
   128         // Nothing to be done 
       
   129         DLERROR(( "Argument error. ChildCount: %d Given index: %d, size: %d",
       
   130                   ChildCount(), aIndex, aSize ));
       
   131         DASSERT( EFalse );
       
   132         User::Leave( KErrArgument );
       
   133         }
       
   134 
       
   135     DLTRACE(( _L("Node: %S, %S"), &Namespace(), &Id() ));
       
   136 
       
   137     // Search bundle may contain transparent stuff, so use server child count for loading
       
   138     // to get correct indexing on server side.
       
   139     return CNcdSearchNodeFolderProxy::LoadChildrenL( 
       
   140         0,
       
   141         ServerChildCount(),
       
   142         aMode,
       
   143         aObserver );
       
   144     }