1 /* |
|
2 * Copyright (c) 2005-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: Methods for Sync Log handler class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "NSmlDMSyncDialog.h" |
|
22 #include "NSmlDMSyncUtil.h" |
|
23 #include <NSmlDMSync.rsg> |
|
24 #include "NSmlDMSyncProfile.h" |
|
25 #include "NSmlDMSyncDebug.h" |
|
26 |
|
27 #include <aknPopup.h> |
|
28 #include <aknlists.h> |
|
29 #include <StringLoader.h> |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // ShowDialogL |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 TBool CNSmlDMSyncDialog::ShowDialogL( TInt aProfileId, |
|
36 RSyncMLSession* aSyncSession ) |
|
37 { |
|
38 CNSmlDMSyncDialog* dialog = CNSmlDMSyncDialog::NewL( aProfileId, |
|
39 aSyncSession ); |
|
40 CleanupStack::PushL( dialog ); |
|
41 dialog->PopupLogViewL(); |
|
42 CleanupStack::PopAndDestroy( dialog ); |
|
43 return ETrue; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // NewL |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CNSmlDMSyncDialog* CNSmlDMSyncDialog::NewL( TInt aProfileId, |
|
51 RSyncMLSession* aSyncSession ) |
|
52 { |
|
53 CNSmlDMSyncDialog* self = new ( ELeave ) CNSmlDMSyncDialog( aProfileId, |
|
54 aSyncSession ); |
|
55 CleanupStack::PushL(self); |
|
56 self->ConstructL(); |
|
57 CleanupStack::Pop(); |
|
58 return(self); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CNSmlDMSyncDialog |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CNSmlDMSyncDialog::CNSmlDMSyncDialog( TInt aProfileId, |
|
66 RSyncMLSession* aSyncSession ) |
|
67 { |
|
68 iProfileId = aProfileId; |
|
69 iSyncSession = aSyncSession; |
|
70 |
|
71 __ASSERT_DEBUG(iSyncSession, TUtil::Panic(KErrArgument)); |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // Symbian OS default constructor can leave. |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 void CNSmlDMSyncDialog::ConstructL() |
|
79 { |
|
80 FLOG( "CNSmlDMSyncDialog::ConstructL()" ); |
|
81 |
|
82 iLogItems = CEikonEnv::Static()->ReadDesCArrayResourceL( R_SML_LOG_ITEMS ); |
|
83 |
|
84 iProfile = CNSmlDMSyncProfile::NewL( KUidSmlSyncApp.iUid, iSyncSession ); |
|
85 iProfile->OpenL( iProfileId, ESmlOpenReadWrite ); |
|
86 |
|
87 iHistoryJob = iProfile->LatestHistoryJob(); |
|
88 if ( !iHistoryJob ) |
|
89 { |
|
90 FLOG( "CNSmlDMSyncDialog::ConstructL() KErrNotFound" ); |
|
91 User::Leave( KErrNotFound ); |
|
92 } |
|
93 } |
|
94 |
|
95 // ---------------------------------------------------------------------------- |
|
96 // Destructor |
|
97 // ---------------------------------------------------------------------------- |
|
98 // |
|
99 CNSmlDMSyncDialog::~CNSmlDMSyncDialog() |
|
100 { |
|
101 delete iLogItems; |
|
102 delete iProfile; |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // PopupLogViewL |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 void CNSmlDMSyncDialog::PopupLogViewL() |
|
110 { |
|
111 FLOG( "CNSmlDMSyncDialog::PopupLogViewL()" ); |
|
112 |
|
113 CAknSingleHeadingPopupMenuStyleListBox* listBox = |
|
114 new (ELeave) CAknSingleHeadingPopupMenuStyleListBox; |
|
115 CleanupStack::PushL( listBox ); |
|
116 |
|
117 CAknPopupList* popupList = CAknPopupList::NewL( |
|
118 listBox, |
|
119 R_AVKON_SOFTKEYS_OK_EMPTY__OK, |
|
120 AknPopupLayouts::EMenuWindow ); |
|
121 CleanupStack::PushL( popupList ); |
|
122 |
|
123 listBox->ConstructL( popupList, EAknListBoxViewerFlags ); |
|
124 |
|
125 CDesCArray* array = ( CDesCArray* )listBox->Model()->ItemTextArray(); |
|
126 listBox->CreateScrollBarFrameL( ETrue ); |
|
127 listBox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
128 CEikScrollBarFrame::EOff, |
|
129 CEikScrollBarFrame::EAuto ); |
|
130 |
|
131 // read synclog and trap error if there aren't any content types |
|
132 TRAP_IGNORE( FormatLogViewListL( array ) ); |
|
133 |
|
134 FLOG( "CNSmlDMSyncDialog::PopupLogViewL() set title" ); |
|
135 |
|
136 HBufC* titleText = StringLoader::LoadLC( R_SML_LOG_SYNCLOG_TITLE ); |
|
137 popupList->SetTitleL( titleText->Des() ); |
|
138 CleanupStack::PopAndDestroy( titleText ); |
|
139 popupList->ExecuteLD(); |
|
140 |
|
141 CleanupStack::Pop( popupList ); |
|
142 CleanupStack::PopAndDestroy( listBox ); |
|
143 |
|
144 FLOG( "CNSmlDMSyncDialog::PopupLogViewL() Done" ); |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // FormatLogViewListL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 void CNSmlDMSyncDialog::FormatLogViewListL( CDesCArray* aArray ) |
|
152 { |
|
153 FLOG( "CNSmlDMSyncDialog::FormatLogViewListL()" ); |
|
154 |
|
155 TBuf<KBufSize> buf( KNullDesC ); |
|
156 TInt num = KErrNotFound; |
|
157 |
|
158 aArray->Reset(); |
|
159 TBuf<KBufSize256> tempBuf; |
|
160 |
|
161 tempBuf.Append( (*iLogItems)[EHeadingProfile] ); //profile name heading |
|
162 tempBuf.Append( KNSmlTab ); |
|
163 FLOG( "CNSmlDMSyncDialog::FormatLogViewListL() get name" ); |
|
164 iProfile->GetName( buf ); |
|
165 tempBuf.Append( buf ); |
|
166 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( tempBuf ); |
|
167 aArray->AppendL( tempBuf ); |
|
168 |
|
169 tempBuf.Zero(); |
|
170 tempBuf.Append( (*iLogItems)[EHeadingServer] ); // server name heading |
|
171 tempBuf.Append( KNSmlTab ); |
|
172 |
|
173 iProfile->GetHostAddress( buf, num ); |
|
174 tempBuf.Append( buf ); |
|
175 aArray->AppendL( tempBuf ); |
|
176 |
|
177 TTime time = iHistoryJob->TimeStamp(); |
|
178 |
|
179 TUtil::GetDateTextL(buf, time); |
|
180 tempBuf.Zero(); |
|
181 tempBuf.Append( (*iLogItems)[EHeadingDate] ); // synchronisation date heading |
|
182 tempBuf.Append( KNSmlTab ); |
|
183 tempBuf.Append( buf ); |
|
184 AknTextUtils::DisplayTextLanguageSpecificNumberConversion(tempBuf); |
|
185 aArray->AppendL(tempBuf); |
|
186 |
|
187 TUtil::GetTimeTextL(buf, time); |
|
188 |
|
189 tempBuf.Zero(); |
|
190 tempBuf.Append((*iLogItems)[EHeadingTime]); // synchronisation time heading |
|
191 tempBuf.Append(KNSmlTab); |
|
192 tempBuf.Append(buf); |
|
193 |
|
194 AknTextUtils::DisplayTextLanguageSpecificNumberConversion( tempBuf ); |
|
195 aArray->AppendL(tempBuf); |
|
196 |
|
197 // check sync error |
|
198 TInt status = iHistoryJob->ResultCode(); |
|
199 TInt syncTaskError = KErrNone; |
|
200 TInt count = iHistoryJob->TaskCount(); |
|
201 for (TInt i=0; i<count; i++) |
|
202 { |
|
203 const CSyncMLHistoryJob::TTaskInfo& taskInfo = iHistoryJob->TaskAt(i); |
|
204 if (taskInfo.iError != KErrNone) |
|
205 { |
|
206 syncTaskError = taskInfo.iError; |
|
207 } |
|
208 } |
|
209 iProfile->CloseHistoryLog(); |
|
210 |
|
211 tempBuf.Zero(); |
|
212 tempBuf.Append((*iLogItems)[EHeadingStatus]); // status heading |
|
213 tempBuf.Append(KNSmlTab); |
|
214 |
|
215 if ( status != KErrNone ) |
|
216 { |
|
217 if ( status == KErrCancel ) |
|
218 { |
|
219 ReadL( buf, R_QTN_SML_LOG_CANCELLED ); |
|
220 } |
|
221 else |
|
222 { |
|
223 ReadL( buf, R_QTN_SML_LOG_ERR ); |
|
224 } |
|
225 tempBuf.Append( buf ); |
|
226 aArray->AppendL( tempBuf ); |
|
227 return; |
|
228 } |
|
229 else if ( syncTaskError != KErrNone ) |
|
230 { |
|
231 ReadL( buf, R_QTN_SML_LOG_ERR ); |
|
232 tempBuf.Append( buf); |
|
233 aArray->AppendL( tempBuf ); |
|
234 } |
|
235 else |
|
236 { |
|
237 ReadL( buf, R_QTN_SML_LOG_OK ); |
|
238 tempBuf.Append( buf ); |
|
239 aArray->AppendL( tempBuf ); |
|
240 } |
|
241 |
|
242 FLOG( "CNSmlDMSyncDialog::FormatLogViewListL() Done" ); |
|
243 } |
|
244 |
|
245 // ----------------------------------------------------------------------------- |
|
246 // CNSmlDMSyncDialog::ReadL |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 void CNSmlDMSyncDialog::ReadL( TDes& aText, TInt aResourceId ) |
|
250 { |
|
251 FLOG( "CNSmlDMSyncDialog::ReadL()" ); |
|
252 |
|
253 HBufC* buf = StringLoader::LoadLC( aResourceId ); |
|
254 TUtil::StrCopy( aText, *buf ); |
|
255 CleanupStack::PopAndDestroy( buf ); |
|
256 } |
|
257 |
|
258 // End of File |
|