connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ConfirmationQueryNotif.cpp
branchRCL_3
changeset 58 83ca720e2b9a
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
       
     1 /*
       
     2 * Copyright (c) 2005 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 CConfirmationQueryNotif.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "ConfirmationQueryNotif.h"
       
    21 #include "ConfirmationQuery.h"
       
    22 #include "ConnectionUiUtilitiesCommon.h"
       
    23 #include "ConnUiUtilsNotif.h"
       
    24 #include "ConnectionDialogsLogger.h"
       
    25 
       
    26 #include <ConnUiUtilsNotif.rsg>
       
    27 #include <StringLoader.h>
       
    28 
       
    29 #include <cmmanager.h>
       
    30 #include <cmmanagerext.h>
       
    31 #include <cmconnectionmethod.h>
       
    32 #include <cmdestination.h>
       
    33 #include <ConnectionUiUtilities.h>
       
    34 #include <datamobilitycommsdattypes.h>
       
    35 #include <ctsydomainpskeys.h>
       
    36 
       
    37 using namespace CMManager;
       
    38 
       
    39 // ================= MEMBER FUNCTIONS =======================
       
    40 
       
    41 // ---------------------------------------------------------
       
    42 // CConfirmationQueryNotif::CConfirmationQueryNotif()
       
    43 // ---------------------------------------------------------
       
    44 //
       
    45 CConfirmationQueryNotif::CConfirmationQueryNotif()
       
    46 : iConnMethod( 0 ), 
       
    47   iChoice( EMsgQueryCancelled )
       
    48     {
       
    49     }
       
    50 
       
    51 
       
    52 // ---------------------------------------------------------
       
    53 // CConfirmationQueryNotif* CConfirmationQueryNotif::NewL()
       
    54 // ---------------------------------------------------------
       
    55 //
       
    56 CConfirmationQueryNotif* CConfirmationQueryNotif::NewL( 
       
    57                                         const TBool aResourceFileResponsible )
       
    58     {
       
    59     CConfirmationQueryNotif* self = new ( ELeave ) CConfirmationQueryNotif();
       
    60     CleanupStack::PushL( self );
       
    61     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
    62     CleanupStack::Pop();
       
    63 
       
    64     return self;
       
    65     }
       
    66 
       
    67 
       
    68 // ---------------------------------------------------------
       
    69 // CConfirmationQueryNotif::~CConfirmationQueryNotif()
       
    70 // ---------------------------------------------------------
       
    71 //
       
    72 CConfirmationQueryNotif::~CConfirmationQueryNotif()
       
    73     {   
       
    74     if ( iLaunchDialogAsync )
       
    75         {
       
    76         delete iLaunchDialogAsync;
       
    77         iLaunchDialogAsync = NULL;
       
    78         }
       
    79     }
       
    80 
       
    81 // ---------------------------------------------------------
       
    82 // CConfirmationQueryNotif::RegisterL()
       
    83 // ---------------------------------------------------------
       
    84 //
       
    85 CConfirmationQueryNotif::TNotifierInfo CConfirmationQueryNotif::RegisterL()
       
    86     {
       
    87     iInfo.iUid = KUidConfirmationQuery;
       
    88     iInfo.iPriority = ENotifierPriorityHigh;
       
    89     iInfo.iChannel = KUidConfirmationQuery;
       
    90 
       
    91     return iInfo;
       
    92     }
       
    93 
       
    94 // ---------------------------------------------------------
       
    95 // void CConfirmationQueryNotif::StartL
       
    96 // ---------------------------------------------------------
       
    97 //
       
    98 void CConfirmationQueryNotif::StartL( const TDesC8& aBuffer, 
       
    99                                     TInt aReplySlot,
       
   100                                     const RMessagePtr2& aMessage )
       
   101     {
       
   102     if ( iLaunchDialogAsync )
       
   103         {
       
   104         if ( iLaunchDialogAsync->IsActive() )
       
   105            {
       
   106            // Dialog is already active
       
   107            aMessage.Complete( KErrServerBusy );
       
   108            return;
       
   109            }    
       
   110         }
       
   111     
       
   112     TInt err( KErrNone );
       
   113     TInt emergencyCallState( 0 );
       
   114     
       
   115     // Check if emergency call is ongoing. If it is then do not display the dialog.    
       
   116     err = RProperty::Get( KPSUidCtsyEmergencyCallInfo,
       
   117             KCTSYEmergencyCallInfo,
       
   118             emergencyCallState );
       
   119 
       
   120     if ( (err == KErrNone && emergencyCallState) || ScreenSaverOn() || AutolockOn() )
       
   121         {
       
   122         // Emergency call, screen saver or autolock is active. Cancel the dialog. 
       
   123         CLOG_WRITE( "CConfirmationQueryNotif::StartL: Emergency call, Screen saver or Autolock is active." );
       
   124         aMessage.WriteL( aReplySlot, TPckg<TMsgQueryLinkedResults>( EMsgQueryCancelled ) );
       
   125         aMessage.Complete( KErrNone );
       
   126         return;
       
   127         }
       
   128 
       
   129     iChoice = EMsgQueryCancelled; 
       
   130     TPckgBuf<TConnUiUiDestConnMethodNoteId> input;
       
   131     input.Copy( aBuffer );
       
   132     iNoteInfo = input();
       
   133     
       
   134     iReplySlot = aReplySlot;
       
   135     iMessage = aMessage;
       
   136     iCancelled = EFalse;
       
   137 
       
   138     if ( iLaunchDialogAsync )
       
   139         {
       
   140         delete iLaunchDialogAsync;
       
   141         iLaunchDialogAsync = NULL;
       
   142         }
       
   143     
       
   144     if ( iNoteInfo.iNoteId == EConfirmMethodUsageQueryInHomeNetwork )
       
   145         {
       
   146         TCallBack cb( LaunchDialogL, this );
       
   147         iLaunchDialogAsync = new( ELeave ) CAsyncCallBack( cb, CActive::EPriorityHigh );    
       
   148         }
       
   149     else
       
   150         {
       
   151         TCallBack cb( LaunchDialogVisitorL, this );
       
   152         iLaunchDialogAsync = new( ELeave ) CAsyncCallBack( cb, CActive::EPriorityHigh );    
       
   153         }
       
   154 
       
   155     iLaunchDialogAsync->CallBack();
       
   156     }
       
   157 
       
   158 
       
   159 // ---------------------------------------------------------
       
   160 // void CConfirmationQueryNotif::Cancel()
       
   161 // ---------------------------------------------------------
       
   162 //
       
   163 void CConfirmationQueryNotif::Cancel()
       
   164     {
       
   165     CLOG_ENTERFN( "CConfirmationQueryNotif::Cancel" );
       
   166     if ( !iCancelled )
       
   167         {
       
   168         iCancelled = ETrue;
       
   169         if ( !iMessage.IsNull() )
       
   170             {
       
   171             iMessage.Complete( KErrCancel );
       
   172             }
       
   173         
       
   174         if ( iDialog )
       
   175             {
       
   176             delete iDialog;
       
   177             iDialog = NULL;
       
   178             }
       
   179         
       
   180         if ( iDialogVisitor )
       
   181             {
       
   182             delete iDialogVisitor;
       
   183             iDialogVisitor = NULL;
       
   184             }
       
   185         }
       
   186     
       
   187     CLOG_LEAVEFN( "CConfirmationQueryNotif::Cancel" );
       
   188     }
       
   189 
       
   190 
       
   191 // ---------------------------------------------------------
       
   192 // void CConfirmationQueryNotif::CompleteL( TInt aStatus )
       
   193 // ---------------------------------------------------------
       
   194 //
       
   195 void CConfirmationQueryNotif::CompleteL( TInt aStatus )
       
   196     {  
       
   197     CLOG_ENTERFN( "CConfirmationQueryNotif::CompleteL" );
       
   198     iCancelled = ETrue;   
       
   199     if ( !iMessage.IsNull() )
       
   200         {  
       
   201         if ( aStatus == KErrNone )
       
   202             {
       
   203             iMessage.WriteL( iReplySlot, TPckg<TMsgQueryLinkedResults>( iChoice ) );
       
   204             }
       
   205         iMessage.Complete( aStatus );
       
   206         }
       
   207       
       
   208     Cancel();
       
   209     
       
   210     CLOG_LEAVEFN( "CConfirmationQueryNotif::CompleteL" );
       
   211     }
       
   212 
       
   213 // ---------------------------------------------------------------
       
   214 // void CConfirmationQueryNotif::SetSelectedChoiceL( TInt aChoice )
       
   215 // ----------------------------------------------------------------
       
   216 //
       
   217 void CConfirmationQueryNotif::SetSelectedChoiceL ( TInt aChoice )
       
   218     {
       
   219     CLOG_ENTERFN( "CConfirmationQueryNotif::SetSelectedChoiceL" );
       
   220     iChoice = (TMsgQueryLinkedResults)aChoice;
       
   221     CLOG_LEAVEFN( "CConfirmationQueryNotif::SetSelectedChoiceL" );
       
   222     }
       
   223 
       
   224 // ---------------------------------------------------------
       
   225 // TInt CConfirmationQueryNotif::LaunchDialogL()
       
   226 // ---------------------------------------------------------
       
   227 //
       
   228 TInt CConfirmationQueryNotif::LaunchDialogL( TAny* aObject )
       
   229     {
       
   230     CLOG_ENTERFN( "CCConfirmationQueryNotif::LaunchDialogL" );
       
   231     CConfirmationQueryNotif* myself =
       
   232                             static_cast<CConfirmationQueryNotif*>( aObject );
       
   233     
       
   234     myself->iDialog = new ( ELeave ) CConfirmationQuery( myself );
       
   235     myself->iDialog->PrepareLC( R_MESSAGE_QUERY );
       
   236                             
       
   237     // Create the list box items
       
   238     RArray<TMsgQueryLinkedResults> choices;
       
   239     CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat(2);
       
   240     CleanupStack::PushL( array );
       
   241     HBufC* heading = NULL;
       
   242     HBufC* messageBase = NULL;
       
   243     HBufC* automatic = NULL;
       
   244     HBufC* thisTime = NULL;
       
   245 
       
   246     automatic = StringLoader::LoadLC( R_QTN_OCC_LIST_CS_DATA_HOME_NW_AUTOMATIC );
       
   247     thisTime = StringLoader::LoadLC( R_QTN_OCC_LIST_CS_DATA_HOME_NW_THIS_TIME );
       
   248                                 
       
   249     heading = StringLoader::LoadLC( R_QTN_OCC_PRMPT_CS_DATA_HOME_NW );
       
   250     messageBase = StringLoader::LoadLC( R_QTN_OCC_DETAIL_CS_DATA_HOME_NW );
       
   251     // the order of the query options depends on the location
       
   252     choices.Append(EMsgQueryAutomatically);
       
   253     choices.Append(EMsgQueryThisTime);
       
   254     array->AppendL( *automatic );
       
   255     array->AppendL( *thisTime );
       
   256  
       
   257     // Set the dialog heading and message text
       
   258     myself->iDialog->Heading()->SetTextL(*heading);
       
   259     myself->iDialog->MessageBox()->SetMessageTextL(messageBase);
       
   260     CleanupStack::PopAndDestroy( messageBase );
       
   261     CleanupStack::PopAndDestroy( heading );
       
   262                             
       
   263     // Set the options to the listbox
       
   264     myself->iDialog->SetChoices(choices);
       
   265 
       
   266     myself->iDialog->SetItemTextArray( array );
       
   267     myself->iDialog->SetOwnershipType(ELbmOwnsItemArray); // ownership transferred to listbox
       
   268     myself->iDialog->ListBox()->HandleItemAdditionL();
       
   269                             
       
   270     CleanupStack::Pop( thisTime );
       
   271     CleanupStack::Pop( automatic );
       
   272     CleanupStack::Pop( array );
       
   273     myself->iDialog->RunLD();
       
   274                                  
       
   275     CLOG_LEAVEFN( "CConfirmationQueryNotif::LaunchDialogL" );
       
   276     return 0;   
       
   277     }
       
   278 
       
   279 // ---------------------------------------------------------
       
   280 // TInt CConfirmationQueryNotif::LaunchDialogVisitorL()
       
   281 // ---------------------------------------------------------
       
   282 //
       
   283 TInt CConfirmationQueryNotif::LaunchDialogVisitorL( TAny* aObject )
       
   284     {
       
   285     CLOG_ENTERFN( "CCConfirmationQueryNotif::LaunchDialogVisitorL" );
       
   286     CConfirmationQueryNotif* myself =
       
   287                             static_cast<CConfirmationQueryNotif*>( aObject );
       
   288 
       
   289     myself->iDialogVisitor = new ( ELeave ) CConfirmationQueryVisitor( myself );
       
   290     myself->iDialogVisitor->PrepareLC( R_VISITOR_QUERY );
       
   291 
       
   292     HBufC* heading  = NULL;
       
   293     HBufC* message  = NULL;
       
   294     TInt resourceId = R_QTN_OCC_DETAIL_CS_DATA_FOREIGN_NW;
       
   295     heading         = StringLoader::LoadLC( 
       
   296                       R_QTN_OCC_PRMPT_CS_DATA_FOREIGN_NW );
       
   297 
       
   298     CDesCArrayFlat* strings = new( ELeave ) CDesCArrayFlat( 2 );
       
   299     CleanupStack::PushL( strings );
       
   300 
       
   301     HBufC* messageBase = StringLoader::LoadL( resourceId, *strings );
       
   302     CleanupStack::PopAndDestroy( strings );
       
   303 
       
   304     CleanupStack::PushL( messageBase );
       
   305     TInt lenMsg = messageBase->Des().Length();
       
   306 
       
   307     message = HBufC::NewL( lenMsg );
       
   308     TPtr messagePtr = message->Des();
       
   309     messagePtr.Append( messageBase->Des() ); 
       
   310 
       
   311     CleanupStack::PopAndDestroy( messageBase );
       
   312 
       
   313     CleanupStack::PushL( message );
       
   314     myself->iDialogVisitor->SetMessageTextL( *message );
       
   315     CleanupStack::PopAndDestroy( message );
       
   316 
       
   317     myself->iDialogVisitor->QueryHeading()->SetTextL( *heading );
       
   318     CleanupStack::PopAndDestroy( heading );
       
   319 
       
   320     myself->iDialogVisitor->RunLD();
       
   321     CLOG_LEAVEFN( "CConfirmationQueryNotif::LaunchDialogVisitorL" );
       
   322     return 0;
       
   323     }
       
   324 
       
   325 // End of File