|
1 /* |
|
2 * Copyright (c) 2009 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: Methods for the SyncML Appserver starter notifier |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "syncmlmmcwatcher.h" |
|
19 |
|
20 // ----------------------------------------------------------------------------- |
|
21 // CSyncmlmmcwatcher::NewL() |
|
22 // ----------------------------------------------------------------------------- |
|
23 CSyncmlmmcwatcher* CSyncmlmmcwatcher::NewL( MSyncMLQueryMmcObserver* aObserver ) |
|
24 { |
|
25 CSyncmlmmcwatcher* self = new( ELeave ) CSyncmlmmcwatcher( aObserver ); |
|
26 CleanupStack::PushL( self ); |
|
27 self->ConstructL(); |
|
28 CleanupStack::Pop( self ); |
|
29 return self; |
|
30 } |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CSyncmlmmcwatcher::CSyncmlmmcwatcher() |
|
34 // ----------------------------------------------------------------------------- |
|
35 inline CSyncmlmmcwatcher::CSyncmlmmcwatcher(MSyncMLQueryMmcObserver* aObserver) |
|
36 { |
|
37 immcobserver = aObserver; |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CSyncmlmmcwatcher::ConstructL() |
|
42 // ----------------------------------------------------------------------------- |
|
43 void CSyncmlmmcwatcher::ConstructL() |
|
44 { |
|
45 TInt err = iMemoryCard.Connect(); |
|
46 if ( err == KErrNone ) |
|
47 { |
|
48 } |
|
49 |
|
50 else |
|
51 User::LeaveIfError(err); |
|
52 iDiskNotifyHandler = CDiskNotifyHandler::NewL( *this, iMemoryCard ); |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CSyncmlmmcwatcher::StartL() |
|
57 // Logs a request to notify the disk events |
|
58 // ----------------------------------------------------------------------------- |
|
59 void CSyncmlmmcwatcher::StartL() |
|
60 { |
|
61 FLOG(_L("CSyncmlmmcwatcher::Start- begin")); |
|
62 |
|
63 if(iDiskNotifyHandler) |
|
64 { |
|
65 iDiskNotifyHandler->NotifyDisk(); |
|
66 } |
|
67 } |
|
68 |
|
69 // ---------------------------------------------------------------------------------------- |
|
70 // CSyncmlmmcwatcher::~CSyncmlmmcwatcher() |
|
71 // Destructor |
|
72 // ---------------------------------------------------------------------------------------- |
|
73 CSyncmlmmcwatcher::~CSyncmlmmcwatcher() |
|
74 { |
|
75 FLOG(_L("CSyncmlmmcwatcher::~CSyncmlmmcwatcher()")); |
|
76 if(iDiskNotifyHandler) |
|
77 { |
|
78 iDiskNotifyHandler->CancelNotifyDisk(); |
|
79 delete iDiskNotifyHandler; |
|
80 iDiskNotifyHandler = NULL; |
|
81 } |
|
82 |
|
83 if(iMemoryCard.Handle()) |
|
84 { |
|
85 iMemoryCard.Close(); |
|
86 } |
|
87 } |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // CSyncmlmmcwatcher::HandleNotifyDisk |
|
91 // Callback method to notify disk events |
|
92 // --------------------------------------------------------------------------- |
|
93 // |
|
94 void CSyncmlmmcwatcher::HandleNotifyDisk( TInt aError, const TDiskEvent& aEvent ) |
|
95 { |
|
96 FTRACE( FPrint( |
|
97 _L( "CSysApMMCObserver::HandleNotifyDisk: error: %d, type: %d, drive: %d," ), |
|
98 aError, aEvent.iType, aEvent.iDrive ) ); |
|
99 |
|
100 if ( aError != KErrNone ) |
|
101 { |
|
102 return; |
|
103 } |
|
104 else |
|
105 { |
|
106 if(immcobserver) |
|
107 { |
|
108 FLOG(_L("mmc removal check")); |
|
109 TInt diskinserted = EFalse; |
|
110 RProperty::Get(KPSUidUikon, KUikMMCInserted,diskinserted); |
|
111 if(diskinserted)//EDiskStatusChanged called for insert & hard removal |
|
112 { |
|
113 FLOG(_L("disk inserted")); |
|
114 } |
|
115 else |
|
116 { |
|
117 FLOG(_L("disk removed")); |
|
118 immcobserver->MmcRemoved(); |
|
119 } |
|
120 FLOG(_L("mmcremoved call completed")); |
|
121 } |
|
122 } |
|
123 |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // CSyncmlmmcwatcher::CancelMmcwatch |
|
128 // Cancels the notification |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 void CSyncmlmmcwatcher::CancelMmcwatch() |
|
132 { |
|
133 if(iDiskNotifyHandler) |
|
134 { |
|
135 iDiskNotifyHandler->CancelNotifyDisk(); |
|
136 } |
|
137 } |