ncdengine/provider/client/src/ncdnodeseenproxy.cpp
changeset 4 32704c33136d
equal deleted inserted replaced
-1:000000000000 4:32704c33136d
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:   ?description
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "ncdnodeseenproxy.h"
       
    20 #include "ncdnodeproxy.h"
       
    21 #include "catalogsinterfaceidentifier.h"
       
    22 #include "catalogsdebug.h"
       
    23 #include "catalogsclientserver.h"
       
    24 #include "ncdnodefunctionids.h"
       
    25 
       
    26 // ======== MEMBER FUNCTIONS ========
       
    27 
       
    28 CNcdNodeSeenProxy* CNcdNodeSeenProxy::NewL(
       
    29     MCatalogsClientServer& aSession,
       
    30     TInt aHandle,
       
    31     CNcdNodeProxy& aNode ) 
       
    32     {
       
    33     DLTRACEIN((""));
       
    34     CNcdNodeSeenProxy* self = NewLC( aSession, aHandle, aNode );
       
    35     CleanupStack::Pop( self );
       
    36     return self;
       
    37     }
       
    38     
       
    39     
       
    40 CNcdNodeSeenProxy* CNcdNodeSeenProxy::NewLC(
       
    41     MCatalogsClientServer& aSession,
       
    42     TInt aHandle,
       
    43     CNcdNodeProxy& aNode ) 
       
    44     {
       
    45     DLTRACEIN((""));
       
    46     CNcdNodeSeenProxy* self = new( ELeave ) CNcdNodeSeenProxy(
       
    47         aSession, aHandle, aNode );
       
    48     // Using PushL because the object does not have any references yet
       
    49     CleanupStack::PushL( self );
       
    50     self->ConstructL();
       
    51     return self;
       
    52     }   
       
    53     
       
    54 
       
    55 CNcdNodeSeenProxy::CNcdNodeSeenProxy(
       
    56     MCatalogsClientServer& aSession,
       
    57     TInt aHandle,
       
    58     CNcdNodeProxy& aNode ) :
       
    59     CNcdInterfaceBaseProxy( aSession, aHandle, &aNode ),
       
    60     iSeen( EFalse ) 
       
    61     {
       
    62     }
       
    63     
       
    64 
       
    65 void CNcdNodeSeenProxy::ConstructL() 
       
    66     {
       
    67     DLTRACEIN((""));
       
    68     // Register the interface.
       
    69     MNcdNodeSeen* seen( this );
       
    70     DLINFO(("Seen-ptr: %X, this: %X", seen, this ));
       
    71     AddInterfaceL(
       
    72         CCatalogsInterfaceIdentifier::NewL(
       
    73             seen, this, MNcdNodeSeen::KInterfaceUid ) );
       
    74     
       
    75     // Internalize the state from server side.
       
    76     InternalizeL();
       
    77     }
       
    78     
       
    79 
       
    80 CNcdNodeSeenProxy::~CNcdNodeSeenProxy() 
       
    81     {
       
    82     DLTRACEIN((""));
       
    83     
       
    84     // Remove interfaces implemented by this class from the interface list.
       
    85     // So, the interface list is up to date when this class object is deleted.
       
    86     RemoveInterface( MNcdNodeSeen::KInterfaceUid );
       
    87     }
       
    88 
       
    89     
       
    90 void CNcdNodeSeenProxy::InternalizeL()
       
    91     {
       
    92     DLTRACEIN((""));
       
    93     
       
    94     TBool seen( EFalse );
       
    95     
       
    96     User::LeaveIfError(
       
    97         ClientServerSession().SendSync(
       
    98             NcdNodeFunctionIds::ENcdInternalize,
       
    99             KNullDesC(),
       
   100             seen,
       
   101             Handle() ) );
       
   102             
       
   103     iSeen = seen;
       
   104     }
       
   105     
       
   106 
       
   107 TBool CNcdNodeSeenProxy::IsSeen() const 
       
   108     {
       
   109     DLTRACEIN(("seen: %d", iSeen));
       
   110     return iSeen;
       
   111     }
       
   112     
       
   113 void CNcdNodeSeenProxy::SetSeenL()
       
   114     {
       
   115     DLTRACEIN((""));
       
   116     
       
   117     // Send the message to server side.
       
   118     TInt output;
       
   119     User::LeaveIfError(
       
   120         ClientServerSession().SendSync(
       
   121             NcdNodeFunctionIds::ENcdNodeSeenSetSeen,
       
   122             KNullDesC(),
       
   123             output,
       
   124             Handle() ) );
       
   125             
       
   126     // Do not update the internal state here, since the change
       
   127     // must take place only just when client-server session is closed.
       
   128     }