|
1 /* |
|
2 * Copyright (c) 2007 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdnodeseenimpl.h" |
|
20 #include "catalogsdebug.h" |
|
21 #include "ncdnodefunctionids.h" |
|
22 #include "catalogsbasemessage.h" |
|
23 #include "ncdnodeimpl.h" |
|
24 #include "ncdnodelink.h" |
|
25 |
|
26 CNcdNodeSeen* CNcdNodeSeen::NewL( CNcdNodeSeenInfo& aSeenInfo, CNcdNode& aNode ) |
|
27 { |
|
28 CNcdNodeSeen* self = NewLC( aSeenInfo, aNode ); |
|
29 CleanupStack::Pop( self ); |
|
30 return self; |
|
31 } |
|
32 |
|
33 |
|
34 CNcdNodeSeen* CNcdNodeSeen::NewLC( CNcdNodeSeenInfo& aSeenInfo, CNcdNode& aNode ) |
|
35 { |
|
36 CNcdNodeSeen* self = new ( ELeave ) CNcdNodeSeen( aSeenInfo, aNode ); |
|
37 CleanupClosePushL( *self ); |
|
38 self->ConstructL(); |
|
39 return self; |
|
40 } |
|
41 |
|
42 CNcdNodeSeen::CNcdNodeSeen( CNcdNodeSeenInfo& aSeenInfo, CNcdNode& aNode ) : |
|
43 iSeenInfo( aSeenInfo ), |
|
44 iOwnerNode( aNode ) |
|
45 { |
|
46 } |
|
47 |
|
48 void CNcdNodeSeen::ConstructL() |
|
49 { |
|
50 } |
|
51 |
|
52 CNcdNodeSeen::~CNcdNodeSeen() |
|
53 { |
|
54 DLTRACEIN(("")); |
|
55 } |
|
56 |
|
57 |
|
58 TBool CNcdNodeSeen::IsSeenL() |
|
59 { |
|
60 DLTRACEIN(("")); |
|
61 return iSeenInfo.IsSeenL( iOwnerNode.Identifier() ); |
|
62 } |
|
63 |
|
64 |
|
65 void CNcdNodeSeen::SetSeenL() |
|
66 { |
|
67 DLTRACEIN(("")); |
|
68 iSeenInfo.SetSeenL( iOwnerNode.Identifier() ); |
|
69 } |
|
70 |
|
71 void CNcdNodeSeen::ReceiveMessage( |
|
72 MCatalogsBaseMessage* aMessage, |
|
73 TInt aFunctionNumber ) |
|
74 { |
|
75 DLTRACEIN(("")) |
|
76 |
|
77 DASSERT( aMessage ); |
|
78 |
|
79 TInt trapError( KErrNone ); |
|
80 |
|
81 switch( aFunctionNumber ) |
|
82 { |
|
83 case NcdNodeFunctionIds::ENcdInternalize: |
|
84 TRAP( trapError, InternalizeRequestL( *aMessage ) ); |
|
85 break; |
|
86 |
|
87 case NcdNodeFunctionIds::ENcdNodeSeenSetSeen: |
|
88 TRAP( trapError, SetSeenRequestL( *aMessage ) ); |
|
89 break; |
|
90 |
|
91 case NcdNodeFunctionIds::ENcdRelease: |
|
92 ReleaseRequest( *aMessage ); |
|
93 break; |
|
94 |
|
95 default: |
|
96 DLERROR(("Unidentified function request")); |
|
97 DASSERT( EFalse ); |
|
98 break; |
|
99 } |
|
100 |
|
101 if ( trapError != KErrNone ) |
|
102 { |
|
103 // Because something went wrong the complete has not been |
|
104 // yet called for the message. |
|
105 // So, inform the client about the error. |
|
106 aMessage->CompleteAndRelease( trapError ); |
|
107 } |
|
108 } |
|
109 |
|
110 |
|
111 void CNcdNodeSeen::CounterPartLost( const MCatalogsSession& /*aSession*/ ) |
|
112 { |
|
113 DLTRACEIN(("")); |
|
114 } |
|
115 |
|
116 |
|
117 void CNcdNodeSeen::InternalizeRequestL( MCatalogsBaseMessage& aMessage ) |
|
118 { |
|
119 DLTRACEIN(("")); |
|
120 TBool seen = IsSeenL(); |
|
121 aMessage.CompleteAndReleaseL( seen, KErrNone ); |
|
122 } |
|
123 |
|
124 |
|
125 void CNcdNodeSeen::SetSeenRequestL( MCatalogsBaseMessage& aMessage ) |
|
126 { |
|
127 DLTRACEIN(("")); |
|
128 SetSeenL(); |
|
129 aMessage.CompleteAndRelease( KErrNone ); |
|
130 } |
|
131 |
|
132 |
|
133 void CNcdNodeSeen::ReleaseRequest( MCatalogsBaseMessage& aMessage ) const |
|
134 { |
|
135 DLTRACEIN(("")); |
|
136 |
|
137 // Decrease the reference count for this object. |
|
138 // When the reference count reaches zero, this object will be destroyed |
|
139 // and removed from the session. |
|
140 MCatalogsSession& requestSession( aMessage.Session() ); |
|
141 TInt handle( aMessage.Handle() ); |
|
142 aMessage.CompleteAndRelease( KErrNone ); |
|
143 requestSession.RemoveObject( handle ); |
|
144 |
|
145 DLTRACEOUT(("")); |
|
146 } |