connectionutilities/ConnectionDialogs/ConnectionUiUtilities/src/ActiveWrapper.cpp
changeset 0 5a93021fdf25
child 20 9c97ad6591ae
child 57 05bc53fe583b
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     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: 
       
    15 *    CActiveWrapper implementation file
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 #include <e32base.h>
       
    22 
       
    23 #include "ActiveWrapper.h"
       
    24 #include "ConnectionDialogsLogger.h"
       
    25 
       
    26 // LOCAL CONSTANTS AND MACROS
       
    27 
       
    28 // ---------------------------------------------------------
       
    29 // CActiveWrapper::NewL
       
    30 //
       
    31 // Two-phased constructor.
       
    32 // ---------------------------------------------------------
       
    33 //
       
    34 CActiveWrapper* CActiveWrapper::NewL( const TUint aIndexOfNote )
       
    35     {
       
    36     CLOG_ENTERFN( "CActiveWrapper::NewL()" );
       
    37     CActiveWrapper* self = new ( ELeave ) CActiveWrapper( aIndexOfNote );
       
    38     CleanupStack::PushL( self );
       
    39 
       
    40     self->ConstructL();
       
    41     
       
    42     CleanupStack::Pop( self );
       
    43     CLOG_LEAVEFN( "CActiveWrapper::NewL()" );
       
    44     
       
    45     return self;
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------
       
    49 // CActiveWrapper::ConstructL
       
    50 //
       
    51 // Symbian OS default constructor can leave.
       
    52 // ---------------------------------------------------------
       
    53 //
       
    54 void CActiveWrapper::ConstructL()
       
    55     {
       
    56     CLOG_ENTERFN( "CActiveWrapper::ConstructL()" );
       
    57 
       
    58     User::LeaveIfError( iNotif.Connect() );
       
    59     CActiveScheduler::Add( this );
       
    60 
       
    61     CLOG_LEAVEFN( "CActiveWrapper::ConstructL()" );
       
    62     }
       
    63 
       
    64 
       
    65 // ---------------------------------------------------------
       
    66 // CActiveWrapper::CActiveWrapper
       
    67 //
       
    68 // C++ constructor can NOT contain any code, that
       
    69 // might leave.
       
    70 // ---------------------------------------------------------
       
    71 //
       
    72 CActiveWrapper::CActiveWrapper( const TUint aIndexOfNote ) 
       
    73 : CActive( CActive::EPriorityStandard ),
       
    74   iIndexOfNote( aIndexOfNote )
       
    75     {
       
    76     }
       
    77 
       
    78 
       
    79 // ---------------------------------------------------------
       
    80 // CActiveWrapper::~CActiveWrapper
       
    81 //
       
    82 // Destructor
       
    83 // ---------------------------------------------------------
       
    84 //
       
    85 CActiveWrapper::~CActiveWrapper()
       
    86     {
       
    87     CLOG_ENTERFN( "CActiveWrapper::~CActiveWrapper()" );
       
    88 
       
    89     Cancel();
       
    90 
       
    91     CLOG_WRITE( "CActiveWrapper::~CActiveWrapper Canceled" );
       
    92 
       
    93     iNotif.Close();
       
    94 
       
    95     CLOG_LEAVEFN( "CActiveWrapper::~CActiveWrapper()" );
       
    96     }
       
    97 
       
    98 
       
    99 // ---------------------------------------------------------
       
   100 // CActiveWrapper::RunL
       
   101 //
       
   102 // From active object framework
       
   103 // ---------------------------------------------------------
       
   104 //
       
   105 void CActiveWrapper::RunL() 
       
   106     {
       
   107     CLOG_ENTERFN( "CActiveWrapper::RunL()" );            
       
   108 
       
   109     CLOG_WRITEF( _L( "Completing request with %d" ), iStatus.Int() );
       
   110 
       
   111     if ( iWait.IsStarted() )
       
   112         {
       
   113         CLOG_WRITEF( _L( "AsyncStop" ) );
       
   114 
       
   115         iWait.AsyncStop();
       
   116         }
       
   117     else 
       
   118         {
       
   119         if( ( (iStatus == KErrNone) || ( iStatus == KErrNotFound ) ) )
       
   120             {
       
   121             switch ( iIndexOfNote )    
       
   122                 {
       
   123                 case ESearchWlan :
       
   124                     {
       
   125                     *iSSID = iNetworkPrefs().iSsId;
       
   126                     *iConnectionMode = iNetworkPrefs().iNetworkMode;
       
   127                     *iSecurityMode = iNetworkPrefs().iSecMode;
       
   128                     *iExtSecurityMode = iNetworkPrefs().iExtSecMode;
       
   129                     *iProtectedSetupSupported = 
       
   130                                             iNetworkPrefs().iProtectedSetupSupported;
       
   131 
       
   132                     HBufC* ssid16 = HBufC::NewLC( iNetworkPrefs().iSsId.Length() );
       
   133                     ssid16->Des().Copy( *iSSID ); 
       
   134                     CLOG_WRITEF( _L( "iSSID : %S" ), ssid16 );    
       
   135                     CleanupStack::PopAndDestroy( ssid16 );
       
   136 
       
   137                     CLOG_WRITEF( _L( "iConnectionMode : %d" ),  *iConnectionMode );    
       
   138                     CLOG_WRITEF( _L( "iSecurityMode : %d" ),  *iSecurityMode );
       
   139                     CLOG_WRITEF( _L( "iExtSecurityMode : %d" ),  *iExtSecurityMode );
       
   140                     break;
       
   141                     }
       
   142                 case EWlanEasyWep :
       
   143                     {
       
   144                     iKey->Copy( iWepKey().iKey );
       
   145                     *iHex = iWepKey().iHex;        
       
   146                     break;
       
   147                     }
       
   148                 case EWlanEasyWpa :
       
   149                     {
       
   150                     iKey->Copy( iWpaKey() );
       
   151                     break;
       
   152                     }
       
   153                 default:
       
   154                     {
       
   155                     }
       
   156                 }
       
   157             }
       
   158 
       
   159         if ( iRS )
       
   160             {
       
   161             TRequestStatus* pS = iRS;
       
   162             User::RequestComplete( pS, iStatus.Int() );
       
   163             iRS = NULL;
       
   164             }
       
   165         }
       
   166     
       
   167     CLOG_LEAVEFN( "CActiveWrapper::RunL()" );                
       
   168     }
       
   169 
       
   170 
       
   171 // ---------------------------------------------------------
       
   172 // CActiveWrapper::DoCancel
       
   173 //
       
   174 // From active object framework
       
   175 // ---------------------------------------------------------
       
   176 //
       
   177 void CActiveWrapper::DoCancel()
       
   178     {
       
   179     CLOG_ENTERFN( "CActiveWrapper::DoCancel()" );
       
   180 
       
   181     switch( iIndexOfNote )
       
   182         {
       
   183         case ESearchWlan:
       
   184             {
       
   185             iNotif.CancelSearchWLANNetwork();
       
   186             
       
   187             if ( iRS )
       
   188                 {
       
   189                 TRequestStatus* pS = iRS;
       
   190                 User::RequestComplete( pS, KErrCancel );	
       
   191                 }
       
   192             
       
   193             break;
       
   194             }
       
   195 
       
   196         case EOffLineWlan:
       
   197             {
       
   198             iNotif.CancelOffLineWlanNote();
       
   199             break;
       
   200             }
       
   201 
       
   202         case EConnViaDestCM:
       
   203             {
       
   204             iNotif.CancelConnectedViaDestAndConnMethodNote();
       
   205             break;
       
   206             }
       
   207 
       
   208         case EChangingConnTo:
       
   209             {
       
   210             iNotif.CancelChangingConnectionToNote();
       
   211             break;
       
   212             }
       
   213 
       
   214         case EConnViaCM:
       
   215             {
       
   216             iNotif.CancelConnectedViaConnMethodNote();            
       
   217             break;
       
   218             }
       
   219         case EWlanEasyWep:
       
   220             {
       
   221             iNotif.CancelEasyWepDlg();
       
   222             
       
   223             if ( iRS )
       
   224                 {
       
   225                 TRequestStatus* pS = iRS;
       
   226                 User::RequestComplete( pS, KErrCancel );	
       
   227                 }
       
   228                         
       
   229             break;
       
   230             }
       
   231         case EWlanEasyWpa:
       
   232             {
       
   233             iNotif.CancelEasyWpaDlg();
       
   234             
       
   235             if ( iRS )
       
   236                 {
       
   237                 TRequestStatus* pS = iRS;
       
   238                 User::RequestComplete( pS, KErrCancel );	
       
   239                 }
       
   240                         
       
   241             break;
       
   242             }
       
   243         default:
       
   244             {
       
   245 		    break;
       
   246             }
       
   247         }
       
   248 
       
   249     if ( iWait.IsStarted() )
       
   250         {
       
   251         iWait.AsyncStop();
       
   252         }
       
   253 
       
   254     CLOG_LEAVEFN( "CActiveWrapper::DoCancel()" );
       
   255     }
       
   256 
       
   257 
       
   258 // ---------------------------------------------------------
       
   259 // CActiveWrapper::StartSearchWLANNetwork
       
   260 //
       
   261 // Starts the active object
       
   262 // ---------------------------------------------------------
       
   263 //
       
   264 void CActiveWrapper::StartSearchWLANNetwork( 
       
   265                         TPckgBuf<TConnUiUiWlanNetworkPrefs>& aNetworkPrefs )
       
   266     {
       
   267     CLOG_ENTERFN( "CActiveWrapper::StartSearchWLANNetwork()" );
       
   268     
       
   269     if ( IsActive() == EFalse )
       
   270         {
       
   271         CLOG_WRITE( "NOT active" );
       
   272                         
       
   273         iNotif.SearchWLANNetwork( aNetworkPrefs, iStatus, EFalse );
       
   274         SetActive();
       
   275         iWait.Start();
       
   276         }
       
   277     else
       
   278         {
       
   279         CLOG_WRITE( "Already active" );
       
   280         }
       
   281                         
       
   282     CLOG_LEAVEFN( "CActiveWrapper::StartSearchWLANNetwork()" );
       
   283     }
       
   284 
       
   285 
       
   286 // ---------------------------------------------------------
       
   287 // CActiveWrapper::StartSearchWLANNetworkAsync
       
   288 //
       
   289 // Starts the active object
       
   290 // ---------------------------------------------------------
       
   291 //
       
   292 void CActiveWrapper::StartSearchWLANNetworkAsync( TRequestStatus& aStatus, 
       
   293                                 TWlanSsid& aSSID,
       
   294                                 TWlanConnectionMode& aConnectionMode,
       
   295                                 TWlanConnectionSecurityMode& aSecurityMode,
       
   296                                 TWlanConnectionExtentedSecurityMode& aExtSecurityMode, 
       
   297                                 TBool& aProtectedSetupSupported )
       
   298     {
       
   299     CLOG_ENTERFN( "CActiveWrapper::StartSearchWLANNetworkAsync()" );
       
   300     
       
   301     if ( IsActive() == EFalse )
       
   302         {
       
   303         CLOG_WRITE( "NOT active" );
       
   304 
       
   305         iSSID = &aSSID;
       
   306         iConnectionMode = &aConnectionMode;
       
   307         iSecurityMode = &aSecurityMode;
       
   308         iExtSecurityMode = &aExtSecurityMode;
       
   309         iProtectedSetupSupported = &aProtectedSetupSupported;
       
   310         iNetworkPrefs();
       
   311 
       
   312         iRS = &aStatus;
       
   313         *iRS = KRequestPending;
       
   314 
       
   315         SetActive();
       
   316 
       
   317         iNotif.SearchWLANNetwork( iNetworkPrefs, iStatus, ETrue );
       
   318         }
       
   319     else
       
   320         {
       
   321         CLOG_WRITE( "Already active" );
       
   322         }
       
   323                         
       
   324     CLOG_LEAVEFN( "CActiveWrapper::StartSearchWLANNetworkAsync()" );
       
   325     }
       
   326 // ---------------------------------------------------------
       
   327 // CActiveWrapper::StartEasyWepDlg
       
   328 //
       
   329 // Starts the active object
       
   330 // ---------------------------------------------------------
       
   331 //
       
   332 TInt CActiveWrapper::StartEasyWepDlg( TPckgBuf< TWepKeyData >& aKey )
       
   333     {
       
   334     if ( IsActive() == EFalse )
       
   335         {
       
   336         iIndexOfNote = EWlanEasyWep;
       
   337         iNotif.EasyWepDlg( aKey, iStatus );
       
   338         SetActive();
       
   339         iWait.Start();
       
   340         }
       
   341     return iStatus.Int();  
       
   342     }
       
   343 
       
   344 // ---------------------------------------------------------
       
   345 // CActiveWrapper::StartEasyWepDlgAsync
       
   346 //
       
   347 // Starts the active object
       
   348 // ---------------------------------------------------------
       
   349 //
       
   350 void CActiveWrapper::StartEasyWepDlgAsync( TRequestStatus& aStatus, TDes* aKey, TBool& aHex )
       
   351     {
       
   352     if ( IsActive() == EFalse )
       
   353         {
       
   354         iKey = aKey;
       
   355         iHex = &aHex;
       
   356         iWepKey();
       
   357         iWepKey().iKey.Copy( *aKey );
       
   358         iIndexOfNote = EWlanEasyWep;
       
   359         iNotif.EasyWepDlg( iWepKey, iStatus );
       
   360         iRS = &aStatus;
       
   361         *iRS = KRequestPending;        
       
   362         SetActive();
       
   363         }
       
   364     }
       
   365 
       
   366 
       
   367 // ---------------------------------------------------------
       
   368 // CActiveWrapper::StartEasyWpaDlg
       
   369 //
       
   370 // Starts the active object
       
   371 // ---------------------------------------------------------
       
   372 //
       
   373 TInt CActiveWrapper::StartEasyWpaDlg( TPckgBuf< TBuf< KEasyWpaQueryMaxLength > >& aKey )
       
   374     {
       
   375     if ( IsActive() == EFalse )
       
   376         {
       
   377         iIndexOfNote = EWlanEasyWpa;
       
   378         iNotif.EasyWpaDlg( aKey, iStatus );
       
   379         SetActive();
       
   380         iWait.Start();
       
   381         }
       
   382     return iStatus.Int();  
       
   383     }
       
   384 
       
   385 // ---------------------------------------------------------
       
   386 // CActiveWrapper::StartEasyWpaDlgAsync
       
   387 //
       
   388 // Starts the active object
       
   389 // ---------------------------------------------------------
       
   390 //
       
   391 void CActiveWrapper::StartEasyWpaDlgAsync( TRequestStatus& aStatus, TDes* aKey )
       
   392     {
       
   393     if ( IsActive() == EFalse )
       
   394         {
       
   395         iKey = aKey;
       
   396         iWpaKey();
       
   397         iWpaKey().Copy( *aKey );
       
   398         iIndexOfNote = EWlanEasyWpa;
       
   399         iNotif.EasyWpaDlg( iWpaKey, iStatus );
       
   400         iRS = &aStatus;
       
   401         *iRS = KRequestPending;        
       
   402         SetActive();
       
   403         }
       
   404     }
       
   405 
       
   406 // ---------------------------------------------------------
       
   407 // CActiveWrapper::StartGenericNote
       
   408 //
       
   409 // Starts the active object
       
   410 // ---------------------------------------------------------
       
   411 //
       
   412 void CActiveWrapper::StartGenericNote( const TUint aIndexOfNote, 
       
   413                                        const TUint32 aConnMId /* = 0 */,
       
   414                                        const TUint32 aDestId /* = 0 */ )
       
   415     {
       
   416     // Do not use logs here it cause crash in MPM server
       
   417 
       
   418     if ( IsActive() == EFalse )
       
   419         {
       
   420         switch ( aIndexOfNote )
       
   421             {
       
   422             case EOffLineWlan:
       
   423                 {
       
   424                 iNotif.OffLineWlanNote( iStatus, EFalse );
       
   425                 break;
       
   426                 }
       
   427 
       
   428             case EWlanDisabled:
       
   429                 {
       
   430                 iNotif.OffLineWlanDisabledNote( iStatus );
       
   431                 break;
       
   432                 }
       
   433 
       
   434             case EWlanNetwUnavail:
       
   435                 {
       
   436                 iNotif.WLANNetworkUnavailableNote( iStatus );
       
   437                 break;
       
   438                 }
       
   439 
       
   440             case EConnViaDestCM:
       
   441                 {
       
   442                 iNotif.ConnectedViaDestAndConnMethodNote( aDestId, aConnMId,
       
   443                                                           iStatus );
       
   444                 break;
       
   445                 }
       
   446 
       
   447             case EChangingConnTo:
       
   448                 {
       
   449                 iNotif.ChangingConnectionToNote( aConnMId, iStatus );
       
   450                 break;
       
   451                 }
       
   452 
       
   453             case EConnViaCM:
       
   454                 {
       
   455                 iNotif.ConnectedViaConnMethodNote( aConnMId, iStatus );
       
   456                 break;
       
   457                 }
       
   458 
       
   459             case ENoWlanNetwsAvail:
       
   460                 {
       
   461                 iNotif.NoWLANNetworksAvailableNote( iStatus );
       
   462                 break;
       
   463                 }
       
   464 
       
   465             default:
       
   466                 {
       
   467                 return;
       
   468                 }
       
   469             }
       
   470 
       
   471         iIndexOfNote = aIndexOfNote;
       
   472         SetActive();
       
   473         iWait.Start();
       
   474         }
       
   475     else
       
   476         {
       
   477         }
       
   478     }
       
   479 
       
   480 // ---------------------------------------------------------
       
   481 // CActiveWrapper::StartEasyWapiDlg
       
   482 //
       
   483 // Starts the active object
       
   484 // ---------------------------------------------------------
       
   485 //
       
   486 TInt CActiveWrapper::StartEasyWapiDlg( TPckgBuf< TBuf< KEasyWapiQueryMaxLength > >& aKey )
       
   487     {
       
   488     if ( IsActive() == EFalse )
       
   489         {
       
   490         iIndexOfNote = EWlanEasyWapi;
       
   491         iNotif.EasyWapiDlg( aKey, iStatus );
       
   492         SetActive();
       
   493         iWait.Start();
       
   494         }
       
   495 
       
   496     return iStatus.Int();  
       
   497     }
       
   498 
       
   499 // ---------------------------------------------------------
       
   500 // CActiveWrapper::StartConnectingViaDiscreetPopup
       
   501 //
       
   502 // Starts the active object
       
   503 // ---------------------------------------------------------
       
   504 //
       
   505 void CActiveWrapper::StartConnectingViaDiscreetPopup( TPckgBuf< TConnUiConnectingViaDiscreetPopup>& aInfo )
       
   506     {
       
   507     if ( IsActive() == EFalse )
       
   508         {
       
   509         iIndexOfNote = EConnectingViaDiscreetPopup;
       
   510         iNotif.ConnectingViaDiscreetPopup( aInfo, iStatus );
       
   511         SetActive();
       
   512         iWait.Start();
       
   513         }
       
   514 
       
   515     }
       
   516 
       
   517 
       
   518 // ---------------------------------------------------------
       
   519 // CActiveWrapper::StartConnectionErrorDiscreetPopup
       
   520 //
       
   521 // Starts the active object
       
   522 // ---------------------------------------------------------
       
   523 //
       
   524 void CActiveWrapper::StartConnectionErrorDiscreetPopup( TPckgBuf<TInt>& aErrCode )
       
   525     {
       
   526     if ( IsActive() == EFalse )
       
   527         {
       
   528         iIndexOfNote = EConnectionErrorDiscreetPopup;
       
   529         iNotif.ConnectionErrorDiscreetPopup( aErrCode, iStatus );
       
   530         SetActive();
       
   531         iWait.Start();
       
   532         }
       
   533 
       
   534     }
       
   535 
       
   536 // End of File