apengine/apsettingshandlerui/src/ApSelQueryDialog.cpp
changeset 66 ed07dcc72692
parent 47 cb7afde124a3
equal deleted inserted replaced
64:84c6623982f6 66:ed07dcc72692
    45 // ================= MEMBER FUNCTIONS =======================
    45 // ================= MEMBER FUNCTIONS =======================
    46 
    46 
    47 // Destructor
    47 // Destructor
    48 CApSelQueryDialog::~CApSelQueryDialog()
    48 CApSelQueryDialog::~CApSelQueryDialog()
    49     {
    49     {
    50     APSETUILOGGER_ENTERFN( EOther,"SelQuery::~CApSelQueryDialog")
       
    51     
       
    52     if ( iDataModel )
       
    53         {
       
    54         if ( iDataModel->Database() )
       
    55             {
       
    56             // iModel is deleted by the ListBox because LB owns the model
       
    57             iDataModel->Database()->RemoveObserver( this );
       
    58             }
       
    59         }
       
    60 
       
    61     APSETUILOGGER_LEAVEFN( EOther,"SelQuery::~CApSelQueryDialog")
       
    62     }
    50     }
    63 
    51 
    64 
    52 
    65 
    53 
    66 // Constructor
    54 // Constructor
    67 CApSelQueryDialog::CApSelQueryDialog( CApSettingsModel& aModel,
    55 CApSelQueryDialog::CApSelQueryDialog( CApSettingsModel& aModel,
    68                                       TUint32* aIndex )
    56                                       TUint32* aIndex )
    69 :CAknListQueryDialog( (TInt*)aIndex ),
    57 :CAknListQueryDialog( (TInt*)aIndex ),
    70 iNeedUnlock( EFalse )
    58 iNeedUnlock( EFalse )
    71     {
    59     {
    72     iDataModel = &aModel;
       
    73     iSelected = aIndex;
       
    74     }
    60     }
    75 
    61 
    76 
    62 
    77 
    63 
    78 // ---------------------------------------------------------
    64 // ---------------------------------------------------------
    80 // called by the active access point framework
    66 // called by the active access point framework
    81 // ---------------------------------------------------------
    67 // ---------------------------------------------------------
    82 //
    68 //
    83 void CApSelQueryDialog::HandleApDbEventL( TEvent anEvent )
    69 void CApSelQueryDialog::HandleApDbEventL( TEvent anEvent )
    84     {
    70     {
    85     APSETUILOGGER_ENTERFN( EOther,"SelQuery::HandleApDbEventL")
       
    86     
       
    87     switch ( anEvent )
       
    88         {
       
    89         case EDbChanged:
       
    90             {
       
    91             FillListBoxWithDataL();
       
    92             break;
       
    93             }
       
    94         case EDbClosing:
       
    95             {
       
    96             break;
       
    97             }
       
    98         case EDbAvailable:
       
    99             {
       
   100             if ( iNeedUnlock )
       
   101                 {
       
   102                 FillListBoxWithDataL();
       
   103                 }
       
   104             break;
       
   105             }
       
   106         default:
       
   107             {
       
   108             __ASSERT_DEBUG( EFalse, Panic( EUnknownCase ) );
       
   109             break;
       
   110             }
       
   111         }
       
   112     
       
   113     APSETUILOGGER_LEAVEFN( EOther,"SelQuery::HandleApDbEventL")
       
   114     }
    71     }
   115 
    72 
   116 
    73 
   117 
    74 
   118 
    75 
   121 // called by framework before dialog is shown
    78 // called by framework before dialog is shown
   122 // ---------------------------------------------------------
    79 // ---------------------------------------------------------
   123 //
    80 //
   124 void CApSelQueryDialog::PreLayoutDynInitL()
    81 void CApSelQueryDialog::PreLayoutDynInitL()
   125     {
    82     {
   126     APSETUILOGGER_ENTERFN( EOther,"SelQuery::PreLayoutDynInitL")
       
   127     
       
   128     // parent creates the private listbox
       
   129     CAknListQueryDialog::PreLayoutDynInitL();
       
   130     // and now we get access to it...
       
   131     CAknListQueryControl *control = 
       
   132             ( CAknListQueryControl* )Control( EListQueryControl );
       
   133     iList = control->Listbox();
       
   134     LoadIconsL();
       
   135     FillListBoxWithDataL();
       
   136     iDataModel->Database()->AddObserverL( this );
       
   137     
       
   138     APSETUILOGGER_LEAVEFN( EOther,"SelQuery::PreLayoutDynInitL")
       
   139     }
    83     }
   140 
    84 
   141 
    85 
   142 // ---------------------------------------------------------
    86 // ---------------------------------------------------------
   143 // CApSelQueryDialog::PostLayoutDynInitL();
    87 // CApSelQueryDialog::PostLayoutDynInitL();
   144 // called by framework before dialog is shown
    88 // called by framework before dialog is shown
   145 // ---------------------------------------------------------
    89 // ---------------------------------------------------------
   146 //
    90 //
   147 void CApSelQueryDialog::PostLayoutDynInitL()
    91 void CApSelQueryDialog::PostLayoutDynInitL()
   148     {
    92     {
   149     APSETUILOGGER_ENTERFN( EOther,"SelQuery::PostLayoutDynInitL")
       
   150     
       
   151     CAknListQueryDialog::PostLayoutDynInitL();
       
   152     
       
   153     APSETUILOGGER_LEAVEFN( EOther,"SelQuery::PostLayoutDynInitL")
       
   154     }
    93     }
   155 
    94 
   156 
    95 
   157 // ---------------------------------------------------------
    96 // ---------------------------------------------------------
   158 // CApSelQueryDialog::OkToExitL( TInt aButtonId )
    97 // CApSelQueryDialog::OkToExitL( TInt aButtonId )
   159 // called by framework when the OK button is pressed
    98 // called by framework when the OK button is pressed
   160 // ---------------------------------------------------------
    99 // ---------------------------------------------------------
   161 //
   100 //
   162 TBool CApSelQueryDialog::OkToExitL( TInt aButtonId )
   101 TBool CApSelQueryDialog::OkToExitL( TInt aButtonId )
   163     {
   102     {
   164     APSETUILOGGER_ENTERFN( EOther,"SelQuery::OkToExitL")
   103     return EFalse;
   165     
       
   166     // Translate the button presses into commands for the appui & current
       
   167     // view to handle
       
   168     TBool retval( EFalse );
       
   169     if ( aButtonId == EAknSoftkeySelect )
       
   170         {
       
   171         TInt idx = iList->CurrentItemIndex();
       
   172         if ( idx >= 0 )
       
   173             {
       
   174             if ( iModel->At( iList->CurrentItemIndex() )->IsReadOnly() )
       
   175                 { // read only, do not accept
       
   176                 // show note
       
   177                 ShowNoteL( R_APUI_NOTE_CANNOT_USE_PROTECTED_AP );
       
   178                 retval = EFalse;
       
   179                 }
       
   180             else
       
   181                 {
       
   182                 *iSelected = iModel->At( iList->CurrentItemIndex() )->Uid();
       
   183                 retval = ETrue;
       
   184                 }
       
   185             }
       
   186         }
       
   187     else
       
   188         {
       
   189         if ( aButtonId == EAknSoftkeyBack )
       
   190             {
       
   191             retval = ETrue;
       
   192             }
       
   193         }
       
   194     
       
   195     APSETUILOGGER_LEAVEFN( EOther,"SelQuery::OkToExitL")
       
   196     return retval;
       
   197     }
   104     }
   198 
   105 
   199 
   106 
   200 
   107 
   201 
   108 
   205 // ---------------------------------------------------------
   112 // ---------------------------------------------------------
   206 //
   113 //
   207 TKeyResponse CApSelQueryDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent,
   114 TKeyResponse CApSelQueryDialog::OfferKeyEventL( const TKeyEvent& aKeyEvent,
   208                                               TEventCode aType)
   115                                               TEventCode aType)
   209     {
   116     {
   210     APSETUILOGGER_ENTERFN( EOther,"SelQuery::OfferKeyEventL")
   117     User::Leave( KErrNotSupported );
   211     
       
   212     TKeyResponse retval;
       
   213     if ( aType == EEventKey )
       
   214         {
       
   215         if ( aKeyEvent.iCode == EKeyOK )
       
   216             { // process only if command is available...
       
   217             ProcessCommandL( EApSelCmdSelect );
       
   218             retval = EKeyWasConsumed;
       
   219             }
       
   220         else
       
   221             {
       
   222             retval = CAknListQueryDialog::OfferKeyEventL(
       
   223                                     aKeyEvent, aType );
       
   224             }
       
   225         }
       
   226     else
       
   227         {
       
   228         retval = CAknListQueryDialog::OfferKeyEventL( aKeyEvent, aType );
       
   229         }
       
   230     
       
   231     APSETUILOGGER_LEAVEFN( EOther,"SelQuery::OfferKeyEventL")
       
   232     return retval;
       
   233     }
   118     }
   234 
   119 
   235 
   120 
   236 
   121 
   237 // From MEikCommandObserver
   122 // From MEikCommandObserver
   239 // CApSelQueryDialog::ProcessCommandL
   124 // CApSelQueryDialog::ProcessCommandL
   240 // ---------------------------------------------------------
   125 // ---------------------------------------------------------
   241 //
   126 //
   242 void CApSelQueryDialog::ProcessCommandL( TInt aCommandId )
   127 void CApSelQueryDialog::ProcessCommandL( TInt aCommandId )
   243     {
   128     {
   244     APSETUILOGGER_ENTERFN( EOther,"SelQuery::ProcessCommandL")
       
   245     
       
   246     if ( MenuShowing() )
       
   247         {
       
   248         HideMenu();
       
   249         }
       
   250 
       
   251     switch ( aCommandId )
       
   252         {
       
   253         case EAknSoftkeyOptions:
       
   254             {
       
   255             DisplayMenuL();
       
   256             break;
       
   257             }
       
   258         case EAknSoftkeyBack:
       
   259             {
       
   260             TryExitL( EFalse );
       
   261             break;
       
   262             }
       
   263         case EApSelCmdSelect:
       
   264             {
       
   265             TryExitL( EAknSoftkeySelect );
       
   266             break;
       
   267             }
       
   268         case EAknCmdHelp:
       
   269             {
       
   270 		    FeatureManager::InitializeLibL();
       
   271 		    TBool helpSupported = FeatureManager::FeatureSupported( KFeatureIdHelp );
       
   272 		    FeatureManager::UnInitializeLib();
       
   273 			if ( helpSupported )
       
   274 				{            
       
   275             	iDataModel->LaunchHelpL();
       
   276 				}
       
   277             break;
       
   278             }
       
   279         case EApSelCmdExit:
       
   280         case EEikCmdExit:
       
   281             {
       
   282             TryExitL( EFalse );
       
   283             break;
       
   284             }
       
   285         default:
       
   286             {
       
   287             // silently ignore it
       
   288             break;
       
   289             }
       
   290         }
       
   291     
       
   292     APSETUILOGGER_LEAVEFN( EOther,"SelQuery::ProcessCommandL")
       
   293     }
   129     }
   294 
   130 
   295 
   131 
   296 
   132 
   297 // ---------------------------------------------------------
   133 // ---------------------------------------------------------
   299 // called when listbopx needs to be filled with data
   135 // called when listbopx needs to be filled with data
   300 // ---------------------------------------------------------
   136 // ---------------------------------------------------------
   301 //
   137 //
   302 void CApSelQueryDialog::FillListBoxWithDataL()
   138 void CApSelQueryDialog::FillListBoxWithDataL()
   303     {
   139     {
   304     APSETUILOGGER_ENTERFN( EOther,"SelQuery::FillListBoxWithDataL")
       
   305     
       
   306     TBool needtopop( EFalse );
       
   307 
       
   308     if ( ! iModel )
       
   309         {
       
   310         // we must use temp var to satisfy CodeScanner
       
   311         CApSelectorListboxModel* tmp = new( ELeave )CApSelectorListboxModel( 
       
   312                                 CApSelectorListboxModel::EGraphicProtection );
       
   313         // although it will be member, but mainly owned by the listbox,
       
   314         // so as long as ownership is not transferred, MUST push it
       
   315         CleanupStack::PushL( tmp );
       
   316         iModel = tmp;
       
   317         // we need to Pop after ownership is passed to listbox
       
   318         needtopop = ETrue;
       
   319         }
       
   320     TBool isLocked( EFalse );
       
   321     iNeedUnlock = EFalse;
       
   322     iDataModel->AllListItemDataL( isLocked, *iModel, KEApIspTypeAll,
       
   323                                   EApBearerTypeAll, KEApSortNameAscending,
       
   324                                   iDataModel->RequestedIPvType(), 
       
   325                                   EVpnFilterNoVpn,
       
   326                                   EFalse );
       
   327 
       
   328     if ( isLocked )
       
   329         {
       
   330         iNeedUnlock = ETrue;
       
   331         }
       
   332 
       
   333     SetItemTextArray( iModel );
       
   334     if ( needtopop )
       
   335         { 
       
   336         // it signals that ownership of iModel had JUST been passed,
       
   337         // so we can Pop it.
       
   338         CleanupStack::Pop( iModel);
       
   339         }
       
   340     
       
   341     APSETUILOGGER_LEAVEFN( EOther,"SelQuery::FillListBoxWithDataL")
       
   342     }
   140     }
   343 
   141 
   344 
   142 
   345 
   143 
   346 
   144 
   349 // called when listbox is constructed 
   147 // called when listbox is constructed 
   350 // ---------------------------------------------------------
   148 // ---------------------------------------------------------
   351 //
   149 //
   352 TInt CApSelQueryDialog::LoadIconsL()
   150 TInt CApSelQueryDialog::LoadIconsL()
   353     {
   151     {
   354     APSETUILOGGER_ENTERFN( EOther,"SelQuery::LoadIconsL")
       
   355     
       
   356     CArrayPtr< CGulIcon >* icons = new( ELeave ) CAknIconArray( KGranularity );
       
   357     CleanupStack::PushL( icons );
       
   358 
       
   359     MAknsSkinInstance* skinInstance = AknsUtils::SkinInstance();
       
   360 
       
   361     TParse mbmFile;
       
   362     User::LeaveIfError( mbmFile.Set( KFileIcons, &KDC_APP_BITMAP_DIR, NULL ) );
       
   363 
       
   364     icons->AppendL( AknsUtils::CreateGulIconL( 
       
   365                             skinInstance, 
       
   366                             KAknsIIDQgnIndiSettProtectedAdd,
       
   367                             mbmFile.FullName(), 
       
   368                             EMbmApsettingsQgn_indi_sett_protected_add, 
       
   369                             EMbmApsettingsQgn_indi_sett_protected_add_mask ) );
       
   370 
       
   371     SetIconArrayL( icons );
       
   372 
       
   373     CleanupStack::Pop(); // icons
       
   374 
       
   375     APSETUILOGGER_LEAVEFN( EOther,"SelQuery::LoadIconsL")
       
   376     return 0;
   152     return 0;
   377     }
   153     }
   378 
   154 
   379 // End of File
   155 // End of File