|
1 /* |
|
2 * Copyright (c) 2008 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: active object, that monitors link disconnection |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INTERNAL HEADERS |
|
20 #include "ikeconnectioninterface.h" |
|
21 #include "vpnconnection.h" |
|
22 |
|
23 // CLASS HEADER |
|
24 #include "disconnectionobserver.h" |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // Two-phased constructor. |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CDisconnectionObserver* CDisconnectionObserver::NewL( CIkeConnectionInterface& aIkeConnectionInterface, |
|
33 MDisconnectionObserverCallback& aCallback ) |
|
34 { |
|
35 CDisconnectionObserver* self = new (ELeave) CDisconnectionObserver( aIkeConnectionInterface, |
|
36 aCallback ); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------- |
|
41 // Destructor. |
|
42 // --------------------------------------------------------------------------- |
|
43 // |
|
44 CDisconnectionObserver::~CDisconnectionObserver() |
|
45 { |
|
46 Cancel(); |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // Constructor. |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CDisconnectionObserver::CDisconnectionObserver( CIkeConnectionInterface& aIkeConnectionInterface, |
|
54 MDisconnectionObserverCallback& aCallback ) |
|
55 : CActive( EPriorityStandard ), |
|
56 iIkeConnectionInterface( aIkeConnectionInterface ), |
|
57 iCallback( aCallback ) |
|
58 { |
|
59 CActiveScheduler::Add( this ); |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // Requests asynchronous link disconnection notification. |
|
64 // --------------------------------------------------------------------------- |
|
65 // |
|
66 void CDisconnectionObserver::StartObserving() |
|
67 { |
|
68 iIkeConnectionInterface.NotifyDisconnect( iStatus ); |
|
69 SetActive(); |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------------------------- |
|
73 // From class CActive |
|
74 // Handles completion of asynchronous notification request. |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 void CDisconnectionObserver::RunL() |
|
78 { |
|
79 iCallback.DisconnectIndication( iStatus.Int() ); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // From class CActive |
|
84 // Handles cancellation of asynchronous notification request. |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CDisconnectionObserver::DoCancel() |
|
88 { |
|
89 iIkeConnectionInterface.CancelNotifyDisconnect(); |
|
90 } |
|
91 |