author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 27 Apr 2010 18:02:57 +0300 | |
branch | RCL_3 |
changeset 97 | 41f0cfe18c80 |
parent 33 | 0173bcd7697c |
child 110 | c734af59ce98 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). |
2 |
// All rights reserved. |
|
3 |
// This component and the accompanying materials are made available |
|
4 |
// under the terms of the License "Eclipse Public License v1.0" |
|
5 |
// which accompanies this distribution, and is available |
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 |
// |
|
8 |
// Initial Contributors: |
|
9 |
// Nokia Corporation - initial contribution. |
|
10 |
// |
|
11 |
// Contributors: |
|
12 |
// |
|
13 |
// Description: |
|
14 |
// |
|
15 |
||
16 |
/** |
|
17 |
@file |
|
18 |
@internalTechnology |
|
19 |
*/ |
|
20 |
||
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
21 |
|
0 | 22 |
#include <e32base.h> |
23 |
||
24 |
#include "msctypes.h" |
|
25 |
#include "cusbhostmslogicalunit.h" |
|
33
0173bcd7697c
Revision: 201001
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
26 |
#include "tlogicalunitlist.h" |
0 | 27 |
|
28 |
#include "msdebug.h" |
|
29 |
#include "debug.h" |
|
30 |
||
31 |
TLogicalUnitList::~TLogicalUnitList() |
|
32 |
{ |
|
33 |
__MSFNLOG |
|
34 |
iLu.ResetAndDestroy(); |
|
35 |
} |
|
36 |
||
37 |
void TLogicalUnitList::AddLuL(CUsbHostMsLogicalUnit* aLu) |
|
38 |
{ |
|
39 |
__MSFNLOG |
|
40 |
__HOSTPRINT1(_L("Adding LU 0x%x"), aLu); |
|
41 |
TInt r= FindLu(aLu->Lun()); |
|
42 |
||
43 |
if (r < 0) |
|
44 |
{ |
|
45 |
if (r != KErrNotFound) |
|
46 |
{ |
|
47 |
User::Leave(r); |
|
48 |
} |
|
49 |
} |
|
50 |
else // If it is able to find the lun already |
|
51 |
{ |
|
52 |
User::Leave(KErrAlreadyExists); |
|
53 |
} |
|
54 |
||
55 |
User::LeaveIfError(iLu.Append(aLu)); |
|
56 |
} |
|
57 |
||
58 |
||
59 |
void TLogicalUnitList::RemoveLuL(TLun aLun) |
|
60 |
{ |
|
61 |
__MSFNLOG |
|
62 |
TInt index = FindLu(aLun); |
|
63 |
User::LeaveIfError(index); |
|
64 |
||
65 |
CUsbHostMsLogicalUnit* lu = iLu[index]; |
|
66 |
TRAPD(err, lu->UnInitL()); |
|
67 |
delete lu; |
|
68 |
iLu.Remove(index); |
|
69 |
if(err != KErrNone) |
|
70 |
User::Leave(err); |
|
71 |
} |
|
72 |
||
73 |
||
74 |
void TLogicalUnitList::RemoveAllLuL() |
|
75 |
{ |
|
76 |
__MSFNLOG |
|
77 |
TInt ret = KErrNone; |
|
78 |
for (TInt index = 0; index < iLu.Count(); index++) |
|
79 |
{ |
|
80 |
CUsbHostMsLogicalUnit* lu = iLu[index]; |
|
81 |
TRAPD(err, lu->UnInitL()); |
|
82 |
delete lu; |
|
83 |
// set return flag for first error condition |
|
84 |
if (ret == KErrNone && err != KErrNone) |
|
85 |
ret = err; |
|
86 |
} |
|
87 |
||
88 |
iLu.Reset(); |
|
89 |
User::LeaveIfError(ret); |
|
90 |
} |
|
91 |
||
92 |
TInt TLogicalUnitList::Count() const |
|
93 |
{ |
|
94 |
__MSFNSLOG |
|
95 |
return iLu.Count(); |
|
96 |
} |
|
97 |
||
98 |
TInt TLogicalUnitList::FindLu(TLun aLun) const |
|
99 |
{ |
|
100 |
__MSFNSLOG |
|
101 |
||
102 |
TInt index; |
|
103 |
for (index = 0; index < iLu.Count(); index++) |
|
104 |
{ |
|
97
41f0cfe18c80
Revision: 201017
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
33
diff
changeset
|
105 |
__HOSTPRINT2(_L("search LUN=%d : interface id = %d"), aLun, iLu[index]->Lun()); |
0 | 106 |
if (iLu[index]->Lun() == aLun) |
107 |
{ |
|
108 |
break; |
|
109 |
} |
|
110 |
} |
|
111 |
||
112 |
if (index == iLu.Count()) |
|
113 |
{ |
|
114 |
return KErrNotFound; |
|
115 |
} |
|
116 |
||
117 |
return index; // Instead of KErrNone, we pass the index >= 0 of the aLun in the list |
|
118 |
} |
|
119 |
||
120 |
CUsbHostMsLogicalUnit& TLogicalUnitList::GetLuL(TLun aLun) const |
|
121 |
{ |
|
122 |
__MSFNSLOG |
|
123 |
TInt index = FindLu(aLun); |
|
124 |
User::LeaveIfError(index); |
|
125 |
return *iLu[index]; |
|
126 |
} |