|
1 /* |
|
2 * Copyright (c) 2005 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: Fota server update and download functionality |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "deviceupdatemoniter.h" |
|
19 #include "DeviceUpdateDebug.h" |
|
20 |
|
21 // -------------------------------------------------------------------------- |
|
22 // CDeviceUpdateMoniter::NewL |
|
23 // -------------------------------------------------------------------------- |
|
24 // |
|
25 CDeviceUpdateMoniter* CDeviceUpdateMoniter::NewL (MDeviceMoniterObserver* aObserver) |
|
26 { |
|
27 FLOG(_L("CDeviceUpdateMoniter::NewL >>")); |
|
28 CDeviceUpdateMoniter* h=new (ELeave)CDeviceUpdateMoniter; |
|
29 h->iObserver = aObserver; |
|
30 h->ConstructL(); |
|
31 FLOG(_L("CDeviceUpdateMoniter::NewL <<")); |
|
32 return h; |
|
33 } |
|
34 |
|
35 void CDeviceUpdateMoniter::ConstructL() |
|
36 { |
|
37 FLOG(_L("CDeviceUpdateMoniter::ConstructL >>")); |
|
38 TInt err = RProperty::Define(TUid::Uid(KOmaDMAppUid), KFotaServerActive, RProperty::EInt); |
|
39 |
|
40 if(err == KErrAlreadyExists) |
|
41 { |
|
42 TInt value; |
|
43 RProperty::Get(TUid::Uid(KOmaDMAppUid), KFotaServerActive, value); |
|
44 if(value) |
|
45 iObserver->UpdateDMUI(EFalse); |
|
46 } |
|
47 err = iProperty.Attach(TUid::Uid(KOmaDMAppUid), KFotaServerActive); |
|
48 if(err == KErrNone) |
|
49 { |
|
50 iProperty.Subscribe(iStatus); |
|
51 if ( !IsActive() ) |
|
52 { |
|
53 SetActive(); |
|
54 } |
|
55 } |
|
56 FLOG(_L("CDeviceUpdateMoniter::ConstructL <<")); |
|
57 } |
|
58 |
|
59 |
|
60 void CDeviceUpdateMoniter::StartMoniter() |
|
61 { |
|
62 FLOG(_L("CDeviceUpdateMoniter::StartMoniter() >>")); |
|
63 iProperty.Subscribe(iStatus); |
|
64 if ( !IsActive() ) |
|
65 { |
|
66 SetActive(); |
|
67 } |
|
68 FLOG(_L("CDeviceUpdateMoniter::StartMoniter <<")); |
|
69 } |
|
70 |
|
71 // -------------------------------------------------------------------------- |
|
72 CDeviceUpdateMoniter::CDeviceUpdateMoniter() |
|
73 : CActive(EPriorityNormal) |
|
74 { |
|
75 FLOG(_L("CDeviceUpdateMoniter::CDeviceUpdateMoniter() >>")); |
|
76 CActiveScheduler::Add( this ); |
|
77 FLOG(_L("CDeviceUpdateMoniter::CDeviceUpdateMoniter <<")); |
|
78 } |
|
79 |
|
80 // -------------------------------------------------------------------------- |
|
81 CDeviceUpdateMoniter::~CDeviceUpdateMoniter() |
|
82 { |
|
83 FLOG(_L("CDeviceUpdateMoniter::~CDeviceUpdateMoniter >>")); |
|
84 //iNotifier.Close(); FOTA_10.1 changes |
|
85 //Cancel(); |
|
86 FLOG(_L("CDeviceUpdateMoniter::~CDeviceUpdateMoniter <<")); |
|
87 } |
|
88 |
|
89 // -------------------------------------------------------------------------- |
|
90 void CDeviceUpdateMoniter::RunL() |
|
91 { |
|
92 FLOG(_L("CDeviceUpdateMoniter::RunL >>")); |
|
93 TInt value; |
|
94 TUid uid = {0x102072C4}; |
|
95 |
|
96 RProperty::Get(TUid::Uid(KOmaDMAppUid), KFotaServerActive, value); |
|
97 if(value) |
|
98 iObserver->UpdateDMUI(EFalse); |
|
99 else |
|
100 iObserver->UpdateDMUI(ETrue); |
|
101 StartMoniter(); |
|
102 FLOG(_L("CDeviceUpdateMoniter::RunL <<")); |
|
103 } |
|
104 |
|
105 // -------------------------------------------------------------------------- |
|
106 TInt CDeviceUpdateMoniter::RunError(TInt aError) |
|
107 { |
|
108 FLOG(_L("CDeviceUpdateMoniter::RunL %d"),aError); |
|
109 return aError; |
|
110 } |
|
111 |
|
112 TInt CDeviceUpdateMoniter::CancelRequest() |
|
113 { |
|
114 FLOG(_L("CDeviceUpdateMoniter::CancelRequest %d")); |
|
115 |
|
116 } |
|
117 |
|
118 // -------------------------------------------------------------------------- |
|
119 void CDeviceUpdateMoniter::DoCancel() |
|
120 { |
|
121 FLOG(_L("CDeviceUpdateMoniter::DoCancel >>")); |
|
122 iProperty.Cancel(); |
|
123 FLOG(_L("CDeviceUpdateMoniter::DoCancel <<")); |
|
124 } |
|
125 |