|
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: Presence Service Connection own presence subscription implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ownpresencesubscriptionitem.h" |
|
20 #include "presenceinfofilterimp.h" |
|
21 #include "ximpitemparent.h" |
|
22 #include "ximppanics.h" |
|
23 #include "ximppsccontext.h" |
|
24 #include "documentutils.h" |
|
25 #include "ownpresenceeventimp.h" |
|
26 |
|
27 #include "ximptrace.h" |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // COwnPresenceSubscriptionItem::COwnPresenceSubscriptionItem() |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 COwnPresenceSubscriptionItem::COwnPresenceSubscriptionItem( MXIMPItemParentBase& aParent ) |
|
34 : CXIMPSubscriptionItemBase( aParent ) |
|
35 { |
|
36 } |
|
37 |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // COwnPresenceSubscriptionItem::ConstructL() |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 void COwnPresenceSubscriptionItem::ConstructL() |
|
44 { |
|
45 BaseConstructL(); |
|
46 } |
|
47 |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // COwnPresenceSubscriptionItem::NewL() |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 COwnPresenceSubscriptionItem* COwnPresenceSubscriptionItem::NewLC( MXIMPItemParentBase& aParent ) |
|
54 { |
|
55 COwnPresenceSubscriptionItem* self = new( ELeave ) COwnPresenceSubscriptionItem( aParent ); |
|
56 CleanupClosePushL( *self ); |
|
57 self->ConstructL(); |
|
58 return self; |
|
59 } |
|
60 |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // CXIMPHost::~CXIMPHost() |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 COwnPresenceSubscriptionItem::~COwnPresenceSubscriptionItem() |
|
67 { |
|
68 MXIMPItemParent* presCache = static_cast<MXIMPItemParent*>(iParent.GetInterface(PRESENCE_ITEM_PARENT)); |
|
69 presCache->RemoveMe( this ); |
|
70 |
|
71 delete iPif; |
|
72 delete iPresenceInfo; |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // COwnPresenceSubscriptionItem::SubscriptionPif() |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 EXPORT_C CPresenceInfoFilterImp& COwnPresenceSubscriptionItem::SubscriptionPif() |
|
80 { |
|
81 TRACE(_L("COwnPresenceSubscriptionItem::SubscriptionPif" ) ); |
|
82 __ASSERT_ALWAYS( iPif, User::Panic( NXIMPPrivPanic::KCategory, |
|
83 NXIMPPrivPanic::EOwnPresencePifNotSet ) ); |
|
84 return *iPif; |
|
85 } |
|
86 // --------------------------------------------------------------------------- |
|
87 // COwnPresenceSubscriptionItem::SynthesiseSubscriptionEventToL() |
|
88 // --------------------------------------------------------------------------- |
|
89 // |
|
90 void COwnPresenceSubscriptionItem::SynthesiseSubscriptionEventToL( |
|
91 MXIMPPscContext* aContext, TBool aForceEvent ) |
|
92 { |
|
93 TRACE_1( _L("COwnPresenceSubscriptionItem::SynthesiseSubscriptionEventTo() aForce=%d"), aForceEvent ); |
|
94 CXIMPDataSubscriptionStateImp* status = StatusLC( aContext ); |
|
95 |
|
96 COwnPresenceEventImp* newEvent = NULL; |
|
97 if( status->DataState() == MXIMPDataSubscriptionState::EDataAvailable ) |
|
98 { |
|
99 __ASSERT_ALWAYS( iPresenceInfo, User::Panic( NXIMPPrivPanic::KCategory, |
|
100 NXIMPPrivPanic::EOwnPresencePresenceInfoDoesNotExist ) ); |
|
101 |
|
102 CPresenceInfoImp* filteredPresenceInfo = DocumentUtils::CollectFilteredPresenceInfoLC( |
|
103 *( aContext->PresenceInfoFilter( MXIMPPscContext::EOwnPresenceFilter ) ), *iPresenceInfo ); |
|
104 |
|
105 newEvent = COwnPresenceEventImp::NewL( status ); // CSI: 35 # Event is put to cleanupstack in next branch. |
|
106 newEvent->SetPresenceInfo( filteredPresenceInfo ); |
|
107 CleanupStack::Pop( filteredPresenceInfo ); |
|
108 } |
|
109 else if( aForceEvent ) |
|
110 { |
|
111 newEvent = COwnPresenceEventImp::NewL( status ); // CSI: 35 # Event is put to cleanupstack in next branch. |
|
112 } |
|
113 |
|
114 if( newEvent ) |
|
115 { |
|
116 CleanupStack::Pop(); //status |
|
117 CleanupStack::PushL( newEvent ); |
|
118 MXIMPItemParent* presCache = static_cast<MXIMPItemParent*>(iParent.GetInterface(PRESENCE_ITEM_PARENT)); |
|
119 presCache->AddEventL( *newEvent, aContext ); |
|
120 } |
|
121 CleanupStack::PopAndDestroy(); //status || newEvent depending on branch |
|
122 } |
|
123 |
|
124 // --------------------------------------------------------------------------- |
|
125 // COwnPresenceSubscriptionItem::SetSubscriptionPif() |
|
126 // --------------------------------------------------------------------------- |
|
127 // |
|
128 EXPORT_C void COwnPresenceSubscriptionItem::SetSubscriptionPif( CPresenceInfoFilterImp* aPif ) |
|
129 { |
|
130 TRACE(_L("COwnPresenceSubscriptionItem::SetSubscriptionPif" ) ); |
|
131 delete iPif; |
|
132 iPif = aPif; |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // COwnPresenceSubscriptionItem::CollectSubscriptionPifWithoutCtxL() |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 EXPORT_C CPresenceInfoFilterImp* |
|
140 COwnPresenceSubscriptionItem::CollectSubscriptionPifWithoutCtxL( |
|
141 MXIMPPscContext* aContext ) |
|
142 { |
|
143 TRACE(_L("COwnPresenceSubscriptionItem::CollectSubscriptionPifWithoutCtxL" ) ); |
|
144 RPointerArray< CPresenceInfoFilterImp > arrayOfPifs; |
|
145 CleanupClosePushL( arrayOfPifs ); |
|
146 |
|
147 TInt count = iContexts.Count(); |
|
148 for( TInt a = 0; a < count; ++a ) |
|
149 { |
|
150 if( iContexts[ a ] != aContext ) |
|
151 { |
|
152 CPresenceInfoFilterImp* filter = iContexts[ a ]->PresenceInfoFilter( |
|
153 MXIMPPscContext::EOwnPresenceFilter ); |
|
154 if ( filter ) |
|
155 { |
|
156 arrayOfPifs.AppendL( filter ); |
|
157 } |
|
158 } |
|
159 } |
|
160 CPresenceInfoFilterImp* pifWithoutCtx = DocumentUtils::InfoFilterUnionL( arrayOfPifs ); |
|
161 CleanupStack::PopAndDestroy(); // arrayOfPifs |
|
162 return pifWithoutCtx; |
|
163 } |
|
164 |
|
165 |
|
166 // --------------------------------------------------------------------------- |
|
167 // COwnPresenceSubscriptionItem::SetPresenceInfoL() |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 EXPORT_C void COwnPresenceSubscriptionItem::SetPresenceInfoL( |
|
171 CPresenceInfoImp* aPresenceInfo ) |
|
172 { |
|
173 TRACE(_L("COwnPresenceSubscriptionItem::SetPresenceInfoL" ) ); |
|
174 delete iPresenceInfo; |
|
175 iPresenceInfo = aPresenceInfo; |
|
176 iSubscriptionState->SetDataStateL( MXIMPDataSubscriptionState::EDataAvailable ); |
|
177 } |
|
178 |
|
179 // --------------------------------------------------------------------------- |
|
180 // COwnPresenceSubscriptionItem::CleanExpired() |
|
181 // --------------------------------------------------------------------------- |
|
182 // |
|
183 void COwnPresenceSubscriptionItem::CleanExpired() |
|
184 { |
|
185 |
|
186 } |
|
187 |
|
188 // End of file |