|
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: Main classes for Out of Memory Monitor. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32property.h> |
|
19 #include "oomsubscribehelper.h" |
|
20 #include "oomtraces.h" |
|
21 |
|
22 // --------------------------------------------------------- |
|
23 // |
|
24 // --------------------------------------------------------- |
|
25 // |
|
26 CSubscribeHelper::CSubscribeHelper(TCallBack aCallBack, RProperty& aProperty) |
|
27 : CActive(EPriorityNormal), iCallBack(aCallBack), iProperty(aProperty) |
|
28 { |
|
29 FUNC_LOG; |
|
30 |
|
31 CActiveScheduler::Add(this); |
|
32 } |
|
33 |
|
34 // --------------------------------------------------------- |
|
35 // |
|
36 // --------------------------------------------------------- |
|
37 // |
|
38 CSubscribeHelper::~CSubscribeHelper() |
|
39 { |
|
40 FUNC_LOG; |
|
41 |
|
42 Cancel(); |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------- |
|
46 // |
|
47 // --------------------------------------------------------- |
|
48 // |
|
49 void CSubscribeHelper::Subscribe() |
|
50 { |
|
51 FUNC_LOG; |
|
52 |
|
53 if (!IsActive()) |
|
54 { |
|
55 iProperty.Subscribe(iStatus); |
|
56 SetActive(); |
|
57 } |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------- |
|
61 // |
|
62 // --------------------------------------------------------- |
|
63 // |
|
64 void CSubscribeHelper::StopSubscribe() |
|
65 { |
|
66 FUNC_LOG; |
|
67 |
|
68 Cancel(); |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 // --------------------------------------------------------- |
|
74 // |
|
75 void CSubscribeHelper::RunL() |
|
76 { |
|
77 FUNC_LOG; |
|
78 |
|
79 if (iStatus.Int() == KErrNone) |
|
80 { |
|
81 iCallBack.CallBack(); |
|
82 Subscribe(); |
|
83 } |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------- |
|
87 // |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 void CSubscribeHelper::DoCancel() |
|
91 { |
|
92 FUNC_LOG; |
|
93 |
|
94 iProperty.Cancel(); |
|
95 } |
|
96 |