|
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: DriveUtilities |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef DRIVEUTILITIES_H |
|
19 #define DRIVEUTILITIES_H |
|
20 |
|
21 #include "javaosheaders.h" |
|
22 #include "comms.h" |
|
23 |
|
24 #include <string> |
|
25 #include <vector> |
|
26 |
|
27 namespace java |
|
28 { |
|
29 namespace comms |
|
30 { |
|
31 class CommsEndpoint; |
|
32 } // namespace comms |
|
33 |
|
34 namespace fileutils |
|
35 { |
|
36 |
|
37 struct driveInfo |
|
38 { |
|
39 driveInfo():iIsPresent(false), iIsRemovable(false), |
|
40 iIsLocal(false), iIsReadOnly(false), iId(0), iIsExternallyMountable(false) |
|
41 {} |
|
42 |
|
43 std::wstring iRootPath; |
|
44 bool iIsPresent; |
|
45 bool iIsRemovable; |
|
46 bool iIsLocal; |
|
47 bool iIsReadOnly; |
|
48 unsigned int iId; |
|
49 bool iIsExternallyMountable; |
|
50 }; |
|
51 |
|
52 typedef std::vector<driveInfo> driveInfos; |
|
53 |
|
54 class DriveListenerInterface |
|
55 { |
|
56 public: |
|
57 enum |
|
58 { |
|
59 REMOVABLE_MEDIA_INSERTED_C = 1, |
|
60 REMOVABLE_MEDIA_REMOVED_C, // = 2 |
|
61 // possibe future operations |
|
62 // for remote drives |
|
63 // DRIVE_MOUNTED_C, |
|
64 // DRIVE_UNMOUNTED_C |
|
65 // for local drives, |
|
66 // DRIVE_ADDDED_C |
|
67 // DRIVE_REMOVED_C |
|
68 }; |
|
69 |
|
70 virtual void driveChanged(const int& aOperation, const driveInfo& aDriveInfo) = 0; |
|
71 }; |
|
72 |
|
73 class DriveObserverServerInterface |
|
74 { |
|
75 public: |
|
76 virtual ~DriveObserverServerInterface() = 0; |
|
77 |
|
78 virtual void startServer(java::comms::CommsEndpoint* aComms) = 0; |
|
79 virtual void stopServer() = 0; |
|
80 |
|
81 // For local listeners |
|
82 virtual void registerListener(DriveListenerInterface* aListener) = 0; |
|
83 virtual void unregisterListener(DriveListenerInterface* aListener) = 0; |
|
84 }; |
|
85 |
|
86 OS_NONSHARABLE_CLASS(DriveUtilities) |
|
87 { |
|
88 public: |
|
89 |
|
90 ////////////// Client API start ////////////////////////////////////////// |
|
91 // These methods are intended for client users of drive observer API |
|
92 /** |
|
93 * Returns the list of all defined drives/roots within the system. |
|
94 * |
|
95 * @param[in/out] aDriveInfo: a reference to a collection which receives |
|
96 * the all defined drives within the system |
|
97 */ |
|
98 OS_IMPORT static void getAllDrives(driveInfos& aDriveInfos); |
|
99 |
|
100 /** |
|
101 * Returns the list of available drives/roots wich are present and accesible. |
|
102 * |
|
103 * @param[in/out] aDriveInfo: a reference to a collection which receives |
|
104 * the existing drives with accesible media within the system |
|
105 */ |
|
106 OS_IMPORT static void getAccesibleDrives(driveInfos& aDriveInfos); |
|
107 |
|
108 /** |
|
109 * Registers a listener for drive changed events |
|
110 * |
|
111 * @param[in] aListener: pointer to an interface implementing callback methods |
|
112 */ |
|
113 OS_IMPORT static void registerListener(DriveListenerInterface* aListener, |
|
114 const int& aServerAddress = java::comms::IPC_ADDRESS_JAVA_CAPTAIN_C); |
|
115 /** |
|
116 * Unregisters a listener for drive changed events |
|
117 * |
|
118 * @param[in] aListener: pointer to an interface implementing callback methods |
|
119 */ |
|
120 OS_IMPORT static void unregisterListener(DriveListenerInterface* aListener, |
|
121 const int& aServerAddress = java::comms::IPC_ADDRESS_JAVA_CAPTAIN_C); |
|
122 ////////////// Client API stop ////////////////////////////////////////// |
|
123 |
|
124 ////////////// Server API start ////////////////////////////////////////// |
|
125 // Following methods are to be used only by DriveObserver server instantianter |
|
126 // which is currently javacaptain. The interface to create a server side instance |
|
127 // is here in order to enable drive observer functionality also on platforms |
|
128 // and configurations which do not have javacaptain running |
|
129 ////////////// Server API start ////////////////////////////////////////// |
|
130 OS_IMPORT static DriveObserverServerInterface* getDriveObserverServer(); |
|
131 }; |
|
132 |
|
133 } // end of namespace fileutils |
|
134 } // end of namespace java |
|
135 #endif // DRIVEUTILITIES_H |
|
136 |