author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:15:33 +0300 | |
branch | RCL_3 |
changeset 85 | 38bb213f60ba |
parent 68 | 9da50d567e3c |
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> |
|
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
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 |
||
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
121 |
void CPbk2CmdItemMyCard::MyCardEvent( MPbk2MyCardObserver::TMyCardStatusEvent aEvent ) |
63 | 122 |
{ |
85
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
123 |
// always inform these |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
124 |
if( aEvent == EStateThumbnailLoaded || |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
125 |
aEvent == EStateThumbnailNotFound ) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
126 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
127 |
if( iObserver ) |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
128 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
129 |
iObserver->CmdItemVisibilityChanged( CommandId(), ETrue ); |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
130 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
131 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
132 |
// status change |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
133 |
else |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
134 |
{ |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
135 |
NotifyVisibiltyChange( IsEnabled() ) ; |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
136 |
} |
38bb213f60ba
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
68
diff
changeset
|
137 |
} |
63 | 138 |
|
139 |
void CPbk2CmdItemMyCard::FormatDataL( |
|
140 |
MPbk2DoubleListboxDataElement& aDataElement ) |
|
141 |
{ |
|
142 |
HBufC* txt = NULL; |
|
143 |
TPbk2IconId iconId; |
|
144 |
MVPbkContactLink* link = iMyCard.MyCardLink(); |
|
145 |
CSpbContentProvider::TSpbContentType type = CSpbContentProvider::ETypeNone; |
|
146 |
||
147 |
//if link exists |
|
148 |
if( link ) |
|
149 |
{ |
|
150 |
iStatusProvider.GetContentL( *link, txt, iconId, type ); |
|
151 |
} |
|
152 |
||
153 |
if( link && type != CSpbContentProvider::ETypeSocialStatus ) |
|
154 |
{ |
|
155 |
MVPbkStoreContact* storeContact = iMyCard.MyCardStoreContact(); |
|
156 |
||
157 |
if( storeContact ) |
|
158 |
{ |
|
159 |
CPbk2ApplicationServices* appServices = CPbk2ApplicationServices::InstanceL(); |
|
160 |
MPbk2ContactNameFormatter& nameFormatter = appServices->NameFormatter(); |
|
161 |
||
162 |
delete txt; |
|
163 |
txt = NULL; |
|
164 |
||
165 |
if( FeatureManager::FeatureSupported( KFeatureIdFfContactsCompanyNames ) ) |
|
166 |
{ |
|
167 |
MPbk2ContactNameFormatter2* nameformatterExtension = |
|
168 |
reinterpret_cast<MPbk2ContactNameFormatter2*>( nameFormatter. |
|
169 |
ContactNameFormatterExtension( MPbk2ContactNameFormatterExtension2Uid ) ); |
|
170 |
||
171 |
txt = nameformatterExtension->GetContactTitleWithCompanyNameL( storeContact->Fields(), |
|
172 |
MPbk2ContactNameFormatter::EUseSeparator | |
|
173 |
MPbk2ContactNameFormatter::EPreserveLeadingSpaces ); |
|
174 |
} |
|
175 |
else |
|
176 |
{ |
|
177 |
txt = nameFormatter.GetContactTitleL( storeContact->Fields(), |
|
178 |
MPbk2ContactNameFormatter::EUseSeparator | |
|
179 |
MPbk2ContactNameFormatter::EPreserveLeadingSpaces ); |
|
180 |
} |
|
181 |
||
182 |
Release( appServices ); |
|
183 |
} |
|
184 |
} |
|
185 |
||
186 |
aDataElement.SetText( MPbk2DoubleListboxDataElement::EStatusText, txt, |
|
187 |
MPbk2DoubleListboxDataElement::ETypeGenericText ); |
|
188 |
aDataElement.SetIconId( MPbk2DoubleListboxDataElement::EThumbnail,iMyCard.MyCardIconId() ); |
|
189 |
} |
|
190 |
||
191 |
const MVPbkContactLink* CPbk2CmdItemMyCard::Link() |
|
192 |
{ |
|
193 |
return iMyCard.MyCardLink(); |
|
194 |
} |
|
195 |
||
196 |
||
197 |
||
198 |
void CPbk2CmdItemMyCard::NotifyVisibiltyChange( TBool aShow ) |
|
199 |
{ |
|
200 |
TBool change(EFalse); |
|
201 |
TBool show = aShow && iMyCard.MyCardState() != CPbk2MyCard::EUnkown; |
|
202 |
||
203 |
if( show ) |
|
204 |
{ |
|
205 |
if( iLastNotif!=EmcLastNotifVisible ) |
|
206 |
{ |
|
207 |
change = ETrue; |
|
208 |
} |
|
209 |
} |
|
210 |
else |
|
211 |
{ |
|
212 |
//no op for EmcLastNotifHidden and EmcLastNotifNone |
|
213 |
if( iLastNotif==EmcLastNotifVisible ) |
|
214 |
{ |
|
215 |
change = ETrue; |
|
216 |
} |
|
217 |
} |
|
218 |
||
219 |
if( iObserver && change ) |
|
220 |
{ |
|
221 |
iObserver->CmdItemVisibilityChanged(CommandId(), show); |
|
222 |
iLastNotif = show ? EmcLastNotifVisible : EmcLastNotifHidden; |
|
223 |
} |
|
224 |
} |
|
225 |
||
226 |
// end of file |