|
1 /* |
|
2 * Copyright (c) 2002-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: A class for showing copy contacts results |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "TPbk2CopyContactsResults.h" |
|
22 |
|
23 #include <StringLoader.h> |
|
24 #include <aknnotewrappers.h> |
|
25 #include <Pbk2Commands.rsg> |
|
26 |
|
27 namespace{ |
|
28 |
|
29 const TInt KGranularity( 2 ); |
|
30 |
|
31 } |
|
32 |
|
33 const TInt KZero = 0; |
|
34 // ============================ MEMBER FUNCTIONS =============================== |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // TPbk2CopyContactsResults::TPbk2CopyContactsResults |
|
38 // C++ default constructor can NOT contain any code, that |
|
39 // might leave. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 EXPORT_C TPbk2CopyContactsResults::TPbk2CopyContactsResults() |
|
43 : iCopied( KZero ), |
|
44 iNotCopied( KZero ), |
|
45 iName( KNullDesC ), |
|
46 iOneContactCopiedResId( KErrNotFound ), |
|
47 iOneContactNotCopiedResId( KErrNotFound ), |
|
48 iMultipleContactsCopiedResId( KErrNotFound ) |
|
49 { |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // TPbk2CopyContactsResults::TPbk2CopyContactsResults |
|
54 // C++ default constructor can NOT contain any code, that |
|
55 // might leave. |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 EXPORT_C TPbk2CopyContactsResults::TPbk2CopyContactsResults |
|
59 ( TInt aCopied, TInt aTotal ) |
|
60 : iCopied( aCopied ), |
|
61 iNotCopied( aTotal - aCopied ), |
|
62 iName( KNullDesC ), |
|
63 iOneContactCopiedResId( KErrNotFound ), |
|
64 iOneContactNotCopiedResId( KErrNotFound ), |
|
65 iMultipleContactsCopiedResId( KErrNotFound ) |
|
66 { |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // TPbk2CopyContactsResults::TPbk2CopyContactsResults |
|
71 // C++ default constructor can NOT contain any code, that |
|
72 // might leave. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C TPbk2CopyContactsResults::TPbk2CopyContactsResults |
|
76 ( TInt aCopied, const TDesC& aName ) |
|
77 : iCopied( aCopied ), |
|
78 iNotCopied( KZero ), |
|
79 iName( aName ), |
|
80 iOneContactCopiedResId( KErrNotFound ), |
|
81 iOneContactNotCopiedResId( KErrNotFound ), |
|
82 iMultipleContactsCopiedResId( KErrNotFound ) |
|
83 { |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // TPbk2CopyContactsResults::ShowNoteL |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 EXPORT_C void TPbk2CopyContactsResults::ShowNoteL() |
|
91 { |
|
92 HBufC* prompt = NULL; |
|
93 |
|
94 if ( iName.Length() == 0 ) |
|
95 { |
|
96 if ( iNotCopied == 0 ) |
|
97 { |
|
98 if ( iMultipleContactsCopiedResId == KErrNotFound ) |
|
99 { |
|
100 // Use default text resource |
|
101 prompt = StringLoader::LoadLC |
|
102 ( R_QTN_PBCOP_NOTE_N_ENTRY_COPY_PB, iCopied ); |
|
103 } |
|
104 else |
|
105 { |
|
106 prompt = StringLoader::LoadLC |
|
107 ( iMultipleContactsCopiedResId, iCopied ); |
|
108 } |
|
109 } |
|
110 else // (iNotCopied > 0) |
|
111 { |
|
112 if ( iCopied == 1 && iNotCopied == 1 ) |
|
113 { |
|
114 prompt = |
|
115 StringLoader::LoadLC( R_QTN_PBCOP_INFO_ONE_OK_ONE_NOT ); |
|
116 } |
|
117 else if ( iCopied == 1 && iNotCopied > 1 ) |
|
118 { |
|
119 prompt = StringLoader::LoadLC( |
|
120 R_QTN_PBCOP_INFO_ONE_OK_N_NOT, iNotCopied); |
|
121 } |
|
122 else if ( ( iCopied == 0 || iCopied > 1 ) && iNotCopied == 1 ) |
|
123 { |
|
124 prompt = |
|
125 StringLoader::LoadLC |
|
126 ( R_QTN_PBCOP_INFO_N_OK_ONE_NOT, iCopied ); |
|
127 } |
|
128 else if ((iCopied == 0 || iCopied > 1) && |
|
129 (iNotCopied == 0 || iNotCopied > 1)) |
|
130 { |
|
131 CArrayFixFlat<TInt>* array = |
|
132 new( ELeave ) CArrayFixFlat<TInt>( KGranularity ); |
|
133 CleanupStack::PushL( array ); |
|
134 array->AppendL( iCopied ); |
|
135 array->AppendL( iNotCopied ); |
|
136 prompt = |
|
137 StringLoader::LoadL( R_QTN_PBCOP_INFO_N_OK_N_NOT, *array ); |
|
138 CleanupStack::PopAndDestroy( array ); |
|
139 CleanupStack::PushL( prompt ); |
|
140 } |
|
141 } |
|
142 } |
|
143 else // Only one contact was marked to be copied |
|
144 { |
|
145 if ( iCopied > 0 ) |
|
146 { |
|
147 if ( iOneContactCopiedResId == KErrNotFound ) |
|
148 { |
|
149 // Use default text resource |
|
150 prompt = StringLoader::LoadLC |
|
151 ( R_QTN_PBCOP_NOTE_CONTACT_COPIED_PB2, iName ); |
|
152 } |
|
153 else |
|
154 { |
|
155 prompt = StringLoader::LoadLC( iOneContactCopiedResId, iName ); |
|
156 } |
|
157 } |
|
158 else |
|
159 { |
|
160 if ( iOneContactNotCopiedResId == KErrNotFound ) |
|
161 { |
|
162 // Use default text resource |
|
163 prompt = StringLoader::LoadLC |
|
164 ( R_QTN_PBCOP_NOTE_ENTRY_NOT_COPIED, iName ); |
|
165 } |
|
166 else |
|
167 { |
|
168 prompt = StringLoader::LoadLC( iOneContactNotCopiedResId, iName ); |
|
169 } |
|
170 } |
|
171 } |
|
172 |
|
173 if ( prompt ) |
|
174 { |
|
175 CAknConfirmationNote* dlg = new( ELeave ) CAknConfirmationNote( EFalse ); |
|
176 dlg->SetTimeout( CAknNoteDialog::ELongTimeout ); |
|
177 dlg->ExecuteLD( *prompt ); |
|
178 CleanupStack::PopAndDestroy(prompt ); |
|
179 } |
|
180 } |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // TPbk2CopyContactsResults::ShowErrorNoteL |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 EXPORT_C void TPbk2CopyContactsResults::ShowErrorNoteL() |
|
187 { |
|
188 HBufC* prompt = StringLoader::LoadLC( R_QTN_PBCOP_NOTE_COPY_NOT_WORK ); |
|
189 CAknErrorNote* note = new( ELeave ) CAknErrorNote( ETrue ); |
|
190 note->ExecuteLD( *prompt ); |
|
191 CleanupStack::PopAndDestroy( prompt ); |
|
192 } |
|
193 |
|
194 EXPORT_C void |
|
195 TPbk2CopyContactsResults::SetOneContactCopiedTextRes( TInt aResId ) |
|
196 { |
|
197 iOneContactCopiedResId = aResId; |
|
198 } |
|
199 |
|
200 EXPORT_C void |
|
201 TPbk2CopyContactsResults::SetOneContactNotCopiedTextRes( TInt aResId ) |
|
202 { |
|
203 iOneContactNotCopiedResId = aResId; |
|
204 } |
|
205 |
|
206 EXPORT_C void |
|
207 TPbk2CopyContactsResults::SetMultipleContactsCopiedTextRes( TInt aResId ) |
|
208 { |
|
209 iMultipleContactsCopiedResId = aResId; |
|
210 } |
|
211 |
|
212 // End of File |