author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 14 Sep 2010 20:54:53 +0300 | |
branch | RCL_3 |
changeset 68 | 9da50d567e3c |
parent 63 | f4a778e096c2 |
child 85 | 38bb213f60ba |
permissions | -rw-r--r-- |
63 | 1 |
/* |
2 |
* Copyright (c) 2005-2007 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 |
// Includes |
|
19 |
#include "cpbk2cmditemmycard.h" |
|
20 |
||
21 |
// Pbk2 |
|
22 |
#include "CPbk2AddFavoritesVisibility.h" |
|
23 |
#include <Pbk2Commands.hrh> |
|
68
9da50d567e3c
Revision: 201033
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
63
diff
changeset
|
24 |
#include <pbk2exnameslistres.rsg> |
63 | 25 |
#include <MPbk2AppUi.h> |
26 |
#include <MPbk2ApplicationServices.h> |
|
27 |
#include "cpbk2mycard.h" |
|
28 |
#include "Pbk2NamesListEx.hrh" |
|
29 |
#include <TPbk2IconId.h> |
|
30 |
#include <Pbk2InternalUID.h> |
|
31 |
#include <MVPbkContactLink.h> |
|
32 |
#include <spbcontentprovider.h> |
|
33 |
#include <CPbk2ApplicationServices.h> |
|
34 |
#include <MVPbkStoreContact.h> |
|
35 |
#include <MPbk2ContactNameFormatter.h> |
|
36 |
#include <MPbk2ContactNameFormatter2.h> |
|
37 |
#include <featmgr.h> |
|
38 |
||
39 |
// General |
|
40 |
#include <StringLoader.h> |
|
41 |
||
42 |
#include "pbk2contactuicontroldoublelistboxextension.h" |
|
43 |
||
44 |
CPbk2CmdItemMyCard* CPbk2CmdItemMyCard::NewLC( |
|
45 |
CPbk2MyCard& aMyCard, |
|
46 |
CSpbContentProvider& aStatusProvider ) |
|
47 |
{ |
|
48 |
CPbk2CmdItemMyCard* self = new (ELeave) CPbk2CmdItemMyCard( |
|
49 |
aMyCard, aStatusProvider ); |
|
50 |
CleanupStack::PushL( self ); |
|
51 |
self->ConstructL(); |
|
52 |
return self; |
|
53 |
} |
|
54 |
||
55 |
void CPbk2CmdItemMyCard::ConstructL() |
|
56 |
{ |
|
57 |
iCreateMyCardText = StringLoader::LoadL( R_QTN_CONTACTS_MC_SET_UP_MY_CARD ); |
|
58 |
iOpenMyCardText = StringLoader::LoadL( R_QTN_CONTACTS_MC_MY_CARD ); |
|
59 |
iMyCard.SetObserverL(*this); |
|
60 |
} |
|
61 |
||
62 |
CPbk2CmdItemMyCard::CPbk2CmdItemMyCard( |
|
63 |
CPbk2MyCard& aMyCard, |
|
64 |
CSpbContentProvider& aStatusProvider ) |
|
65 |
: iMyCard(aMyCard), |
|
66 |
iStatusProvider( aStatusProvider ) |
|
67 |
{ |
|
68 |
} |
|
69 |
||
70 |
CPbk2CmdItemMyCard::~CPbk2CmdItemMyCard() |
|
71 |
{ |
|
72 |
delete iCreateMyCardText; |
|
73 |
delete iOpenMyCardText; |
|
74 |
iMyCard.RemoveObserver(*this); |
|
75 |
} |
|
76 |
||
77 |
TPtrC CPbk2CmdItemMyCard::NameForUi() const |
|
78 |
{ |
|
79 |
TPtrC ptr(iOpenMyCardText->Des()); |
|
80 |
if (iMyCard.MyCardState() == CPbk2MyCard::ENonExisting) |
|
81 |
{ |
|
82 |
ptr.Set(iCreateMyCardText->Des()); |
|
83 |
} |
|
84 |
return ptr; |
|
85 |
} |
|
86 |
||
87 |
TBool CPbk2CmdItemMyCard::IsEnabled() const |
|
88 |
{ |
|
89 |
return iEnabled; |
|
90 |
} |
|
91 |
||
92 |
void CPbk2CmdItemMyCard::SetEnabled( TBool aEnabled ) |
|
93 |
{ |
|
94 |
iEnabled = aEnabled; |
|
95 |
NotifyVisibiltyChange(aEnabled); |
|
96 |
} |
|
97 |
||
98 |
TInt CPbk2CmdItemMyCard::CommandId() const |
|
99 |
{ |
|
100 |
return EPbk2CmdOpenMyCard; |
|
101 |
} |
|
102 |
||
103 |
void CPbk2CmdItemMyCard::SetVisibilityObserver( |
|
104 |
MPbk2CmdItemVisibilityObserver* aObserver) |
|
105 |
{ |
|
106 |
iObserver = aObserver; |
|
107 |
NotifyVisibiltyChange(IsEnabled()); |
|
108 |
} |
|
109 |
||
110 |
||
111 |
TAny* CPbk2CmdItemMyCard::ControlCmdItemExtension( |
|
112 |
TUid aExtensionUid ) |
|
113 |
{ |
|
114 |
if( aExtensionUid == TUid::Uid( KPbk2ControlCmdItemExtensionUID ) ) |
|
115 |
{ |
|
116 |
return static_cast<MPbk2DoubleListboxCmdItemExtension*>( this ); |
|
117 |
} |
|
118 |
return NULL; |
|
119 |
} |
|
120 |
||
121 |
void CPbk2CmdItemMyCard::MyCardEvent( MPbk2MyCardObserver::TMyCardStatusEvent /*aEvent*/ ) |
|
122 |
{ |
|
123 |
NotifyVisibiltyChange( IsEnabled() ); |
|
124 |
} |
|
125 |
||
126 |
void CPbk2CmdItemMyCard::FormatDataL( |
|
127 |
MPbk2DoubleListboxDataElement& aDataElement ) |
|
128 |
{ |
|
129 |
HBufC* txt = NULL; |
|
130 |
TPbk2IconId iconId; |
|
131 |
MVPbkContactLink* link = iMyCard.MyCardLink(); |
|
132 |
CSpbContentProvider::TSpbContentType type = CSpbContentProvider::ETypeNone; |
|
133 |
||
134 |
//if link exists |
|
135 |
if( link ) |
|
136 |
{ |
|
137 |
iStatusProvider.GetContentL( *link, txt, iconId, type ); |
|
138 |
} |
|
139 |
||
140 |
if( link && type != CSpbContentProvider::ETypeSocialStatus ) |
|
141 |
{ |
|
142 |
MVPbkStoreContact* storeContact = iMyCard.MyCardStoreContact(); |
|
143 |
||
144 |
if( storeContact ) |
|
145 |
{ |
|
146 |
CPbk2ApplicationServices* appServices = CPbk2ApplicationServices::InstanceL(); |
|
147 |
MPbk2ContactNameFormatter& nameFormatter = appServices->NameFormatter(); |
|
148 |
||
149 |
delete txt; |
|
150 |
txt = NULL; |
|
151 |
||
152 |
if( FeatureManager::FeatureSupported( KFeatureIdFfContactsCompanyNames ) ) |
|
153 |
{ |
|
154 |
MPbk2ContactNameFormatter2* nameformatterExtension = |
|
155 |
reinterpret_cast<MPbk2ContactNameFormatter2*>( nameFormatter. |
|
156 |
ContactNameFormatterExtension( MPbk2ContactNameFormatterExtension2Uid ) ); |
|
157 |
||
158 |
txt = nameformatterExtension->GetContactTitleWithCompanyNameL( storeContact->Fields(), |
|
159 |
MPbk2ContactNameFormatter::EUseSeparator | |
|
160 |
MPbk2ContactNameFormatter::EPreserveLeadingSpaces ); |
|
161 |
} |
|
162 |
else |
|
163 |
{ |
|
164 |
txt = nameFormatter.GetContactTitleL( storeContact->Fields(), |
|
165 |
MPbk2ContactNameFormatter::EUseSeparator | |
|
166 |
MPbk2ContactNameFormatter::EPreserveLeadingSpaces ); |
|
167 |
} |
|
168 |
||
169 |
Release( appServices ); |
|
170 |
} |
|
171 |
} |
|
172 |
||
173 |
aDataElement.SetText( MPbk2DoubleListboxDataElement::EStatusText, txt, |
|
174 |
MPbk2DoubleListboxDataElement::ETypeGenericText ); |
|
175 |
aDataElement.SetIconId( MPbk2DoubleListboxDataElement::EThumbnail,iMyCard.MyCardIconId() ); |
|
176 |
} |
|
177 |
||
178 |
const MVPbkContactLink* CPbk2CmdItemMyCard::Link() |
|
179 |
{ |
|
180 |
return iMyCard.MyCardLink(); |
|
181 |
} |
|
182 |
||
183 |
||
184 |
||
185 |
void CPbk2CmdItemMyCard::NotifyVisibiltyChange( TBool aShow ) |
|
186 |
{ |
|
187 |
TBool change(EFalse); |
|
188 |
TBool show = aShow && iMyCard.MyCardState() != CPbk2MyCard::EUnkown; |
|
189 |
||
190 |
if( show ) |
|
191 |
{ |
|
192 |
if( iLastNotif!=EmcLastNotifVisible ) |
|
193 |
{ |
|
194 |
change = ETrue; |
|
195 |
} |
|
196 |
} |
|
197 |
else |
|
198 |
{ |
|
199 |
//no op for EmcLastNotifHidden and EmcLastNotifNone |
|
200 |
if( iLastNotif==EmcLastNotifVisible ) |
|
201 |
{ |
|
202 |
change = ETrue; |
|
203 |
} |
|
204 |
} |
|
205 |
||
206 |
if( iObserver && change ) |
|
207 |
{ |
|
208 |
iObserver->CmdItemVisibilityChanged(CommandId(), show); |
|
209 |
iLastNotif = show ? EmcLastNotifVisible : EmcLastNotifHidden; |
|
210 |
} |
|
211 |
} |
|
212 |
||
213 |
// end of file |