DirectPrint/DirectPrintApp/ui/src/directprintsettingview.cpp
branchRCL_3
changeset 12 613a5ff70823
child 15 2275db202402
equal deleted inserted replaced
8:3f1fec088555 12:613a5ff70823
       
     1 /*
       
     2 * Copyright (c) 2010 Kanrikogaku Kenkyusho, Ltd.
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of the License "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 * Kanrikogaku Kenkyusho, Ltd. - Initial contribution
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 * {Description of the file}
       
    16 *
       
    17 */
       
    18 
       
    19 // System include files
       
    20 #include <aknviewappui.h>
       
    21 #include <akntoolbar.h>
       
    22 #include <barsread.h>
       
    23 #include <DirectPrintApp.rsg>
       
    24 #include <AknSettingItemList.h>
       
    25 #include <eiklbx.h>
       
    26 #include <bautils.h>
       
    27 #include <driveinfo.h>
       
    28 #include <pathinfo.h>
       
    29 
       
    30 // User include files
       
    31 #include "clog.h"
       
    32 #include "directprintapp.hrh"
       
    33 #include "DirectPrintAppAppUi.h"
       
    34 #include "DirectPrintEngine.h"
       
    35 #include "DirectPrintModel.h"
       
    36 #include "directprintsettingview.h"
       
    37 #include "DirectPrintBearerMgr.h"
       
    38 
       
    39 #include "directprintbasecapability.h"
       
    40 #include "directprintlistcapability.h"
       
    41 #include "directprinttextcapability.h"
       
    42 #include "directprintprintsettings.h"
       
    43 #include "imageprint.h"
       
    44 #include "directprintcapabilitycodes.h"
       
    45 
       
    46 CDirectPrintPrinterSettingView::CDirectPrintPrinterSettingView()
       
    47 	{
       
    48 	iListBox = NULL;
       
    49 	}
       
    50 
       
    51 CDirectPrintPrinterSettingView::~CDirectPrintPrinterSettingView()
       
    52 	{
       
    53 	AppUi()->RemoveFromViewStack(*this, iListBox);
       
    54 	delete iListBox;
       
    55 	}
       
    56 
       
    57 CDirectPrintPrinterSettingView* CDirectPrintPrinterSettingView::NewL()
       
    58 	{
       
    59 	CDirectPrintPrinterSettingView* self = CDirectPrintPrinterSettingView::NewLC();
       
    60 	CleanupStack::Pop(self);
       
    61 	return self;
       
    62 	}
       
    63 
       
    64 CDirectPrintPrinterSettingView* CDirectPrintPrinterSettingView::NewLC()
       
    65 	{
       
    66 	CDirectPrintPrinterSettingView* self = new(ELeave) CDirectPrintPrinterSettingView();
       
    67 	CleanupStack::PushL(self);
       
    68 	self->ConstructL();
       
    69 	return self;
       
    70 	}
       
    71 
       
    72 void CDirectPrintPrinterSettingView::ConstructL()
       
    73 	{
       
    74 	LOG("CDirectPrintPrinterSettingView::ConstructL BEGIN");
       
    75 	BaseConstructL(R_DIRECTPRINT_PRINTERSETTING_VIEW);
       
    76 
       
    77 	iViewId = TUid::Uid(EDirectPrintPrinterSettingViewId);
       
    78 	LOG("CDirectPrintPrinterSettingView::ConstructL END");
       
    79 	}
       
    80 
       
    81 void CDirectPrintPrinterSettingView::HandleCommandL(TInt aCommand)
       
    82 	{
       
    83 	switch (aCommand)
       
    84 		{
       
    85 		case EAknSoftkeyBack:
       
    86 			{
       
    87 			iListBox->StoreSettingsL();
       
    88 			StoreDriverInfoL();
       
    89 			StoreTypeInfoL();
       
    90 			StoreBearerInfoL();
       
    91 			StoreExtendSettingsL();
       
    92 			WriteDataL(); // write to model
       
    93 			GetBearerMgr()->SetJobSettings(); // write to bearer
       
    94 			GetModel().SetIsNewData(EFalse);
       
    95 
       
    96 			AppUi()->HandleCommandL(EDirectPrintCmdIdPrinterSettingViewBack);
       
    97 			}
       
    98 			break;
       
    99 		default:
       
   100 			{
       
   101 			AppUi()->HandleCommandL(aCommand);
       
   102 			}
       
   103 			break;
       
   104 		}
       
   105 	}
       
   106 
       
   107 void CDirectPrintPrinterSettingView::HandleEditItemL(TInt aIndex, TBool aChanged)
       
   108 	{
       
   109 	if (aChanged)
       
   110 		{
       
   111 		TBuf<25> titleBearer;
       
   112 		CEikonEnv::Static()->ReadResource(titleBearer, R_DIRECTPRINT_PRINTERSETTING_ITEM_BEARER);
       
   113 
       
   114 		TPtrC name = (*(iListBox->SettingItemArray()))[aIndex]->SettingName();
       
   115 		if (name.Compare(titleBearer) == 0)
       
   116 			{
       
   117 			ReloadListL();
       
   118 			}
       
   119 		}
       
   120 	}
       
   121 
       
   122 void CDirectPrintPrinterSettingView::DoActivateL(const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
       
   123 	{
       
   124 	LOG("CDirectPrintPrinterSettingView::DoActivateL BEGIN");
       
   125 
       
   126 	if (GetModel().IsNewData())
       
   127 		{
       
   128 		NewDataL();
       
   129 		}
       
   130 	else
       
   131 		{
       
   132 		ReadDataL();
       
   133 		}
       
   134 
       
   135 	if (!iListBox)
       
   136 		{
       
   137 		// Create list box
       
   138 		iListBox = CDirectPrintSettingListBox::NewL(ClientRect());
       
   139 		iListBox->SetMopParent(this);
       
   140 		iListBox->SetSettingListObserver(this);
       
   141 		iListBox->ConstructFromResourceL(R_DIRECTPRINT_PRINTERSETTING_ITEM_LIST);
       
   142 		iListBox->ActivateL();
       
   143 		}
       
   144 	else
       
   145 		{
       
   146 		iListBox->SettingItemArray()->ResetAndDestroy();
       
   147 		}
       
   148 
       
   149 	LoadListL();
       
   150 	LoadDriverInfoL();
       
   151 	LoadTypeInfoL();
       
   152 	LoadBearerInfoL();
       
   153 	LoadExtendListL();
       
   154 	iListBox->LoadSettingsL();
       
   155 	AppUi()->AddToStackL(*this, iListBox);
       
   156 	iListBox->MakeVisible(ETrue);
       
   157 	iListBox->DrawNow();
       
   158 
       
   159 	// set the title pane
       
   160 	SetActiveTitleL(R_DIRECTPRINT_PRINTERSETTING_TITLE);
       
   161 	LOG("CDirectPrintPrinterSettingView::DoActivateL END");
       
   162 	}
       
   163 
       
   164 void CDirectPrintPrinterSettingView::DoDeactivate()
       
   165 	{
       
   166 	LOG("CDirectPrintPrinterSettingView::DoDeactivate BEGIN");
       
   167 	iListBox->MakeVisible(EFalse);
       
   168 	AppUi()->RemoveFromViewStack(*this, iListBox);
       
   169 	LOG("CDirectPrintPrinterSettingView::DoDeactivate END");
       
   170 	}
       
   171 
       
   172 void CDirectPrintPrinterSettingView::LoadListL()
       
   173 	{
       
   174 	LOG("CDirectPrintPrinterSettingView::LoadListL BEGIN");
       
   175 
       
   176 	TBuf<25> itemTitle;
       
   177 
       
   178 	// Common setting item
       
   179 	CAknTextSettingItem* item1 = new (ELeave) CAknTextSettingItem(ESettingViewItemPrinterName, iPrinterName);
       
   180 	CleanupStack::PushL(item1);
       
   181 	item1->SetEmptyItemTextL( _L("None") );
       
   182 	CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_PRINTERSETTING_ITEM_PRINTERNAME);
       
   183 	item1->ConstructL(EFalse, ESettingViewItemPrinterName, itemTitle, NULL, R_DIRECTPRINT_PRINTERSETTING_TEXT_SETTING_PAGE, -1);
       
   184 	iListBox->SettingItemArray()->AppendL(item1);
       
   185 	CleanupStack::Pop(item1);
       
   186 
       
   187 	LOG("CDirectPrintPrinterSettingView::LoadListL 1");
       
   188 
       
   189 	iDriver = 0;
       
   190 	CAknEnumeratedTextPopupSettingItem* item2 = new (ELeave) CAknEnumeratedTextPopupSettingItem(ESettingViewItemDriver, iDriver);
       
   191 	CleanupStack::PushL(item2);
       
   192 	CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_PRINTERSETTING_ITEM_DRIVER);
       
   193 	item2->ConstructL(EFalse, ESettingViewItemDriver, itemTitle, NULL, R_DIRECTPRINT_PRINTERSETTING_POPUP_SETTING_PAGE, -1, 0, R_DIRECTPRINT_PRINTERSETTING_POPUP_SETTING_TEXTS);
       
   194 
       
   195 	LOG("CDirectPrintPrinterSettingView::LoadListL 2");
       
   196 	// set printer driver
       
   197 		{
       
   198 		const TInt KSettingItemArrayGranularity = 5;
       
   199 		// Construct the array
       
   200 		CArrayPtr<CAknEnumeratedText>* enumeratedTextArray; 
       
   201 		enumeratedTextArray = new( ELeave ) CArrayPtrFlat<CAknEnumeratedText>( KSettingItemArrayGranularity );
       
   202 		CleanupStack::PushL( enumeratedTextArray );
       
   203 
       
   204 		// Construct a dummy array for popup text, needed to avoid a panic
       
   205 		CArrayPtr<HBufC>* popupTextArray; 
       
   206 		popupTextArray = new( ELeave ) CArrayPtrFlat<HBufC>( KSettingItemArrayGranularity );
       
   207 		CleanupStack::PushL( popupTextArray );
       
   208 
       
   209 		CDirectPrintAppAppUi* appui = static_cast<CDirectPrintAppAppUi*>( AppUi() );
       
   210 		CDirectPrintEngine* engine = appui->Engine();
       
   211 
       
   212 		// Read in the texts to be used in the setting item list
       
   213 		TInt index;
       
   214 		// Loop through all the texts 
       
   215 
       
   216 		LOG1("ModelCount=[%d]", engine->ModelCount());
       
   217 
       
   218 		for (index=0; index < engine->ModelCount(); index++)
       
   219 			{
       
   220 			HBufC* thisText = HBufC::NewLC(KMaxPrinterModelNameLength); 
       
   221 			TPtr thisTextDes = thisText->Des();
       
   222 			engine->ModelName(index, thisTextDes);
       
   223 			CAknEnumeratedText* enumeratedText = new( ELeave ) CAknEnumeratedText( index, thisText );
       
   224 			CleanupStack::Pop( thisText ); 
       
   225 			CleanupStack::PushL( enumeratedText );
       
   226 			enumeratedTextArray->AppendL( enumeratedText );
       
   227 			CleanupStack::Pop( enumeratedText ); 
       
   228 			}
       
   229 		if (engine->ModelCount() > 0)
       
   230 			{
       
   231 			item2->SetEnumeratedTextArrays( enumeratedTextArray, popupTextArray );
       
   232 			}
       
   233 		CleanupStack::Pop( popupTextArray );
       
   234 		CleanupStack::Pop( enumeratedTextArray );
       
   235 		}
       
   236 	LOG("CDirectPrintPrinterSettingView::LoadListL 2-2");
       
   237 
       
   238 	iListBox->SettingItemArray()->AppendL(item2);
       
   239 	CleanupStack::Pop(item2);
       
   240 
       
   241 	LOG("CDirectPrintPrinterSettingView::LoadListL 3");
       
   242 	iType = 0;
       
   243 	CAknEnumeratedTextPopupSettingItem* item3 = new (ELeave) CAknEnumeratedTextPopupSettingItem(ESettingViewItemType, iType);
       
   244 	CleanupStack::PushL(item3);
       
   245 	CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_PRINTERSETTING_ITEM_TYPE);
       
   246 	item3->ConstructL(EFalse, ESettingViewItemType, itemTitle, NULL, R_DIRECTPRINT_PRINTERSETTING_POPUP_SETTING_PAGE, -1, 0, R_DIRECTPRINT_PRINTERSETTING_TYPE_POPUP_SETTING_TEXTS);
       
   247 	iListBox->SettingItemArray()->AppendL(item3);
       
   248 	CleanupStack::Pop(item3);
       
   249 
       
   250 	iBearer = 0;
       
   251 	LOG("CDirectPrintPrinterSettingView::LoadListL 4");
       
   252 	CAknEnumeratedTextPopupSettingItem* item4 = new (ELeave) CAknEnumeratedTextPopupSettingItem(ESettingViewItemBearer, iBearer);
       
   253 	CleanupStack::PushL(item4);
       
   254 	CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_PRINTERSETTING_ITEM_BEARER);
       
   255 	item4->ConstructL(EFalse, ESettingViewItemBearer, itemTitle, NULL, R_DIRECTPRINT_PRINTERSETTING_POPUP_SETTING_PAGE, -1, 0, R_DIRECTPRINT_PRINTERSETTING_BEARER_POPUP_SETTING_TEXTS);
       
   256 
       
   257 	SetBearerListL(item4);
       
   258 
       
   259 	iListBox->SettingItemArray()->AppendL(item4);
       
   260 	CleanupStack::Pop(item4);
       
   261 
       
   262 	LOG("CDirectPrintPrinterSettingView::LoadListL xxx");
       
   263 
       
   264 	iListBox->ListBox()->SetCurrentItemIndex(0);
       
   265 	LOG("CDirectPrintPrinterSettingView::LoadListL xx");
       
   266 	iListBox->HandleChangeInItemArrayOrVisibilityL(); 
       
   267 	LOG("CDirectPrintPrinterSettingView::LoadListL END");
       
   268 	}
       
   269 
       
   270 void CDirectPrintPrinterSettingView::LoadExtendListL()
       
   271 	{
       
   272 	// Initialize capabilities for bearer
       
   273 	GetBearerMgr()->InitCapabilitiesL(iBearer);
       
   274 
       
   275 	// Extend setting item
       
   276 	CDirectPrintPrintSettings* printSettings = GetBearerMgr()->PrinterSettingsL();
       
   277 	TInt count = printSettings->iCapabilities.Count();
       
   278 	for (TInt i=0; i<count; i++)
       
   279 		{
       
   280 		CAknSettingItem* item = printSettings->iCapabilities[i]->SettingItemLC(ESettingViewItemExtent+i);
       
   281 		iListBox->SettingItemArray()->AppendL(item);
       
   282 		CleanupStack::Pop(item);
       
   283 		}
       
   284 
       
   285 	LoadExtendSettingsL();
       
   286 
       
   287 	iListBox->HandleChangeInItemArrayOrVisibilityL(); 
       
   288 	}
       
   289 
       
   290 void CDirectPrintPrinterSettingView::ReloadListL()
       
   291 	{
       
   292 	iListBox->StoreSettingsL();
       
   293 	StoreDriverInfoL();
       
   294 	StoreTypeInfoL();
       
   295 	StoreBearerInfoL();
       
   296 	StoreExtendSettingsL();
       
   297 
       
   298 	iListBox->SettingItemArray()->ResetAndDestroy();
       
   299 	LoadListL();
       
   300 	LoadDriverInfoL();
       
   301 	LoadTypeInfoL();
       
   302 	LoadBearerInfoL();
       
   303 
       
   304 	LoadExtendListL();
       
   305 
       
   306 	iListBox->LoadSettingsL();
       
   307 	iListBox->DrawNow();
       
   308 	}
       
   309 
       
   310 void CDirectPrintPrinterSettingView::SetBearerListL(CAknEnumeratedTextPopupSettingItem* item)
       
   311 	{
       
   312 	TInt err = GetBearerMgr()->GetProtocolNames(iBearerList);
       
   313 	if (!err)
       
   314 		{
       
   315 		CArrayPtr<CAknEnumeratedText>* textArray = item->EnumeratedTextArray();
       
   316 		textArray->ResetAndDestroy();
       
   317 
       
   318 		TInt count = iBearerList.Count();
       
   319 		for (TInt i=0; i<count; i++)
       
   320 			{
       
   321 			CAknEnumeratedText* enumText = new (ELeave) CAknEnumeratedText(i, iBearerList[i].iName.AllocLC());
       
   322 			CleanupStack::Pop();
       
   323 			CleanupStack::PushL(enumText);
       
   324 			textArray->AppendL(enumText);
       
   325 			CleanupStack::Pop();
       
   326 			}
       
   327 		}
       
   328 	}
       
   329 
       
   330 void CDirectPrintPrinterSettingView::ReadDataL()
       
   331 	{
       
   332 	LOG("CDirectPrintPrinterSettingView::ReadDataL BEGIN");
       
   333 	CDirectPrintModel& model = GetModel();
       
   334 	TDirectPrintPrinterData printerData;
       
   335 	TInt index = model.SelectPrinter();
       
   336 	if (index >= 0)
       
   337 		{
       
   338 		model.GetPrinterDataL(index, printerData);
       
   339 		}
       
   340 	else
       
   341 		{
       
   342 		model.SetCurrentPrinter(0);
       
   343 		}
       
   344 
       
   345 	TDirectPrintBearerData bearerData;
       
   346 	index = model.CurrentBearer();
       
   347 	if (index >= 0)
       
   348 		{
       
   349 		//model.GetBearerDataL(index, bearerData);
       
   350 		model.GetSelectedBearerDataL(bearerData);
       
   351 		}
       
   352 	else
       
   353 		{
       
   354 		model.SetCurrentBearer(0);
       
   355 		}
       
   356 
       
   357 	iPrinterId = printerData.iPrinterId;
       
   358 	iPrinterName.Copy(printerData.iPrinterName);
       
   359 	iDriverName.Copy(printerData.iDriverName);
       
   360 	iTypeName.Copy(printerData.iTypeName);
       
   361 	//iDriver = 1;
       
   362 	//iBearer = 1;
       
   363 	//iAccessPoint = 0;
       
   364 	iAccessPointName.Copy(bearerData.iAccessPoint);
       
   365 	iBearerName.Copy(bearerData.iBearerName);
       
   366 	iPort = bearerData.iPort;
       
   367 	if (bearerData.iHostName.Length() > 0)
       
   368 		{
       
   369 		iHost.Copy(bearerData.iHostName);
       
   370 		}
       
   371 	iUserName.Copy(bearerData.iUserName);
       
   372 	iQue.Copy(bearerData.iQueName);
       
   373 
       
   374 	LOG("CDirectPrintPrinterSettingView::ReadDataL END");
       
   375 	}
       
   376 
       
   377 void CDirectPrintPrinterSettingView::WriteDataL()
       
   378 	{
       
   379 	LOG("CDirectPrintPrinterSettingView::WriteDataL BEGIN");
       
   380 	TDirectPrintPrinterData printerData;
       
   381 	printerData.iPrinterId = iPrinterId;
       
   382 	printerData.iPrinterName.Copy(iPrinterName);
       
   383 //	printerData.iPrinterDriver = iDriverUid;
       
   384 	printerData.iDriverName.Copy(iDriverName);
       
   385 //	printerData.iPrinterType = iType;
       
   386 	printerData.iTypeName.Copy(iTypeName);
       
   387 
       
   388 	TDirectPrintBearerData bearerData;
       
   389 	bearerData.iPrinterId = iPrinterId;
       
   390 	bearerData.iBearerName.Copy(iBearerName);
       
   391 	bearerData.iAccessPoint.Copy(iAccessPointName);
       
   392 	bearerData.iHostName.Copy(iHost);
       
   393 	bearerData.iPort = iPort;
       
   394 	bearerData.iUserName.Copy(iUserName);
       
   395 	bearerData.iQueName.Copy(iQue);
       
   396 
       
   397 	CDirectPrintModel& model = GetModel();
       
   398 	if (model.IsNewData())
       
   399 		{
       
   400 		if (model.PrinterCount() == 0)
       
   401 			{
       
   402 			model.SetCurrentPrinter(0);
       
   403 			model.SetCurrentBearer(0);
       
   404 			}
       
   405 		model.SetPrinterDataL(model.PrinterCount(), printerData);
       
   406 		model.SetBearerDataL(model.BearerCount(), bearerData);
       
   407 		}
       
   408 	else
       
   409 		{
       
   410 		model.SetPrinterDataL(model.SelectPrinter(), printerData);
       
   411 		//model.SetBearerDataL(model.CurrentBearer(), bearerData);
       
   412 		model.SetBearerDataL(bearerData);
       
   413 		}
       
   414 	LOG("CDirectPrintPrinterSettingView::WriteDataL END");
       
   415 	}
       
   416 
       
   417 void CDirectPrintPrinterSettingView::NewDataL()
       
   418 	{
       
   419 	CDirectPrintModel& model = GetModel();
       
   420 	TInt count = model.PrinterCount();
       
   421 
       
   422 	TBuf<50> buf;
       
   423 	TBool IsNewName = EFalse;
       
   424 	for (TInt i=1; !IsNewName; i++)
       
   425 		{
       
   426 		buf.Format(_L("Printer%d"), count+i);
       
   427 		IsNewName = ETrue;
       
   428 
       
   429 		for (TInt j=0; j<count; j++)
       
   430 			{
       
   431 			TDirectPrintPrinterData printerData;
       
   432 			model.GetPrinterDataL(j, printerData);
       
   433 			if (printerData.iPrinterName.Compare(buf) == 0)
       
   434 				{
       
   435 				IsNewName = EFalse;
       
   436 				break;
       
   437 				}
       
   438 			}
       
   439 		}
       
   440 
       
   441 	iPrinterId = model.NewPrinterId();
       
   442 	iPrinterName.Copy(buf);
       
   443 	iDriver = 0;
       
   444 	iBearer = 0;
       
   445 	iAccessPoint = 0;
       
   446 //	iAccessPointName.Copy(_L("WLAN_ap1"));
       
   447 //	iHostIp.SetAddress(3232235530);
       
   448 	iPort = 80;
       
   449 	iUserName.Copy(_L(""));
       
   450 	iQue.Copy(_L(""));
       
   451 	}
       
   452 
       
   453 void CDirectPrintPrinterSettingView::LoadDriverInfoL()
       
   454 	{
       
   455 	TBuf<25> itemTitle;
       
   456 	CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_PRINTERSETTING_ITEM_DRIVER);
       
   457 	CAknEnumeratedTextPopupSettingItem* item = static_cast<CAknEnumeratedTextPopupSettingItem*>(GetSettingItemL(itemTitle));
       
   458 	CArrayPtr<CAknEnumeratedText>* textArray = item->EnumeratedTextArray();
       
   459 	TInt count = textArray->Count();
       
   460 
       
   461 	for (TInt i=0; i<count; i++)
       
   462 		{
       
   463 		if (iDriverName.Compare((*textArray)[i]->Value()->Des()) == 0)
       
   464 			{
       
   465 			iDriver = i;
       
   466 			}
       
   467 		}
       
   468 	}
       
   469 
       
   470 void CDirectPrintPrinterSettingView::LoadTypeInfoL()
       
   471 	{
       
   472 	TBuf<25> itemTitle;
       
   473 	CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_PRINTERSETTING_ITEM_TYPE);
       
   474 	CAknEnumeratedTextPopupSettingItem* item = static_cast<CAknEnumeratedTextPopupSettingItem*>(GetSettingItemL(itemTitle));
       
   475 	CArrayPtr<CAknEnumeratedText>* textArray = item->EnumeratedTextArray();
       
   476 	TInt count = textArray->Count();
       
   477 
       
   478 	for (TInt i=0; i<count; i++)
       
   479 		{
       
   480 		if (iTypeName.Compare((*textArray)[i]->Value()->Des()) == 0)
       
   481 			{
       
   482 			iType = i;
       
   483 			}
       
   484 		}
       
   485 	}
       
   486 
       
   487 void CDirectPrintPrinterSettingView::LoadBearerInfoL()
       
   488 	{
       
   489 	TBuf<25> itemTitle;
       
   490 	CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_PRINTERSETTING_ITEM_BEARER);
       
   491 	CAknEnumeratedTextPopupSettingItem* item = static_cast<CAknEnumeratedTextPopupSettingItem*>(GetSettingItemL(itemTitle));
       
   492 	CArrayPtr<CAknEnumeratedText>* textArray = item->EnumeratedTextArray();
       
   493 	TInt count = textArray->Count();
       
   494 
       
   495 	for (TInt i=0; i<count; i++)
       
   496 		{
       
   497 		if (iBearerName.Compare((*textArray)[i]->Value()->Des()) == 0)
       
   498 			{
       
   499 			iBearer = i;
       
   500 			}
       
   501 		}
       
   502 	}
       
   503 
       
   504 void CDirectPrintPrinterSettingView::LoadItemInfoL(TInt aResouceId, const TDesC& aInfo, TInt& aIndex)
       
   505 	{
       
   506 	TBuf<25> itemTitle;
       
   507 	CEikonEnv::Static()->ReadResource(itemTitle, aResouceId);
       
   508 	CAknEnumeratedTextPopupSettingItem* item = static_cast<CAknEnumeratedTextPopupSettingItem*>(GetSettingItemL(itemTitle));
       
   509 	CArrayPtr<CAknEnumeratedText>* textArray = item->EnumeratedTextArray();
       
   510 	TInt count = textArray->Count();
       
   511 
       
   512 	for (TInt i=0; i<count; i++)
       
   513 		{
       
   514 		if (aInfo.Compare((*textArray)[i]->Value()->Des()) == 0)
       
   515 			{
       
   516 			aIndex = i;
       
   517 			}
       
   518 		}
       
   519 	}
       
   520 
       
   521 void CDirectPrintPrinterSettingView::LoadExtendSettingsL()
       
   522 	{
       
   523 	CDirectPrintPrintSettings* printSettings = GetBearerMgr()->PrinterSettingsL();
       
   524 	TInt count = printSettings->iCapabilities.Count();
       
   525 	for (TInt i=0; i<count; i++)
       
   526 		{
       
   527 		switch (printSettings->iCapabilities[i]->iUid)
       
   528 			{
       
   529 			case EDirectPrintCapabAP:
       
   530 				{
       
   531 				CAknEnumeratedTextPopupSettingItem* item = static_cast<CAknEnumeratedTextPopupSettingItem*>(GetSettingItemL(printSettings->iCapabilities[i]->iTitle));
       
   532 				CArrayPtr<CAknEnumeratedText>* textArray = item->EnumeratedTextArray();
       
   533 				TInt count = textArray->Count();
       
   534 
       
   535 				for (TInt j=0; j<count; j++)
       
   536 					{
       
   537 					if (iAccessPointName.Compare((*textArray)[j]->Value()->Des()) == 0)
       
   538 						{
       
   539 						CDirectPrintListCapability* capability = static_cast<CDirectPrintListCapability*>(printSettings->iCapabilities[i]);
       
   540 						capability->iEnumIndex = j;
       
   541 						capability->iValue = capability->iEnumIDs[j];
       
   542 						break;
       
   543 						}
       
   544 					}
       
   545 				}
       
   546 				break;
       
   547 			case EDirectPrintCapabHost:
       
   548 				{
       
   549 				CDirectPrintTextCapability* capability = static_cast<CDirectPrintTextCapability*>(printSettings->iCapabilities[i]);
       
   550 				capability->iText.Copy(iHost);
       
   551 				}
       
   552 				break;
       
   553 			case EDirectPrintCapabPort:
       
   554 				{
       
   555 				printSettings->iCapabilities[i]->iValue = iPort;
       
   556 				}
       
   557 				break;
       
   558 			case EDirectPrintCapabUser:
       
   559 				{
       
   560 				CDirectPrintTextCapability* capability = static_cast<CDirectPrintTextCapability*>(printSettings->iCapabilities[i]);
       
   561 				capability->iText.Copy(iUserName);
       
   562 				}
       
   563 				break;
       
   564 			case EDirectPrintCapabQue:
       
   565 				{
       
   566 				CDirectPrintTextCapability* capability = static_cast<CDirectPrintTextCapability*>(printSettings->iCapabilities[i]);
       
   567 				capability->iText.Copy(iQue);
       
   568 				}
       
   569 				break;
       
   570 			default:
       
   571 				break;
       
   572 			}
       
   573 		}
       
   574 	}
       
   575 
       
   576 void CDirectPrintPrinterSettingView::StoreDriverInfoL()
       
   577 	{
       
   578 	TBuf<25> itemTitle;
       
   579 	CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_PRINTERSETTING_ITEM_DRIVER);
       
   580 	iDriverName.Copy(GetSettingItemL(itemTitle)->SettingTextL());
       
   581 	}
       
   582 
       
   583 void CDirectPrintPrinterSettingView::StoreTypeInfoL()
       
   584 	{
       
   585 	TBuf<25> itemTitle;
       
   586 	CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_PRINTERSETTING_ITEM_TYPE);
       
   587 	iTypeName.Copy(GetSettingItemL(itemTitle)->SettingTextL());
       
   588 	}
       
   589 
       
   590 void CDirectPrintPrinterSettingView::StoreBearerInfoL()
       
   591 	{
       
   592 	TBuf<25> itemTitle;
       
   593 	CEikonEnv::Static()->ReadResource(itemTitle, R_DIRECTPRINT_PRINTERSETTING_ITEM_BEARER);
       
   594 	iBearerName.Copy(GetSettingItemL(itemTitle)->SettingTextL());
       
   595 	}
       
   596 
       
   597 void CDirectPrintPrinterSettingView::StoreItemInfoL(TInt aResouceId, TDes& aInfo)
       
   598 	{
       
   599 	TBuf<25> itemTitle;
       
   600 	CEikonEnv::Static()->ReadResource(itemTitle, aResouceId);
       
   601 	aInfo.Copy(GetSettingItemL(itemTitle)->SettingTextL());
       
   602 	}
       
   603 
       
   604 void CDirectPrintPrinterSettingView::StoreExtendSettingsL()
       
   605 	{
       
   606 	CDirectPrintPrintSettings* printSettings = GetBearerMgr()->PrinterSettingsL();
       
   607 	TInt count = printSettings->iCapabilities.Count();
       
   608 	for (TInt i=0; i<count; i++)
       
   609 		{
       
   610 		switch (printSettings->iCapabilities[i]->iUid)
       
   611 			{
       
   612 			case EDirectPrintCapabAP:
       
   613 				{
       
   614 				CDirectPrintListCapability* capability = static_cast<CDirectPrintListCapability*>(printSettings->iCapabilities[i]);
       
   615 				iAccessPointName.Copy(GetSettingItemL(capability->iTitle)->SettingTextL());
       
   616 				capability->iValue = capability->iEnumIDs[capability->iEnumIndex];
       
   617 				}
       
   618 				break;
       
   619 			case EDirectPrintCapabHost:
       
   620 				{
       
   621 				iHost.Copy(GetSettingItemL(printSettings->iCapabilities[i]->iTitle)->SettingTextL());
       
   622 				}
       
   623 				break;
       
   624 			case EDirectPrintCapabPort:
       
   625 				{
       
   626 				iPort = printSettings->iCapabilities[i]->iValue;
       
   627 				}
       
   628 				break;
       
   629 			case EDirectPrintCapabUser:
       
   630 				{
       
   631 				iUserName.Copy(GetSettingItemL(printSettings->iCapabilities[i]->iTitle)->SettingTextL());
       
   632 				}
       
   633 				break;
       
   634 			case EDirectPrintCapabQue:
       
   635 				{
       
   636 				iQue.Copy(GetSettingItemL(printSettings->iCapabilities[i]->iTitle)->SettingTextL());
       
   637 				}
       
   638 				break;
       
   639 			default:
       
   640 				break;
       
   641 			}
       
   642 		}
       
   643 	}
       
   644 
       
   645 CAknSettingItem* CDirectPrintPrinterSettingView::GetSettingItemL(const TDesC& aItemTitle)
       
   646 	{
       
   647 	CAknSettingItem* item = NULL;
       
   648 	CAknSettingItemArray* array = iListBox->SettingItemArray();
       
   649 	TInt count = array->Count();
       
   650 
       
   651 	for (TInt i=0; i<count; i++)
       
   652 		{
       
   653 		item = (*array)[i];
       
   654 		TPtrC name = item->SettingName();
       
   655 		if (name.Compare(aItemTitle) == 0)
       
   656 			{
       
   657 			break;
       
   658 			}
       
   659 		item = NULL;
       
   660 		}
       
   661 
       
   662 	return item;
       
   663 	}
       
   664 
       
   665 CDirectPrintBearerMgr* CDirectPrintPrinterSettingView::GetBearerMgr()
       
   666 	{
       
   667 	return (static_cast<CDirectPrintAppAppUi*>(AppUi()))->BearerMgr();
       
   668 	}
       
   669