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: IETF SIMPLE Protocol implementation for XIMP Framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32std.h> |
|
20 #include <simplefactory.h> |
|
21 #include <msimplewinfowatcher.h> |
|
22 #include <msimpleconnection.h> |
|
23 |
|
24 #include "presencepluginwinfo.h" |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // CPresencePluginWinfo::CPresencePluginWinfo() |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CPresencePluginWinfo::CPresencePluginWinfo( |
|
33 MPresencePluginConnectionObs& aObs, |
|
34 MSimpleConnection& aConn ) |
|
35 :iConnObs( aObs ), iConnection( aConn ), |
|
36 iSubscribed( EFalse ), |
|
37 iWinfoCompleted( EFalse ) |
|
38 { |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // CPresencePluginWinfo::ConstructL() |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 void CPresencePluginWinfo::ConstructL( ) |
|
46 { |
|
47 iWinfoWatcher = TSimpleFactory::NewWinfoWatcherL( iConnection, *this ); |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CPresencePluginWinfo::NewL() |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CPresencePluginWinfo* CPresencePluginWinfo::NewL( |
|
55 MPresencePluginConnectionObs& aObs, |
|
56 MSimpleConnection& aConn ) |
|
57 { |
|
58 DP_SDA("CPresencePluginWinfo::NewL"); |
|
59 CPresencePluginWinfo* self = |
|
60 new( ELeave ) CPresencePluginWinfo( aObs, aConn ); |
|
61 CleanupStack::PushL( self ); |
|
62 self->ConstructL( ); |
|
63 CleanupStack::Pop( self ); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // CPresencePluginWinfo::~CPresencePluginWinfo() |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 CPresencePluginWinfo::~CPresencePluginWinfo() |
|
72 { |
|
73 if ( iWinfoWatcher ) |
|
74 { |
|
75 iWinfoWatcher->Close(); |
|
76 } |
|
77 } |
|
78 |
|
79 // --------------------------------------------------------------------------- |
|
80 // CPresencePluginWinfo::SetHost() |
|
81 // --------------------------------------------------------------------------- |
|
82 // |
|
83 void CPresencePluginWinfo::SetHost( |
|
84 MXIMPProtocolConnectionHost* aHost ) |
|
85 { |
|
86 iHost = aHost; |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CPresencePluginWinfo::SubscribeWinfoListL() |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 void CPresencePluginWinfo::SubscribeWinfoListL( TXIMPRequestId aReqId ) |
|
94 { |
|
95 DP_SDA("CPresencePluginWinfo::SubscribeWinfoListL"); |
|
96 iWinfoCompleted = EFalse; |
|
97 if ( !iSubscribed ) |
|
98 { |
|
99 DP_SDA("CPresencePluginWinfo::SubscribeWinfoListL !iSubscribed"); |
|
100 iSimpleId = iWinfoWatcher->SubscribeWatcherListL( NULL ); |
|
101 iSubscribed = ETrue; |
|
102 iXIMPId = aReqId; |
|
103 } |
|
104 else |
|
105 { |
|
106 DP_SDA("CPresencePluginWinfo::SubscribeWinfoListL else "); |
|
107 iSimpleId = 0; |
|
108 iXIMPId = aReqId; |
|
109 WinfoReqCompleteL( iSimpleId, KErrNone ); |
|
110 } |
|
111 DP_SDA("CPresencePluginWinfo::SubscribeWinfoListL end"); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // CPresencePluginWinfo::UnsubscribeWinfoListL() |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 void CPresencePluginWinfo::UnsubscribeWinfoListL( TXIMPRequestId aReqId ) |
|
119 { |
|
120 if ( iSubscribed ) |
|
121 { |
|
122 iSubscribed = EFalse; |
|
123 iSimpleId = iWinfoWatcher->UnsubscribeL(); |
|
124 iXIMPId = aReqId; |
|
125 } |
|
126 else |
|
127 { |
|
128 iSimpleId = 0; |
|
129 iXIMPId = aReqId; |
|
130 WinfoReqCompleteL( iSimpleId, KErrNone ); |
|
131 } |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CPresencePluginWinfo::WinfoReqCompleteL() |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 void CPresencePluginWinfo::WinfoReqCompleteL( TInt aOpId, TInt aStatus ) |
|
139 { |
|
140 DP_SDA("CPresencePluginWinfo::WinfoReqCompleteL"); |
|
141 if ( iSimpleId == aOpId ) |
|
142 { |
|
143 iWinfoCompleted = ETrue; |
|
144 iSimpleId = 0; |
|
145 iConnObs.CompleteReq( iXIMPId, aStatus ); |
|
146 // Do not wait MXIMPProtocolConnectionHostObserver callback, this |
|
147 // class is ready to serve the next request now. |
|
148 iXIMPId = TXIMPRequestId(); |
|
149 } |
|
150 } |
|
151 |
|
152 // --------------------------------------------------------------------------- |
|
153 // CPresencePluginWinfo::WinfoTerminatedL() |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void CPresencePluginWinfo::WinfoTerminatedL( |
|
157 TInt aOpId, TInt aReason ) |
|
158 { |
|
159 |
|
160 if ( iSimpleId == aOpId ) |
|
161 { |
|
162 iSimpleId = 0; |
|
163 iConnObs.WinfoTerminatedL( aReason ); |
|
164 } |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // CPresencePluginWinfo::WinfoNotificationL() |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 void CPresencePluginWinfo::WinfoNotificationL( |
|
172 MSimpleWinfo& aWinfo ) |
|
173 { |
|
174 if ( !iWinfoCompleted ) |
|
175 { |
|
176 WinfoReqCompleteL( iSimpleId, KErrNone ); |
|
177 } |
|
178 iConnObs.WinfoNotification( aWinfo ); |
|
179 } |
|
180 |
|
181 // End of file |
|