24
|
1 |
// Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
#include "phoneonoff.h"
|
|
17 |
#include <sacls.h>
|
|
18 |
|
|
19 |
|
|
20 |
//
|
|
21 |
// ------> MPhoneOnOffObserver (source)
|
|
22 |
//
|
|
23 |
|
|
24 |
EXPORT_C void MPhoneOnOffObserver::PhoneIsOff()
|
|
25 |
{
|
|
26 |
}
|
|
27 |
|
|
28 |
EXPORT_C void MPhoneOnOffObserver::PhoneIsOn()
|
|
29 |
{
|
|
30 |
}
|
|
31 |
|
|
32 |
|
|
33 |
//
|
|
34 |
// ------> CPhoneOnOff (source)
|
|
35 |
//
|
|
36 |
|
|
37 |
CPhoneOnOff::CPhoneOnOff(MPhoneOnOffObserver& aPropertyPhoneWatcher)
|
|
38 |
: CActive(CActive::EPriorityHigh), iPropertyPhoneWatcher(aPropertyPhoneWatcher)
|
|
39 |
{
|
|
40 |
CActiveScheduler::Add(this);
|
|
41 |
}
|
|
42 |
|
|
43 |
CPhoneOnOff::~CPhoneOnOff()
|
|
44 |
{
|
|
45 |
Cancel();
|
|
46 |
iPhonePowerProperty.Close();
|
|
47 |
}
|
|
48 |
|
|
49 |
void CPhoneOnOff::ConstructL()
|
|
50 |
{
|
|
51 |
// Attach to Phone Power property
|
|
52 |
User::LeaveIfError(iPhonePowerProperty.Attach(KUidSystemCategory, KUidPhonePwr.iUid));
|
|
53 |
IssueRequestL();
|
|
54 |
}
|
|
55 |
|
|
56 |
void CPhoneOnOff::IssueRequestL()
|
|
57 |
{
|
|
58 |
iPhonePowerProperty.Subscribe(iStatus);
|
|
59 |
|
|
60 |
SetActive();
|
|
61 |
iStatus = KRequestPending;
|
|
62 |
}
|
|
63 |
|
|
64 |
void CPhoneOnOff::RunL()
|
|
65 |
{
|
|
66 |
if (iStatus.Int() == KErrNone)
|
|
67 |
{
|
|
68 |
IssueRequestL(); // reissue subscribe before checking property
|
|
69 |
|
|
70 |
TInt phoneStatus;
|
|
71 |
User::LeaveIfError(iPhonePowerProperty.Get(phoneStatus));
|
|
72 |
|
|
73 |
// Notify faxwatcher of phone off
|
|
74 |
if (phoneStatus == ESAPhoneOff)
|
|
75 |
iPropertyPhoneWatcher.PhoneIsOff();
|
|
76 |
else
|
|
77 |
iPropertyPhoneWatcher.PhoneIsOn();
|
|
78 |
}
|
|
79 |
}
|
|
80 |
|
|
81 |
void CPhoneOnOff::DoCancel()
|
|
82 |
{
|
|
83 |
iPhonePowerProperty.Cancel();
|
|
84 |
}
|