upnpsettings/upnpgsplugin/src/upnpappsettingitemhomeiap.cpp
branchIOP_Improvements
changeset 40 08b5eae9f9ff
parent 39 6369bfd1b60d
child 41 b4d83ea1d6e2
equal deleted inserted replaced
39:6369bfd1b60d 40:08b5eae9f9ff
     1 /*
       
     2 * Copyright (c) 2008 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:      Implements home network IAP setting item class to home
       
    15 *                network setting item list.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 
       
    24 
       
    25 // INCLUDE FILES
       
    26 // System
       
    27 #include <StringLoader.h>           // stringloader
       
    28 #include <aknmessagequerydialog.h>  // caknmessagequerydialog
       
    29 #include <aknradiobuttonsettingpage.h> // caknradiobuttonsettingpage
       
    30 #include <WlanCdbCols.h>            // wlan_service
       
    31 #include <wlanmgmtcommon.h>         // twlanssid
       
    32 #include <agentdialog.h>            // rgenconagentdialogserver
       
    33 #include <aknnotewrappers.h>        // cakninformationnote
       
    34 #include <cmmanager.h>
       
    35 #include <cmconnectionmethoddef.h>
       
    36 #include <commdb.h>                 //CCommsDatabase          
       
    37 #include "upnpavcontrollerfactory.h"
       
    38 #include "upnpsettingsengine.h"
       
    39 #include "upnpsettingsengine.hrh"
       
    40 
       
    41 // internal
       
    42 #include "upnpappsettingitemhomeiap.h"
       
    43 #include "upnpappsettingslist.h"    // ewlanunsecured
       
    44 #include "upnpfilesharingengine.h"  // cupnpfilesharingengine
       
    45 
       
    46 #include <upnpgspluginrsc.rsg>
       
    47 
       
    48 _LIT( KComponentLogfile, "upnpgsplugin.txt");
       
    49 #include "upnplog.h"
       
    50 
       
    51 // ================= MEMBER FUNCTIONS =======================
       
    52 
       
    53 // --------------------------------------------------------------------------
       
    54 // UPnPAppSettingItemHomeIAP::NewL()
       
    55 // --------------------------------------------------------------------------
       
    56 //
       
    57 UPnPAppSettingItemHomeIAP* UPnPAppSettingItemHomeIAP::NewL(
       
    58     TInt aIdentifier,
       
    59     TInt& aIAPSetting,
       
    60     TInt& aIAPId,
       
    61     TInt& aWAPId,
       
    62     TBool& aSharingState )
       
    63     {
       
    64     __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
       
    65     UPnPAppSettingItemHomeIAP* self = new (ELeave) UPnPAppSettingItemHomeIAP(
       
    66         aIdentifier,
       
    67         aIAPSetting,
       
    68         aIAPId,
       
    69         aWAPId,
       
    70         aSharingState );
       
    71 
       
    72     CleanupStack::PushL(self);
       
    73     self->ConstructL();
       
    74     CleanupStack::Pop(self);
       
    75     __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
       
    76     return self;
       
    77     }
       
    78 
       
    79 // --------------------------------------------------------------------------
       
    80 // UPnPAppSettingItemHomeIAP::UPnPAppSettingItemHomeIAP()
       
    81 // --------------------------------------------------------------------------
       
    82 //
       
    83 UPnPAppSettingItemHomeIAP::UPnPAppSettingItemHomeIAP(
       
    84     TInt aIdentifier,
       
    85     TInt& aIAPSetting,
       
    86     TInt& aIAPId,
       
    87     TInt& aWAPId,
       
    88     TBool& aSharingState ) :
       
    89     CAknEnumeratedTextPopupSettingItem(aIdentifier, aIAPSetting),
       
    90     iIAPSetting(aIAPSetting),
       
    91     iIAPId(aIAPId),
       
    92     iWAPId(aWAPId),
       
    93     iSharingState( aSharingState )
       
    94     {
       
    95     }
       
    96 
       
    97 // --------------------------------------------------------------------------
       
    98 // UPnPAppSettingItemHomeIAP::ConstructL()
       
    99 // --------------------------------------------------------------------------
       
   100 //
       
   101 void UPnPAppSettingItemHomeIAP::ConstructL()
       
   102     {
       
   103     __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
       
   104 
       
   105     iCoeEnv = CCoeEnv::Static();
       
   106     __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
       
   107     }
       
   108 
       
   109 // --------------------------------------------------------------------------
       
   110 // UPnPAppSettingItemHomeIAP::~UPnPAppSettingItemHomeIAP()
       
   111 // --------------------------------------------------------------------------
       
   112 //
       
   113 UPnPAppSettingItemHomeIAP::~UPnPAppSettingItemHomeIAP()
       
   114     {
       
   115     __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
       
   116     delete iItemText;
       
   117     delete iIAPName;
       
   118 
       
   119     iIAPIdArray.Close();
       
   120     __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
       
   121     }
       
   122 
       
   123 // --------------------------------------------------------------------------
       
   124 // UPnPAppSettingPageHomeIAP::CreateAndExecuteSettingPageL ()
       
   125 // --------------------------------------------------------------------------
       
   126 //
       
   127 void UPnPAppSettingItemHomeIAP::CreateAndExecuteSettingPageL()
       
   128     {
       
   129     __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
       
   130     // if sharing is on, only information note is displayed
       
   131     UPnPAVControllerFactory::TAVControllerServerStatus status;
       
   132     UPnPAVControllerFactory::Status( status );
       
   133     if ( iSharingState || status == UPnPAVControllerFactory::EStatusActive )
       
   134         {
       
   135         CAknInformationNote* note = new (ELeave) CAknInformationNote;
       
   136         HBufC* noteText = iCoeEnv->AllocReadResourceLC(
       
   137             R_QTN_IUPNP_IAP_TURN_SHARING_OFF);
       
   138         note->ExecuteLD(*noteText);
       
   139         CleanupStack::PopAndDestroy(noteText);
       
   140         return;
       
   141         }
       
   142 
       
   143     // Resets the member array for iap ids.
       
   144     // Creates new array for iap names.
       
   145     iIAPIdArray.Reset();
       
   146     CDesCArray* array = new (ELeave) CDesCArrayFlat(5);
       
   147     CleanupStack::PushL(array);
       
   148 
       
   149     // adds static setting page items from resource
       
   150     // and stores the number of static items.
       
   151     AddStaticItemsL(array);
       
   152     TInt staticItemCount = array->Count();
       
   153     
       
   154     // adds wlan access points, array GETS the ownership
       
   155     CUPnPSettingsEngine::GetWLANAccessPointsL( array, iIAPIdArray );
       
   156     
       
   157     MAknQueryValue* qValue = QueryValue();
       
   158     User::LeaveIfNull(qValue);
       
   159     LoadL();
       
   160     StoreL();
       
   161 
       
   162     TInt idx = GetIAPIndex( staticItemCount );
       
   163     if ( idx >= array->MdcaCount() )
       
   164         {
       
   165         idx = array->MdcaCount() - 1;
       
   166         }
       
   167     // setting page is launched
       
   168     CAknSettingPage* dlg = new (ELeave) CAknRadioButtonSettingPage(
       
   169         SettingPageResourceId(),
       
   170         idx,
       
   171         array);
       
   172 
       
   173     if (dlg->ExecuteLD())
       
   174         {
       
   175         switch (idx)
       
   176             {
       
   177             case EUPnPSettingsEngineIAPItemNone:
       
   178                 {
       
   179                 DisplayInfoL(R_IBU_GALLERY_UPDATE_NOTE_TITLE_TEXT,
       
   180                              R_IBU_GALLERY_UPDATE_NOTAVAIL_NOTE_TEXT,
       
   181                              R_HOMECONNECT_INFO_QUERY);
       
   182                 qValue->SetCurrentValueIndex(EUPnPSettingsEngineIAPItemNone);
       
   183                 iIAPId = EUPnPSettingsEngineIAPIdNone;
       
   184                 iIAPSetting = EUPnPSettingsEngineIAPItemNone;
       
   185                 break;
       
   186                 }
       
   187             case EUPnPSettingsEngineIAPItemAlwaysAsk:
       
   188                 {
       
   189                 qValue->SetCurrentValueIndex(EUPnPSettingsEngineIAPItemAlwaysAsk);
       
   190                 iIAPId = EUPnPSettingsEngineIAPIdAlwaysAsk;
       
   191                 iIAPSetting = EUPnPSettingsEngineIAPItemAlwaysAsk;
       
   192                 DisplayInfoL(R_IBU_GALLERY_UPDATE_NOTE_TITLE_TEXT,
       
   193                              R_IBU_GALLERY_UPDATE_NOTE_TEXT,
       
   194                              R_HOMECONNECT_INFO_QUERY);
       
   195                 break;
       
   196                 }
       
   197             case EUPnPSettingsEngineIAPItemUserDefined: // Create new
       
   198                 {
       
   199                 // new iap wlan iap creation is started here
       
   200                 
       
   201                 TInt old_iap = iIAPId;
       
   202                 
       
   203                 CUPnPSettingsEngine::CreateAccessPointL();
       
   204                 
       
   205                 //We have to re-get all the wlan iaps again since
       
   206                 //user may modify the iap list   
       
   207                 RArray<TInt64> newArray;
       
   208                 CleanupClosePushL( newArray );
       
   209                 
       
   210                 //We only are interested in the iap ids
       
   211                 CUPnPSettingsEngine::GetWLANAccessPointsL(
       
   212                                                     NULL, 
       
   213                                                     newArray );
       
   214                 
       
   215                 if( newArray.Count() <= 0 ) //if no iap exisits
       
   216                     {
       
   217                     //if previous iap is not "None" or "Always ask"
       
   218                     if( old_iap > EUPnPSettingsEngineIAPIdAlwaysAsk )
       
   219                         {
       
   220                         DisplayInfoL(
       
   221                             R_IBU_GALLERY_UPDATE_NOTE_TITLE_TEXT,
       
   222                             R_IBU_GALLERY_UPDATE_NOTAVAIL_NOTE_TEXT,
       
   223                             R_HOMECONNECT_INFO_QUERY);
       
   224                         iIAPId = EUPnPSettingsEngineIAPIdNone;
       
   225                         
       
   226                         qValue->SetCurrentValueIndex(
       
   227                                             EUPnPSettingsEngineIAPItemNone );
       
   228                         iIAPSetting = EUPnPSettingsEngineIAPItemNone;
       
   229                         }
       
   230                     iIAPIdArray.Reset();
       
   231                     CleanupStack::PopAndDestroy( &newArray );
       
   232                     }
       
   233                 else
       
   234                     {
       
   235                     TBool newiap = ETrue;
       
   236                     TInt lastItemIndex = newArray.Count() - 1;
       
   237                     //if the last item on the new iap list 
       
   238                     //is found in the old iap array
       
   239                     //then we think no new iap is created
       
   240                     for( TInt i = 0; i < iIAPIdArray.Count(); i++ )
       
   241                         {                        
       
   242                         if( newArray[lastItemIndex] == iIAPIdArray[i] )
       
   243                             {
       
   244                             newiap = EFalse; 
       
   245                             i = iIAPIdArray.Count();
       
   246                             }
       
   247                         }
       
   248                     
       
   249                     //get the new iap list
       
   250                     iIAPIdArray.Reset();
       
   251                     for( TInt i = 0; i < newArray.Count(); i++ )
       
   252                         {
       
   253                         iIAPIdArray.AppendL( newArray[i] );
       
   254                         }                        
       
   255                     CleanupStack::PopAndDestroy( &newArray );
       
   256                     
       
   257                     if( newiap )
       
   258                         {
       
   259                         iIAPId = iIAPIdArray[lastItemIndex];//get new iap
       
   260                         iIAPSetting = 
       
   261                                 EUPnPSettingsEngineIAPItemUserDefined;
       
   262                         // show confirmation note if connection is 
       
   263                         // unsecured, the database store the value of
       
   264                         // the securitymode,such as EOpen,EWep,E802_1x,
       
   265                         // EWpa,if select other securitymode except 
       
   266                         // EOpen, the return value of the 
       
   267                         // CheckAPSecurityL fuction is not EWLanUnsecured
       
   268                         if ( CheckAPSecurityL(iIAPId) == EWLanUnsecured )
       
   269                             {
       
   270                             CAknQueryDialog* dlg = 
       
   271                                                 CAknQueryDialog::NewL();
       
   272                             if (!(dlg->ExecuteLD(
       
   273                             R_UNSECURED_CONNECTIONS_CONFIRMATION_QUERY)))
       
   274                                 {
       
   275                                 //user cancels the dialog
       
   276                                 UsePreviousIapL( old_iap ); 
       
   277                                 }
       
   278                             }
       
   279                         else
       
   280                             {
       
   281                             // show 'Sharing Changed' note ( None -> sharing)
       
   282                             if(old_iap == EUPnPSettingsEngineIAPIdNone &&
       
   283                                iIAPId != old_iap )
       
   284                                 {
       
   285                                 DisplayInfoL(
       
   286                                      R_IBU_GALLERY_UPDATE_NOTE_TITLE_TEXT,
       
   287                                      R_IBU_GALLERY_UPDATE_NOTE_TEXT,
       
   288                                      R_HOMECONNECT_INFO_QUERY);
       
   289                                 }  
       
   290                             }    
       
   291                         }
       
   292                     else 
       
   293                         {
       
   294                         UsePreviousIapL(old_iap);
       
   295                         } //if( newiap )
       
   296                     } //if( newArray.Count() <= 0 )
       
   297                 break;
       
   298                 }
       
   299             default: // Predefined iap is selected
       
   300                 {
       
   301                 TInt index;
       
   302                 TInt old_iap = iIAPId;
       
   303                 TBool iapchange = EFalse;
       
   304                 // iap id is set
       
   305                 if ( idx - staticItemCount >= 0 )
       
   306                     {
       
   307                     index = idx - staticItemCount;
       
   308                     if (CheckAPSecurityL(iIAPIdArray[index]) ==
       
   309                         EWLanUnsecured)
       
   310                         {
       
   311                         // show confirmation note if connection is unsecured
       
   312                         CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   313                         if (dlg->ExecuteLD(
       
   314                             R_UNSECURED_CONNECTIONS_CONFIRMATION_QUERY))
       
   315                             {
       
   316                             //if "Continue"
       
   317                             iapchange = ETrue;
       
   318                             }
       
   319                         }
       
   320                     else
       
   321                         {
       
   322                         iapchange = ETrue;
       
   323                         }
       
   324                    
       
   325                     if( iapchange )
       
   326                         {
       
   327                         iIAPSetting = EUPnPSettingsEngineIAPItemUserDefined;
       
   328                         iIAPId = iIAPIdArray[index];
       
   329                         qValue->SetCurrentValueIndex(
       
   330                             EUPnPSettingsEngineIAPItemUserDefined);
       
   331 
       
   332                         // if previous iap was 'None' and current iap
       
   333                         // is not 'None'
       
   334                         if ( old_iap == EUPnPSettingsEngineIAPIdNone &&
       
   335                              iIAPId != old_iap )
       
   336                             {
       
   337                             DisplayInfoL(
       
   338                                 R_IBU_GALLERY_UPDATE_NOTE_TITLE_TEXT,
       
   339                                 R_IBU_GALLERY_UPDATE_NOTE_TEXT,
       
   340                                 R_HOMECONNECT_INFO_QUERY);
       
   341                             }
       
   342                         }
       
   343                     }
       
   344                 break;
       
   345                 }
       
   346             }
       
   347         }
       
   348     LoadL();
       
   349     StoreL();
       
   350 
       
   351     CleanupStack::PopAndDestroy(array);
       
   352     __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
       
   353     }
       
   354 
       
   355 // --------------------------------------------------------------------------
       
   356 // UPnPAppSettingItemHomeIAP::ChangeIAPNameL()
       
   357 // --------------------------------------------------------------------------
       
   358 //
       
   359 void UPnPAppSettingItemHomeIAP::ChangeIAPNameL()
       
   360     {
       
   361     __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
       
   362     delete iIAPName;
       
   363     iIAPName = NULL;
       
   364     
       
   365     iIAPName = CUPnPSettingsEngine::GetCurrentIapNameL( iIAPId );
       
   366     
       
   367     __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
       
   368     }
       
   369 
       
   370 // --------------------------------------------------------------------------
       
   371 // UPnPAppSettingItemHomeIAP::CheckAPSecurity
       
   372 // Checks if selected access point is unsecured and shows warning note
       
   373 // --------------------------------------------------------------------------
       
   374 //
       
   375 TInt UPnPAppSettingItemHomeIAP::CheckAPSecurityL(TInt aAccessPoint)
       
   376     {
       
   377     __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
       
   378     TUint32 serviceId = 0;
       
   379     TUint32 securityMode = 0;
       
   380 
       
   381     CCommsDatabase* db = CCommsDatabase::NewL( EDatabaseTypeIAP );
       
   382     CleanupStack::PushL( db );
       
   383 
       
   384     CCommsDbTableView* view = db->OpenViewMatchingUintLC(TPtrC(IAP),
       
   385                               TPtrC(COMMDB_ID), aAccessPoint);
       
   386 
       
   387     TInt error = view->GotoFirstRecord();
       
   388 
       
   389     if( error == KErrNone )
       
   390         {
       
   391         view->ReadUintL(TPtrC(IAP_SERVICE), serviceId);
       
   392         }
       
   393 
       
   394     CCommsDbTableView* wLanServiceTable = NULL;
       
   395 
       
   396     TRAPD(err,
       
   397     {// this leaves if the table is empty....
       
   398     wLanServiceTable = db->OpenViewMatchingUintLC(
       
   399         TPtrC( WLAN_SERVICE ),
       
   400         TPtrC( WLAN_SERVICE_ID ),
       
   401         serviceId );
       
   402     CleanupStack::Pop( wLanServiceTable );
       
   403     });
       
   404 
       
   405     if ( err == KErrNone )
       
   406         {
       
   407         CleanupStack::PushL( wLanServiceTable );
       
   408 
       
   409         TInt errorCode = wLanServiceTable->GotoFirstRecord();
       
   410 
       
   411         if ( errorCode == KErrNone )
       
   412             {//read securityMode value
       
   413             wLanServiceTable->ReadUintL(TPtrC( WLAN_SECURITY_MODE ),
       
   414                                         securityMode );
       
   415             }
       
   416 
       
   417         CleanupStack::PopAndDestroy(wLanServiceTable);
       
   418         }
       
   419 
       
   420     else if (err != KErrNotFound)
       
   421         {
       
   422         User::LeaveIfError(err);
       
   423         }
       
   424 
       
   425     CleanupStack::PopAndDestroy(2); // view, db
       
   426     __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
       
   427 
       
   428     return securityMode;
       
   429     }
       
   430 
       
   431 // --------------------------------------------------------------------------
       
   432 // CUPnPAppSettingsList::DisplayInfoL();
       
   433 // Shows message query to user
       
   434 // --------------------------------------------------------------------------
       
   435 //
       
   436 void UPnPAppSettingItemHomeIAP::DisplayInfoL(TInt aHeaderResourceId,
       
   437                                              TInt aMessageResourceId,
       
   438                                              TInt aDialogResourceId)
       
   439     {
       
   440     __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
       
   441     HBufC* noteHeader = StringLoader::LoadL(
       
   442         aHeaderResourceId);
       
   443     CleanupStack::PushL(noteHeader);
       
   444     HBufC* noteMsg = StringLoader::LoadL(
       
   445         aMessageResourceId);
       
   446     CleanupStack::PushL(noteMsg);
       
   447 
       
   448     CAknMessageQueryDialog* dlg = CAknMessageQueryDialog::NewL(*noteMsg);
       
   449 
       
   450     dlg->PrepareLC(aDialogResourceId);
       
   451     dlg->QueryHeading()->SetTextL(*noteHeader);
       
   452     dlg->RunLD();
       
   453 
       
   454     CleanupStack::PopAndDestroy(noteMsg);
       
   455     CleanupStack::PopAndDestroy(noteHeader);
       
   456     __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
       
   457     }
       
   458 
       
   459 // --------------------------------------------------------------------------
       
   460 // UPnPAppSettingItemHomeIAP::SettingTextL()
       
   461 // --------------------------------------------------------------------------
       
   462 //
       
   463 const TDesC& UPnPAppSettingItemHomeIAP::SettingTextL()
       
   464     {
       
   465     __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
       
   466     delete iItemText;
       
   467     iItemText = NULL;
       
   468     LoadL();
       
   469     StoreL();
       
   470 
       
   471     switch ( iIAPSetting )
       
   472         {
       
   473         case EUPnPSettingsEngineIAPItemAlwaysAsk:
       
   474             {
       
   475             iItemText = iCoeEnv->AllocReadResourceL(
       
   476                 R_QTN_IUPNP_ITEM_HOME_IAP_ALWAYS_ASK );
       
   477             break;
       
   478             }
       
   479         case EUPnPSettingsEngineIAPItemUserDefined:
       
   480             {
       
   481             // changes iap name according to iap id
       
   482             ChangeIAPNameL();
       
   483 
       
   484             if ( !iIAPName )
       
   485                 {
       
   486                 iItemText = iCoeEnv->AllocReadResourceL(
       
   487                     R_QTN_IUPNP_ITEM_HOME_IAP_USER_DEFINED );
       
   488                 }
       
   489             else
       
   490                 {
       
   491                 iItemText = iIAPName->AllocL();
       
   492                 }
       
   493 
       
   494             break;
       
   495             }
       
   496         case EUPnPSettingsEngineIAPItemNone:
       
   497             {
       
   498             iItemText = iCoeEnv->AllocReadResourceL(
       
   499                 R_QTN_IUPNP_ITEM_HOME_IAP_NONE );
       
   500             break;
       
   501             }
       
   502         default:
       
   503             {
       
   504             break;
       
   505             }
       
   506         }
       
   507     __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
       
   508     return *iItemText;
       
   509     }
       
   510 
       
   511 // --------------------------------------------------------------------------
       
   512 // UPnPAppSettingItemHomeIAP::AddStaticItemsL()
       
   513 // --------------------------------------------------------------------------
       
   514 //
       
   515 void UPnPAppSettingItemHomeIAP::AddStaticItemsL(CDesCArray* aArray)
       
   516     {
       
   517     __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
       
   518     // None
       
   519     HBufC* buf = iCoeEnv->AllocReadResourceLC(
       
   520         R_QTN_IUPNP_HOME_IAP_NONE);
       
   521     aArray->AppendL(*buf);
       
   522     CleanupStack::PopAndDestroy(buf); // buf
       
   523     buf = NULL;
       
   524 
       
   525     // Always ask
       
   526     buf = iCoeEnv->AllocReadResourceLC(
       
   527         R_QTN_IUPNP_HOME_IAP_ALWAYS_ASK);
       
   528     aArray->AppendL(*buf);
       
   529     CleanupStack::PopAndDestroy(buf);
       
   530     buf = NULL;
       
   531 
       
   532     // Create new
       
   533     buf = iCoeEnv->AllocReadResourceLC(
       
   534         R_QTN_IUPNP_HOME_IAP_CREATE_NEW);
       
   535     aArray->AppendL(*buf);
       
   536     CleanupStack::PopAndDestroy(buf);
       
   537     buf = NULL;
       
   538     __LOG8_1( "%s end.", __PRETTY_FUNCTION__ );
       
   539     }
       
   540 
       
   541 // --------------------------------------------------------------------------
       
   542 // UPnPAppSettingItemHomeIAP::UsePreviousIapL()
       
   543 // --------------------------------------------------------------------------
       
   544 //
       
   545 void UPnPAppSettingItemHomeIAP::UsePreviousIapL( TInt aOldIap )
       
   546     {
       
   547     // dialog cancelled, using old iap value
       
   548     iIAPId = aOldIap;
       
   549     
       
   550     if( iIAPId == EUPnPSettingsEngineIAPIdNone )
       
   551         {
       
   552         iIAPSetting = EUPnPSettingsEngineIAPItemNone;
       
   553         }
       
   554     else if( iIAPId == EUPnPSettingsEngineIAPIdAlwaysAsk )
       
   555         {
       
   556         iIAPSetting = EUPnPSettingsEngineIAPItemAlwaysAsk;
       
   557         }
       
   558     else //search for the old iap
       
   559         {
       
   560         TBool oldiapthere = EFalse;
       
   561         for( TInt i = 0; i < iIAPIdArray.Count(); i++ )
       
   562             {
       
   563             if( iIAPId == iIAPIdArray[i] )
       
   564                 {
       
   565                 oldiapthere = ETrue;
       
   566                 i = iIAPIdArray.Count();
       
   567                 }
       
   568             }
       
   569         if( !oldiapthere )
       
   570             {
       
   571             iIAPId = EUPnPSettingsEngineIAPIdNone;
       
   572             iIAPSetting = EUPnPSettingsEngineIAPItemNone;
       
   573             DisplayInfoL(R_IBU_GALLERY_UPDATE_NOTE_TITLE_TEXT,
       
   574                              R_IBU_GALLERY_UPDATE_NOTAVAIL_NOTE_TEXT,
       
   575                              R_HOMECONNECT_INFO_QUERY);
       
   576             }
       
   577         else
       
   578             {
       
   579             iIAPSetting = EUPnPSettingsEngineIAPItemUserDefined;
       
   580             }    
       
   581         }   
       
   582     }
       
   583     
       
   584 // --------------------------------------------------------------------------
       
   585 // UPnPAppSettingItemHomeIAP::GetIAPIndex()
       
   586 // --------------------------------------------------------------------------
       
   587 //
       
   588 TInt UPnPAppSettingItemHomeIAP::GetIAPIndex( TInt aStaticCount )
       
   589     {
       
   590     __LOG("GetIAPIndex");  
       
   591     TInt iapIndex = KErrNotFound;
       
   592     if( iIAPId == EUPnPSettingsEngineIAPIdNone ) //NONE
       
   593         {
       
   594         iapIndex = EUPnPSettingsEngineIAPItemNone;
       
   595         }
       
   596     else if( iIAPId == EUPnPSettingsEngineIAPIdAlwaysAsk ) //ALWAYS ASK
       
   597         {
       
   598         iapIndex = EUPnPSettingsEngineIAPItemAlwaysAsk;
       
   599         }
       
   600     else //pre-defined iap, index should never be Create New
       
   601         {
       
   602         iapIndex+=aStaticCount;
       
   603         for( TInt i = 0; i < iIAPIdArray.Count(); i++ )
       
   604             {
       
   605             iapIndex++;
       
   606             __LOG1("iap %d", iIAPIdArray[i] );  
       
   607             if( iIAPId == iIAPIdArray[i] )
       
   608                 {
       
   609                 i = iIAPIdArray.Count();
       
   610                 }
       
   611             }
       
   612         }
       
   613         
       
   614     return iapIndex;    
       
   615     }    
       
   616 // End of File