|
1 /* |
|
2 * Copyright (c) 2010 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 // Include Files |
|
20 |
|
21 |
|
22 #include <e32base.h> |
|
23 #include <e32std.h> |
|
24 #include <f32file.h> |
|
25 #include "AppRegExec.h" |
|
26 #include "NotifyChange.h" |
|
27 |
|
28 // Constants |
|
29 // Global Variables |
|
30 // Local Functions |
|
31 |
|
32 LOCAL_C void MainL() |
|
33 { |
|
34 RFs fs; |
|
35 User::LeaveIfError(fs.Connect()); |
|
36 CleanupClosePushL(fs); |
|
37 TInt driveNumber=EDriveA; |
|
38 TChar driveLetter; |
|
39 TDriveList drivelist; |
|
40 User::LeaveIfError(fs.DriveList(drivelist)); |
|
41 TInt count = 0; |
|
42 CNotifyChange* notify; |
|
43 for (driveNumber=EDriveA; driveNumber<=EDriveZ;driveNumber++) |
|
44 { |
|
45 // if drive-list entry non-zero, drive is available |
|
46 if (drivelist[driveNumber]) |
|
47 { |
|
48 User::LeaveIfError(fs.DriveToChar(driveNumber,driveLetter)); |
|
49 notify = CNotifyChange::NewL(driveLetter); |
|
50 CleanupStack::PushL(notify); |
|
51 count ++; |
|
52 notify->StartFilesystemMonitor(); |
|
53 } |
|
54 } |
|
55 CActiveScheduler::Start(); |
|
56 fs.Close(); |
|
57 CleanupStack::PopAndDestroy(count); |
|
58 CleanupStack::PopAndDestroy(&fs); |
|
59 } |
|
60 |
|
61 LOCAL_C void DoStartL() |
|
62 { |
|
63 // Create active scheduler (to run active objects) |
|
64 CActiveScheduler* scheduler = new (ELeave) CActiveScheduler(); |
|
65 CleanupStack::PushL(scheduler); |
|
66 CActiveScheduler::Install(scheduler); |
|
67 |
|
68 MainL(); |
|
69 |
|
70 // Delete active scheduler |
|
71 CleanupStack::PopAndDestroy(scheduler); |
|
72 } |
|
73 |
|
74 // Global Functions |
|
75 |
|
76 GLDEF_C TInt E32Main() |
|
77 { |
|
78 // Create cleanup stack |
|
79 __UHEAP_MARK; |
|
80 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
81 // Run application code inside TRAP harness, wait keypress when terminated |
|
82 TRAPD(mainError, DoStartL()); |
|
83 if(mainError != KErrNone) |
|
84 { |
|
85 OstTrace1( TRACE_FATAL, __E32MAIN_DOSTARTL_FAIL, "AppRegExec::E32Main - DoStartL failed;mainError=%d", mainError ); |
|
86 } |
|
87 delete cleanup; |
|
88 __UHEAP_MARKEND; |
|
89 return mainError; |
|
90 } |
|
91 |