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 |
|
|
21 |
#include <e32base.h>
|
|
22 |
#include <e32base_private.h>
|
|
23 |
#include <d32usbdi.h>
|
|
24 |
|
|
25 |
#include <d32usbtransfers.h>
|
|
26 |
#include "msctypes.h"
|
|
27 |
#include "mscutils.h"
|
|
28 |
#include "shared.h"
|
|
29 |
#include "msgservice.h"
|
|
30 |
#include "botmsctypes.h"
|
|
31 |
|
|
32 |
#include "mprotocol.h"
|
|
33 |
#include "mtransport.h"
|
|
34 |
#include "cbulkonlytransport.h"
|
|
35 |
#include "cusbhostmslogicalunit.h"
|
|
36 |
#include "cusbhostmsdevice.h"
|
|
37 |
#include "cusbmssuspendresume.h"
|
|
38 |
|
|
39 |
#include "msdebug.h"
|
|
40 |
#include "debug.h"
|
|
41 |
|
|
42 |
TLogicalUnitList::~TLogicalUnitList()
|
|
43 |
{
|
|
44 |
__MSFNLOG
|
|
45 |
iLu.ResetAndDestroy();
|
|
46 |
}
|
|
47 |
|
|
48 |
void TLogicalUnitList::AddLuL(CUsbHostMsLogicalUnit* aLu)
|
|
49 |
{
|
|
50 |
__MSFNLOG
|
|
51 |
__HOSTPRINT1(_L("Adding LU 0x%x"), aLu);
|
|
52 |
TInt r= FindLu(aLu->Lun());
|
|
53 |
|
|
54 |
if (r < 0)
|
|
55 |
{
|
|
56 |
if (r != KErrNotFound)
|
|
57 |
{
|
|
58 |
User::Leave(r);
|
|
59 |
}
|
|
60 |
}
|
|
61 |
else // If it is able to find the lun already
|
|
62 |
{
|
|
63 |
User::Leave(KErrAlreadyExists);
|
|
64 |
}
|
|
65 |
|
|
66 |
User::LeaveIfError(iLu.Append(aLu));
|
|
67 |
}
|
|
68 |
|
|
69 |
|
|
70 |
void TLogicalUnitList::RemoveLuL(TLun aLun)
|
|
71 |
{
|
|
72 |
__MSFNLOG
|
|
73 |
TInt index = FindLu(aLun);
|
|
74 |
User::LeaveIfError(index);
|
|
75 |
|
|
76 |
CUsbHostMsLogicalUnit* lu = iLu[index];
|
|
77 |
TRAPD(err, lu->UnInitL());
|
|
78 |
delete lu;
|
|
79 |
iLu.Remove(index);
|
|
80 |
if(err != KErrNone)
|
|
81 |
User::Leave(err);
|
|
82 |
}
|
|
83 |
|
|
84 |
|
|
85 |
void TLogicalUnitList::RemoveAllLuL()
|
|
86 |
{
|
|
87 |
__MSFNLOG
|
|
88 |
TInt ret = KErrNone;
|
|
89 |
for (TInt index = 0; index < iLu.Count(); index++)
|
|
90 |
{
|
|
91 |
CUsbHostMsLogicalUnit* lu = iLu[index];
|
|
92 |
TRAPD(err, lu->UnInitL());
|
|
93 |
delete lu;
|
|
94 |
// set return flag for first error condition
|
|
95 |
if (ret == KErrNone && err != KErrNone)
|
|
96 |
ret = err;
|
|
97 |
}
|
|
98 |
|
|
99 |
iLu.Reset();
|
|
100 |
User::LeaveIfError(ret);
|
|
101 |
}
|
|
102 |
|
|
103 |
TInt TLogicalUnitList::Count() const
|
|
104 |
{
|
|
105 |
__MSFNSLOG
|
|
106 |
return iLu.Count();
|
|
107 |
}
|
|
108 |
|
|
109 |
TInt TLogicalUnitList::FindLu(TLun aLun) const
|
|
110 |
{
|
|
111 |
__MSFNSLOG
|
|
112 |
|
|
113 |
TInt index;
|
|
114 |
for (index = 0; index < iLu.Count(); index++)
|
|
115 |
{
|
|
116 |
__HOSTPRINT2(_L("search %d : interface id = %d\n"), aLun, iLu[index]->Lun());
|
|
117 |
if (iLu[index]->Lun() == aLun)
|
|
118 |
{
|
|
119 |
break;
|
|
120 |
}
|
|
121 |
}
|
|
122 |
|
|
123 |
if (index == iLu.Count())
|
|
124 |
{
|
|
125 |
return KErrNotFound;
|
|
126 |
}
|
|
127 |
|
|
128 |
return index; // Instead of KErrNone, we pass the index >= 0 of the aLun in the list
|
|
129 |
}
|
|
130 |
|
|
131 |
CUsbHostMsLogicalUnit& TLogicalUnitList::GetLuL(TLun aLun) const
|
|
132 |
{
|
|
133 |
__MSFNSLOG
|
|
134 |
TInt index = FindLu(aLun);
|
|
135 |
User::LeaveIfError(index);
|
|
136 |
return *iLu[index];
|
|
137 |
}
|