|
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 #include "upnpremotableappstore.h" |
|
21 #include "OstTraceDefinitions.h" |
|
22 #ifdef OST_TRACE_COMPILER_IN_USE |
|
23 #include "upnpremotableappstoreTraces.h" |
|
24 #endif |
|
25 |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =================================== |
|
28 |
|
29 // --------------------------------------------------------------------------------- |
|
30 // CUpnpRemotableAppStore::NewL |
|
31 // Two-phased constructor. |
|
32 // --------------------------------------------------------------------------------- |
|
33 // |
|
34 CUpnpRemotableAppStore* CUpnpRemotableAppStore::NewL() |
|
35 { |
|
36 OstTraceFunctionEntry0( CUPNPREMOTABLEAPPSTORE_NEWL_ENTRY ); |
|
37 return ( new (ELeave) CUpnpRemotableAppStore()); |
|
38 } |
|
39 |
|
40 // --------------------------------------------------------------------------------- |
|
41 // CUpnpRemotableAppStore::CUpnpRemotableAppStore |
|
42 // C++ default constructor can NOT contain any code, that |
|
43 // might leave. |
|
44 // --------------------------------------------------------------------------------- |
|
45 // |
|
46 CUpnpRemotableAppStore::CUpnpRemotableAppStore( ) |
|
47 { |
|
48 |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------------- |
|
52 // CUpnpRemotableAppStore::~CUpnpRemotableAppStore |
|
53 // Destructor |
|
54 // --------------------------------------------------------------------------------- |
|
55 // |
|
56 CUpnpRemotableAppStore::~CUpnpRemotableAppStore() |
|
57 { |
|
58 OstTraceFunctionEntry0( CUPNPREMOTABLEAPPSTORE_CUPNPREMOTABLEAPPSTORE_ENTRY ); |
|
59 iRemotableAppArray.ResetAndDestroy(); |
|
60 iRemotableAppArray.Close(); |
|
61 iAppIdArray.Close(); |
|
62 OstTraceFunctionExit0( CUPNPREMOTABLEAPPSTORE_CUPNPREMOTABLEAPPSTORE_EXIT ); |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------------- |
|
66 // CUpnpRemotableAppStore::AppendRemotableAppL |
|
67 // Method is used to create a list of all the registered apps |
|
68 // @param aApp Pointer to CUpnpRemotableApp object |
|
69 // --------------------------------------------------------------------------------- |
|
70 // |
|
71 void CUpnpRemotableAppStore::AddRemotableAppL( CUpnpRemotableApp* aApp ) |
|
72 { |
|
73 OstTraceFunctionEntry0( CUPNPREMOTABLEAPPSTORE_ADDREMOTABLEAPPL_ENTRY ); |
|
74 TInt appId = aApp->AppId(); |
|
75 if ( iAppIdArray.Find( appId ) == KErrNotFound ) |
|
76 { |
|
77 // Register all distinct apps |
|
78 OstTrace1( TRACE_FLOW, CUPNPREMOTABLEAPPSTORE_ADDREMOTABLEAPPL, "CUpnpRemotableAppStore::AddRemotableAppL;appId=%d", appId ); |
|
79 iRemotableAppArray.AppendL(aApp); |
|
80 iAppIdArray.AppendL( appId ); |
|
81 } |
|
82 else |
|
83 { |
|
84 // Delete the duplicate remotable app object |
|
85 delete aApp; |
|
86 aApp = NULL; |
|
87 } |
|
88 OstTraceFunctionExit0( CUPNPREMOTABLEAPPSTORE_ADDREMOTABLEAPPL_EXIT ); |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------------- |
|
92 // CUpnpRemotableAppStore::RemoveRemotableApp |
|
93 // Method is used to remove the app frpm the list of already registered apps |
|
94 // @param aAppId App to be removed |
|
95 // --------------------------------------------------------------------------------- |
|
96 // |
|
97 TInt CUpnpRemotableAppStore::RemoveRemotableApp( TUint aAppId ) |
|
98 { |
|
99 OstTraceFunctionEntry0( CUPNPREMOTABLEAPPSTORE_REMOVEREMOTABLEAPP_ENTRY ); |
|
100 TInt ret(KErrNotFound); |
|
101 TInt appIndex = iAppIdArray.Find( aAppId ); |
|
102 if ( appIndex != KErrNotFound ) |
|
103 { |
|
104 // If appID is matched then delete the Remotable App object and remove |
|
105 // the object pointer from the array |
|
106 iAppIdArray.Remove(appIndex); |
|
107 delete iRemotableAppArray[appIndex]; |
|
108 iRemotableAppArray[appIndex] = NULL; |
|
109 iRemotableAppArray.Remove(appIndex); |
|
110 ret = KErrNone; |
|
111 } |
|
112 OstTrace1( TRACE_NORMAL, CUPNPREMOTABLEAPPSTORE_REMOVEREMOTABLEAPP, "CUpnpRemotableAppStore::RemoveRemotableApp;ret=%d", ret ); |
|
113 OstTraceFunctionExit0( CUPNPREMOTABLEAPPSTORE_REMOVEREMOTABLEAPP_EXIT ); |
|
114 return ret; |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------------- |
|
118 // CUpnpRemotableAppStore::FetchRemotableApp |
|
119 // Method is used to fetch the list of registered apps |
|
120 // @param aAppId App ID of the application whose access is needed |
|
121 // @return Returns reference to CUpnpRemotableApp object |
|
122 // --------------------------------------------------------------------------------- |
|
123 // |
|
124 CUpnpRemotableApp& CUpnpRemotableAppStore::FetchRemotableApp( TInt aAppIndex )const |
|
125 { |
|
126 OstTraceFunctionEntry0( CUPNPREMOTABLEAPPSTORE_FETCHREMOTABLEAPP_ENTRY ); |
|
127 ASSERT( aAppIndex >=0 ); |
|
128 OstTraceFunctionExit0( CUPNPREMOTABLEAPPSTORE_FETCHREMOTABLEAPP_EXIT ); |
|
129 return *iRemotableAppArray[aAppIndex]; |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------------- |
|
133 // CUpnpRemotableAppStore::AppIdArray |
|
134 // Method is used to fetch the list of appIDs of registered apps |
|
135 // @return Returns reference to an array of TInt objects |
|
136 // --------------------------------------------------------------------------------- |
|
137 // |
|
138 const RArray<TUint>& CUpnpRemotableAppStore::AppIdArray()const |
|
139 { |
|
140 OstTraceFunctionEntry0( CUPNPREMOTABLEAPPSTORE_APPIDARRAY_ENTRY ); |
|
141 OstTraceFunctionExit0( CUPNPREMOTABLEAPPSTORE_APPIDARRAY_EXIT ); |
|
142 return iAppIdArray; |
|
143 } |
|
144 |
|
145 // End of File |