|
1 /* |
|
2 * Copyright (c) 2008 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: Implementation of detailsview plugin control container |
|
15 * |
|
16 */ |
|
17 // settings |
|
18 |
|
19 #include <spsettings.h> |
|
20 #include <spentry.h> |
|
21 #include <spproperty.h> |
|
22 #include <e32property.h> |
|
23 #include <imconnectionproviderconsts.h> |
|
24 |
|
25 #include "cvimpstdetailsviewpluginfactory.h" |
|
26 #include "cvimpstdetailsviewplugin.h" |
|
27 #include "vimpstdebugtrace.h" |
|
28 // meco service uid |
|
29 #define KMECOIMPLEMENTATIONUID 0x20012423 |
|
30 // --------------------------------------------------------------------------- |
|
31 // CVIMPSTDetailsViewPluginFactory::NewL |
|
32 // --------------------------------------------------------------------------- |
|
33 // |
|
34 CVIMPSTDetailsViewPluginFactory* CVIMPSTDetailsViewPluginFactory::NewL() |
|
35 { |
|
36 CVIMPSTDetailsViewPluginFactory* self = new ( ELeave ) CVIMPSTDetailsViewPluginFactory(); |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop();//self, do not pass the parameter to pop since this is an M Class.. |
|
40 return self; |
|
41 } |
|
42 |
|
43 // --------------------------------------------------------------------------- |
|
44 // CVIMPSTDetailsViewPluginFactory::CVIMPSTDetailsViewPluginFactory |
|
45 // --------------------------------------------------------------------------- |
|
46 // |
|
47 CVIMPSTDetailsViewPluginFactory::CVIMPSTDetailsViewPluginFactory(): |
|
48 iServiceId( 0 ) |
|
49 { |
|
50 } |
|
51 |
|
52 // --------------------------------------------------------------------------- |
|
53 // CVIMPSTDetailsViewPluginFactory::ConstructL |
|
54 // --------------------------------------------------------------------------- |
|
55 // |
|
56 void CVIMPSTDetailsViewPluginFactory::ConstructL() |
|
57 { |
|
58 TRACED( T_LIT("CVIMPSTDetailsViewPluginFactory::ConstructL() start") ); |
|
59 RProperty::Define(KMeCoPropertyUid, KMeCoXSPDetailsServiceIdKey, RProperty::EInt, |
|
60 ECapabilityReadUserData ,ECapabilityWriteUserData); |
|
61 |
|
62 ReadServiceIdL(); |
|
63 if(iServiceIds.Count() == 0) |
|
64 { |
|
65 User::Leave(KErrArgument); |
|
66 } |
|
67 TRACED( T_LIT("CVIMPSTDetailsViewPluginFactory::ConstructL() end") ); |
|
68 } |
|
69 // --------------------------------------------------------------------------- |
|
70 // CVIMPSTDetailsViewPluginFactory::~CVIMPSTDetailsViewPluginFactory |
|
71 // --------------------------------------------------------------------------- |
|
72 // |
|
73 CVIMPSTDetailsViewPluginFactory::~CVIMPSTDetailsViewPluginFactory() |
|
74 { |
|
75 iServiceIds.Reset(); |
|
76 iServiceIds.Close(); |
|
77 RProperty::Set(KMeCoPropertyUid, KMeCoXSPDetailsServiceIdKey, 0 ); //reset to zero |
|
78 } |
|
79 |
|
80 // --------------------------------------------------------------------------- |
|
81 // CVIMPSTDetailsViewPluginFactory::TabViewCount |
|
82 // --------------------------------------------------------------------------- |
|
83 // |
|
84 TInt CVIMPSTDetailsViewPluginFactory::TabViewCount() |
|
85 { |
|
86 // read the service id from RProperty |
|
87 RProperty::Get(KMeCoPropertyUid, KMeCoXSPDetailsServiceIdKey, iServiceId ); |
|
88 TInt returnVal = 0; |
|
89 if( iServiceId <= 0 ) |
|
90 { |
|
91 TRACED( T_LIT("CVIMPSTDetailsViewPluginFactory::TabViewCount() iservice <=0") ); |
|
92 return iServiceIds.Count(); |
|
93 } |
|
94 else |
|
95 { |
|
96 TRACED( T_LIT("CVIMPSTDetailsViewPluginFactory::TabViewCount() iservice > 0") ); |
|
97 iServiceIds.Reset(); |
|
98 iServiceIds.Append( iServiceId ); |
|
99 returnVal = 1; |
|
100 } |
|
101 return returnVal; |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------------------------- |
|
105 // CVIMPSTDetailsViewPluginFactory::CreateTabViewL |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 CCCAppViewPluginBase* CVIMPSTDetailsViewPluginFactory::CreateTabViewL( TInt aIndex ) |
|
109 { |
|
110 TRACED( T_LIT("CVIMPSTDetailsViewPluginFactory::CreateTabViewL() start") ); |
|
111 TRACED( T_LIT("CVIMPSTDetailsViewPluginFactory::CreateTabViewL() aIndex = %d"),aIndex ); |
|
112 CCCAppViewPluginBase* viewPluginBase = NULL; |
|
113 if( aIndex < iServiceIds.Count() && aIndex >= 0 ) |
|
114 { |
|
115 TRACED( T_LIT("CVIMPSTDetailsViewPluginFactory::CreateTabViewL() creating view aIndex = %d"),aIndex ); |
|
116 viewPluginBase = CVIMPSTDetailsViewPlugin::NewL( iServiceIds[aIndex]); |
|
117 TRACED( T_LIT("CVIMPSTDetailsViewPluginFactory::CreateTabViewL() view created") ); |
|
118 } |
|
119 else |
|
120 { |
|
121 User::Leave(KErrArgument); |
|
122 } |
|
123 TRACED( T_LIT("CVIMPSTDetailsViewPluginFactory::CreateTabViewL() end ") ); |
|
124 return viewPluginBase; |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // CVIMPSTDetailsViewPluginFactory::ReadServiceIdL |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
|
131 TInt CVIMPSTDetailsViewPluginFactory::ReadServiceIdL() |
|
132 { |
|
133 CSPSettings* settings = CSPSettings::NewLC(); |
|
134 iServiceIds.Reset(); |
|
135 ///////////////////////Get Service Id//////////////// |
|
136 RArray<TServiceId> services; |
|
137 CleanupClosePushL( services ); |
|
138 settings->FindServiceIdsL( services ); |
|
139 const TInt serviceCount = services.Count(); |
|
140 for ( TInt i( 0 ); i < serviceCount; i++ ) |
|
141 { |
|
142 TInt refContactUid = KErrNotFound; |
|
143 CSPProperty* property = CSPProperty::NewLC(); |
|
144 settings->FindPropertyL( services[i],EPropertyContactViewPluginId,*property ); |
|
145 if ( property ) |
|
146 { |
|
147 property->GetValue( refContactUid ); |
|
148 } |
|
149 CleanupStack::PopAndDestroy( property ); |
|
150 if ( (TUid::Uid( refContactUid ) == TUid::Uid( KMECOIMPLEMENTATIONUID )) |
|
151 || (TUid::Uid( refContactUid ) == TUid::Uid( 0x20007B6D ) ) |
|
152 || (TUid::Uid( refContactUid ) == TUid::Uid( 0x2002B334 ))) |
|
153 { |
|
154 iServiceIds.Append( services[i] ); |
|
155 } |
|
156 } |
|
157 CleanupStack::PopAndDestroy( &services ); |
|
158 CleanupStack::PopAndDestroy( settings ); |
|
159 return iServiceIds.Count(); |
|
160 } |