|
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 #include "CBlacklistMgr.h" |
|
19 #include <HarvesterServerLogger.h> |
|
20 |
|
21 // ----------------------------------------------------------------------------- |
|
22 // CBlacklistMgr::NewL() |
|
23 // ----------------------------------------------------------------------------- |
|
24 // |
|
25 CBlacklistMgr* CBlacklistMgr::NewL() |
|
26 { |
|
27 CPIXLOGSTRING("CBlacklistMgr::NewL(): Entered"); |
|
28 CBlacklistMgr* instance = CBlacklistMgr::NewLC(); |
|
29 CleanupStack::Pop( instance ); |
|
30 CPIXLOGSTRING("CBlacklistMgr::NewL(): Exit"); |
|
31 return instance; |
|
32 } |
|
33 |
|
34 // ----------------------------------------------------------------------------- |
|
35 // CBlacklistMgr::NewLC() |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CBlacklistMgr* CBlacklistMgr::NewLC() |
|
39 { |
|
40 CBlacklistMgr* instance = new (ELeave) CBlacklistMgr(); |
|
41 CleanupStack::PushL( instance ); |
|
42 instance->ConstructL(); |
|
43 return instance; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CBlacklistMgr::CBlacklistMgr() |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CBlacklistMgr::CBlacklistMgr() |
|
51 { |
|
52 //Do the necessary initialisation |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CBlacklistMgr::~CBlacklistMgr |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CBlacklistMgr::~CBlacklistMgr() |
|
60 { |
|
61 delete iBlacklistDb; |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CBlacklistMgr::ConstructL() |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CBlacklistMgr::ConstructL() |
|
69 { |
|
70 CPIXLOGSTRING("CBlacklistMgr::ConstructL(): Entered"); |
|
71 iBlacklistDb = CBlacklistDb::NewL(); |
|
72 CPIXLOGSTRING("CBlacklistMgr::ConstructL(): Exit"); |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CBlacklistMgr::AddL() |
|
77 // ----------------------------------------------------------------------------- |
|
78 // |
|
79 TInt CBlacklistMgr::AddL( TUid aPluginUid , TInt aVersion ) |
|
80 { |
|
81 //Add the item record to database |
|
82 CPIXLOGSTRING3("CBlacklistMgr::AddL(): Uid = %x and Version = %d" , aPluginUid.iUid , aVersion); |
|
83 //Check if the record with given plugin uid is already available in database or not |
|
84 //If available just update version number in the same record |
|
85 //If there is no record found in database with given uid, add new record with given details |
|
86 TInt err = KErrNone; |
|
87 const TBool isfound = iBlacklistDb->FindL( aPluginUid.iUid ); |
|
88 |
|
89 if (isfound) |
|
90 { |
|
91 err = iBlacklistDb->UpdateL( aPluginUid.iUid , aVersion ); |
|
92 } |
|
93 else |
|
94 { |
|
95 err = iBlacklistDb->AddL( aPluginUid.iUid , aVersion ); |
|
96 } |
|
97 |
|
98 CPIXLOGSTRING("CBlacklistMgr::AddL(): Exit"); |
|
99 return err; |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CBlacklistMgr::RemoveL() |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 void CBlacklistMgr::Remove( TUid aPluginUid ) |
|
107 { |
|
108 CPIXLOGSTRING2("CBlacklistMgr::RemoveL(): Uid = %x " , aPluginUid.iUid ); |
|
109 //Remove the item record to database |
|
110 iBlacklistDb->Remove( aPluginUid.iUid ); |
|
111 |
|
112 CPIXLOGSTRING("CBlacklistMgr::RemoveL(): Exit"); |
|
113 } |
|
114 |
|
115 // ----------------------------------------------------------------------------- |
|
116 // CBlacklistMgr::iSAvailableL() |
|
117 // ----------------------------------------------------------------------------- |
|
118 // |
|
119 TBool CBlacklistMgr::FindL( TUid aPluginUid , TInt aVersion ) |
|
120 { |
|
121 CPIXLOGSTRING3("CBlacklistMgr::FindL(): Uid = %x and Version = %d" , aPluginUid.iUid , aVersion); |
|
122 //Check if the item is available in database |
|
123 TBool found = iBlacklistDb->FindWithVersionL( aPluginUid.iUid , aVersion ); |
|
124 |
|
125 if(found) |
|
126 { |
|
127 CPIXLOGSTRING("UID is Black listed"); |
|
128 } |
|
129 else |
|
130 { |
|
131 CPIXLOGSTRING("UID is not Black listed"); |
|
132 } |
|
133 return found; |
|
134 } |