connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/connectionerrordiscreetpopup.cpp
changeset 20 9c97ad6591ae
parent 18 fcbbe021d614
child 21 b8e8e15e80f2
child 23 7ec726f93df1
child 28 860702281757
equal deleted inserted replaced
18:fcbbe021d614 20:9c97ad6591ae
     1 /*
       
     2  * Copyright (c) 2009 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:  Implementation of CConnectionErrorDiscreetPopup.
       
    15  *
       
    16  */
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include "connectionerrordiscreetpopup.h"
       
    20 #include <akndiscreetpopup.h>
       
    21 #include <aknsconstants.hrh>
       
    22 #include <StringLoader.h>
       
    23 #include <cmmanagerext.h>
       
    24 #include <cmconnectionmethod.h>
       
    25 #include <cmconnectionmethodext.h>
       
    26 #include <cmpluginwlandef.h>
       
    27 #include <avkon.hrh>
       
    28 #include <connectionuiutilities.mbg>
       
    29 #include <ConnUiUtilsNotif.rsg>
       
    30 
       
    31 #ifdef _DEBUG
       
    32 #include <e32debug.h>
       
    33 #endif
       
    34 
       
    35 // Error code definitions are from these headers
       
    36 #include <wlanerrorcodes.h> // WLAN-specific error code definitions
       
    37 #include <in_iface.h>
       
    38 #include <etelpckt.h>       // GPRS-specific causes for Session Management
       
    39 #include <nd_err.h>         // NetDial errors
       
    40 #include <inet6err.h>       // IPv6 error constants
       
    41 #include <rmmcustomapi.h>
       
    42 
       
    43 // Errors in UI spec not found elsewhere
       
    44 const TInt KErrPDPMaxContextsReached = -6000;
       
    45 const TInt KErrDndNameNotFound = -5120;
       
    46 const TInt KErrGeneralConnection = -50000;
       
    47 const TInt KErrGenConnNoGPRSNetwork = -3609;
       
    48 
       
    49 // No discreet popup => Uid 0
       
    50 const TUid KDiscreetPopupUidNone =
       
    51     {
       
    52     0x0
       
    53     };
       
    54 // Path of the app's iconfile
       
    55 _LIT( KIconFileName, "\\resource\\apps\\connectionuiutilities.mif" );
       
    56 
       
    57 // ================= MEMBER FUNCTIONS =======================
       
    58 
       
    59 // ---------------------------------------------------------
       
    60 // CConnectionErrorDiscreetPopup::CConnectionErrorDiscreetPopup
       
    61 // ---------------------------------------------------------
       
    62 //
       
    63 CConnectionErrorDiscreetPopup::CConnectionErrorDiscreetPopup(
       
    64         CConnectionErrorDiscreetPopupNotif* aNotif) :
       
    65     CActive(EPriorityUserInput), // Standard priority
       
    66             iNotif(aNotif), iErrorCode(KErrNone)
       
    67     {
       
    68     }
       
    69 
       
    70 // ---------------------------------------------------------
       
    71 // CConnectionErrorDiscreetPopup::NewLC
       
    72 // ---------------------------------------------------------
       
    73 //
       
    74 CConnectionErrorDiscreetPopup* CConnectionErrorDiscreetPopup::NewLC(
       
    75         CConnectionErrorDiscreetPopupNotif* aNotif)
       
    76     {
       
    77     CConnectionErrorDiscreetPopup* self =
       
    78             new (ELeave) CConnectionErrorDiscreetPopup(aNotif);
       
    79     CleanupStack::PushL(self);
       
    80     self->ConstructL();
       
    81     return self;
       
    82     }
       
    83 
       
    84 // ---------------------------------------------------------
       
    85 // CConnectionErrorDiscreetPopup::NewL
       
    86 // ---------------------------------------------------------
       
    87 //
       
    88 CConnectionErrorDiscreetPopup* CConnectionErrorDiscreetPopup::NewL(
       
    89         CConnectionErrorDiscreetPopupNotif* aNotif)
       
    90     {
       
    91     CConnectionErrorDiscreetPopup* self =
       
    92             CConnectionErrorDiscreetPopup::NewLC(aNotif);
       
    93     CleanupStack::Pop(self);
       
    94     return self;
       
    95     }
       
    96 
       
    97 // ---------------------------------------------------------
       
    98 // CConnectionErrorDiscreetPopup::ConstructL
       
    99 // ---------------------------------------------------------
       
   100 //
       
   101 void CConnectionErrorDiscreetPopup::ConstructL()
       
   102     {
       
   103     CActiveScheduler::Add(this); // Add to scheduler
       
   104     icmManager.OpenL();
       
   105     }
       
   106 
       
   107 // ---------------------------------------------------------
       
   108 // CConnectionErrorDiscreetPopup::~CConnectionErrorDiscreetPopup
       
   109 // ---------------------------------------------------------
       
   110 //
       
   111 CConnectionErrorDiscreetPopup::~CConnectionErrorDiscreetPopup()
       
   112     {
       
   113     Cancel(); // Cancel any request, if outstanding
       
   114     icmManager.Close();
       
   115     // Delete instance variables if any
       
   116     }
       
   117 
       
   118 // ---------------------------------------------------------
       
   119 // CConnectionErrorDiscreetPopup::DoCancel
       
   120 // ---------------------------------------------------------
       
   121 //
       
   122 void CConnectionErrorDiscreetPopup::DoCancel()
       
   123     {
       
   124     }
       
   125 
       
   126 // ---------------------------------------------------------
       
   127 // CConnectionErrorDiscreetPopup::StartL
       
   128 // ---------------------------------------------------------
       
   129 //
       
   130 void CConnectionErrorDiscreetPopup::StartL(TUint32 aErrCode)
       
   131     {
       
   132     Cancel(); // Cancel any request, just to be sure
       
   133 
       
   134     iErrorCode = aErrCode;
       
   135 
       
   136     SetActive(); // Tell scheduler a request is active
       
   137     iClientStatus = &iStatus;
       
   138     User::RequestComplete(iClientStatus, KErrNone);
       
   139 
       
   140     // Complete the note so client can continue its tasks
       
   141     // immediately
       
   142     iNotif->SetCancelledFlag(ETrue);
       
   143     iNotif->CompleteL(KErrNone);
       
   144     }
       
   145 
       
   146 // ---------------------------------------------------------
       
   147 // CConnectionErrorDiscreetPopup::RunL
       
   148 // ---------------------------------------------------------
       
   149 //
       
   150 void CConnectionErrorDiscreetPopup::RunL()
       
   151     {
       
   152     if (iStatus == KErrNone)
       
   153         {
       
   154         TInt text1 = 0;
       
   155         TInt text2 = 0;
       
   156         TInt bitmapId = 0;
       
   157         TInt maskId = 0;
       
   158         // Show only if error code can be resolved
       
   159         if (ResolveErrorCode(text1, text2, bitmapId, maskId))
       
   160             {
       
   161             // Load strings from resources
       
   162             HBufC* stringText1 = StringLoader::LoadLC(text1);
       
   163             HBufC* stringText2 = StringLoader::LoadLC(text2);
       
   164             CAknDiscreetPopup::ShowGlobalPopupL(*stringText1, // 1st text row
       
   165                     *stringText2, // second text row
       
   166                     KAknsIIDDefault, // icon skin id
       
   167                     KIconFileName, // bitmap file path
       
   168                     bitmapId, // bitmap id
       
   169                     maskId, // mask id
       
   170                     KAknDiscreetPopupDurationLong, // flags
       
   171                     0, // command id
       
   172                     NULL, // command observer
       
   173                     KDiscreetPopupUidNone, // application to be launched
       
   174                     KDiscreetPopupUidNone); // view to be activated
       
   175 
       
   176             CleanupStack::PopAndDestroy(2, stringText1);
       
   177             }
       
   178         }
       
   179 
       
   180     // Cleanup
       
   181     iNotif->Cancel();
       
   182     }
       
   183 
       
   184 // ---------------------------------------------------------
       
   185 // CConnectionErrorDiscreetPopup::RunError
       
   186 // ---------------------------------------------------------
       
   187 //
       
   188 TInt CConnectionErrorDiscreetPopup::RunError(TInt aError)
       
   189     {
       
   190     return aError;
       
   191     }
       
   192 
       
   193 // ---------------------------------------------------------
       
   194 // CConnectionErrorDiscreetPopup::ResolveErrorCode
       
   195 // ---------------------------------------------------------
       
   196 //
       
   197 TInt CConnectionErrorDiscreetPopup::ResolveErrorCode(TInt& aText1,
       
   198         TInt& aText2, TInt& aBitmap, TInt& aMask)
       
   199     {
       
   200     
       
   201 #ifdef _DEBUG
       
   202     RDebug::Print( _L("CConnectionErrorDiscreetPopup::ResolveErrorCode - code %d"),
       
   203             iErrorCode );
       
   204 #endif
       
   205     
       
   206     // Icons, which are resolved at the end
       
   207     enum TIconType
       
   208         {
       
   209         EIconWlan, EIconCellular, EIconNone
       
   210         };
       
   211 
       
   212     // For most cases, icon is WLAN
       
   213     TIconType icon = EIconWlan;
       
   214 
       
   215     // For most cases, aText1 = "Connection failed"
       
   216     aText1 = R_QTN_OCC_CONNECTION_FAILED_DISCREET_POPUP_TEXT1;
       
   217 
       
   218     // Resolve aText1, aText2 and icon of error code.
       
   219     // Groups are from OCC GUI spec 1.0
       
   220     switch (iErrorCode)
       
   221         {
       
   222         
       
   223         // Group 1
       
   224         case KErrIfChangingPassword:
       
   225             icon = EIconCellular;
       
   226             // These were GPRS; fall through
       
   227         case KErrWlanInternalError:
       
   228             aText2 = R_QTN_OCC_INTERNAL_ERROR_DISCREET_POPUP_TEXT2;
       
   229             break;
       
   230 
       
   231         // Group 2
       
   232         case KErrWlanNetworkNotFound:
       
   233             aText2 = R_QTN_OCC_WLAN_NOT_FOUND_DISCREET_POPUP_TEXT2;
       
   234             break;
       
   235 
       
   236         // Group 3
       
   237         case KErrGprsUserAuthenticationFailure:
       
   238             icon = EIconCellular;
       
   239         // These were GPRS; fall through
       
   240         case KErrWlanOpenAuthFailed:
       
   241         case KErrWlanSharedKeyAuthRequired:
       
   242         case KErrWlanWpaAuthRequired:
       
   243         case KErrWlanWpaAuthFailed:
       
   244         case KErrWlan802dot1xAuthFailed:
       
   245         case KErrWlanWpaCounterMeasuresActive:
       
   246         case KErrWlanPskModeRequired:
       
   247         case KErrWlanEapModeRequired:
       
   248         case KErrWlanEapSimFailed:
       
   249         case KErrWlanEapTlsFailed:
       
   250         case KErrWlanEapPeapFailed:
       
   251         case KErrWlanEapMsChapv2: // Is the same as KErrWlanEapMsChaPFailed
       
   252         case KErrWlanEapAkaFailed:
       
   253         case KErrWlanEapTtlsFailed:
       
   254         case KErrWlanLeapFailed:
       
   255         case KErrWlanEapGtcFailed:
       
   256         case KErrWlanWpa2OnlyModeNotSupported:
       
   257         case KErrWlanEapFastTunnelCompromiseError:
       
   258         case KErrWlanEapFastUnexpextedTlvExhanged:
       
   259         case KErrWlanEapFastNoPacNorCertsToAuthenticateWithProvDisabled:
       
   260         case KErrWlanEapFastNoMatchingPacForAid:
       
   261         case KErrWlanEapFastAuthFailed:
       
   262         case KErrWlanEapFastPacStoreCorrupted:
       
   263             aText2 = R_QTN_OCC_AUTH_ERROR_DISCREET_POPUP_TEXT2;
       
   264             break;
       
   265 
       
   266         // Group 4
       
   267         case KErrWlanSharedKeyAuthFailed:
       
   268         case KErrWlanIllegalWpaPskKey:
       
   269         case KErrWlanIllegalEncryptionKeys:
       
   270             aText2 = R_QTN_OCC_CHECK_KEY_DISCREET_POPUP_TEXT2;
       
   271             break;
       
   272 
       
   273         // Group 5
       
   274         case KErrExitModemError:
       
   275         case KErrExitLoginFail:
       
   276         case KErrExitScriptTimeOut:
       
   277         case KErrExitScriptError:
       
   278         case KErrIfAuthenticationFailure:
       
   279         case KErrIfAuthNotSecure:
       
   280         case KErrIfAccountDisabled:
       
   281         case KErrIfRestrictedLogonHours:
       
   282         case KErrIfPasswdExpired:
       
   283         case KErrIfNoDialInPermission:
       
   284         case KErrGprsMissingorUnknownAPN:
       
   285             icon = EIconCellular;
       
   286             aText2 = R_QTN_OCC_CHECK_SETTINGS_DISCREET_POPUP_TEXT2;
       
   287             break;
       
   288 
       
   289         // Group 6
       
   290         case KErrWlanSimNotInstalled:
       
   291             aText2 = R_QTN_OCC_SIM_ERROR_DISCREET_POPUP_TEXT2;
       
   292             break;
       
   293 
       
   294         // Group 7
       
   295         case KErrWlanNotSubscribed:
       
   296         case KErrWlanAccessBarred:
       
   297             aText2 = R_QTN_OCC_SERVICE_ERROR_DISCREET_POPUP_TEXT2;
       
   298             break;
       
   299 
       
   300         // Group 8
       
   301         case KErrPermissionDenied:
       
   302             icon = EIconNone;  // Permission denied may come with any bearer.
       
   303         // Fall through
       
   304         case KErrWlanPasswordExpired:
       
   305         case KErrWlanNoDialinPermissions:
       
   306         case KErrWlanAccountDisabled:
       
   307         case KErrWlanRestrictedLogonHours:
       
   308         case KErrWlanServerCertificateExpired:
       
   309         case KErrWlanCerficateVerifyFailed:
       
   310         case KErrWlanNoUserCertificate:
       
   311         case KErrWlanNoCipherSuite:
       
   312         case KErrWlanUserRejected:
       
   313         case KErrWlanUserCertificateExpired:
       
   314             aText2 = R_QTN_OCC_ACCESS_ERROR_DISCREET_POPUP_TEXT2;
       
   315             break;
       
   316 
       
   317         // Group 9
       
   318         case KErrPDPMaxContextsReached:
       
   319             icon = EIconCellular;
       
   320             // These were GPRS; fall through
       
   321         case KErrWlanConnAlreadyActive:
       
   322             aText2 = R_QTN_OCC_ALREADY_ACT_DISCREET_POPUP_TEXT2;
       
   323             break;
       
   324 
       
   325         // Group 10
       
   326         case KErrWlanSignalTooWeak:
       
   327             aText2 = R_QTN_OCC_WLAN_WEAK_DISCREET_POPUP_TEXT2;
       
   328             break;
       
   329 
       
   330         // Group 11
       
   331         case KErrIfCallbackNotAcceptable:
       
   332         case KErrIfDNSNotFound:
       
   333         case KErrIfLRDBadLine:
       
   334         case KErrNetUnreach:
       
   335         case KErrHostUnreach:
       
   336         case KErrNoProtocolOpt:
       
   337         case KErrUrgentData:
       
   338         case KErrInet6NoRoute:
       
   339         case KErrDndNameNotFound:
       
   340         case KErrGeneralConnection:
       
   341         case KErrGprsMSCTemporarilyNotReachable:
       
   342         case KErrGprsLlcOrSndcpFailure:
       
   343         case KErrGprsInsufficientResources:
       
   344         case KErrGprsActivationRejectedByGGSN:
       
   345         case KErrPacketDataTsyInvalidAPN:
       
   346             icon = EIconCellular;
       
   347             // These were GPRS; fall through
       
   348         case KErrWlanRoamingFailed:
       
   349             aText2 = R_QTN_OCC_TRY_AGAIN_DISCREET_POPUP_TEXT2;
       
   350             break;
       
   351 
       
   352         // Group 12
       
   353         case KErrGenConnNoGPRSNetwork:
       
   354         case KErrGprsServicesNotAllowed:
       
   355         case KErrGprsAndNonGprsServicesNotAllowed:
       
   356         case KErrGprsMSIdentityCannotBeDerivedByTheNetwork:
       
   357         case KErrGprsMSImplicitlyDetached:
       
   358         case KErrGsmMMNetworkFailure:
       
   359         case KErrGprsUnknownPDPAddress:
       
   360         case KErrGprsActivationRejected:
       
   361         case KErrGsmMMServiceOptionNotSubscribed:
       
   362         case KErrGsmMMServiceOptionTemporaryOutOfOrder:
       
   363         case KErrGprsNSAPIAlreadyUsed:
       
   364         case KErrGprsQoSNotAccepted:
       
   365         case KErrGprsReactivationRequested:
       
   366             icon = EIconCellular;
       
   367             aText2 = R_QTN_OCC_CONN_UNAVAILABLE_DISCREET_POPUP_TEXT2;
       
   368             break;
       
   369 
       
   370         // Group 13
       
   371         case KErrWlanProtectedSetupDevicePasswordAuthFailure:
       
   372         case KErrWlanProtectedSetupPINMethodNotSupported:
       
   373         case KErrWlanProtectedSetupPBMethodNotSupported:
       
   374             aText1 = R_QTN_OCC_CONFIG_FAILED_DISCREET_POPUP_TEXT1;
       
   375             aText2 = R_QTN_OCC_AUTH_ERROR_DISCREET_POPUP_TEXT2;
       
   376             break;
       
   377 
       
   378         // Group 14
       
   379         case KErrWlanProtectedSetupOOBInterfaceReadError:
       
   380         case KErrWlanProtectedSetupDecryptionCRCFailure:
       
   381         case KErrWlanProtectedSetup2_4ChannelNotSupported:
       
   382         case KErrWlanProtectedSetup5_0ChannelNotSupported:
       
   383         case KErrWlanProtectedSetupNetworkAuthFailure:
       
   384         case KErrWlanProtectedSetupNoDHCPResponse:
       
   385         case KErrWlanProtectedSetupFailedDHCPConfig:
       
   386         case KErrWlanProtectedSetupIPAddressConflict:
       
   387         case KErrWlanProtectedSetupCouldNotConnectToRegistrar:
       
   388         case KErrWlanProtectedSetupMultiplePBCSessionsDetected:
       
   389         case KErrWlanProtectedSetupRogueActivitySuspected:
       
   390         case KErrWlanProtectedSetupDeviceBusy:
       
   391         case KErrWlanProtectedSetupSetupLocked:
       
   392         case KErrWlanProtectedSetupMessageTimeout:
       
   393         case KErrWlanProtectedSetupRegistrationSessionTimeout:
       
   394             aText1 = R_QTN_OCC_CONFIG_FAILED_DISCREET_POPUP_TEXT1;
       
   395             aText2 = R_QTN_OCC_TRY_AGAIN_DISCREET_POPUP_TEXT2;
       
   396             break;
       
   397 
       
   398         // Skipped errors, for which popup is not shown.
       
   399         case KErrNone:
       
   400         case KErrConnectionTerminated:
       
   401         case KErrDisconnected:
       
   402         case KErrCancel:
       
   403             return EFalse;
       
   404 
       
   405         // For error values not specifically mapped to any error message
       
   406         // the discreet pop-up #12 is used.
       
   407         default:
       
   408             aText2 = R_QTN_OCC_CONN_UNAVAILABLE_DISCREET_POPUP_TEXT2;
       
   409             icon = EIconNone;
       
   410             break;
       
   411         }
       
   412 
       
   413     // Resolve icon to aBitmap & aMask
       
   414     switch (icon)
       
   415         {
       
   416         case EIconWlan:
       
   417             aBitmap = EMbmConnectionuiutilitiesQgn_prop_wlan_bearer;
       
   418             aMask = EMbmConnectionuiutilitiesQgn_prop_wlan_bearer_mask;
       
   419             break;
       
   420         case EIconCellular:
       
   421             aBitmap = EMbmConnectionuiutilitiesQgn_prop_wml_gprs;
       
   422             aMask = EMbmConnectionuiutilitiesQgn_prop_wml_gprs_mask;
       
   423             break;
       
   424         default:
       
   425             ASSERT(icon == EIconNone);
       
   426             aBitmap = -1;
       
   427             aMask = -1;
       
   428             break;
       
   429         }
       
   430 
       
   431     return ETrue;
       
   432     }