1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
1 // Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). |
2 // All rights reserved. |
2 // All rights reserved. |
3 // This component and the accompanying materials are made available |
3 // This component and the accompanying materials are made available |
4 // under the terms of the License "Eclipse Public License v1.0" |
4 // under the terms of the License "Eclipse Public License v1.0" |
5 // which accompanies this distribution, and is available |
5 // which accompanies this distribution, and is available |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
38 #include "cusbotgserver.h" |
37 #include "cusbotgserver.h" |
39 #include "cusbotgsession.h" |
38 #include "cusbotgsession.h" |
40 |
39 |
41 |
40 |
42 CUsbOtgSession* CUsbOtgSession::NewL() |
41 CUsbOtgSession* CUsbOtgSession::NewL() |
43 { |
42 { |
44 __MSFNSLOG |
43 CUsbOtgSession* r = new (ELeave) CUsbOtgSession(); |
45 CUsbOtgSession* r = new (ELeave) CUsbOtgSession(); |
44 CleanupStack::PushL(r); |
46 CleanupStack::PushL(r); |
45 r->ConstructL(); |
47 r->ConstructL(); |
46 CleanupStack::Pop(); |
48 CleanupStack::Pop(); |
47 return r; |
49 return r; |
48 } |
50 } |
|
51 |
49 |
52 |
50 |
53 CUsbOtgSession::CUsbOtgSession() |
51 CUsbOtgSession::CUsbOtgSession() |
54 { |
52 { |
55 __MSFNSLOG |
53 } |
56 |
|
57 } |
|
58 |
54 |
59 void CUsbOtgSession::ConstructL() |
55 void CUsbOtgSession::ConstructL() |
60 { |
56 { |
61 __MSFNSLOG |
57 } |
62 } |
|
63 |
58 |
64 |
59 |
65 void CUsbOtgSession::CreateL() |
60 void CUsbOtgSession::CreateL() |
66 { |
61 { |
67 __MSFNSLOG |
|
68 Server().AddSession(); |
62 Server().AddSession(); |
69 } |
63 } |
70 |
64 |
71 |
65 |
72 CUsbOtgSession::~CUsbOtgSession() |
66 CUsbOtgSession::~CUsbOtgSession() |
73 { |
67 { |
74 __MSFNSLOG |
|
75 Server().RemoveSession(); |
68 Server().RemoveSession(); |
76 } |
69 } |
77 |
70 |
78 |
71 |
79 void CUsbOtgSession::ServiceL(const RMessage2& aMessage) |
72 void CUsbOtgSession::ServiceL(const RMessage2& aMessage) |
80 { |
73 { |
81 __MSFNSLOG |
74 DispatchMessageL(aMessage); |
82 DispatchMessageL(aMessage); |
75 } |
83 } |
|
84 |
76 |
85 |
77 |
86 void CUsbOtgSession::DispatchMessageL(const RMessage2& aMessage) |
78 void CUsbOtgSession::DispatchMessageL(const RMessage2& aMessage) |
87 { |
79 { |
88 __MSFNSLOG |
80 TInt ret = KErrNone; |
89 TInt ret = KErrNone; |
|
90 |
81 |
91 switch (aMessage.Function()) |
82 switch (aMessage.Function()) |
92 { |
83 { |
93 case EUsbOtgDeviceInserted: |
84 case EUsbOtgDeviceInserted: |
94 DeviceInsertedL(aMessage); |
85 DeviceInsertedL(aMessage); |
95 break; |
86 break; |
96 case EUsbOtgNotifyChange: |
87 case EUsbOtgNotifyChange: |
97 NotifyChange(aMessage); |
88 NotifyChange(aMessage); |
98 break; |
89 break; |
99 case EUsbOtgNotifyChangeCancel: |
90 case EUsbOtgNotifyChangeCancel: |
100 NotifyChangeCancel(); |
91 NotifyChangeCancel(); |
101 break; |
92 break; |
102 case EUsbOtgBusDrop: |
93 case EUsbOtgBusDrop: |
103 ret = BusDrop(); |
94 ret = BusDrop(); |
104 break; |
95 break; |
105 default: |
96 default: |
106 aMessage.Panic(KUsbOtgClientPncCat, EUsbOtgPanicIllegalIPC); |
97 aMessage.Panic(KUsbOtgClientPncCat, EUsbOtgPanicIllegalIPC); |
107 break; |
98 break; |
108 } |
99 } |
109 |
100 |
110 aMessage.Complete(ret); |
101 aMessage.Complete(ret); |
111 } |
102 } |
112 |
103 |
113 |
104 |
114 void CUsbOtgSession::DeviceInsertedL(const RMessage2& aMessage) |
105 void CUsbOtgSession::DeviceInsertedL(const RMessage2& aMessage) |
115 { |
106 { |
116 __MSFNSLOG |
|
117 TBool inserted = Server().iUsbOtg->DeviceInserted(); |
107 TBool inserted = Server().iUsbOtg->DeviceInserted(); |
118 TPckgBuf<TBool> p(inserted); |
108 TPckgBuf<TBool> p(inserted); |
119 aMessage.WriteL(0,p); |
109 aMessage.WriteL(0,p); |
120 } |
110 } |
121 |
111 |
122 void CUsbOtgSession::NotifyChange(const RMessage2& aMessage) |
112 void CUsbOtgSession::NotifyChange(const RMessage2& aMessage) |
123 { |
113 { |
124 __MSFNSLOG |
|
125 Server().iUsbOtg->NotifyChange(aMessage); |
114 Server().iUsbOtg->NotifyChange(aMessage); |
126 } |
115 } |
127 |
116 |
128 |
117 |
129 void CUsbOtgSession::NotifyChangeCancel() |
118 void CUsbOtgSession::NotifyChangeCancel() |
130 { |
119 { |
131 __MSFNSLOG |
|
132 Server().iUsbOtg->NotifyChangeCancel(); |
120 Server().iUsbOtg->NotifyChangeCancel(); |
133 } |
121 } |
134 |
122 |
135 |
123 |
136 TInt CUsbOtgSession::BusDrop() |
124 TInt CUsbOtgSession::BusDrop() |
137 { |
125 { |
138 __MSFNSLOG |
|
139 return Server().iUsbOtg->BusDrop(); |
126 return Server().iUsbOtg->BusDrop(); |
140 } |
127 } |