|
1 /* |
|
2 * Copyright (c) 2004 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: Presence attribute transaction factory. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CPEngAttributeTransactionFactory.h" |
|
20 #include "CPEngAttributePublishHandler.h" |
|
21 #include "CPEngPresenceNotificationHandler.h" |
|
22 #include "CPEngAttributeFetchHandler.h" |
|
23 |
|
24 #include "MPEngPresenceAttrTransactionEnv.h" |
|
25 #include "MPEngPresenceAttrManager.h" |
|
26 #include "MPEngPresenceAdvancedAttrModel2.h" |
|
27 |
|
28 #include "PEngWVAttributeConstructorFactory.h" |
|
29 #include "RObjectArray.h" |
|
30 #include "CPEngSessionSlotId.h" |
|
31 #include "PEngAddressUtils.h" |
|
32 |
|
33 #include <E32Std.h> |
|
34 #include <PEngPresenceEngineConsts2.h> |
|
35 |
|
36 |
|
37 |
|
38 // ============================ MEMBER FUNCTIONS =============================== |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CPEngAttributeTransactionFactory::NewL() |
|
42 // Two-phased constructor. |
|
43 // ----------------------------------------------------------------------------- |
|
44 // |
|
45 CPEngAttributeTransactionFactory* CPEngAttributeTransactionFactory::NewL( |
|
46 const CPEngSessionSlotId& aSlotId, |
|
47 MPEngPresenceAttrTransactionEnv& aTransEnv, |
|
48 MPEngPresenceAttrManager& aAttrManager ) |
|
49 { |
|
50 CPEngAttributeTransactionFactory* self = new ( ELeave ) CPEngAttributeTransactionFactory( |
|
51 aTransEnv, |
|
52 aAttrManager ); |
|
53 |
|
54 CleanupClosePushL( *self ); //reference counted singleton |
|
55 self->ConstructL( aSlotId ); |
|
56 CleanupStack::Pop(); //self |
|
57 |
|
58 return self; |
|
59 } |
|
60 |
|
61 |
|
62 // Destructor |
|
63 CPEngAttributeTransactionFactory::~CPEngAttributeTransactionFactory() |
|
64 { |
|
65 TRAP_IGNORE( iTransEnv.HandleNetworkSessionStateChangeL( EFalse ) ); |
|
66 delete iDomain; |
|
67 |
|
68 if ( iRefsOwned ) |
|
69 { |
|
70 iTransEnv.Close(); |
|
71 iAttributeManager.Close(); |
|
72 } |
|
73 } |
|
74 |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CPEngAttributeTransactionFactory::CPEngAttributeTransactionFactory |
|
78 // C++ default constructor can NOT contain any code, that |
|
79 // might leave. |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CPEngAttributeTransactionFactory::CPEngAttributeTransactionFactory( |
|
83 MPEngPresenceAttrTransactionEnv& aTransEnv, |
|
84 MPEngPresenceAttrManager& aAttrManager ) |
|
85 : iTransEnv( aTransEnv ), |
|
86 iAttributeManager( aAttrManager ), |
|
87 iRefsOwned( EFalse ) |
|
88 { |
|
89 } |
|
90 |
|
91 |
|
92 // ----------------------------------------------------------------------------- |
|
93 // CPEngAttributeTransactionFactory::ConstructL() |
|
94 // Symbian 2nd phase constructor can leave. |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 void CPEngAttributeTransactionFactory::ConstructL( const CPEngSessionSlotId& aSlotId ) |
|
98 { |
|
99 CPEngSessionSlotObject::ConstructL( aSlotId ); |
|
100 |
|
101 //resolve transaction domain |
|
102 iDomain = PEngAddressUtils::WVDomain( aSlotId.UserId() ).AllocL(); |
|
103 iCspVersion = PEngWVCspVersion::SelectVersionL(); |
|
104 |
|
105 RObjectArray< MPEngPresenceAttrModel2 > sessionAttributes; |
|
106 CleanupClosePushL( sessionAttributes ); |
|
107 |
|
108 PEngWVAttributeConstructorFactory::LoadSessionTracingAttributesL( sessionAttributes, |
|
109 iAttributeManager ); |
|
110 iTransEnv.SetSessionTracingAttributesL( sessionAttributes ); |
|
111 CleanupStack::PopAndDestroy(); //closes sessionAttributes |
|
112 |
|
113 |
|
114 iTransEnv.HandleNetworkSessionStateChangeL( ETrue ); |
|
115 |
|
116 iRefsOwned = ETrue; |
|
117 } |
|
118 |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CPEngAttributeTransactionFactory::Close() |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 void CPEngAttributeTransactionFactory::Close() |
|
125 { |
|
126 CPEngSessionSlotObject::Close(); |
|
127 } |
|
128 |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CPEngAttributeTransactionFactory::IncomingTransactionHandlerL() |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 MPEngIncomingTransactionHandler* CPEngAttributeTransactionFactory:: |
|
135 IncomingTransactionHandlerL( const TDesC8& aIncomingRequest ) |
|
136 { |
|
137 MPEngIncomingTransactionHandler* handler = NULL; |
|
138 |
|
139 if ( CPEngPresenceNotificationHandler::CanHandleL( aIncomingRequest ) ) |
|
140 { |
|
141 //This is a presence notification |
|
142 handler = CPEngPresenceNotificationHandler::NewL( *iDomain, |
|
143 iCspVersion, |
|
144 iAttributeManager, |
|
145 iTransEnv ); |
|
146 } |
|
147 |
|
148 return handler; |
|
149 } |
|
150 |
|
151 |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CPEngAttributeTransactionFactory::OutgoingTransactionHandlerL() |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CPEngAttributeTransactionFactory::OutgoingTransactionHandlerL( |
|
158 TInt aOperation, |
|
159 const TDesC16& aData, |
|
160 RPointerArray<MPEngOutgoingTransactionHandler>& aHandlers ) |
|
161 { |
|
162 if ( aOperation == EPEngTransOpOwnAttributePublish ) |
|
163 { |
|
164 CPEngAttributePublishHandler* publisher = CPEngAttributePublishHandler::NewLC( iAttributeManager, |
|
165 iTransEnv, |
|
166 aData, |
|
167 aOperation, |
|
168 iCspVersion ); |
|
169 aHandlers.AppendL( publisher ); |
|
170 CleanupStack::Pop( publisher ); |
|
171 } |
|
172 |
|
173 |
|
174 else if ( ( aOperation == EPEngTransOpAttributeFetchToCache ) || |
|
175 ( aOperation == EPEngTransOpAttributeFetchToObjects ) ) |
|
176 { |
|
177 CPEngAttributeFetchHandler* fetcher = CPEngAttributeFetchHandler::NewLC( iAttributeManager, |
|
178 *iDomain, |
|
179 aData, |
|
180 aOperation, |
|
181 iCspVersion ); |
|
182 aHandlers.AppendL( fetcher ); |
|
183 CleanupStack::Pop( fetcher ); |
|
184 } |
|
185 } |
|
186 |
|
187 |
|
188 // End of File |