connectionutilities/ConnectionDialogs/ConnectionUiUtilities/NotifSrc/cellulardataconfirmation.cpp
branchRCL_3
changeset 58 83ca720e2b9a
parent 57 05bc53fe583b
child 62 bb1f80fb7db2
equal deleted inserted replaced
57:05bc53fe583b 58:83ca720e2b9a
     1 /*
       
     2 * Copyright (c) 2010 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: Prompt Dialog implementation
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <StringLoader.h>
       
    21 #include <connuiutilsnotif.rsg>
       
    22 #include <hb/hbcore/hbsymbianvariant.h>
       
    23 #include "ConnectionDialogsLogger.h"
       
    24 #include "cellulardataconfirmation.h"
       
    25 #include "ConnectionDialogsNotifBase.h"
       
    26 #include "ConnectionDialogsUidDefs.h"
       
    27 #include "ConnUiUtilsNotif.h"
       
    28 #include "devicedialogobserver.h"
       
    29 
       
    30 
       
    31 // CONSTANTS
       
    32 const TInt KVariableLength = 30;
       
    33 _LIT( KHomenetwork, "homenetwork");
       
    34 _LIT(KType, "com.nokia.ipconnmgmt.promptdialog/1.0");
       
    35 
       
    36 // ---------------------------------------------------------
       
    37 // CCellularDataConfirmation::CCellularDataConfirmation()
       
    38 // ---------------------------------------------------------
       
    39 //
       
    40 CCellularDataConfirmation::CCellularDataConfirmation()
       
    41     {
       
    42     iCompleted = EFalse;
       
    43     iChoice = EMsgQueryCancelled;
       
    44     iObserver = NULL;
       
    45     iDialog = NULL;
       
    46     }
       
    47 
       
    48 // ---------------------------------------------------------
       
    49 // CCellularDataConfirmation::~CCellularDataConfirmation()
       
    50 // ---------------------------------------------------------
       
    51 //
       
    52 CCellularDataConfirmation::~CCellularDataConfirmation()
       
    53     {
       
    54     CLOG_ENTERFN( "CCellularDataConfirmation::~CCellularDataConfirmation" );
       
    55     delete iDialog;
       
    56     delete iObserver;
       
    57     CLOG_LEAVEFN( "CCellularDataConfirmation::~CCellularDataConfirmation" );
       
    58     }
       
    59 
       
    60 // ---------------------------------------------------------
       
    61 // CCellularDataConfirmation* CCellularDataConfirmation::NewL
       
    62 // ---------------------------------------------------------
       
    63 //
       
    64 CCellularDataConfirmation* CCellularDataConfirmation::NewL( 
       
    65                                         const TBool aResourceFileResponsible )
       
    66     {
       
    67     CLOG_ENTERFN( "CCellularDataConfirmation::NewL" );
       
    68     CCellularDataConfirmation* self = new ( ELeave ) CCellularDataConfirmation();
       
    69     CleanupStack::PushL( self );
       
    70     self->ConstructL( KResourceFileName, aResourceFileResponsible );
       
    71     CleanupStack::Pop();
       
    72     CLOG_LEAVEFN( "CCellularDataConfirmation::NewL" );
       
    73     return self;
       
    74     }
       
    75 
       
    76 // ---------------------------------------------------------
       
    77 // void CCellularDataConfirmation::StartL
       
    78 // ---------------------------------------------------------
       
    79 //
       
    80 void CCellularDataConfirmation::StartL( const TDesC8& aBuffer, 
       
    81                                         TInt aReplySlot, 
       
    82                                         const RMessagePtr2& aMessage )
       
    83     {
       
    84     CLOG_ENTERFN( "CCellularDataConfirmation::StartL" );
       
    85     iChoice = EMsgQueryCancelled; 
       
    86     TPckgBuf<TConnUiUiDestConnMethodNoteId> input;
       
    87     TConnUiUiDestConnMethodNoteId noteInfo;
       
    88     input.Copy( aBuffer );
       
    89     noteInfo = input();   
       
    90     iReplySlot = aReplySlot;
       
    91     iMessage = aMessage;
       
    92     
       
    93     // Create the list box items
       
    94     RArray<TMsgQueryLinkedResults> choices;           
       
    95     
       
    96     // Observer is needed in order to get the user inputs
       
    97     iObserver = CDeviceDialogObserver::NewL( this );
       
    98     iDialog = CHbDeviceDialogSymbian::NewL();
       
    99     
       
   100     // The variant map is needed to construct the dialog correctly,
       
   101     // information whether we are in home network is needed
       
   102     TBuf<KVariableLength> key(KHomenetwork);
       
   103     TBool homeNetwork;
       
   104     if ( noteInfo.iNoteId == EConfirmMethodUsageQueryInHomeNetwork ) 
       
   105         {
       
   106         homeNetwork = ETrue;
       
   107         choices.Append(EMsgQueryAutomatically);
       
   108         choices.Append(EMsgQueryThisTime);
       
   109         choices.Append(EMsgQueryCancelled);
       
   110         }
       
   111     else
       
   112         {
       
   113         homeNetwork = EFalse;
       
   114         choices.Append(EMsgQueryThisTime);
       
   115         choices.Append(EMsgQueryAutomatically);
       
   116         choices.Append(EMsgQueryCancelled);
       
   117         }
       
   118     // Set the choice order for the observer so that it knows which button press
       
   119     // means which choice
       
   120     iObserver->SetChoices(choices);
       
   121     
       
   122     // Create the variant data information for the plugin
       
   123     CHbSymbianVariantMap* map = CHbSymbianVariantMap::NewL();
       
   124     CleanupStack::PushL( map );
       
   125     CHbSymbianVariant *variant =  CHbSymbianVariant::NewL ( &homeNetwork, CHbSymbianVariant::EBool );
       
   126     CleanupStack::PushL( variant );
       
   127     TInt error = map->Add( key, variant);
       
   128     User::LeaveIfError( error );
       
   129     CleanupStack::Pop( variant ); // map's cleanup sequence handles variant.
       
   130     
       
   131     // Show the dialog.
       
   132     error = iDialog->Show( KType, *map, iObserver );
       
   133     User::LeaveIfError( error );
       
   134     CleanupStack::PopAndDestroy( map ); 
       
   135     CLOG_LEAVEFN( "CCellularDataConfirmation::StartL" );
       
   136     }
       
   137 
       
   138 // ---------------------------------------------------------
       
   139 // void CConfirmationQueryNotif::CompleteL( TInt aStatus )
       
   140 // ---------------------------------------------------------
       
   141 //
       
   142 void CCellularDataConfirmation::CompleteL( TInt aStatus )
       
   143     {   
       
   144     CLOG_ENTERFN( "CCellularDataConfirmation::CompleteL" );
       
   145     if ( !iCompleted )
       
   146         {
       
   147         if ( !iMessage.IsNull() )
       
   148             {  
       
   149             iMessage.WriteL( iReplySlot, TPckg<TMsgQueryLinkedResults>( iChoice ) );
       
   150             iMessage.Complete( aStatus );
       
   151             iCompleted = ETrue;
       
   152             } 
       
   153         }
       
   154     CLOG_LEAVEFN( "CCellularDataConfirmation::CompleteL" );
       
   155     }
       
   156 
       
   157 // ---------------------------------------------------------------
       
   158 // void CConfirmationQueryNotif::SetSelectedChoiceL( TInt aChoice )
       
   159 // ----------------------------------------------------------------
       
   160 //
       
   161 void CCellularDataConfirmation::SetSelectedChoice ( TInt aChoice )
       
   162     {
       
   163     CLOG_ENTERFN( "CCellularDataConfirmation::SetSelectedChoice" );
       
   164     iChoice = (TMsgQueryLinkedResults)aChoice;
       
   165     CLOG_LEAVEFN( "CCellularDataConfirmation::SetSelectedChoice" );
       
   166     }
       
   167 
       
   168 // ---------------------------------------------------------------
       
   169 // void CCellularDataConfirmation::Cancel()
       
   170 // ----------------------------------------------------------------
       
   171 //
       
   172 void CCellularDataConfirmation::Cancel()
       
   173     {
       
   174     CLOG_ENTERFN( "CCellularDataConfirmation::Cancel" );
       
   175     if ( !iCompleted )
       
   176         {
       
   177         iDialog->Cancel(); 
       
   178         TRAP_IGNORE( iMessage.WriteL( iReplySlot, 
       
   179             TPckg<TMsgQueryLinkedResults>( EMsgQueryCancelled ) ));
       
   180         iMessage.Complete( KErrCancel ); 
       
   181         }
       
   182     CLOG_LEAVEFN( "CCellularDataConfirmation::Cancel" );
       
   183     }
       
   184 
       
   185 // ---------------------------------------------------------------
       
   186 // CCellularDataConfirmation::TNotifierInfo 
       
   187 // CCellularDataConfirmation::RegisterL()
       
   188 // ----------------------------------------------------------------
       
   189 //
       
   190 CCellularDataConfirmation::TNotifierInfo CCellularDataConfirmation::RegisterL()
       
   191     {
       
   192     CLOG_ENTERFN( "CCellularDataConfirmation::RegisterL" );
       
   193     iInfo.iUid = KUidConfirmationQuery;
       
   194     iInfo.iPriority = ENotifierPriorityHigh;
       
   195     iInfo.iChannel = KUidConfirmationQuery;
       
   196     CLOG_LEAVEFN( "CCellularDataConfirmation::RegisterL" );
       
   197     return iInfo;
       
   198     }