|
1 /* |
|
2 * Copyright (c) 2006 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: Factory for creating branding |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "cbsfactory.h" |
|
20 #include "cbsaccess.h" |
|
21 #include "cbsupdater.h" |
|
22 #include "mbsaccess.h" |
|
23 #include "mbsupdater.h" |
|
24 #include "cbsclient.h" |
|
25 #include "debugtrace.h" |
|
26 |
|
27 // ============================ MEMBER FUNCTIONS =============================== |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // BrandingFactory::NewL |
|
31 // Two-phased constructor. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 EXPORT_C CBSFactory* CBSFactory::NewL( const TDesC8& aDefaultBrandId, |
|
35 const TDesC8& aApplicationId ) |
|
36 { |
|
37 TRACE( T_LIT("CBSFactory::NewL begin") ); |
|
38 CBSFactory* self = new ( ELeave ) CBSFactory() ; |
|
39 CleanupStack::PushL( self ); |
|
40 self->ConstructL( aDefaultBrandId, aApplicationId ); |
|
41 CleanupStack::Pop( self ); //self |
|
42 TRACE( T_LIT("CBSFactory::NewL end") ); |
|
43 return self; |
|
44 } |
|
45 |
|
46 |
|
47 // C++ default constructor can NOT contain any code, that |
|
48 // might leave. |
|
49 // |
|
50 CBSFactory::CBSFactory() |
|
51 { |
|
52 } |
|
53 |
|
54 // destructor |
|
55 CBSFactory::~CBSFactory() |
|
56 { |
|
57 delete iDefaultBrand; |
|
58 delete iApplicationId; |
|
59 if( iServerKeepAlive ) |
|
60 { |
|
61 iServerKeepAlive->Close(); |
|
62 } |
|
63 delete iServerKeepAlive; |
|
64 } |
|
65 |
|
66 // Symbian OS default constructor can leave. |
|
67 void CBSFactory::ConstructL( const TDesC8& aDefaultBrandId, |
|
68 const TDesC8& aApplicationId ) |
|
69 { |
|
70 iDefaultBrand = aDefaultBrandId.AllocL(); |
|
71 iApplicationId = aApplicationId.AllocL(); |
|
72 iServerKeepAlive = new(ELeave) RBSClient(); // CSI: 74 # this needs to be like this |
|
73 User::LeaveIfError( iServerKeepAlive->Connect() ); |
|
74 } |
|
75 |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CBSFactory::CreateAccessL() |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 EXPORT_C MBSAccess* CBSFactory::CreateAccessL( const TDesC8& aBrandId, |
|
82 TLanguage aLanguageId, |
|
83 TBool aCacheData, /* = EFalse */ |
|
84 TInt aReserved /*= 0*/ ) |
|
85 { |
|
86 TRACE( T_LIT("CBSFactory::CreateAccessL begin") ); |
|
87 CBSAccess* access = CBSAccess::NewL( aBrandId, *iApplicationId, *iDefaultBrand, |
|
88 aLanguageId, aCacheData, aReserved ); |
|
89 TRACE( T_LIT("CBSFactory::CreateAccessL end") ); |
|
90 return access; |
|
91 } |
|
92 |
|
93 // ----------------------------------------------------------------------------- |
|
94 // CBSFactory::CreateAccessL() |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 EXPORT_C MBSAccess* CBSFactory::CreateAccessLC( const TDesC8& aBrandId, |
|
98 TLanguage aLanguageId, |
|
99 TBool aCacheData, /* = EFalse */ |
|
100 TInt aReserved /*= 0 */) |
|
101 { |
|
102 CBSAccess* access = CBSAccess::NewL( aBrandId, *iApplicationId, *iDefaultBrand, |
|
103 aLanguageId, aCacheData, aReserved ); |
|
104 CleanupClosePushL( *access ); |
|
105 return access; |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CBSFactory::CreateUpdaterL() |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 EXPORT_C MBSUpdater* CBSFactory::CreateUpdaterL() |
|
113 { |
|
114 CBSUpdater* updater = CBSUpdater::NewL( *iApplicationId ); |
|
115 return updater; |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CBSFactory::CreateUpdaterLC() |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 EXPORT_C MBSUpdater* CBSFactory::CreateUpdaterLC() |
|
123 { |
|
124 CBSUpdater* updater = CBSUpdater::NewL( *iApplicationId ); |
|
125 CleanupClosePushL( *updater ); |
|
126 return updater; |
|
127 } |
|
128 |
|
129 // End of File |
|
130 |