omaprovisioning/provisioning/AuthTypePlugin/src/Authtypeplugin.cpp
changeset 73 ae69c2e8bc34
parent 71 d2517372cc44
child 77 9f85c58c0592
equal deleted inserted replaced
71:d2517372cc44 73:ae69c2e8bc34
     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:  AuthtypePlugin implementation.
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 // User includes
       
    20 #include    "Authtypeplugin.h"
       
    21 
       
    22 #include    <gsparentplugin.h>
       
    23 #include    <gscommon.hrh>
       
    24 #include    <AuthtypepluginRsc.rsg> // GUI Resource
       
    25 #include    <Authtypeplugin.mbg>
       
    26 #include    <gsprivatepluginproviderids.h>
       
    27 #include    <gsfwviewuids.h>
       
    28 #include    "ProvisioningInternalCRKeys.h"
       
    29 #include    <gsbaseview.h>
       
    30 
       
    31 // System includes
       
    32 #include    <AknWaitDialog.h>
       
    33 #include    <AknNullService.h>
       
    34 #include    <aknnotewrappers.h>
       
    35 #include    <akntextsettingpage.h>
       
    36 #include    <aknViewAppUi.h>
       
    37 #include    <bautils.h>
       
    38 #include    <featmgr.h>
       
    39 #include    <StringLoader.h>
       
    40 
       
    41 #include    <badesca.h>
       
    42 #include    <aknlists.h> 
       
    43 #include    <AknListBoxSettingPage.h> 
       
    44 #include    <centralrepository.h>
       
    45 #include    "ProvisioningDebug.h"
       
    46 
       
    47 // ========================= MEMBER FUNCTIONS ================================
       
    48 
       
    49 // ---------------------------------------------------------------------------
       
    50 // CAuthtypePlugin::CAuthtypePlugin()
       
    51 // Constructor
       
    52 // ---------------------------------------------------------------------------
       
    53 //
       
    54 CAuthtypePlugin::CAuthtypePlugin() :
       
    55     iResources( *iCoeEnv)
       
    56     {
       
    57     }
       
    58 
       
    59 // ---------------------------------------------------------------------------
       
    60 // CAuthtypePlugin::~CAuthtypePlugin()
       
    61 // Destructor
       
    62 // ---------------------------------------------------------------------------
       
    63 //
       
    64 CAuthtypePlugin::~CAuthtypePlugin()
       
    65     {
       
    66     iResources.Close();
       
    67     }
       
    68 
       
    69 // ---------------------------------------------------------------------------
       
    70 // CAuthtypePlugin::ConstructL(const TRect& aRect)
       
    71 // Symbian OS two-phased constructor
       
    72 // ---------------------------------------------------------------------------
       
    73 //
       
    74 void CAuthtypePlugin::ConstructL()
       
    75     {
       
    76 
       
    77     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::ConstructL:" ) );
       
    78     OpenLocalizedResourceFileL(KOperatorLogoResourceFileName, iResources);
       
    79     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::ConstructL: DONE" ) );
       
    80 
       
    81     }
       
    82 
       
    83 // ---------------------------------------------------------------------------
       
    84 // CAuthtypePlugin::NewL()
       
    85 // Static constructor
       
    86 // ---------------------------------------------------------------------------
       
    87 //
       
    88 CAuthtypePlugin* CAuthtypePlugin::NewL(TAny* /*aInitParams*/)
       
    89     {
       
    90 
       
    91     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::NewL:" ) );
       
    92 
       
    93     CAuthtypePlugin* self = new( ELeave ) CAuthtypePlugin();
       
    94     CleanupStack::PushL(self);
       
    95     self->ConstructL();
       
    96     CleanupStack::Pop(self);
       
    97     return self;
       
    98 
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CAuthtypePlugin::Id
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 TUid CAuthtypePlugin::Id() const
       
   106     {
       
   107     return KAuthtypePluginUID;
       
   108     }
       
   109 
       
   110 // -----------------------------------------------------------------------------
       
   111 // CAuthtypePlugin::DoActivateL
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 void CAuthtypePlugin::DoActivateL(const TVwsViewId& /*aPrevViewId*/,
       
   115         TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)
       
   116     {
       
   117 
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CAuthtypePlugin::DoDeactivate
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void CAuthtypePlugin::DoDeactivate()
       
   125     {
       
   126 
       
   127     }
       
   128 
       
   129 // ========================= From CGSPluginInterface ==================
       
   130 
       
   131 
       
   132 // -----------------------------------------------------------------------------
       
   133 // CAuthtypePlugin::GetCaptionL
       
   134 // -----------------------------------------------------------------------------
       
   135 //
       
   136 void CAuthtypePlugin::GetCaptionL(TDes& aCaption) const
       
   137     {
       
   138 
       
   139     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::GetCaptionL" ) );
       
   140 
       
   141     HBufC* result = StringLoader::LoadL( R_SET_CONF_MSG_AUTHENTICATION_CP);
       
   142     aCaption.Copy( *result);
       
   143     delete result;
       
   144 
       
   145     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::GetCaptionL  DONE" ) );
       
   146     }
       
   147 
       
   148 // -----------------------------------------------------------------------------
       
   149 // CAuthtypePlugin::PluginProviderCategory
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 TInt CAuthtypePlugin::PluginProviderCategory() const
       
   153     {
       
   154     return KGSPluginProviderInternal;
       
   155     }
       
   156 
       
   157 // -----------------------------------------------------------------------------
       
   158 // CAuthtypePlugin::ItemType()
       
   159 // -----------------------------------------------------------------------------
       
   160 //
       
   161 TGSListboxItemTypes CAuthtypePlugin::ItemType()
       
   162     {
       
   163     return EGSItemTypeSettingDialog;
       
   164     }
       
   165 
       
   166 // -----------------------------------------------------------------------------
       
   167 // CAuthtypePlugin::GetValue()
       
   168 // -----------------------------------------------------------------------------
       
   169 //
       
   170 void CAuthtypePlugin::GetValue(const TGSPluginValueKeys /*aKey*/, TDes& /*aValue*/)
       
   171     {
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CAuthtypePlugin::HandleSelection()
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 void CAuthtypePlugin::HandleSelection(const TGSSelectionTypes /*aSelectionType*/)
       
   179     {
       
   180     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::HandleSelection" ) );
       
   181 
       
   182     TRAP_IGNORE( HandleItemContentL() );
       
   183 
       
   184     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::HandleSelection  DONE" ) );
       
   185     }
       
   186 
       
   187 // ---------------------------------------------------------------------------
       
   188 // CAuthtypePlugin::CreateIconL
       
   189 // ---------------------------------------------------------------------------
       
   190 //
       
   191 CGulIcon* CAuthtypePlugin::CreateIconL(const TUid aIconType)
       
   192     {
       
   193 
       
   194     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::CreateIconL" ) );
       
   195 
       
   196     //EMbm<Mbm_file_name><Bitmap_name>
       
   197     CGulIcon* icon;
       
   198     TParse* fp = new( ELeave ) TParse();
       
   199     CleanupStack::PushL(fp);
       
   200     fp->Set(KAuthtypePluginIconDirAndName, &KDC_BITMAP_DIR, NULL);
       
   201 
       
   202     if (aIconType == KGSIconTypeLbxItem)
       
   203         {
       
   204         icon = AknsUtils::CreateGulIconL(AknsUtils::SkinInstance(),
       
   205                 KAknsIIDDefault, fp->FullName(),
       
   206                 EMbmAuthtypepluginQgn_prop_set_conn_config,
       
   207                 EMbmAuthtypepluginQgn_prop_set_conn_config_mask);
       
   208         }
       
   209     else
       
   210         {
       
   211         icon = CGSPluginInterface::CreateIconL(aIconType);
       
   212         }
       
   213 
       
   214     CleanupStack::PopAndDestroy(fp);
       
   215 
       
   216     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::CreateIconL:  DONE" ) );
       
   217 
       
   218     return icon;
       
   219 
       
   220     }
       
   221 
       
   222 // -----------------------------------------------------------------------------
       
   223 // CAuthtypePlugin::OpenLocalizedResourceFileL()
       
   224 // -----------------------------------------------------------------------------
       
   225 //
       
   226 void CAuthtypePlugin::OpenLocalizedResourceFileL(
       
   227         const TDesC& aResourceFileName, RConeResourceLoader& aResourceLoader)
       
   228     {
       
   229 
       
   230     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::OpenLocalizedResourceFileL" ) );
       
   231 
       
   232     RFs fsSession;
       
   233     User::LeaveIfError(fsSession.Connect() );
       
   234 
       
   235     CleanupClosePushL(fsSession);
       
   236 
       
   237     // Find the resource file:
       
   238     TParse parse;
       
   239     parse.Set(aResourceFileName, &KDC_RESOURCE_FILES_DIR, NULL);
       
   240     TFileName fileName(parse.FullName() );
       
   241 
       
   242     // Get language of resource file:
       
   243     BaflUtils::NearestLanguageFile(fsSession, fileName);
       
   244 
       
   245     // Open resource file:
       
   246     aResourceLoader.OpenL(fileName);
       
   247 
       
   248     CleanupStack::PopAndDestroy(); //fssession
       
   249 
       
   250     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::OpenLocalizedResourceFileL  DONE" ) );
       
   251     }
       
   252 
       
   253 // -----------------------------------------------------------------------------
       
   254 // CAuthtypePlugin::HandleItemContentL()
       
   255 // -----------------------------------------------------------------------------
       
   256 //
       
   257 
       
   258 void CAuthtypePlugin::HandleItemContentL()
       
   259     {
       
   260 
       
   261     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::HandleItemContentL" ) );
       
   262 
       
   263     // Holds the index of selected item 
       
   264     TInt selectedItem(KThirdItemSelected);
       
   265 
       
   266     // Holds the authentication type value
       
   267     TInt getAuthValue(KAllMethodsSupported);
       
   268 
       
   269     //Load all the strings from resource file 
       
   270 
       
   271     HBufC *title = StringLoader::LoadLC(R_QTN_SET_CONF_AUTH_METHOD);
       
   272 
       
   273     HBufC *netPinSupport = StringLoader::LoadLC(R_QTN_CONF_AUTH_NETWORK_PIN);
       
   274     HBufC *netUserPinSupport =
       
   275             StringLoader::LoadLC(R_QTN_CONF_AUTH_NETWORK_OR_USER_PIN);
       
   276     HBufC *allMethodsSupport = StringLoader::LoadLC(R_QTN_CONF_AUTH_ALL_AUTH);
       
   277 
       
   278     //creation of list
       
   279 
       
   280     CAknSinglePopupMenuStyleListBox* list = new(ELeave)CAknSinglePopupMenuStyleListBox;
       
   281     CleanupStack::PushL(list);
       
   282 
       
   283     CAknPopupList* popupList = CAknPopupList::NewL(list, 
       
   284     R_AVKON_SOFTKEYS_OK_CANCEL__OK, AknPopupLayouts::EMenuWindow);
       
   285 
       
   286     CleanupStack::PushL(popupList);
       
   287 
       
   288     list->ConstructL(popupList, 0);
       
   289     list->CreateScrollBarFrameL(ETrue);
       
   290     list->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,
       
   291             CEikScrollBarFrame::EAuto);
       
   292 
       
   293     //Append strings into array which will be populated into list
       
   294 
       
   295     CDesCArrayFlat* ItemArray = new(ELeave)CDesCArrayFlat(3);
       
   296     CleanupStack::PushL(ItemArray);
       
   297 
       
   298     ItemArray->AppendL(*netPinSupport);
       
   299     ItemArray->AppendL(*netUserPinSupport);
       
   300     ItemArray->AppendL(*allMethodsSupport);
       
   301 
       
   302     CleanupStack::Pop(); //ItemArray
       
   303 
       
   304     list->Model()->SetItemTextArray(ItemArray);
       
   305     list->Model()->SetOwnershipType(ELbmOwnsItemArray);
       
   306 
       
   307     popupList->SetTitleL(*title);
       
   308 
       
   309     /* Get authentication type value from Central Repository and based on current cenrep value
       
   310      * List box item will be selected */
       
   311 
       
   312     CRepository * rep= NULL;
       
   313     TRAPD( err, rep = CRepository::NewL( KCRUidOMAProvisioningLV ))
       
   314     ;
       
   315 
       
   316     if (err == KErrNone)
       
   317         {
       
   318         rep->Get(KOMAProvAuthenticationLVFlag, getAuthValue);
       
   319         delete rep;
       
   320         }
       
   321 
       
   322     switch (getAuthValue)
       
   323         {
       
   324         case KNetworkPinOnly:
       
   325             selectedItem = KFirstItemSelected;
       
   326             break;
       
   327 
       
   328         case KNetworkorUserPin:
       
   329             selectedItem = KSecondItemSelected;
       
   330             break;
       
   331 
       
   332         case KAllMethodsSupported:
       
   333             selectedItem = KThirdItemSelected;
       
   334             break;
       
   335 
       
   336         default:
       
   337             break;
       
   338         }
       
   339 
       
   340     list->View()->SetCurrentItemIndex(selectedItem);
       
   341 
       
   342     // Show popup list and then show return value.
       
   343     TInt popupOk = popupList->ExecuteLD();
       
   344 
       
   345     //When user selects item from list based on selection cenrep value will be set
       
   346 
       
   347     if (popupOk)
       
   348         {
       
   349 
       
   350         selectedItem = list->CurrentItemIndex();
       
   351 
       
   352         switch (selectedItem)
       
   353             {
       
   354             case KFirstItemSelected:
       
   355                 SetCenrepItemL(selectedItem, KNetworkPinOnly);
       
   356                 break;
       
   357             case KSecondItemSelected:
       
   358                 SetCenrepItemL(selectedItem, KNetworkorUserPin);
       
   359                 break;
       
   360             case KThirdItemSelected:
       
   361                 SetCenrepItemL(selectedItem, KAllMethodsSupported);
       
   362                 break;
       
   363             default:
       
   364                 break;
       
   365 
       
   366             }
       
   367 
       
   368         }
       
   369 
       
   370     CleanupStack::Pop(); // popuplist
       
   371     CleanupStack::PopAndDestroy(5); // list, title, netPinSupport, netUserPinSupport, allMethodsSupport
       
   372 
       
   373     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::HandleItemContentL  DONE" ) );
       
   374 
       
   375     }
       
   376 
       
   377 // ---------------------------------------------------------
       
   378 // CAuthtypeUIContainer::SetCenrepItemL()
       
   379 // ---------------------------------------------------------
       
   380 //
       
   381 void CAuthtypePlugin::SetCenrepItemL(TInt aSelected, TInt aSetAuthValue)
       
   382     {
       
   383 
       
   384     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::SetCenrepItemL" ) );
       
   385     //Based on current selection item from list set the cenrep with different authentication type
       
   386 
       
   387     CRepository * rep= NULL;
       
   388     TRAPD( err, rep = CRepository::NewL( KCRUidOMAProvisioningLV ))
       
   389     ;
       
   390 
       
   391     if (err == KErrNone)
       
   392         {
       
   393         rep->Set(KOMAProvAuthenticationLVFlag, aSetAuthValue);
       
   394         delete rep;
       
   395         }
       
   396 
       
   397     //Shows Information note to user on selection of second and third Item from List       
       
   398 
       
   399     if (aSelected == KSecondItemSelected)
       
   400         {
       
   401 
       
   402         HBufC
       
   403                 * netUserPinNote =
       
   404                         StringLoader::LoadLC(R_QTN_CONF_AUTH_NETWORK_OR_USER_PIN_NOTE);
       
   405         ShowPopupNoteL(netUserPinNote);
       
   406         CleanupStack::PopAndDestroy(); // netUserPinNote
       
   407         }
       
   408 
       
   409     else
       
   410         if (aSelected == KThirdItemSelected)
       
   411             {
       
   412             HBufC* allMethodsNote =
       
   413                     StringLoader::LoadLC(R_QTN_CONF_AUTH_ALL_AUTH_NOTE);
       
   414             ShowPopupNoteL(allMethodsNote);
       
   415             CleanupStack::PopAndDestroy(); // allMethodsNote
       
   416             }
       
   417 
       
   418     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::SetCenrepItemL  DONE" ) );
       
   419     }
       
   420 
       
   421 // ---------------------------------------------------------
       
   422 // CAuthtypeUIContainer::ShowPopupNoteL()
       
   423 // ---------------------------------------------------------
       
   424 //
       
   425 void CAuthtypePlugin::ShowPopupNoteL(HBufC *aNote)
       
   426     {
       
   427 
       
   428     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::ShowPopupNoteL" ) );
       
   429 
       
   430     CAknQueryDialog* queryDialog = new (ELeave) CAknQueryDialog;
       
   431     queryDialog->ExecuteLD(R_AUTHTYPEUI_INFORMATION_QUERY, *aNote);
       
   432 
       
   433     FLOG( _L( "[AuthtypePlugin] CAuthtypePlugin::ShowPopupNoteL  DONE" ) );
       
   434 
       
   435     }
       
   436 
       
   437 // End of file