connectionutilities/ConnectionDialogs/DisconnectDlg/src/DisconnectDlgUi.cpp
changeset 0 5a93021fdf25
child 26 0a9e01492035
child 41 bbb64eb3bdee
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     1 /*
       
     2 * Copyright (c) 2004 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 *     Defines the main handler, CDisconnectDialogUi and public API for 
       
    16 *     Disconnect Dialog UI.
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "DisconnectDlgUi.h"
       
    23 #include "ActiveDisconnectDlgPlugin.h"
       
    24 #include "ConnectionModel.h"
       
    25 #include "QueryDisconnectDlgDialog.h"
       
    26 #include "ConnectionDialogsUidDefs.h"
       
    27 #include "ConnectionDialogsLogger.h"
       
    28 
       
    29 #include <bautils.h>
       
    30 #include <textresolver.h>
       
    31 
       
    32 #include <DisconnectDlg.rsg>
       
    33 #include <data_caging_path_literals.hrh>
       
    34 
       
    35 
       
    36 // CONSTANTS
       
    37 
       
    38 // ROM folder
       
    39 _LIT( KDriveZ, "z:" );
       
    40 
       
    41 // Name of the RSC file containing resources
       
    42 _LIT( KDisconnectDlgUiRSCFile, "DisconnectDlg.rsc" );
       
    43 
       
    44 /**
       
    45 * Count of used MEikSrvNotifierBase
       
    46 */
       
    47 LOCAL_D const TInt KPluginGranularity = 1;
       
    48 
       
    49 
       
    50 LOCAL_C void CreateNotifiersL( 
       
    51                           CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers );
       
    52 
       
    53 
       
    54 EXPORT_C CArrayPtr<MEikSrvNotifierBase2>* NotifierArray()
       
    55     {
       
    56     CArrayPtrFlat<MEikSrvNotifierBase2>* array = new( ELeave )
       
    57                     CArrayPtrFlat<MEikSrvNotifierBase2>( KPluginGranularity );
       
    58 
       
    59     if ( array )
       
    60         {
       
    61         TRAPD( err, CreateNotifiersL( array ) );
       
    62         if( err )
       
    63             {
       
    64             TInt count = array->Count();
       
    65             while( count-- )
       
    66                 {
       
    67                 ( *array )[count]->Release();
       
    68                 }
       
    69             delete array;
       
    70             array = NULL;
       
    71             }
       
    72         }
       
    73 
       
    74     return( array );
       
    75     }
       
    76 
       
    77 
       
    78 // ---------------------------------------------------------
       
    79 // CreateNotifiersL( CArrayPtrFlat<MEikSrvNotifierBase>* aNotifiers )
       
    80 // ---------------------------------------------------------
       
    81 //
       
    82 LOCAL_C void CreateNotifiersL( 
       
    83                               CArrayPtrFlat<MEikSrvNotifierBase2>* aNotifiers )
       
    84     {
       
    85     MEikSrvNotifierBase2 *serNotify;
       
    86 
       
    87     serNotify = CDisconnectDialogUi::NewL();
       
    88     CleanupStack::PushL( serNotify );
       
    89     aNotifiers->AppendL( serNotify );
       
    90     CleanupStack::Pop( serNotify ); // serNotify
       
    91     }
       
    92 
       
    93 
       
    94 // ================= MEMBER FUNCTIONS =======================
       
    95 
       
    96 // ---------------------------------------------------------
       
    97 // CDisconnectDialogUi::NewLC
       
    98 // ---------------------------------------------------------
       
    99 //
       
   100 CDisconnectDialogUi* CDisconnectDialogUi::NewL()
       
   101     {
       
   102     CDisconnectDialogUi* self = new( ELeave ) CDisconnectDialogUi();
       
   103     CleanupStack::PushL( self );
       
   104     self->ConstructL();
       
   105     CleanupStack::Pop( self ); // self
       
   106 
       
   107     return self;
       
   108     }
       
   109 
       
   110 
       
   111 // ---------------------------------------------------------
       
   112 // CDisconnectDialogUi::~CDisconnectDialogUi
       
   113 // ---------------------------------------------------------
       
   114 //
       
   115 CDisconnectDialogUi::~CDisconnectDialogUi()
       
   116     {
       
   117     delete iActivePlugin; 
       
   118     delete iConnModel;
       
   119     delete iErrorMsgDetails;
       
   120     if ( iResOffset )
       
   121         {
       
   122         CCoeEnv::Static()->DeleteResourceFile( iResOffset );
       
   123         }
       
   124     }
       
   125 
       
   126 
       
   127 // ---------------------------------------------------------
       
   128 // CDisconnectDialogUi::CDisconnectDialogUi
       
   129 // ---------------------------------------------------------
       
   130 //
       
   131 CDisconnectDialogUi::CDisconnectDialogUi()
       
   132 : iDialogRun( EFalse ), 
       
   133   iQueryRun( EFalse ), 
       
   134   iResOffset( 0 ),
       
   135   iConnModel( NULL ), 
       
   136   iIndex( 0 ), 
       
   137   iStarted( EFalse ), 
       
   138   iActivePlugin( NULL )
       
   139     {
       
   140     }
       
   141 
       
   142 
       
   143 // ---------------------------------------------------------
       
   144 // CDisconnectDialogUi::ConstructL
       
   145 // ---------------------------------------------------------
       
   146 //
       
   147 void CDisconnectDialogUi::ConstructL( )
       
   148     {
       
   149     // The resource has to be loaded manually since it is not an application.
       
   150 
       
   151     TFileName resourceFileName;
       
   152 
       
   153     resourceFileName.Append( KDriveZ );
       
   154     resourceFileName.Append( KDC_RESOURCE_FILES_DIR );   
       
   155     resourceFileName.Append( KDisconnectDlgUiRSCFile );
       
   156 
       
   157     BaflUtils::NearestLanguageFile( CCoeEnv::Static()->FsSession(),
       
   158                                     resourceFileName );
       
   159     iResOffset = CCoeEnv::Static()->AddResourceFileL( resourceFileName );
       
   160     }
       
   161 
       
   162 
       
   163 // ---------------------------------------------------------
       
   164 // CDisconnectDialogUi::Cvt
       
   165 // ---------------------------------------------------------
       
   166 //
       
   167 TInt CDisconnectDialogUi::Cvt()
       
   168     {
       
   169     return KErrNone;
       
   170     }
       
   171 
       
   172 
       
   173 // ---------------------------------------------------------
       
   174 // CDisconnectDialogUi::InitializedL
       
   175 // ---------------------------------------------------------
       
   176 //
       
   177 void CDisconnectDialogUi::InitializedL( CConnectionInfo* aConnectionInfo )
       
   178     {
       
   179     CLOG_ENTERFN( "CDisconnectDialogUi::InitializedL" );
       
   180     iQueryRun = EFalse;
       
   181     delete iConnModel;
       
   182     iConnModel = NULL;
       
   183     iConnModel = CConnectionModel::NewL( this, aConnectionInfo );
       
   184 
       
   185     // Now all the info are ready to show
       
   186     // Let's show the dialog        
       
   187     iDialogRun = ETrue;
       
   188     iDisconnectDialog = CDisconnectDlgDialog::NewL( this, iConnModel, 
       
   189                                                     &iIndex, iIapId );
       
   190     iDisconnectDialog->RunDlgLD();
       
   191     iDialogRun = EFalse;
       
   192     
       
   193     CLOG_LEAVEFN( "CDisconnectDialogUi::InitializedL" );    
       
   194     }
       
   195 
       
   196 
       
   197 // ---------------------------------------------------------
       
   198 // void CDisconnectDialogUi::Release()
       
   199 // ---------------------------------------------------------
       
   200 //
       
   201 void CDisconnectDialogUi::Release()
       
   202     {
       
   203     delete this;
       
   204     }
       
   205 
       
   206 
       
   207 // ---------------------------------------------------------
       
   208 // TNotifierInfo CDisconnectDialogUi::RegisterL()
       
   209 // ---------------------------------------------------------
       
   210 //
       
   211 CDisconnectDialogUi::TNotifierInfo CDisconnectDialogUi::RegisterL()
       
   212     {
       
   213     iInfo.iUid = KUidDisconnectDlg;
       
   214     iInfo.iPriority = ENotifierPriorityHigh;
       
   215     iInfo.iChannel = KUidDisconnectDlg;
       
   216 
       
   217     return iInfo;
       
   218     }
       
   219 
       
   220 
       
   221 // ---------------------------------------------------------
       
   222 // TNotifierInfo CDisconnectDialogUi::Info() const
       
   223 // ---------------------------------------------------------
       
   224 //
       
   225 CDisconnectDialogUi::TNotifierInfo CDisconnectDialogUi::Info() const
       
   226     {
       
   227     return iInfo;
       
   228     }
       
   229 
       
   230 
       
   231 // ---------------------------------------------------------
       
   232 // TPtrC8 CDisconnectDialogUi::StartL( const TDesC8& /*aBuffer*/ )
       
   233 // ---------------------------------------------------------
       
   234 //
       
   235 TPtrC8 CDisconnectDialogUi::StartL( const TDesC8& /*aBuffer*/ )
       
   236     {
       
   237     return KNullDesC8().Ptr();
       
   238     }
       
   239 
       
   240 
       
   241 // ---------------------------------------------------------
       
   242 // void CDisconnectDialogUi::StartL( const TDesC8& /*aBuffer*/, 
       
   243 //                                  const TAny* /*aReturnVal*/, 
       
   244 //                                  RMessage /*aMessage*/)
       
   245 // ---------------------------------------------------------
       
   246 //
       
   247 
       
   248 void CDisconnectDialogUi::StartL( const TDesC8& aBuffer, 
       
   249                                   TInt aReplySlot,
       
   250                                   const RMessagePtr2& aMessage )
       
   251     { 
       
   252     CLOG_ENTERFN("CDisconnectDialogUi::StartL");        
       
   253       
       
   254     iStarted = ETrue;
       
   255 
       
   256     TPckgBuf<TDisconnectConnectionPrefs> passedInfo;
       
   257     passedInfo.Copy( aBuffer );
       
   258     iConnectionPrefs = passedInfo();
       
   259     
       
   260     iReplySlot = aReplySlot;    
       
   261     iMessage = aMessage;
       
   262     
       
   263     CLOG_WRITEF(_L( "iCntPrefs.iPrompt: %d" ), iConnectionPrefs.iPrompt );
       
   264     
       
   265     TInt err( KErrNone );    
       
   266     TRAP( err, iActivePlugin = CActiveDisconnectDlgPlugin::NewL( this ) ); 
       
   267     
       
   268     if ( err )
       
   269         {
       
   270         delete iActivePlugin;
       
   271         iActivePlugin = NULL;
       
   272         User::Leave( err );           
       
   273         }
       
   274         
       
   275     iActivePlugin->StartSearchConnections(); 
       
   276      
       
   277     CLOG_LEAVEFN("CDisconnectDialogUi::StartL");        
       
   278     }
       
   279 
       
   280 
       
   281 // ---------------------------------------------------------
       
   282 // void CDisconnectDialogUi::AskDisconnectL
       
   283 // ---------------------------------------------------------
       
   284 //
       
   285 
       
   286 TInt CDisconnectDialogUi::AskDisconnectL()
       
   287     {
       
   288     CLOG_ENTERFN( "CDisconnectDialogUi::AskDisconnectL" );        
       
   289     
       
   290     const TInt KErrorCode = -6000;
       
   291     TInt proceed( KErrNone );
       
   292     TInt textId;
       
   293     TUint textFlags;
       
   294 
       
   295     delete iErrorMsgDetails;
       
   296     iErrorMsgDetails = NULL;
       
   297 
       
   298     CTextResolver* resolver = CTextResolver::NewLC();
       
   299     const TDesC& error = resolver->ResolveErrorString( KErrorCode, 
       
   300                                         textId, textFlags, 
       
   301                                         CTextResolver::ECtxNoCtxNoSeparator );
       
   302 
       
   303     if ( !( textFlags & EErrorResBlankErrorFlag ||
       
   304             textFlags & ETextResolverUnknownErrorFlag ) )
       
   305         {
       
   306         iErrorMsgDetails = error.AllocL();
       
   307 
       
   308         CleanupStack::PopAndDestroy( resolver );
       
   309             
       
   310         iQueryDisconnectDlgDialog = new ( ELeave ) CQueryDisconnectDlgDialog( 
       
   311                                                                         this );
       
   312         iQueryDisconnectDlgDialog->SetPromptL( *iErrorMsgDetails );
       
   313         iQueryRun = ETrue;
       
   314         proceed = iQueryDisconnectDlgDialog->ExecuteLD( 
       
   315                                                     R_DISCONNECTDLG_PROCEED );
       
   316         iQueryRun = EFalse;
       
   317         }
       
   318     else
       
   319         {
       
   320         CleanupStack::PopAndDestroy( resolver );
       
   321         }
       
   322 
       
   323     CLOG_LEAVEFN( "CDisconnectDialogUi::AskDisconnectL" );        
       
   324 
       
   325     return proceed;
       
   326     }
       
   327 
       
   328 
       
   329 // ---------------------------------------------------------
       
   330 // void CDisconnectDialogUi::Cancel()
       
   331 // ---------------------------------------------------------
       
   332 //
       
   333 void CDisconnectDialogUi::Cancel()
       
   334     {
       
   335     CLOG_ENTERFN("CDisconnectDialogUi::Cancel");        
       
   336     
       
   337     delete iActivePlugin;
       
   338     iActivePlugin = NULL;
       
   339     
       
   340     if ( iStarted )
       
   341         {           
       
   342         iStarted = EFalse;
       
   343         if ( !iMessage.IsNull() )
       
   344             {
       
   345             iMessage.Complete( KErrCancel );
       
   346             }
       
   347         }
       
   348        
       
   349     if ( iQueryRun )
       
   350         {
       
   351         delete iQueryDisconnectDlgDialog;
       
   352         }
       
   353 
       
   354     if ( iDialogRun )
       
   355         {
       
   356         delete iDisconnectDialog;
       
   357         }
       
   358         
       
   359     iQueryDisconnectDlgDialog = NULL;
       
   360     iDisconnectDialog = NULL;
       
   361 
       
   362     delete iErrorMsgDetails;
       
   363     iErrorMsgDetails = NULL;
       
   364                 
       
   365     CLOG_LEAVEFN("CDisconnectDialogUi::Cancel");                
       
   366     }
       
   367 
       
   368 
       
   369 // ---------------------------------------------------------
       
   370 // void CDisconnectDialogUi::CompleteL( TInt aStatus )
       
   371 // ---------------------------------------------------------
       
   372 //
       
   373 void CDisconnectDialogUi::CompleteL( TInt aStatus )
       
   374     {
       
   375     CLOG_ENTERFN("CDisconnectDialogUi::CompleteL"); 
       
   376    
       
   377     if ( !iMessage.IsNull() )
       
   378         {
       
   379         if ( aStatus == KErrNone )
       
   380             {
       
   381             iMessage.WriteL( iReplySlot, TPckg<TUint32>( iIapId ) );
       
   382             CLOG_WRITEF( _L( "iIapId : %d" ), iIapId );        
       
   383             }
       
   384       
       
   385         iMessage.Complete( aStatus );
       
   386         }
       
   387     
       
   388     iStarted = EFalse;
       
   389     Cancel();                
       
   390     
       
   391     CLOG_LEAVEFN("CDisconnectDialogUi::CompleteL");        
       
   392     }
       
   393 
       
   394 
       
   395 // ---------------------------------------------------------
       
   396 // TPtrC8 CConnDlgPluginBase::UpdateL(const TDesC8& /*aBuffer*/)
       
   397 // ---------------------------------------------------------
       
   398 //
       
   399 TPtrC8 CDisconnectDialogUi::UpdateL(const TDesC8& /*aBuffer*/)
       
   400     {
       
   401     return KNullDesC8().Ptr();
       
   402     }
       
   403     
       
   404     
       
   405 // ---------------------------------------------------------
       
   406 // void CDisconnectDialogUi::SetClosedIapId
       
   407 // ---------------------------------------------------------
       
   408 //
       
   409 void CDisconnectDialogUi::SetClosedIapId( TUint32 aIapId )
       
   410     {
       
   411     CLOG_ENTERFN("CDisconnectDialogUi::SetClosedIapId");     
       
   412     
       
   413     iIapId = aIapId;
       
   414 
       
   415     CLOG_WRITEF( _L( "iIapId : %d" ), iIapId );
       
   416     CLOG_LEAVEFN("CDisconnectDialogUi::SetClosedIapId");            
       
   417     }
       
   418     
       
   419 
       
   420 // End of File