|
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 #include "caclientsubsession.h" |
|
19 #include "caclientnotifiersession.h" |
|
20 #include "caclientnotifier.h" |
|
21 #include "cainnernotifierfilter.h" |
|
22 #include "casrvdef.h" |
|
23 #include "cainnerentry.h" |
|
24 #include "caclientproxy.h" |
|
25 #include "caclientnotifierproxy.h" |
|
26 #include "cautils.h" |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 // ----------------------------------------------------------------------------- |
|
31 RCaClientSubSession::RCaClientSubSession( |
|
32 const RCaClientNotifierSession* aSession, |
|
33 const IDataObserver* aObserver, |
|
34 const CCaInnerNotifierFilter *aInnerNotifierFilter ) : |
|
35 RSubSessionBase(), iSession( aSession ), iObserver( aObserver ), |
|
36 iInnerNotifierFilter( aInnerNotifierFilter ), |
|
37 iNotifier( NULL ), iMessageSize( NULL ) |
|
38 { |
|
39 |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 // ----------------------------------------------------------------------------- |
|
45 void RCaClientSubSession::CreateL() |
|
46 { |
|
47 iMessageSize = new ( ELeave ) TPckgBuf<TInt> (); |
|
48 User::LeaveIfError( CreateSubSession( *iSession, |
|
49 static_cast<TInt>( EContentArsenalNotifierOpen ) ) ); |
|
50 iNotifier = CCaClientNotifier::NewL( this ); |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 // ----------------------------------------------------------------------------- |
|
56 void RCaClientSubSession::Close() |
|
57 { |
|
58 delete iMessageSize; |
|
59 iMessageSize = NULL; |
|
60 delete iNotifier; |
|
61 iNotifier = NULL; |
|
62 CloseSubSession( EContentArsenalNotifierClose ); |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 // ----------------------------------------------------------------------------- |
|
68 void RCaClientSubSession::RegisterForNotificationsL( |
|
69 TRequestStatus& aStatus ) const |
|
70 { |
|
71 TIpcArgs args; |
|
72 HBufC8* inbuf = MenuUtils::MarshalDataL( *iInnerNotifierFilter, |
|
73 KDefaultExpandSize ); |
|
74 args.Set( KInputPosition1, inbuf ); |
|
75 args.Set( KOutputPosition, iMessageSize ); |
|
76 RSubSessionBase::SendReceive( EContentArsenalNotifierNotify, args, |
|
77 aStatus ); |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 // ----------------------------------------------------------------------------- |
|
83 void RCaClientSubSession::UnregisterForNotifications() const |
|
84 { |
|
85 RSubSessionBase::SendReceive( EContentArsenalNotifierCancel ); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 // ----------------------------------------------------------------------------- |
|
91 void RCaClientSubSession::NotifyObserver( |
|
92 CCaInnerEntry* aEntry, |
|
93 TChangeType aChangeType ) const |
|
94 { |
|
95 switch( iInnerNotifierFilter->GetNotifierType() ) |
|
96 { |
|
97 case CCaInnerNotifierFilter::EEntryChangedWithId: |
|
98 { |
|
99 iObserver->entryChanged( aEntry->GetId(), aChangeType ); |
|
100 break; |
|
101 } |
|
102 case CCaInnerNotifierFilter::EEntryChangedWithEntry: |
|
103 { |
|
104 iObserver->entryChanged( *aEntry, aChangeType ); |
|
105 break; |
|
106 } |
|
107 case CCaInnerNotifierFilter::EEntryTouched: |
|
108 { |
|
109 iObserver->entryTouched( aEntry->GetId() ); |
|
110 break; |
|
111 } |
|
112 case CCaInnerNotifierFilter::EGroupContentChanged: |
|
113 { |
|
114 iObserver->groupContentChanged( aEntry->GetId() ); |
|
115 break; |
|
116 } |
|
117 default: |
|
118 { |
|
119 break; |
|
120 } |
|
121 } |
|
122 } |
|
123 |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 // ----------------------------------------------------------------------------- |
|
127 void RCaClientSubSession::GetChangeInfoAndNotifyObserverL() const |
|
128 { |
|
129 TIpcArgs args; |
|
130 RBuf8 outbuf; |
|
131 outbuf.CleanupClosePushL(); |
|
132 outbuf.CreateL( ( *iMessageSize )() ); |
|
133 TPckg<TChangeType> changeTypePckg( EAddChangeType ); |
|
134 args.Set( KInputPosition1, &outbuf ); |
|
135 args.Set( KInputPosition2, &changeTypePckg ); |
|
136 TInt error = RSubSessionBase::SendReceive( |
|
137 EContentArsenalGetChangeInfo, args ); |
|
138 if( error == KErrNone ) |
|
139 { |
|
140 CCaInnerEntry* entry = CCaInnerEntry::NewLC(); |
|
141 RDesReadStream stream( outbuf ); |
|
142 CleanupClosePushL( stream ); |
|
143 entry->InternalizeL( stream ); |
|
144 CleanupStack::PopAndDestroy( &stream ); |
|
145 TChangeType changeType = changeTypePckg(); |
|
146 NotifyObserver( entry, changeType ); |
|
147 CleanupStack::PopAndDestroy( entry ); |
|
148 } |
|
149 CleanupStack::PopAndDestroy( &outbuf ); |
|
150 } |