connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ActiveConnectViaNote.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) 2006 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 CActiveConnectViaNote.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "ActiveConnectViaNote.h"
       
    21 #include "ConnectViaNoteNotif.h"
       
    22 #include "NoteDlgSuppressingSwitch.h"
       
    23 #include "ConnectionDialogsLogger.h"
       
    24 
       
    25 #include <ConnUiUtilsNotif.rsg>
       
    26 #include <StringLoader.h>
       
    27 
       
    28 #include <eikimage.h>
       
    29 #include <gulicon.h>
       
    30 
       
    31 #include <cmconnectionmethod.h>
       
    32 #include <cmdestination.h>
       
    33 
       
    34 #ifndef __WINS__
       
    35 #include <featmgr.h>
       
    36 #include <wlanmgmtclient.h>
       
    37 #include <cmmanagerext.h>
       
    38 #endif  // !__WINS__
       
    39 
       
    40 // CONSTANTS
       
    41 
       
    42 LOCAL_D const TInt KStringsGranularity = 2;
       
    43 
       
    44 
       
    45 // ================= MEMBER FUNCTIONS =======================
       
    46 
       
    47 // ---------------------------------------------------------
       
    48 // CActiveConnectViaNote::CActiveConnectViaNote()
       
    49 // ---------------------------------------------------------
       
    50 //
       
    51 CActiveConnectViaNote::CActiveConnectViaNote( 
       
    52                            CConnectViaNoteNotif* aNotif, 
       
    53                            const TConnUiUiDestConnMethodNoteId aData ) 
       
    54 : CActive( KErrNone ), 
       
    55   iNotif( aNotif ), 
       
    56   iIcon( NULL ), 
       
    57   iData( aData )
       
    58     {
       
    59     CActiveScheduler::Add( this );            
       
    60     }
       
    61     
       
    62 // ---------------------------------------------------------
       
    63 // CActiveConnectViaNote::DoCancel()
       
    64 // ---------------------------------------------------------
       
    65 // 
       
    66 void CActiveConnectViaNote::DoCancel()
       
    67     {
       
    68     }
       
    69  
       
    70 // ---------------------------------------------------------
       
    71 // CActiveConnectViaNote::RunL()
       
    72 // ---------------------------------------------------------
       
    73 //     
       
    74 void CActiveConnectViaNote::RunL()
       
    75     {
       
    76     CLOG_ENTERFN( "CActiveConnectViaNote::RunL" );  
       
    77     
       
    78     if( iStatus == KErrNone )
       
    79         {
       
    80         iCmManager.OpenL();
       
    81         
       
    82         HBufC* noteText = GetDialogTextL();
       
    83         CleanupStack::PushL( noteText );
       
    84                 
       
    85         CNoteDlgSuppressingSwitch* dialog = new (ELeave) 
       
    86                             CNoteDlgSuppressingSwitch( 
       
    87                             REINTERPRET_CAST( CEikDialog**, &dialog ) );
       
    88         CleanupStack::PushL( dialog );
       
    89         
       
    90         CEikImage* image = CreateEikImageFromCGulIconLC();
       
    91         dialog->SetIconL( image ); //The dialog takes ownership of the pointer
       
    92         CleanupStack::Pop( image );
       
    93         
       
    94         CleanupStack::Pop( dialog );
       
    95 
       
    96         TInt resId = R_CONNECTING_VIA_INFO_NOTE;    
       
    97         switch( iData.iNoteId )
       
    98             {
       
    99             case EConnectedViaDestConnMethodConfirmationNote:
       
   100             case EConnectedViaConnMethodConfirmationNote:
       
   101                 {
       
   102                 resId = R_CONNECTED_VIA_CONFIRM_NOTE;
       
   103                 break;
       
   104                 }
       
   105             case EConnectingToConnMethodInfoNote:
       
   106             default :
       
   107                 {                
       
   108                 break;
       
   109                 }
       
   110             }
       
   111             
       
   112         dialog->PrepareLC( resId );
       
   113         dialog->ActivateL();
       
   114         dialog->SetCurrentLabelL( EGeneralNote, noteText->Des() );
       
   115         
       
   116         dialog->RunDlgLD( CAknNoteDialog::ELongTimeout, 
       
   117                           CAknNoteDialog::ENoTone );
       
   118                                          
       
   119         CleanupStack::PopAndDestroy( noteText );
       
   120         
       
   121         CLOG_WRITE( "CActiveConnectViaNote::RunL: Completing with KErrNone" );
       
   122 
       
   123         iNotif->CompleteL( KErrNone );                     
       
   124         }     
       
   125     
       
   126     CLOG_LEAVEFN( "CActiveConnectViaNote::RunL" );  
       
   127     }
       
   128     
       
   129 // ---------------------------------------------------------
       
   130 // CActiveConnectViaNote::LaunchActiveConnectViaNote()
       
   131 // ---------------------------------------------------------
       
   132 //    
       
   133 void CActiveConnectViaNote::LaunchActiveConnectViaNote()
       
   134     {
       
   135     CLOG_ENTERFN( "CActiveConnectViaNote::LaunchActiveConnectViaNote" );  
       
   136     
       
   137     SetActive();    
       
   138     iClientStatus = &iStatus;
       
   139     User::RequestComplete( iClientStatus, KErrNone );    
       
   140     }
       
   141     
       
   142     
       
   143 // ---------------------------------------------------------
       
   144 // CActiveConnectViaNote::~CActiveConnectViaNote()
       
   145 // ---------------------------------------------------------
       
   146 //    
       
   147 CActiveConnectViaNote::~CActiveConnectViaNote()
       
   148     {
       
   149     Cancel();  
       
   150     iCmManager.Close();  
       
   151        
       
   152     delete iIcon;
       
   153     iIcon = NULL;      
       
   154     }
       
   155     
       
   156 // ---------------------------------------------------------
       
   157 // CActiveConnectViaNote::GetDialogTextL()
       
   158 // ---------------------------------------------------------
       
   159 //    
       
   160 HBufC* CActiveConnectViaNote::GetDialogTextL()
       
   161     {
       
   162     HBufC* tempText = NULL;
       
   163     switch( iData.iNoteId )
       
   164         {
       
   165         case EConnectedViaDestConnMethodConfirmationNote:
       
   166             {
       
   167             HBufC* destName = GetDestinationNameLC( iData.iDestination );
       
   168             HBufC* cmName = GetConnectionMethodNameLC( 
       
   169                                                     iData.iConnectionMethod );
       
   170             CDesCArrayFlat* strings = new( ELeave ) CDesCArrayFlat( 
       
   171                                                         KStringsGranularity );
       
   172             CleanupStack::PushL( strings );
       
   173             
       
   174             strings->AppendL( *destName );   
       
   175             strings->AppendL( *cmName );
       
   176             tempText = StringLoader::LoadL( 
       
   177                                         R_QTN_NETW_CONSET_CONF_CONNECTED_TO,
       
   178                                         *strings );
       
   179 
       
   180             CleanupStack::PopAndDestroy( strings );  
       
   181             CleanupStack::PopAndDestroy( cmName );
       
   182             CleanupStack::PopAndDestroy( destName );
       
   183             break;
       
   184             }
       
   185 
       
   186         case EConnectedViaConnMethodConfirmationNote:
       
   187         case EConnectingToConnMethodInfoNote:
       
   188         default:
       
   189             {
       
   190             HBufC* cmNname = GetConnectionMethodNameLC( 
       
   191                                                     iData.iConnectionMethod );
       
   192             tempText = StringLoader::LoadL( 
       
   193                 ( iData.iNoteId == EConnectedViaConnMethodConfirmationNote ) ?
       
   194                 R_QTN_NETW_CONSET_CONF_CONNECTED_VIA_METHOD : 
       
   195                 R_QTN_NETW_CONSET_INFO_ROAMING_TO,
       
   196                 *cmNname );
       
   197             CleanupStack::PopAndDestroy( cmNname ); 
       
   198             break;
       
   199             }
       
   200         }
       
   201 
       
   202     return tempText;
       
   203     }
       
   204 
       
   205 // ---------------------------------------------------------
       
   206 // CActiveConnectViaNote::GetDestinationNameLC()
       
   207 // ---------------------------------------------------------
       
   208 //    
       
   209 HBufC* CActiveConnectViaNote::GetDestinationNameLC( const TUint32 aDestId )
       
   210     {
       
   211     HBufC* tempDestName( NULL );
       
   212         
       
   213     RCmDestination destination = iCmManager.DestinationL( aDestId );    
       
   214     CleanupClosePushL( destination );
       
   215 
       
   216     tempDestName = destination.NameLC();
       
   217     CleanupStack::Pop( tempDestName );  // tempDestName
       
   218 
       
   219     CleanupStack::PopAndDestroy();  // destination
       
   220     CleanupStack::PushL( tempDestName );
       
   221             
       
   222     return tempDestName;
       
   223     }
       
   224     
       
   225 // ---------------------------------------------------------
       
   226 // CActiveConnectViaNote::GetConnectionMethodNameLC()
       
   227 // ---------------------------------------------------------
       
   228 //    
       
   229 HBufC* CActiveConnectViaNote::GetConnectionMethodNameLC( 
       
   230                                                     const TUint32 aConnMId )
       
   231     {
       
   232     HBufC* tempCMName( NULL );
       
   233     TBool isEasyWlan = EFalse;
       
   234 
       
   235 #ifndef __WINS__
       
   236     
       
   237     FeatureManager::InitializeLibL();
       
   238     TBool isWlanSupported = 
       
   239                     FeatureManager::FeatureSupported( KFeatureIdProtocolWlan );
       
   240     FeatureManager::UnInitializeLib();
       
   241 
       
   242     if ( isWlanSupported )
       
   243         {
       
   244         if ( iCmManager.EasyWlanIdL() == iData.iConnectionMethod )
       
   245             {
       
   246             TWlanSsid ssidConn;
       
   247             CWlanMgmtClient *wlanMgmtClient = CWlanMgmtClient::NewL();
       
   248             CleanupStack::PushL( wlanMgmtClient );
       
   249 
       
   250             if ( !wlanMgmtClient->GetConnectionSsid( ssidConn ) )
       
   251                 {
       
   252                 tempCMName = HBufC::NewL( ssidConn.Length() );
       
   253                 tempCMName->Des().Copy( ssidConn ); 
       
   254                 isEasyWlan = ETrue;
       
   255                 }
       
   256 
       
   257             wlanMgmtClient->CancelNotifications();
       
   258             CleanupStack::PopAndDestroy( wlanMgmtClient );
       
   259             }
       
   260         }
       
   261 #endif  // !__WINS__
       
   262     
       
   263     CLOG_WRITEF( _L( "Connection Method id in CActiveConnectViaNote: %d" ), aConnMId );
       
   264 
       
   265     RCmConnectionMethod connMethod = iCmManager.ConnectionMethodL( aConnMId );
       
   266     CleanupClosePushL( connMethod );
       
   267 
       
   268     TInt tempIcon = connMethod.GetIntAttributeL( CMManager::ECmBearerIcon );
       
   269     CLOG_WRITEF( _L( "tempIcon in CActiveConnectViaNote: %d" ), tempIcon );
       
   270     iIcon = REINTERPRET_CAST( CGulIcon*, tempIcon );
       
   271     
       
   272     if ( !isEasyWlan )
       
   273         {
       
   274         tempCMName = connMethod.GetStringAttributeL( CMManager::ECmName );
       
   275         }
       
   276     
       
   277     CleanupStack::PopAndDestroy();  // connMethod
       
   278     CleanupStack::PushL( tempCMName );
       
   279     
       
   280     return tempCMName;
       
   281     }
       
   282     
       
   283 // ---------------------------------------------------------
       
   284 // CActiveConnectViaNote::CreateEikImageFromCGulIconLC()
       
   285 // ---------------------------------------------------------
       
   286 //   
       
   287 CEikImage* CActiveConnectViaNote::CreateEikImageFromCGulIconLC()
       
   288     {
       
   289     CEikImage* tempImage = new ( ELeave ) CEikImage();
       
   290     
       
   291     if( iIcon )
       
   292         {                
       
   293         CFbsBitmap* bm = iIcon->Bitmap();
       
   294         CFbsBitmap* m = iIcon->Mask();
       
   295         tempImage->SetPicture( bm, m );
       
   296         iIcon->SetBitmapsOwnedExternally( ETrue );                
       
   297         }
       
   298     
       
   299     CleanupStack::PushL( tempImage );
       
   300     return tempImage;    
       
   301     }
       
   302 
       
   303 
       
   304 
       
   305 // End of File