16
|
1 |
/*
|
|
2 |
* Copyright (c) 2005 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: Rsfw GS plugin Settins list container
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <akntitle.h>
|
|
21 |
#include <barsread.h>
|
|
22 |
#include <StringLoader.h>
|
|
23 |
#include <AknQueryDialog.h>
|
|
24 |
#include <aknnotewrappers.h>
|
|
25 |
#include <rsfwgspluginrsc.rsg>
|
|
26 |
#include <uri16.h>
|
|
27 |
|
|
28 |
#include "rsfwgslocalviewids.h"
|
|
29 |
#include "rsfwgsplugin.h"
|
|
30 |
#include "rsfwgsremotedrivesettingscontainer.h"
|
|
31 |
#include "rsfwgspluginsettinglist.h"
|
|
32 |
#include "rsfwgssettingsdata.h"
|
|
33 |
#include "rsfwmountman.h"
|
|
34 |
#include "rsfwmountentry.h"
|
|
35 |
#include "rsfwmountutils.h"
|
|
36 |
#include "rsfwcommon.h"
|
|
37 |
#include "mdebug.h"
|
|
38 |
|
|
39 |
|
|
40 |
// ---------------------------------------------------------------------------
|
|
41 |
// CRsfwGsPluginDriveSettingsContainer::CRsfwGsPluginDriveSettingsContainer()
|
|
42 |
// ---------------------------------------------------------------------------
|
|
43 |
//
|
|
44 |
CRsfwGsPluginDriveSettingsContainer::CRsfwGsPluginDriveSettingsContainer(CAknView* aView) : iView(aView)
|
|
45 |
{
|
|
46 |
|
|
47 |
}
|
|
48 |
|
|
49 |
// ---------------------------------------------------------------------------
|
|
50 |
// CRsfwGsPluginDriveSettingsContainer::ConstructL(const TRect& aRect)
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
//
|
|
53 |
void CRsfwGsPluginDriveSettingsContainer::ConstructL( const TRect& aRect,
|
|
54 |
CRsfwMountMan* aMountMan)
|
|
55 |
{
|
|
56 |
#ifdef _DEBUG
|
|
57 |
RDebug::Print( _L( "[CRsfwGsPluginDriveSettingsContainer] ConstructL()" ) );
|
|
58 |
#endif
|
|
59 |
|
|
60 |
iMountMan = aMountMan;
|
|
61 |
|
|
62 |
CEikStatusPane* sp = static_cast<CAknAppUi*>
|
|
63 |
( iEikonEnv->EikAppUi() )->StatusPane();
|
|
64 |
CAknTitlePane* title = static_cast<CAknTitlePane*>
|
|
65 |
( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
|
|
66 |
|
|
67 |
// Set the proper title of this list
|
|
68 |
TResourceReader rReader;
|
|
69 |
iCoeEnv->CreateResourceReaderLC( rReader, R_GS_RSFW_REMOTE_DRIVE_SETTINGS_VIEW_TITLE );
|
|
70 |
title->SetFromResourceL( rReader );
|
|
71 |
CleanupStack::PopAndDestroy(); //rReader
|
|
72 |
|
|
73 |
CreateWindowL(); // Makes the control a window-owning control
|
|
74 |
|
|
75 |
// construct the data object the settings list will use
|
|
76 |
iData = CRsfwGsSettingsData::NewL();
|
|
77 |
// construct control and set parent
|
|
78 |
iSettingList = CRsfwGsPluginSettingsList::NewL(*iData);
|
|
79 |
iSettingList->SetContainerWindowL(*this);
|
|
80 |
|
|
81 |
// CreateResourceReaderLC will allocate a buffer to be used by
|
|
82 |
// the TResourceReader. This buffer is pushed onto the cleanup
|
|
83 |
// stack - not the TResourceReader itself
|
|
84 |
iEikonEnv->CreateResourceReaderLC(rReader, R_SETTINGS);
|
|
85 |
iSettingList->ConstructFromResourceL(rReader);
|
|
86 |
|
|
87 |
// Clean up the buffer allocated above, NOT the reader itself.
|
|
88 |
// Cannot use expected item overload of PopAndDestroy() as buffer
|
|
89 |
// is inaccessible.
|
|
90 |
CleanupStack::PopAndDestroy();
|
|
91 |
iSettingList->ActivateL();
|
|
92 |
|
|
93 |
iCoeEnv->AddForegroundObserverL( *this );
|
|
94 |
|
|
95 |
SetRect( aRect );
|
|
96 |
ActivateL();
|
|
97 |
|
|
98 |
|
|
99 |
#ifdef _DEBUG
|
|
100 |
RDebug::Print( _L( "[CRsfwGsPluginDriveSettingsContainer] Construct done" ) );
|
|
101 |
#endif
|
|
102 |
}
|
|
103 |
|
|
104 |
// ---------------------------------------------------------------------------
|
|
105 |
// CRsfwGsPluginDriveSettingsContainer::~CRsfwGsPluginDriveSettingsContainer()
|
|
106 |
// ---------------------------------------------------------------------------
|
|
107 |
//
|
|
108 |
CRsfwGsPluginDriveSettingsContainer::~CRsfwGsPluginDriveSettingsContainer()
|
|
109 |
{
|
|
110 |
iCoeEnv->RemoveForegroundObserver( *this );
|
|
111 |
if (iData)
|
|
112 |
delete iData;
|
|
113 |
if(iSettingList) // if setting list has been created
|
|
114 |
{
|
|
115 |
delete iSettingList;
|
|
116 |
iSettingList = NULL;
|
|
117 |
}
|
|
118 |
|
|
119 |
// Ecom session is used to make sure that user gives address
|
|
120 |
// that corresponds to some installed access plugin
|
|
121 |
// (currently via mountils::isaddressvalid)
|
|
122 |
// this closes the session (if not in use anymore)
|
|
123 |
REComSession::FinalClose();
|
|
124 |
}
|
|
125 |
|
|
126 |
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
// CRsfwGsPluginDriveSettingsContainer::SizeChanged()
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
void CRsfwGsPluginDriveSettingsContainer::SizeChanged()
|
|
132 |
{
|
|
133 |
iSettingList->SetRect(Rect());
|
|
134 |
}
|
|
135 |
|
|
136 |
// ---------------------------------------------------------------------------
|
|
137 |
// CRsfwGsPluginDriveSettingsContainer::CountComponentControls() const
|
|
138 |
// ---------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
TInt CRsfwGsPluginDriveSettingsContainer::CountComponentControls() const
|
|
141 |
{
|
|
142 |
return 1;
|
|
143 |
}
|
|
144 |
|
|
145 |
// ---------------------------------------------------------------------------
|
|
146 |
// CRsfwGsPluginDriveSettingsContainer::ComponentControl( TInt aIndex ) const
|
|
147 |
// ---------------------------------------------------------------------------
|
|
148 |
//
|
|
149 |
CCoeControl* CRsfwGsPluginDriveSettingsContainer::ComponentControl( TInt aIndex ) const
|
|
150 |
{
|
|
151 |
switch ( aIndex )
|
|
152 |
{
|
|
153 |
case 0:
|
|
154 |
return iSettingList;
|
|
155 |
default:
|
|
156 |
return NULL;
|
|
157 |
}
|
|
158 |
}
|
|
159 |
|
|
160 |
// ---------------------------------------------------------------------------
|
|
161 |
// CRsfwGsPluginDriveSettingsContainer::EditCurrentItemL()
|
|
162 |
// ---------------------------------------------------------------------------
|
|
163 |
//
|
|
164 |
void CRsfwGsPluginDriveSettingsContainer::EditCurrentItemL()
|
|
165 |
{
|
|
166 |
iSettingList->EditCurrentItemL();
|
|
167 |
}
|
|
168 |
|
|
169 |
// ---------------------------------------------------------------------------
|
|
170 |
// CRsfwGsPluginDriveSettingsContainer::OfferKeyEventL()
|
|
171 |
// ---------------------------------------------------------------------------
|
|
172 |
//
|
|
173 |
TKeyResponse CRsfwGsPluginDriveSettingsContainer::OfferKeyEventL(
|
|
174 |
const TKeyEvent& aKeyEvent,
|
|
175 |
TEventCode aType )
|
|
176 |
{
|
|
177 |
if (iSettingList)
|
|
178 |
return iSettingList->OfferKeyEventL(aKeyEvent, aType);
|
|
179 |
else
|
|
180 |
return EKeyWasNotConsumed;
|
|
181 |
}
|
|
182 |
|
|
183 |
// ---------------------------------------------------------------------------
|
|
184 |
// CRsfwGsPluginDriveSettingsContainer::Draw(const TRect& aRect) const
|
|
185 |
// ---------------------------------------------------------------------------
|
|
186 |
//
|
|
187 |
void CRsfwGsPluginDriveSettingsContainer::Draw(const TRect& aRect) const
|
|
188 |
{
|
|
189 |
CWindowGc& gc = SystemGc();
|
|
190 |
gc.Clear(aRect);
|
|
191 |
}
|
|
192 |
|
|
193 |
|
|
194 |
|
|
195 |
// ---------------------------------------------------------------------------
|
|
196 |
// CRsfwGsPluginDriveSettingsContainer::HandleListBoxEventL()
|
|
197 |
// ---------------------------------------------------------------------------
|
|
198 |
//
|
|
199 |
void CRsfwGsPluginDriveSettingsContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aListBoxEvent)
|
|
200 |
{
|
|
201 |
// if the Select Key has been pressed
|
|
202 |
if ((aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed) ||
|
|
203 |
(aListBoxEvent == MEikListBoxObserver::EEventItemSingleClicked))
|
|
204 |
{
|
|
205 |
iSettingList->EditCurrentItemL();
|
|
206 |
}
|
|
207 |
}
|
|
208 |
|
|
209 |
|
|
210 |
|
|
211 |
// ---------------------------------------------------------------------------
|
|
212 |
// CRsfwGsPluginDriveSettingsContainer::PrepareRemoteDriveForEditingL(TDesC& aRemoteDriveName)
|
|
213 |
// ---------------------------------------------------------------------------
|
|
214 |
//
|
|
215 |
void CRsfwGsPluginDriveSettingsContainer::PrepareRemoteDriveForEditingL(const TDesC& aRemoteDriveName)
|
|
216 |
{
|
|
217 |
DEBUGSTRING(("CRsfwGsPluginDriveSettingsContainer::PrepareRemoteDriveForEditingL enter"));
|
|
218 |
const CRsfwMountEntry* mountEntry = NULL;
|
|
219 |
|
|
220 |
// read the source setting
|
|
221 |
DEBUGSTRING(("read the source setting"));
|
|
222 |
mountEntry = iMountMan->MountEntryL(aRemoteDriveName);
|
|
223 |
User::LeaveIfNull((TAny *)mountEntry);
|
|
224 |
|
|
225 |
// compulsory fields
|
|
226 |
DEBUGSTRING(("compulsory fields"));
|
|
227 |
iData->Reset();
|
|
228 |
iData->iSettingName = *(mountEntry->Item(EMountEntryItemName));
|
|
229 |
iData->iURL =*(mountEntry->Item(EMountEntryItemUri));
|
|
230 |
const HBufC* drive = (mountEntry->Item(EMountEntryItemDrive));
|
|
231 |
if (drive && drive->Length())
|
|
232 |
{
|
|
233 |
iData->iDriveLetter =(*drive)[0];
|
|
234 |
}
|
|
235 |
// optional fields
|
|
236 |
DEBUGSTRING(("optional fields"));
|
|
237 |
if (mountEntry->Item(EMountEntryItemUserName))
|
|
238 |
{
|
|
239 |
DEBUGSTRING(("setting user id"));
|
|
240 |
iData->iUserID = *(mountEntry->Item(EMountEntryItemUserName));
|
|
241 |
}
|
|
242 |
|
|
243 |
if (mountEntry->Item(EMountEntryItemPassword))
|
|
244 |
{
|
|
245 |
DEBUGSTRING(("setting passwd"));
|
|
246 |
iData->iPassword = *(mountEntry->Item(EMountEntryItemPassword));
|
|
247 |
}
|
|
248 |
|
|
249 |
if (mountEntry->Item(EMountEntryItemIap))
|
|
250 |
{
|
|
251 |
DEBUGSTRING16(("setting access pointDes to %S", (mountEntry->Item(EMountEntryItemIap))));
|
|
252 |
iData->iAccessPointDes = *(mountEntry->Item(EMountEntryItemIap));
|
|
253 |
// if the access point name returned from CenRep was '?', set it to "None" in UI
|
|
254 |
if (iData->iAccessPointDes == KIapAskUser)
|
|
255 |
{
|
|
256 |
iData->iAccessPointName = KNullDesC;
|
|
257 |
}
|
|
258 |
else
|
|
259 |
{
|
|
260 |
// try to resolve access point id into name
|
|
261 |
TLex lex(iData->iAccessPointDes);
|
|
262 |
TInt ap, err;
|
|
263 |
err = lex.Val(ap);
|
|
264 |
if (!err)
|
|
265 |
{
|
|
266 |
iSettingList->GetAccessPointNameL(ap, iData->iAccessPointName);
|
|
267 |
DEBUGSTRING(("setting access point"));
|
|
268 |
iData->iAccessPoint = ap;
|
|
269 |
}
|
|
270 |
else
|
|
271 |
{
|
|
272 |
DEBUGSTRING(("setting access point name"));
|
|
273 |
iData->iAccessPointName = KNullDesC;
|
|
274 |
}
|
|
275 |
}
|
|
276 |
}
|
|
277 |
|
|
278 |
DEBUGSTRING(("iData constructed"));
|
|
279 |
iSettingList->LoadSettingsL();
|
|
280 |
SetTitlePaneTextL(iData->iSettingName);
|
|
281 |
iSettingList->ResetItemIndex();
|
|
282 |
DEBUGSTRING(("CRsfwGsPluginDriveSettingsContainer::PrepareRemoteDriveForEditingL exit"));
|
|
283 |
}
|
|
284 |
|
|
285 |
|
|
286 |
// ---------------------------------------------------------------------------
|
|
287 |
// CRsfwGsPluginDriveSettingsContainer::PrepareRemoteDriveNewDefaultL(TDesC& aRemoteDriveName);
|
|
288 |
// ---------------------------------------------------------------------------
|
|
289 |
//
|
|
290 |
void CRsfwGsPluginDriveSettingsContainer::PrepareRemoteDriveNewDefaultL(TDesC& aRemoteDriveName)
|
|
291 |
{
|
|
292 |
iData->Reset();
|
|
293 |
iData->iSettingName = aRemoteDriveName;
|
|
294 |
iSettingList->LoadSettingsL();
|
|
295 |
iSettingList->ResetItemIndex();
|
|
296 |
iSettingList->DrawDeferred();
|
|
297 |
SetTitlePaneTextL(iData->iSettingName);
|
|
298 |
}
|
|
299 |
|
|
300 |
|
|
301 |
// ---------------------------------------------------------------------------
|
|
302 |
// CRsfwGsPluginDriveSettingsContainer::SetTitlePaneTextL( const TDesC& aTitleText ) const
|
|
303 |
// ---------------------------------------------------------------------------
|
|
304 |
//
|
|
305 |
void CRsfwGsPluginDriveSettingsContainer::SetTitlePaneTextL( const TDesC& aTitleText ) const
|
|
306 |
{
|
|
307 |
CAknTitlePane* title = static_cast< CAknTitlePane* >
|
|
308 |
( iEikonEnv->AppUiFactory()->StatusPane()->ControlL(
|
|
309 |
TUid::Uid( EEikStatusPaneUidTitle ) ) );
|
|
310 |
if ( !title )
|
|
311 |
{
|
|
312 |
User::Leave( KErrNotSupported );
|
|
313 |
}
|
|
314 |
title->SetTextL( aTitleText );
|
|
315 |
}
|
|
316 |
|
|
317 |
// ---------------------------------------------------------------------------
|
|
318 |
// CRsfwGsPluginDriveSettingsContainer::AreCompulsoryItemsFilled()
|
|
319 |
// ---------------------------------------------------------------------------
|
|
320 |
//
|
|
321 |
TBool CRsfwGsPluginDriveSettingsContainer::AreCompulsoryItemsFilled()
|
|
322 |
{
|
|
323 |
TUriParser uriParser;
|
|
324 |
uriParser.Parse(iData->iURL);
|
|
325 |
HBufC* host = HBufC::NewL(KMaxURLLength);
|
|
326 |
TPtr hostPtr = host->Des();
|
|
327 |
hostPtr = uriParser.Extract(EUriHost);
|
|
328 |
|
|
329 |
if ( ((iData->iSettingName)!=KNullDesC) && (hostPtr!=KNullDesC))
|
|
330 |
{
|
|
331 |
delete host;
|
|
332 |
return ETrue;
|
|
333 |
}
|
|
334 |
delete host;
|
|
335 |
return EFalse;
|
|
336 |
}
|
|
337 |
|
|
338 |
// ---------------------------------------------------------------------------
|
|
339 |
// CRsfwGsPluginDriveSettingsContainer::DisplayDeleteOrDontSaveDialog()
|
|
340 |
// ---------------------------------------------------------------------------
|
|
341 |
//
|
|
342 |
TBool CRsfwGsPluginDriveSettingsContainer::DisplayDeleteOrDontSaveDialogL()
|
|
343 |
{
|
|
344 |
|
|
345 |
HBufC* myDisplayMessage = NULL;
|
|
346 |
myDisplayMessage = StringLoader::LoadLC(R_STR_REMOTE_DRIVE_CONF_COMPULSORY);
|
|
347 |
CAknQueryDialog* query = CAknQueryDialog::NewL
|
|
348 |
(CAknQueryDialog::EConfirmationTone);
|
|
349 |
TBool answer = query->ExecuteLD( R_CONFIRMATION_QUERY, *myDisplayMessage );
|
|
350 |
CleanupStack::PopAndDestroy(myDisplayMessage);
|
|
351 |
return answer;
|
|
352 |
}
|
|
353 |
|
|
354 |
// ---------------------------------------------------------------------------
|
|
355 |
// CRsfwGsPluginDriveSettingsContainer::DeleteremoteDriveIfExistL()
|
|
356 |
// ---------------------------------------------------------------------------
|
|
357 |
//
|
|
358 |
void CRsfwGsPluginDriveSettingsContainer::DeleteRemoteDriveIfExistL()
|
|
359 |
{
|
|
360 |
iMountMan->DeleteMountEntryL(iData->iDriveLetter);
|
|
361 |
}
|
|
362 |
|
|
363 |
// ---------------------------------------------------------------------------
|
|
364 |
// CRsfwGsPluginDriveSettingsContainer::IsExitProcessingOKL()
|
|
365 |
// ---------------------------------------------------------------------------
|
|
366 |
//
|
|
367 |
TBool CRsfwGsPluginDriveSettingsContainer::IsExitProcessingOKL()
|
|
368 |
{
|
|
369 |
if (AreCompulsoryItemsFilled())
|
|
370 |
{
|
|
371 |
if (!(RsfwMountUtils::IsFriendlyNameValid(iData->iSettingName)))
|
|
372 |
{
|
|
373 |
HBufC* myDisplayMessage = NULL;
|
|
374 |
myDisplayMessage = StringLoader::LoadLC(R_STR_RSFW_ERROR_ILLEGAL_CHARACTERS);
|
|
375 |
CAknErrorNote* errorNote = new CAknErrorNote(EFalse);
|
|
376 |
errorNote->ExecuteLD(*myDisplayMessage);
|
|
377 |
CleanupStack::PopAndDestroy(myDisplayMessage);
|
|
378 |
iSettingList->ListBox()->SetCurrentItemIndex(ESettingItemDriveName-1);
|
|
379 |
return EFalse;
|
|
380 |
}
|
|
381 |
|
|
382 |
// Uri must contain some scheme, like http:// or upnp://
|
|
383 |
if (!IsDriveAddressValidL(iData->iURL))
|
|
384 |
{
|
|
385 |
HBufC* myDisplayMessage = NULL;
|
|
386 |
myDisplayMessage = StringLoader::LoadLC(R_STR_RSFW_ERROR_ILLEGAL_ADDRESS);
|
|
387 |
CAknNoteDialog* noteDlg = new ( ELeave ) CAknNoteDialog( );
|
|
388 |
noteDlg->SetTextL( *myDisplayMessage );
|
|
389 |
noteDlg->ExecuteLD( R_RSFW_INFORMATION_NOTE );
|
|
390 |
CleanupStack::PopAndDestroy(myDisplayMessage);
|
|
391 |
iSettingList->ListBox()->SetCurrentItemIndex(ESettingItemURL-1);
|
|
392 |
return EFalse;
|
|
393 |
}
|
|
394 |
|
|
395 |
// settings seem to be ok
|
|
396 |
return SaveOrCreateAndSaveRemoteDriveL(ETrue);
|
|
397 |
}
|
|
398 |
else
|
|
399 |
{
|
|
400 |
if (DisplayDeleteOrDontSaveDialogL())
|
|
401 |
{
|
|
402 |
DeleteRemoteDriveIfExistL();
|
|
403 |
}
|
|
404 |
else
|
|
405 |
{
|
|
406 |
// set focus on the address field as that is the first (and only)
|
|
407 |
// unfilled compulsary setting field
|
|
408 |
iSettingList->ListBox()->SetCurrentItemIndex(ESettingItemURL-1);
|
|
409 |
return EFalse;
|
|
410 |
}
|
|
411 |
}
|
|
412 |
|
|
413 |
return ETrue;
|
|
414 |
}
|
|
415 |
|
|
416 |
// ---------------------------------------------------------------------------
|
|
417 |
// CRsfwGsPluginDriveSettingsContainer::SaveSettingsL
|
|
418 |
// Attempts to save settings
|
|
419 |
// ---------------------------------------------------------------------------
|
|
420 |
void CRsfwGsPluginDriveSettingsContainer::SaveSettingsL()
|
|
421 |
{
|
|
422 |
if (AreCompulsoryItemsFilled())
|
|
423 |
{
|
|
424 |
if (!(RsfwMountUtils::IsFriendlyNameValid(iData->iSettingName)))
|
|
425 |
{
|
|
426 |
return;
|
|
427 |
}
|
|
428 |
// Uri must contain some scheme, like http:// or upnp://
|
|
429 |
if (!IsDriveAddressValidL(iData->iURL))
|
|
430 |
{
|
|
431 |
return;
|
|
432 |
}
|
|
433 |
// settings seem to be ok
|
|
434 |
SaveOrCreateAndSaveRemoteDriveL(EFalse);
|
|
435 |
}
|
|
436 |
}
|
|
437 |
|
|
438 |
// ---------------------------------------------------------------------------
|
|
439 |
// CRsfwGsPluginDriveSettingsContainer::SaveOrCreateAndSaveremoteDriveL()
|
|
440 |
// ---------------------------------------------------------------------------
|
|
441 |
//
|
|
442 |
TBool CRsfwGsPluginDriveSettingsContainer::SaveOrCreateAndSaveRemoteDriveL(TBool aShowDialog)
|
|
443 |
{
|
|
444 |
// try to get mountentry with this drive letter
|
|
445 |
const CRsfwMountEntry* existingMountEntry = iMountMan->MountEntryL(iData->iDriveLetter);
|
|
446 |
|
|
447 |
// to keep names unique check if the setting with this name is already exist
|
|
448 |
// ask user to change name
|
|
449 |
TBool isConflict;
|
|
450 |
if (existingMountEntry)
|
|
451 |
{
|
|
452 |
isConflict = IsRemoteDriveNameConflictL(iData->iSettingName, *(existingMountEntry->Item(EMountEntryItemDrive)));
|
|
453 |
}
|
|
454 |
else
|
|
455 |
{
|
|
456 |
TBuf<5> bogusDrive;
|
|
457 |
bogusDrive.Append(_L("C:\\"));
|
|
458 |
isConflict = IsRemoteDriveNameConflictL(iData->iSettingName, bogusDrive);
|
|
459 |
}
|
|
460 |
|
|
461 |
if (isConflict)
|
|
462 |
{
|
|
463 |
if (aShowDialog)
|
|
464 |
{
|
|
465 |
HBufC* myFormatMessage = NULL;
|
|
466 |
if ( iData->iSettingName.Length() )
|
|
467 |
{
|
|
468 |
myFormatMessage = StringLoader::LoadLC( R_STR_REMOTE_DRIVE_NAME_ALREADY_EXIST, iData->iSettingName);
|
|
469 |
}
|
|
470 |
else
|
|
471 |
{
|
|
472 |
myFormatMessage = StringLoader::LoadLC( R_STR_REMOTE_DRIVE_NAME_ALREADY_EXIST );
|
|
473 |
}
|
|
474 |
|
|
475 |
CAknErrorNote* note = new CAknErrorNote(EFalse);
|
|
476 |
note->SetTimeout( CAknNoteDialog::ELongTimeout );
|
|
477 |
note->ExecuteLD( *myFormatMessage );
|
|
478 |
CleanupStack::PopAndDestroy(myFormatMessage);
|
|
479 |
// set focus to drive
|
|
480 |
iSettingList->ListBox()->SetCurrentItemIndex(ESettingItemDriveName-1);
|
|
481 |
}
|
|
482 |
return EFalse;
|
|
483 |
}
|
|
484 |
else if (!existingMountEntry || DataChanged(existingMountEntry))
|
|
485 |
{
|
|
486 |
|
|
487 |
CRsfwMountEntry* newMountEntry = CRsfwMountEntry::NewLC();
|
|
488 |
if (existingMountEntry)
|
|
489 |
{
|
|
490 |
// the same drive letter must be set as it is the key
|
|
491 |
newMountEntry->SetItemL(EMountEntryItemDrive, *(existingMountEntry->Item(EMountEntryItemDrive)));
|
|
492 |
}
|
|
493 |
|
|
494 |
newMountEntry->SetItemL(EMountEntryItemName, iData->iSettingName);
|
|
495 |
newMountEntry->SetItemL(EMountEntryItemUri, iData->iURL);
|
|
496 |
if ((iData->iUserID)!=KNullDesC)
|
|
497 |
{
|
|
498 |
newMountEntry->SetItemL(EMountEntryItemUserName, iData->iUserID);
|
|
499 |
}
|
|
500 |
|
|
501 |
if ((iData->iPassword)!=KNullDesC)
|
|
502 |
{
|
|
503 |
newMountEntry->SetItemL(EMountEntryItemPassword, iData->iPassword);
|
|
504 |
}
|
|
505 |
if ((iData->iAccessPointDes)!=KNullDesC)
|
|
506 |
{
|
|
507 |
newMountEntry->SetItemL(EMountEntryItemIap, iData->iAccessPointDes);
|
|
508 |
}
|
|
509 |
else
|
|
510 |
{
|
|
511 |
newMountEntry->SetItemL(EMountEntryItemIap, KIapAskUser);
|
|
512 |
}
|
|
513 |
|
|
514 |
newMountEntry->SetItemL(EMountEntryItemInactivityTimeout, iData->iInActivityTimeout);
|
|
515 |
|
|
516 |
// depending on whether this is new mount created or existing mount edited
|
|
517 |
// choose proper method from MountMan API
|
|
518 |
// pop here from the stack since ownership is passed to the mountman
|
|
519 |
CleanupStack::Pop(newMountEntry);
|
|
520 |
|
|
521 |
if (!existingMountEntry)
|
|
522 |
{
|
|
523 |
iMountMan->AddMountEntryL(newMountEntry);
|
|
524 |
}
|
|
525 |
else
|
|
526 |
{
|
|
527 |
iMountMan->EditMountEntryL(newMountEntry);
|
|
528 |
}
|
|
529 |
}
|
|
530 |
return ETrue;
|
|
531 |
}
|
|
532 |
|
|
533 |
// ---------------------------------------------------------------------------
|
|
534 |
// CRsfwGsPluginDriveSettingsContainer::DataChanged
|
|
535 |
// ---------------------------------------------------------------------------
|
|
536 |
//
|
|
537 |
TBool CRsfwGsPluginDriveSettingsContainer::DataChanged(const CRsfwMountEntry* aCurrentData)
|
|
538 |
{
|
|
539 |
if (!aCurrentData)
|
|
540 |
{
|
|
541 |
return ETrue;
|
|
542 |
}
|
|
543 |
|
|
544 |
// compulsary settings
|
|
545 |
if (iData->iSettingName != *(aCurrentData->Item(EMountEntryItemName)))
|
|
546 |
{
|
|
547 |
return ETrue;
|
|
548 |
}
|
|
549 |
if (iData->iURL != *(aCurrentData->Item(EMountEntryItemUri)))
|
|
550 |
{
|
|
551 |
return ETrue;
|
|
552 |
}
|
|
553 |
|
|
554 |
// optional settings
|
|
555 |
if (!aCurrentData->Item(EMountEntryItemUserName))
|
|
556 |
{
|
|
557 |
if (iData->iUserID != KNullDesC)
|
|
558 |
{
|
|
559 |
return ETrue;
|
|
560 |
}
|
|
561 |
}
|
|
562 |
else
|
|
563 |
{
|
|
564 |
if (iData->iUserID != *(aCurrentData->Item(EMountEntryItemUserName)))
|
|
565 |
{
|
|
566 |
return ETrue;
|
|
567 |
}
|
|
568 |
}
|
|
569 |
|
|
570 |
if (!aCurrentData->Item(EMountEntryItemPassword))
|
|
571 |
{
|
|
572 |
if (iData->iPassword != KNullDesC)
|
|
573 |
{
|
|
574 |
return ETrue;
|
|
575 |
}
|
|
576 |
}
|
|
577 |
else
|
|
578 |
{
|
|
579 |
if (iData->iPassword != *(aCurrentData->Item(EMountEntryItemPassword)))
|
|
580 |
{
|
|
581 |
return ETrue;
|
|
582 |
}
|
|
583 |
}
|
|
584 |
|
|
585 |
if (!aCurrentData->Item(EMountEntryItemIap))
|
|
586 |
{
|
|
587 |
if (iData->iAccessPointDes != KNullDesC)
|
|
588 |
{
|
|
589 |
return ETrue;
|
|
590 |
}
|
|
591 |
}
|
|
592 |
else
|
|
593 |
{
|
|
594 |
if (iData->iAccessPointDes != *(aCurrentData->Item(EMountEntryItemIap)))
|
|
595 |
{
|
|
596 |
return ETrue;
|
|
597 |
}
|
|
598 |
}
|
|
599 |
|
|
600 |
|
|
601 |
return EFalse;
|
|
602 |
}
|
|
603 |
|
|
604 |
// ---------------------------------------------------------------------------
|
|
605 |
// CRsfwGsPluginDriveSettingsContainer::IsRemoteDriveNameExistL(TDesC& aremoteDriveName)
|
|
606 |
//
|
|
607 |
// ---------------------------------------------------------------------------
|
|
608 |
//
|
|
609 |
TBool CRsfwGsPluginDriveSettingsContainer::IsRemoteDriveNameConflictL(
|
|
610 |
TDesC& aRemoteDriveName,
|
|
611 |
const TDesC& aDriveLetter)
|
|
612 |
{
|
|
613 |
TBool ret(EFalse);
|
|
614 |
CDesCArray* remoteDriveList = NULL;
|
|
615 |
|
|
616 |
TRAPD(err, remoteDriveList = LoadRemoteDriveNamesL());
|
|
617 |
if(err!=KErrNone)
|
|
618 |
{
|
|
619 |
return EFalse;
|
|
620 |
}
|
|
621 |
CleanupStack::PushL(remoteDriveList);
|
|
622 |
|
|
623 |
TInt remoteDriveListCount = remoteDriveList->Count();
|
|
624 |
for (TInt i = 0; i< remoteDriveListCount; i++)
|
|
625 |
{
|
|
626 |
if (!((remoteDriveList->MdcaPoint(i)).CompareF(aRemoteDriveName))) // if equal
|
|
627 |
{
|
|
628 |
// check whether the drive letter is the same or not
|
|
629 |
const CRsfwMountEntry* existingDrive =
|
|
630 |
iMountMan->MountEntryL(aRemoteDriveName);
|
|
631 |
if ((existingDrive->Item(EMountEntryItemDrive))->Compare(aDriveLetter) == 0 )
|
|
632 |
{
|
|
633 |
ret = EFalse;
|
|
634 |
}
|
|
635 |
else
|
|
636 |
{
|
|
637 |
ret = ETrue;
|
|
638 |
}
|
|
639 |
break;
|
|
640 |
}
|
|
641 |
}
|
|
642 |
CleanupStack::PopAndDestroy(remoteDriveList);
|
|
643 |
return ret;
|
|
644 |
|
|
645 |
}
|
|
646 |
|
|
647 |
// ---------------------------------------------------------------------------
|
|
648 |
// CRsfwGsPluginDriveSettingsContainer::IsDriveAddressValidL
|
|
649 |
// ---------------------------------------------------------------------------
|
|
650 |
//
|
|
651 |
TBool CRsfwGsPluginDriveSettingsContainer::IsDriveAddressValidL(const TDesC& aDriveAddress)
|
|
652 |
{
|
|
653 |
HBufC8* urlBuffer = HBufC8::NewL(KMaxURLLength);
|
|
654 |
TPtr8 bufPtr = urlBuffer->Des();
|
|
655 |
bufPtr.Append(aDriveAddress);
|
|
656 |
TBool isAddressValid = RsfwMountUtils::IsDriveAddressValid(*urlBuffer);
|
|
657 |
delete urlBuffer;
|
|
658 |
return isAddressValid;
|
|
659 |
}
|
|
660 |
|
|
661 |
// ---------------------------------------------------------------------------
|
|
662 |
// CRsfwGsPluginDriveSettingsContainer::LoadRemoteDriveNamesL
|
|
663 |
// ---------------------------------------------------------------------------
|
|
664 |
//
|
|
665 |
CDesCArray* CRsfwGsPluginDriveSettingsContainer::LoadRemoteDriveNamesL()
|
|
666 |
{
|
|
667 |
CDesCArray* myArray = new (ELeave) CDesC16ArraySeg(4);
|
|
668 |
iMountMan->GetMountNamesL(myArray);
|
|
669 |
return myArray;
|
|
670 |
}
|
|
671 |
|
|
672 |
// ---------------------------------------------------------------------------
|
|
673 |
// CRsfwGsPluginDriveSettingsContainer::HandleResourceChange()
|
|
674 |
// ---------------------------------------------------------------------------
|
|
675 |
void CRsfwGsPluginDriveSettingsContainer::HandleResourceChange( TInt aType )
|
|
676 |
{
|
|
677 |
if ( aType == KAknsMessageSkinChange ||
|
|
678 |
aType == KEikDynamicLayoutVariantSwitch )
|
|
679 |
{
|
|
680 |
if (aType != KAknsMessageSkinChange)
|
|
681 |
{
|
|
682 |
TRect mainPaneRect;
|
|
683 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
|
|
684 |
mainPaneRect);
|
|
685 |
SetRect( mainPaneRect );
|
|
686 |
}
|
|
687 |
|
|
688 |
DrawDeferred();
|
|
689 |
CRsfwGsPlugin* tempView = static_cast<CRsfwGsPlugin*> (iView);
|
|
690 |
tempView->HandleResourceChangeManual(aType);
|
|
691 |
}
|
|
692 |
CCoeControl::HandleResourceChange( aType );
|
|
693 |
}
|
|
694 |
|
|
695 |
|
|
696 |
// ---------------------------------------------------------------------------
|
|
697 |
// CRsfwGsPluginDriveSettingsContainer::HandleResourceChangeManual()
|
|
698 |
// ---------------------------------------------------------------------------
|
|
699 |
void CRsfwGsPluginDriveSettingsContainer::HandleResourceChangeManual(TInt aType)
|
|
700 |
{
|
|
701 |
if (aType != KAknsMessageSkinChange)
|
|
702 |
{
|
|
703 |
TRect mainPaneRect;
|
|
704 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
|
|
705 |
mainPaneRect);
|
|
706 |
SetRect( mainPaneRect );
|
|
707 |
}
|
|
708 |
|
|
709 |
DrawDeferred();
|
|
710 |
iSettingList->HandleResourceChange(aType);
|
|
711 |
}
|
|
712 |
|
|
713 |
// ---------------------------------------------------------------------------
|
|
714 |
// CRsfwGsPluginDriveSettingsContainer::FocusChanged
|
|
715 |
// Set focus on the selected listbox. For animated skins feature.
|
|
716 |
// ---------------------------------------------------------------------------
|
|
717 |
void CRsfwGsPluginDriveSettingsContainer::FocusChanged(TDrawNow /*aDrawNow*/)
|
|
718 |
{
|
|
719 |
if(iSettingList)
|
|
720 |
{
|
|
721 |
iSettingList->SetFocus( IsFocused() );
|
|
722 |
}
|
|
723 |
}
|
|
724 |
|
|
725 |
// ---------------------------------------------------------
|
|
726 |
// CRsfwGsPluginDriveSettingsContainer::GetHelpContext
|
|
727 |
// This function is called when Help application is launched
|
|
728 |
// ---------------------------------------------------------
|
|
729 |
//
|
|
730 |
void CRsfwGsPluginDriveSettingsContainer::GetHelpContext( TCoeHelpContext& aContext ) const
|
|
731 |
{
|
|
732 |
aContext.iMajor = KGSRsfwPluginUID;
|
|
733 |
// aContext.iContext = KRSFW_HLP_EDIT_SET;
|
|
734 |
}
|
|
735 |
|
|
736 |
|
|
737 |
TDes& CRsfwGsPluginDriveSettingsContainer::GetCurrentRemoteDriveName()
|
|
738 |
{
|
|
739 |
return iData->iSettingName;
|
|
740 |
}
|
|
741 |
|
|
742 |
|
|
743 |
// from MCoeForegroundObserver
|
|
744 |
|
|
745 |
void CRsfwGsPluginDriveSettingsContainer::HandleGainingForeground()
|
|
746 |
{
|
|
747 |
|
|
748 |
}
|
|
749 |
|
|
750 |
|
|
751 |
void CRsfwGsPluginDriveSettingsContainer::HandleLosingForeground()
|
|
752 |
{
|
|
753 |
|
|
754 |
}
|
|
755 |
|
|
756 |
|
|
757 |
// End of File
|