connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/ConfirmationQueryNotif.cpp
changeset 0 5a93021fdf25
child 8 2e6c4614c58e
equal deleted inserted replaced
-1:000000000000 0:5a93021fdf25
       
     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 
       
    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     iChoice = EMsgQueryCancelled; 
       
   113     TPckgBuf<TConnUiUiDestConnMethodNoteId> input;
       
   114     input.Copy( aBuffer );
       
   115     iNoteInfo = input();
       
   116     
       
   117     iReplySlot = aReplySlot;
       
   118     iMessage = aMessage;
       
   119     iCancelled = EFalse;
       
   120     
       
   121     TCallBack cb( LaunchDialogL, this );
       
   122     
       
   123     if ( !iLaunchDialogAsync )
       
   124         {
       
   125         iLaunchDialogAsync = new( ELeave ) CAsyncCallBack( cb, CActive::EPriorityHigh );    
       
   126         }
       
   127     
       
   128     iLaunchDialogAsync->CallBack();
       
   129     }
       
   130 
       
   131 
       
   132 // ---------------------------------------------------------
       
   133 // void CConfirmationQueryNotif::Cancel()
       
   134 // ---------------------------------------------------------
       
   135 //
       
   136 void CConfirmationQueryNotif::Cancel()
       
   137     {
       
   138     CLOG_ENTERFN( "CConfirmationQueryNotif::Cancel" );
       
   139     if ( !iCancelled )
       
   140         {
       
   141         iCancelled = ETrue;
       
   142         if ( !iMessage.IsNull() )
       
   143             {
       
   144             iMessage.Complete( KErrCancel );
       
   145             }
       
   146         
       
   147         delete iDialog;
       
   148         iDialog = NULL;
       
   149         }
       
   150     
       
   151     CLOG_LEAVEFN( "CConfirmationQueryNotif::Cancel" );
       
   152     }
       
   153 
       
   154 
       
   155 // ---------------------------------------------------------
       
   156 // void CConfirmationQueryNotif::CompleteL( TInt aStatus )
       
   157 // ---------------------------------------------------------
       
   158 //
       
   159 void CConfirmationQueryNotif::CompleteL( TInt aStatus )
       
   160     {  
       
   161     CLOG_ENTERFN( "CConfirmationQueryNotif::CompleteL" );
       
   162     iCancelled = ETrue;   
       
   163     if ( !iMessage.IsNull() )
       
   164         {  
       
   165         if ( aStatus == KErrNone )
       
   166             {
       
   167             iMessage.WriteL( iReplySlot, TPckg<TMsgQueryLinkedResults>( iChoice ) );
       
   168             }
       
   169         iMessage.Complete( aStatus );
       
   170         }
       
   171       
       
   172     Cancel();
       
   173     
       
   174     CLOG_LEAVEFN( "CConfirmationQueryNotif::CompleteL" );
       
   175     }
       
   176 
       
   177 // ---------------------------------------------------------------
       
   178 // void CConfirmationQueryNotif::SetSelectedChoiceL( TInt aChoice )
       
   179 // ----------------------------------------------------------------
       
   180 //
       
   181 void CConfirmationQueryNotif::SetSelectedChoiceL ( TInt aChoice )
       
   182     {
       
   183     CLOG_ENTERFN( "CConfirmationQueryNotif::SetSelectedChoiceL" );
       
   184     iChoice = (TMsgQueryLinkedResults)aChoice;
       
   185     CLOG_LEAVEFN( "CConfirmationQueryNotif::SetSelectedChoiceL" );
       
   186     }
       
   187 
       
   188 // ---------------------------------------------------------
       
   189 // TInt CConfirmationQueryNotif::LaunchDialogL()
       
   190 // ---------------------------------------------------------
       
   191 //
       
   192 TInt CConfirmationQueryNotif::LaunchDialogL( TAny* aObject )
       
   193     {
       
   194     CLOG_ENTERFN( "CCConfirmationQueryNotif::LaunchDialogL" );
       
   195     CConfirmationQueryNotif* myself =
       
   196                             static_cast<CConfirmationQueryNotif*>( aObject );
       
   197     
       
   198     myself->iDialog = new ( ELeave ) CConfirmationQuery( myself );
       
   199     myself->iDialog->PrepareLC( R_MESSAGE_QUERY );
       
   200                             
       
   201     // Create the list box items
       
   202     RArray<TMsgQueryLinkedResults> choices;
       
   203     CDesCArrayFlat* array = new (ELeave) CDesCArrayFlat(2);
       
   204     CleanupStack::PushL( array );
       
   205     HBufC* heading = NULL;
       
   206     HBufC* messageBase = NULL;
       
   207     HBufC* automatic = NULL;
       
   208     HBufC* thisTime = NULL;
       
   209 
       
   210     automatic = StringLoader::LoadLC( R_QTN_OCC_LIST_CS_DATA_HOME_NW_AUTOMATIC );
       
   211     thisTime = StringLoader::LoadLC( R_QTN_OCC_LIST_CS_DATA_HOME_NW_THIS_TIME );
       
   212                                 
       
   213     if ( myself->iNoteInfo.iNoteId == EConfirmMethodUsageQueryInHomeNetwork ) 
       
   214         {
       
   215         heading = StringLoader::LoadLC( R_QTN_OCC_PRMPT_CS_DATA_HOME_NW );
       
   216         messageBase = StringLoader::LoadLC( R_QTN_OCC_DETAIL_CS_DATA_HOME_NW );
       
   217         // the order of the query options depends on the location
       
   218         choices.Append(EMsgQueryAutomatically);
       
   219         choices.Append(EMsgQueryThisTime);
       
   220         array->AppendL( *automatic );
       
   221         array->AppendL( *thisTime );
       
   222         } 
       
   223     else 
       
   224         {
       
   225         heading = StringLoader::LoadLC( R_QTN_OCC_PRMPT_CS_DATA_FOREIGN_NW );
       
   226         messageBase = StringLoader::LoadLC( R_QTN_OCC_DETAIL_CS_DATA_FOREIGN_NW );
       
   227         // the order of the query options depends on the location
       
   228         choices.Append(EMsgQueryThisTime);
       
   229         choices.Append(EMsgQueryAutomatically);
       
   230         array->AppendL( *thisTime );
       
   231         array->AppendL( *automatic );
       
   232         }              
       
   233 
       
   234     // Set the dialog heading and message text
       
   235     myself->iDialog->Heading()->SetTextL(*heading);
       
   236     myself->iDialog->MessageBox()->SetMessageTextL(messageBase);
       
   237     CleanupStack::PopAndDestroy( messageBase );
       
   238     CleanupStack::PopAndDestroy( heading );
       
   239                             
       
   240     // Set the options to the listbox
       
   241     myself->iDialog->SetChoices(choices);
       
   242 
       
   243     myself->iDialog->SetItemTextArray( array );
       
   244     myself->iDialog->SetOwnershipType(ELbmOwnsItemArray); // ownership transferred to listbox
       
   245     myself->iDialog->ListBox()->HandleItemAdditionL();
       
   246                             
       
   247     CleanupStack::Pop( thisTime );
       
   248     CleanupStack::Pop( automatic );
       
   249     CleanupStack::Pop( array );
       
   250     myself->iDialog->RunLD();
       
   251                                  
       
   252     CLOG_LEAVEFN( "CConfirmationQueryNotif::LaunchDialogL" );
       
   253     return 0;   
       
   254     }
       
   255 
       
   256 // End of File