54
|
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:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef CAMDISKCHANGELISTENER_H
|
|
21 |
#define CAMDISKCHANGELISTENER_H
|
|
22 |
|
|
23 |
// INCLUDES
|
|
24 |
#include <f32file.h>
|
|
25 |
#include "CamPropertyWatcher.h"
|
|
26 |
#include "CamPropertyObserver.h"
|
|
27 |
#include "CamTimer.h"
|
|
28 |
|
|
29 |
// FORWARD DECLARATIONS
|
|
30 |
class MCamDriveChangeNotifierObserver;
|
|
31 |
|
|
32 |
// CLASS DECLARATION
|
|
33 |
|
|
34 |
/**
|
|
35 |
* Mmc Change Notifier.
|
|
36 |
*
|
|
37 |
* @since 5.0
|
|
38 |
*/
|
|
39 |
class MCamDriveChangeNotifierObserver
|
|
40 |
{
|
|
41 |
public:
|
|
42 |
enum TCamDriveChangeType
|
|
43 |
{
|
|
44 |
EDriveDismount,
|
|
45 |
EDriveMount,
|
|
46 |
EDriveUSBMassStorageModeOn,
|
|
47 |
EDriveUSBMassStorageModeOff
|
|
48 |
};
|
|
49 |
|
|
50 |
public: // New functions
|
|
51 |
|
|
52 |
/**
|
|
53 |
* This method is used to notify changes.
|
|
54 |
*/
|
|
55 |
virtual TInt DriveChangeL( TCamDriveChangeType aType ) = 0;
|
|
56 |
|
|
57 |
|
|
58 |
protected:
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Destructor.
|
|
62 |
*/
|
|
63 |
virtual ~MCamDriveChangeNotifierObserver() {}
|
|
64 |
|
|
65 |
};
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Mmc Change Notifier.
|
|
69 |
*
|
|
70 |
* @since 5.0
|
|
71 |
*/
|
|
72 |
class CCamDriveChangeNotifier : public CBase,
|
|
73 |
public MPropertyObserver
|
|
74 |
|
|
75 |
{
|
|
76 |
private:
|
|
77 |
class CCamDiskChangeListener : public CActive
|
|
78 |
{
|
|
79 |
public:
|
|
80 |
static CCamDiskChangeListener* NewLC(
|
|
81 |
RFs& aFs,
|
|
82 |
TDriveNumber aDrive,
|
|
83 |
CCamDriveChangeNotifier& aObserver );
|
|
84 |
~CCamDiskChangeListener();
|
|
85 |
|
|
86 |
void Start();
|
|
87 |
void Stop();
|
|
88 |
|
|
89 |
protected:
|
|
90 |
CCamDiskChangeListener(
|
|
91 |
RFs& aFs,
|
|
92 |
TDriveNumber aDrive,
|
|
93 |
CCamDriveChangeNotifier& aObserver );
|
|
94 |
|
|
95 |
private:
|
|
96 |
/**
|
|
97 |
* From CActive
|
|
98 |
*/
|
|
99 |
void DoCancel();
|
|
100 |
|
|
101 |
/**
|
|
102 |
* From CActive
|
|
103 |
*/
|
|
104 |
void RunL();
|
|
105 |
|
|
106 |
private:
|
|
107 |
RFs& iFs;
|
|
108 |
TDriveNumber iDrive;
|
|
109 |
CCamDriveChangeNotifier& iObserver;
|
|
110 |
};
|
|
111 |
|
|
112 |
public: // Constructors and destructor
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Two-phased constructor.
|
|
116 |
*/
|
|
117 |
static CCamDriveChangeNotifier* NewL(
|
|
118 |
RFs& aFs,
|
|
119 |
MCamDriveChangeNotifierObserver& aObserver );
|
|
120 |
|
|
121 |
/**
|
|
122 |
* Destructor.
|
|
123 |
*/
|
|
124 |
~CCamDriveChangeNotifier();
|
|
125 |
|
|
126 |
public:
|
|
127 |
/**
|
|
128 |
* Called from listeners
|
|
129 |
*/
|
|
130 |
TInt NotifyChangeL(
|
|
131 |
MCamDriveChangeNotifierObserver::TCamDriveChangeType aType );
|
|
132 |
|
|
133 |
/**
|
|
134 |
* Called by the observer when pending dismount can be done.
|
|
135 |
*/
|
|
136 |
void SendAllowDismount();
|
|
137 |
|
|
138 |
// New functions
|
|
139 |
|
|
140 |
void StartMonitoring();
|
|
141 |
|
|
142 |
void CancelMonitoring();
|
|
143 |
|
|
144 |
void USBTimerCallBackL();
|
|
145 |
|
|
146 |
static TInt USBTimerCallBack( TAny* aPtr );
|
|
147 |
|
|
148 |
public: // From MPropertyObserver
|
|
149 |
/**
|
|
150 |
* The value of a watched property has changed
|
|
151 |
* @param aCategory The category of the property
|
|
152 |
* @param aKey the Identifier of the property
|
|
153 |
*/
|
|
154 |
void HandlePropertyChangedL( const TUid& aCategory, const TUint aKey );
|
|
155 |
|
|
156 |
private:
|
|
157 |
|
|
158 |
/**
|
|
159 |
* C++ default constructor.
|
|
160 |
*/
|
|
161 |
CCamDriveChangeNotifier(
|
|
162 |
RFs& aFs,
|
|
163 |
MCamDriveChangeNotifierObserver& aObserver );
|
|
164 |
|
|
165 |
void ConstructL();
|
|
166 |
|
|
167 |
private: // Data
|
|
168 |
// Ref.
|
|
169 |
MCamDriveChangeNotifierObserver& iObserver;
|
|
170 |
|
|
171 |
// Ref. File server session
|
|
172 |
RFs& iFs;
|
|
173 |
|
|
174 |
RPointerArray<CCamDiskChangeListener> iListeners;
|
|
175 |
|
|
176 |
CCamPropertyWatcher* iUsbMSWatcher;
|
|
177 |
|
|
178 |
TBool iMassStorageModeOn;
|
|
179 |
|
|
180 |
CCamTimer* iUSBTimer;
|
|
181 |
|
|
182 |
};
|
|
183 |
|
|
184 |
#endif // CAMDISKCHANGELISTENER_H
|
|
185 |
|
|
186 |
// End of File
|