|
1 /* |
|
2 * Copyright (c) 2003-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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <e32test.h> |
|
19 #include <e32twin.h> |
|
20 #include <c32comm.h> |
|
21 #include <d32comm.h> |
|
22 #include <f32file.h> |
|
23 #include <hal.h> |
|
24 #include <usbman.h> |
|
25 |
|
26 static TInt MainL() |
|
27 { |
|
28 RDebug::Print(_L("Main() - Starting!")); |
|
29 |
|
30 RFs theFs; |
|
31 |
|
32 TInt r = theFs.Connect(); |
|
33 if (r != KErrNone) |
|
34 { |
|
35 RDebug::Print(_L("Main() - Failed to connect to the fs. Error = %d"), r); |
|
36 return r; |
|
37 } |
|
38 |
|
39 RDebug::Print(_L("Main() - Connected to file server")); |
|
40 |
|
41 r = StartC32(); |
|
42 if (r!=KErrNone && r !=KErrAlreadyExists) |
|
43 { |
|
44 RDebug::Print(_L("Main() - Failed to start C32. Error = %d"), r); |
|
45 return r; |
|
46 } |
|
47 |
|
48 RDebug::Print(_L("E32Main: Started c32")); |
|
49 |
|
50 RUsb usb; |
|
51 TInt err = usb.Connect(); |
|
52 if (err != KErrNone) |
|
53 { |
|
54 RDebug::Print(_L("MainL() - Unable to Connect to USB server")); |
|
55 theFs.Close(); |
|
56 return err; |
|
57 } |
|
58 RDebug::Print(_L("MainL() - Connected to USB server")); |
|
59 |
|
60 TUsbServiceState state; |
|
61 |
|
62 err = usb.GetCurrentState(state); |
|
63 if (err != KErrNone) |
|
64 { |
|
65 RDebug::Print(_L("MainL() - Failed to fetch service state from usbman, error %d"), err); |
|
66 } |
|
67 else |
|
68 { |
|
69 RDebug::Print(_L("MainL() - Usb service state = 0x%x"), state); |
|
70 } |
|
71 |
|
72 TRequestStatus status; |
|
73 usb.Start(status); |
|
74 User::WaitForRequest(status); |
|
75 |
|
76 RDebug::Print(_L("Start completed with status %d"), status.Int()); |
|
77 |
|
78 theFs.Close(); |
|
79 RDebug::Print(_L("MainL() - Exiting normally")); |
|
80 return KErrNone; |
|
81 } |
|
82 |
|
83 GLDEF_C TInt E32Main() |
|
84 { |
|
85 CTrapCleanup* cleanup = CTrapCleanup::New(); |
|
86 if(cleanup == NULL) |
|
87 { |
|
88 return KErrNoMemory; |
|
89 } |
|
90 TRAPD(err,err=MainL()); |
|
91 |
|
92 if (err != KErrNone) |
|
93 User::Panic(_L("StartUsb::E32Main - Panic"), err); |
|
94 |
|
95 delete cleanup; |
|
96 return err; |
|
97 } |
|
98 /////////////////////// |