mobilemessaging/smum/src/SmumSettingsDialogCDMA.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002-2008 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 *     Main settings dialog for Sms CDMA
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include <smum.rsg>                     // resouce identifiers
       
    23 
       
    24 // New Symbian Includes for CDMA SMS
       
    25 #include <smutset.h>
       
    26 #include <smuthdr.h>
       
    27 #include <tia637.h>
       
    28 using namespace tia637;
       
    29 
       
    30 #include <smsMessageSettings.h>
       
    31 #include <smsmessagewrappers.h>
       
    32 
       
    33 #include <aknappui.h>                   // CEikStatusPane
       
    34 #include <akntitle.h>                   // CAknTitlePane
       
    35 #include <aknnotewrappers.h>            // Avkon note wrappers
       
    36 #include <aknquerydialog.h>             // CAknQueryDialog
       
    37 #include <eikmenup.h>                   // CEikMenuPane
       
    38 #include <smuthdr.h>                    // CSmsHeader
       
    39 #include <csmsaccount.h>                // CSmsAccount
       
    40 #include <MsvOffPeakTime.h>             // CMsvOffPeakTimes
       
    41 #include <MsvScheduleSettings.h>        // Schedule Settings
       
    42 #include <MsvSysAgentAction.h>          // CMsvSysAgentActions
       
    43 #include <PsVariables.h>                // PS Variables 
       
    44 #include <SaCls.h>
       
    45 #include <StringLoader.h>               // StringLoader
       
    46 #include <akndlgshut.h>                 // AknDialogShutter
       
    47 #include <MuiuMsvUiServiceUtilities.h>  // DiskSpaceBelowCriticalLevelL
       
    48 #include <hlplch.h>                     // HlpLauncher
       
    49 #include <FeatMgr.h>                    // FeatureManager
       
    50 #include <bldvariant.hrh>
       
    51 #include <eikedwin.h>
       
    52 #include <AknSettingPage.h>
       
    53 #include <AknTextSettingPage.h>
       
    54 #include <AknRadioButtonSettingPage.h>
       
    55 #include <AknPasswordSettingPage.h>
       
    56 #include <CPbkContactEngine.h>              // Phonebook Engine
       
    57 #include <CPbkContactItem.h>                // Phonebook Contact
       
    58 #include <CPbkSingleEntryFetchDlg.h>        // Phonebook Dialog
       
    59 #include <RPbkViewResourceFile.h>           // Phonebook Resource
       
    60 #include <CPbkSmsAddressSelect.h>           // Phonebook SMS select number
       
    61 #include <csxhelp/mce.hlp.hrh>
       
    62 #include <csxhelp/sms.hlp.hrh>
       
    63 // locals
       
    64 #include "smsui.pan"                    // for panics
       
    65 #include "SmumSettingsDialogCDMA.h"         // CSmumMainSettingsDialog
       
    66 #include "SmumServiceCentreItemDialog.h"// CSmumAddEditServiceCentreDialog
       
    67 #include "smsu.hrh"                     // resource header
       
    68 #include "Smsetdlgcdma.h"
       
    69 #include <aknsettingpage.h>
       
    70 #include <aknphonenumbereditor.h>
       
    71 
       
    72 // for reading the own number from NAM engine for callback number (not applicable in WINS environment)
       
    73 //#include <TASetCdmaUtility.h>   // RTASettings
       
    74 //#include <TASetCore.h>      // CTASetCore
       
    75 // CONSTANTS
       
    76 const TInt KDefMaxRetries = 1;
       
    77 const TInt KMsgQError = -31003;
       
    78 
       
    79 // Default callback number length
       
    80 const TInt KDefCallbackNumberLength = 17;
       
    81 
       
    82 // ================= MEMBER FUNCTIONS =======================
       
    83 
       
    84 // -----------------------------------------------------------------------------
       
    85 // CSmumMainSettingsDialog::NewL
       
    86 // Two-phased constructor.
       
    87 // -----------------------------------------------------------------------------
       
    88 CSmumMainSettingsDialog* CSmumMainSettingsDialogCDMA::NewL(
       
    89     CSmsSettings&   aSettings, 
       
    90     TInt            aTypeOfSettings,
       
    91     TInt&           aExitCode,
       
    92     CSmsHeader*     aSmsHeader )
       
    93     {
       
    94     CSmumMainSettingsDialogCDMA*  self = new ( ELeave ) CSmumMainSettingsDialogCDMA( 
       
    95         aSettings, aTypeOfSettings, aExitCode, aSmsHeader );
       
    96     
       
    97     CleanupStack::PushL( self );
       
    98     self->ConstructL();
       
    99     CleanupStack::Pop();
       
   100     return self;
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CSmumMainSettingsDialogCDMA::CSmumMainSettingsDialogCDMA
       
   105 // C++ default constructor can NOT contain any code, that
       
   106 // might leave.
       
   107 // -----------------------------------------------------------------------------
       
   108 CSmumMainSettingsDialogCDMA::CSmumMainSettingsDialogCDMA(
       
   109     CSmsSettings&   aSettings, 
       
   110     TInt            aTypeOfSettings,
       
   111     TInt&           aExitCode,
       
   112     CSmsHeader*     aSmsHeader )
       
   113     :   iSettings       ( aSettings ),
       
   114         iTypeOfSettings ( aTypeOfSettings ),
       
   115         iExitCode       ( aExitCode ),
       
   116         iSmsHeader      ( (CSmsHeader*)aSmsHeader ),
       
   117         iLaunchDialog   ( EFalse ),
       
   118         iHelpFeatureSupported ( EFalse ),
       
   119         iPhonebookResource( *iCoeEnv ),
       
   120         iMaxCallbackLength(KDefCallbackNumberLength),
       
   121         iDeliveryAckSupport(EFalse)
       
   122     {
       
   123     }
       
   124     
       
   125 // Destructor
       
   126 CSmumMainSettingsDialogCDMA::~CSmumMainSettingsDialogCDMA()
       
   127     {
       
   128     if ( iListBox )
       
   129         {
       
   130         iListBox->SetScrollBarFrame( NULL, CEikListBox::EOwnedExternally );
       
   131         }
       
   132     delete iPreviousTitleText;
       
   133     delete iNoCallbackNumber;
       
   134     delete iPbkEngine;
       
   135     delete iSmsAccount;
       
   136     iPhonebookResource.Close();
       
   137     FeatureManager::UnInitializeLib();
       
   138     // iSettingsArray, iListBox, iSettings(reference), iSettingsForReadingSCList,
       
   139     // iTitlePane, iPreviousTitleText are
       
   140     // plain pointers to objects owned by other classes which take
       
   141     // care also about deletion.
       
   142     }
       
   143 
       
   144 // -----------------------------------------------------------------------------
       
   145 // CSmumMainSettingsDialogCDMA::ConstructL
       
   146 // Symbian 2nd phase constructor can leave.
       
   147 // -----------------------------------------------------------------------------
       
   148 void CSmumMainSettingsDialogCDMA::ConstructL()
       
   149     {
       
   150     CAknDialog::ConstructL( R_MAIN_SMS_SETTINGS_CHOICE_MENUBAR );
       
   151 
       
   152     // Prepare FeatureManager, read values to members and uninitialize FeatureManager
       
   153     FeatureManager::InitializeLibL();
       
   154     iHelpFeatureSupported = FeatureManager::FeatureSupported( KFeatureIdHelp );
       
   155     iNoCallbackNumber = StringLoader::LoadL( R_QTN_MCE_SETTING_SMS_CB_NONE, iCoeEnv );
       
   156 
       
   157     // Open contact 
       
   158     iPbkEngine = CPbkContactEngine::NewL();
       
   159     iPhonebookResource.OpenL();
       
   160 
       
   161     // Message Queuing Settings
       
   162     //
       
   163     iSmsAccount = CSmsAccount::NewL();
       
   164     
       
   165     // Create the session
       
   166     CRepository* cenRepSession = CRepository::NewLC(KCRUidSmum); 
       
   167     TInt readSetting;
       
   168 
       
   169     // Get max Recipient Phone/Callback number length 
       
   170     if ( cenRepSession->Get( KSmumMaxRecipientPhoneNumberLength, readSetting ) != KErrNone )
       
   171         {
       
   172         readSetting = KDefCallbackNumberLength;
       
   173         }
       
   174     iMaxCallbackLength = readSetting;
       
   175 		
       
   176     // Get the delivery report flag
       
   177     if ( cenRepSession->Get( KSmumDefDelReport, readSetting ) != KErrNone )
       
   178         {
       
   179         readSetting = EFalse;
       
   180         }
       
   181     iDeliveryAckSupport = readSetting;
       
   182     CleanupStack::PopAndDestroy(cenRepSession);
       
   183     }
       
   184 
       
   185 // ----------------------------------------------------
       
   186 // CSmumMainSettingsDialogCDMA::OkToExitL
       
   187 // 
       
   188 // ----------------------------------------------------
       
   189 TInt CSmumMainSettingsDialogCDMA::OkToExitL( TInt aButtonId )
       
   190     {
       
   191     TBool returnValue;
       
   192 
       
   193     switch( aButtonId )
       
   194         {
       
   195         // system / menu exit
       
   196         case EAknSoftkeyCancel: 
       
   197             {
       
   198             if ( iExitCode != ESmumSmsSettingsMenuExit &&
       
   199                  iExitCode != ESmumSmsSettingsSystemExit )
       
   200                 {
       
   201                 // system exit
       
   202                 iExitCode = ESmumSmsSettingsSystemExit;
       
   203                 }
       
   204             TRAPD( error, ClosingDialogL()); // to be sure of not leaving and exiting
       
   205             returnValue = ETrue;
       
   206             }
       
   207             break;
       
   208         // back-key
       
   209         case EAknSoftkeyBack:
       
   210             {
       
   211             iExitCode = ESmumSmsSettingsBack;
       
   212             ClosingDialogL();
       
   213             returnValue = ETrue;
       
   214             }
       
   215             break;
       
   216         // For opening next dialog
       
   217         case EAknSoftkeyShow:
       
   218             {
       
   219             CheckOpeningListBoxItemL( ETrue );
       
   220             returnValue = EFalse;
       
   221             }
       
   222             break;
       
   223         default :
       
   224             returnValue = CAknDialog::OkToExitL( aButtonId );
       
   225             break;
       
   226         }
       
   227 
       
   228     return returnValue;
       
   229     }
       
   230 
       
   231 // ----------------------------------------------------
       
   232 // CSmumMainSettingsDialogCDMA::HandleListBoxEventL
       
   233 //
       
   234 // ----------------------------------------------------
       
   235 void CSmumMainSettingsDialogCDMA::HandleListBoxEventL(
       
   236     CEikListBox* /*aListBox*/, 
       
   237     TListBoxEvent aEventType )
       
   238     {
       
   239     switch( aEventType )
       
   240         {
       
   241         case EEventEnterKeyPressed:
       
   242         case EEventItemSingleClicked:
       
   243             // This has to be made this way, if you want to launch new dialogs
       
   244             // inside the topmost one.
       
   245             // 1. Instead of launching them straightly in HandleListBoxEventL, set a flag.
       
   246             // 2. Then in OfferKeyEventL check the flag, if it is on then call
       
   247             //    TryExitL with some specific value or flag (I used EAknShowKey).
       
   248             // 3. This comes to OkToExitL and here you check that are we launching something
       
   249             //    and launch if we are.
       
   250             iLaunchDialog = ETrue; 
       
   251             break;
       
   252         default :
       
   253             // nothing
       
   254             break;
       
   255         }
       
   256     }
       
   257 
       
   258 // ----------------------------------------------------
       
   259 // CSmumMainSettingsDialogCDMA::ProcessCommandL
       
   260 //
       
   261 // ----------------------------------------------------
       
   262 void CSmumMainSettingsDialogCDMA::ProcessCommandL(
       
   263     TInt aCommandId)
       
   264     {
       
   265     CAknDialog::ProcessCommandL( aCommandId ) ;
       
   266     switch ( aCommandId )
       
   267         {
       
   268         case ESmsSettingsChoiceMenuOpen:
       
   269         case ESmsSettingsChoiceMenuChange:
       
   270             CheckOpeningListBoxItemL( EFalse );
       
   271             break;
       
   272         case EAknCmdHelp:
       
   273             {
       
   274             LaunchHelpL();                
       
   275             }
       
   276             break;
       
   277         case ESmsSettingsChoiceMenuExit:
       
   278             { 
       
   279             iExitCode = ESmumSmsSettingsMenuExit;
       
   280             TryExitL( EAknSoftkeyCancel );
       
   281             }
       
   282             break;
       
   283         default :
       
   284             // nothing
       
   285             break ;
       
   286         }
       
   287     }
       
   288 
       
   289 // ----------------------------------------------------
       
   290 // CSmumMainSettingsDialogCDMA::OfferKeyEventL
       
   291 //
       
   292 // ----------------------------------------------------
       
   293 TKeyResponse CSmumMainSettingsDialogCDMA::OfferKeyEventL(
       
   294     const TKeyEvent& aKeyEvent,
       
   295     TEventCode aType )
       
   296     {
       
   297 
       
   298     TKeyResponse returnValue = CAknDialog::OfferKeyEventL( aKeyEvent, aType );
       
   299 
       
   300     if ( iLaunchDialog && aType == EEventKey )
       
   301         {
       
   302         TryExitL( EAknSoftkeyShow );
       
   303         iLaunchDialog = EFalse;
       
   304         }
       
   305 
       
   306     return returnValue;
       
   307     }
       
   308 
       
   309 // ----------------------------------------------------
       
   310 // CSmumMainSettingsDialogCDMA::PreLayoutDynInitL
       
   311 //
       
   312 // ----------------------------------------------------
       
   313 void CSmumMainSettingsDialogCDMA::PreLayoutDynInitL()
       
   314     {
       
   315     // Creating correct listbox depending Settings vs Sending Options 
       
   316     //
       
   317     iListBox = static_cast<CEikTextListBox*>(Control( ESmsSettingsListBoxId ));
       
   318     
       
   319     // Do we support delivery ack or not
       
   320     //
       
   321     if( iDeliveryAckSupport ) 
       
   322         {
       
   323         iSettingsArray = CSmumSettingsArray::NewL( iTypeOfSettings ? 
       
   324             R_SMS_SENDING_OPTIONS_ITEMS_CDMA : R_SMS_MAIN_SETTINGS_ITEMS_CDMA );
       
   325         }
       
   326     else 
       
   327         {
       
   328         iSettingsArray = CSmumSettingsArray::NewL( iTypeOfSettings ? 
       
   329             R_SMS_SENDING_OPTIONS_ITEMS_CDMA_NO_DELIVERY : R_SMS_MAIN_SETTINGS_ITEMS_CDMA_NO_DELIVERY );
       
   330         }
       
   331     iListBox->SetListBoxObserver( this );
       
   332 
       
   333     // Arabic-indic conversion not to be done to SMSC Name
       
   334     //
       
   335     (*iSettingsArray)[1].iLangSpecificNumConv = EFalse;
       
   336 
       
   337     // Initialize listboxes to settings values
       
   338     //
       
   339     OpeningDialogL();
       
   340 
       
   341     // Scroll bars
       
   342     //
       
   343     iListBox->CreateScrollBarFrameL( ETrue );
       
   344     iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
       
   345         CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
       
   346 
       
   347     CTextListBoxModel* model = iListBox->Model();
       
   348     model->SetItemTextArray( iSettingsArray );
       
   349     }
       
   350 
       
   351 // ---------------------------------------------------------
       
   352 // CSmumMainSettingsDialogCDMA::DynInitMenuPaneL
       
   353 //
       
   354 // ---------------------------------------------------------
       
   355 void CSmumMainSettingsDialogCDMA::DynInitMenuPaneL(
       
   356     TInt aMenuId, 
       
   357     CEikMenuPane* aMenuPane )
       
   358     {
       
   359     switch ( aMenuId )
       
   360         {
       
   361         case R_MAIN_SMS_SETTINGS_CHOICE_MENUPANE:
       
   362             //
       
   363             // When we construct SMS settings' options menu (iTypeOfSettings
       
   364             // being 0 represents SMS settings), we will display "Change"
       
   365             // option, instead of "Open" option for all CDMA SMS settings:
       
   366             // Callback, Delivery Report, and Priority.
       
   367             //
       
   368             aMenuPane->SetItemDimmed( ESmsSettingsChoiceMenuOpen, ETrue );
       
   369             // Help handling
       
   370             aMenuPane->SetItemDimmed( EAknCmdHelp,!iHelpFeatureSupported );
       
   371 
       
   372             break;
       
   373         default :
       
   374             // panic
       
   375             break;
       
   376         }
       
   377     }
       
   378 
       
   379 // ----------------------------------------------------
       
   380 // CSmumMainSettingsDialogCDMA::UpdateSCInUseArrayL
       
   381 //
       
   382 // ----------------------------------------------------
       
   383 void CSmumMainSettingsDialogCDMA::UpdateSCInUseArrayL()
       
   384     {
       
   385     }
       
   386 
       
   387 // ----------------------------------------------------
       
   388 // CSmumMainSettingsDialogCDMA::OpeningDialogL
       
   389 //
       
   390 // ----------------------------------------------------
       
   391 void CSmumMainSettingsDialogCDMA::OpeningDialogL()
       
   392     {
       
   393     // Fetch pointer to titlepane
       
   394     //
       
   395     CEikStatusPane *sp = static_cast<CAknAppUi*>(CEikonEnv::Static()->EikAppUi())->StatusPane();
       
   396     iTitlePane = static_cast <CAknTitlePane*>(sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle )));
       
   397     
       
   398     // Take old titlepane text safe
       
   399     //
       
   400     iPreviousTitleText = ( *iTitlePane->Text() ).Alloc();
       
   401         
       
   402     // Read new titletext and set it
       
   403     //
       
   404     HBufC* text = StringLoader::LoadLC( iTypeOfSettings ?
       
   405         R_QTN_SMS_TITLE_SENDING : R_QTN_MCE_TITLE_SETTINGS_SMS, iCoeEnv );
       
   406     iTitlePane->SetTextL( *text );
       
   407     CleanupStack::PopAndDestroy(); // text
       
   408 
       
   409     TInt choicelistIndex=0;
       
   410 
       
   411     // Callback Number
       
   412     //
       
   413     TPtrC cbNumber = iSettings.MessageSettings().Cdma().CallBackNumber();
       
   414     if ( cbNumber.Size() > 0 )
       
   415 	    {
       
   416 	    iSettingsArray->SetCallBackNumberL( cbNumber );
       
   417 	    }
       
   418     else 
       
   419 	  	{
       
   420 	    iSettingsArray->SetCallBackNumberL( iNoCallbackNumber->Des() );
       
   421 	    }
       
   422     
       
   423     // Priority
       
   424     //
       
   425     TPriorityIndicator pIndicator;
       
   426     pIndicator = iSettings.MessageSettings().Cdma().Priority();
       
   427     
       
   428     switch( pIndicator )
       
   429         {
       
   430 	    case tia637::KBdNormal:
       
   431 	        choicelistIndex  = ESmumPriorityNormal;
       
   432 	        break;
       
   433 	    case tia637::KBdUrgent:
       
   434 	        choicelistIndex  = ESmumPriorityUrgent;
       
   435 	        break;
       
   436 	    default:
       
   437 	        choicelistIndex  = ESmumPriorityNormal;
       
   438 	        break;
       
   439         }
       
   440     SetItem( iTypeOfSettings ?
       
   441              ESmumSendOptPriorityLevelLBICDMA : ESmumPriorityLevelLBICDMA, choicelistIndex);
       
   442 
       
   443     // Message Queuing
       
   444     // We only have Message queuing in the global options
       
   445     // Checks iTypeOfSettings to make sure we only do this in the main menu
       
   446     //
       
   447     
       
   448     // @todo Migrate to central repository
       
   449     //
       
   450     if( !iTypeOfSettings ) 
       
   451         {
       
   452         if ( IsMsgQueuingOnL() )
       
   453             {
       
   454             choicelistIndex = ESmumQueuingOn;
       
   455             }
       
   456         else
       
   457             {
       
   458             choicelistIndex = ESmumQueuingOff;
       
   459             }
       
   460         SetItem( ESmumMessageQueuingLBICDMA , choicelistIndex );
       
   461         }
       
   462 
       
   463     // Delivery ACK
       
   464     //
       
   465     if( iDeliveryAckSupport ) 
       
   466         {
       
   467         TBool deliveryAck = iSettings.MessageSettings().ReplyOptions().DeliveryAck();
       
   468         if (!deliveryAck)
       
   469             {
       
   470             choicelistIndex = ESmumSettingsNo;
       
   471             }
       
   472         else
       
   473             {
       
   474             choicelistIndex = ESmumSettingsYes;
       
   475             }
       
   476         SetItem( iTypeOfSettings ?
       
   477                  ESmumCdmaSendOptDeliveryReportLBICDMA : ESmumDeliveryReportLBICDMA, choicelistIndex);
       
   478         }
       
   479     }
       
   480 
       
   481 // ----------------------------------------------------
       
   482 // CSmumMainSettingsDialogCDMA::ClosingDialogL
       
   483 //
       
   484 // ----------------------------------------------------
       
   485 void CSmumMainSettingsDialogCDMA::ClosingDialogL() const
       
   486     {    
       
   487     // Replace title with old title text
       
   488     //
       
   489     if ( iExitCode == ESmumSmsSettingsBack )
       
   490         {
       
   491         // Replace title with old title text
       
   492         iTitlePane->SetTextL( *iPreviousTitleText );
       
   493         }
       
   494     
       
   495     // Delivery ACK
       
   496     // Transport ACK - enabled, Delivery/User/Read ACK - disabled initially
       
   497     TSmsReplyOptions reply(ETrue, EFalse, EFalse, EFalse);
       
   498     if( iDeliveryAckSupport ) 
       
   499         {
       
   500         TInt item = Item( iTypeOfSettings ? ESmumCdmaSendOptDeliveryReportLBICDMA : ESmumDeliveryReportLBICDMA );
       
   501         // Set Delivert ACK
       
   502         if( item == ESmumSettingsYes )
       
   503 	        {
       
   504 		   	// Set delivery ACK ON
       
   505 		   	reply.SetDeliveryAck(ETrue);
       
   506 		    }
       
   507 	    else
       
   508 	   		{
       
   509 	    	// Set delivery ACK OFF
       
   510 	    	reply.SetDeliveryAck(EFalse);
       
   511 	    	}
       
   512 	    }
       
   513 	iSettings.MessageSettings().SetReplyOptions( reply );
       
   514 	    
       
   515 	// PRIORITY Account setting or Message setting
       
   516 	//
       
   517 	TPriorityIndicator priority;
       
   518     if ( !iTypeOfSettings ) // account setting
       
   519         {
       
   520         switch( Item( ESmumPriorityLevelLBICDMA ))
       
   521             {
       
   522 	        case ESmumPriorityNormal:
       
   523 	            priority = tia637::KBdNormal;	  
       
   524 	            break;
       
   525 	        case ESmumPriorityUrgent:
       
   526 	            priority = tia637::KBdUrgent;
       
   527 	            break;
       
   528 	        default:
       
   529 	            priority = tia637::KBdNormal;	
       
   530 	            break;
       
   531             }
       
   532         }
       
   533     else    // sending option
       
   534         {
       
   535         switch( Item( ESmumSendOptPriorityLevelLBICDMA ))
       
   536             {
       
   537 	        case ESmumPriorityNormal:
       
   538 	            priority = tia637::KBdNormal;	  
       
   539 	            break;
       
   540 	        case ESmumPriorityUrgent:
       
   541 	            priority = tia637::KBdUrgent;
       
   542 	            break;
       
   543 	        default:
       
   544 	            priority = tia637::KBdNormal;	
       
   545 	            break;
       
   546             }
       
   547         } 
       
   548 	iSettings.MessageSettings().Cdma().SetPriority( priority );   
       
   549     
       
   550     // Callback number
       
   551     //
       
   552     HBufC* pNumber = HBufC::NewLC(iMaxCallbackLength);
       
   553     TPtr phoneNumber = pNumber->Des();
       
   554     phoneNumber.Copy(iSettingsArray->CallBackNumber());
       
   555 
       
   556     if (0 == ( phoneNumber.Compare( iNoCallbackNumber->Des() )))
       
   557         {
       
   558         phoneNumber.Zero();
       
   559         }
       
   560     iSettings.MessageSettings().Cdma().SetCallBackNumberL( *pNumber );
       
   561 
       
   562     CleanupStack::PopAndDestroy( pNumber );
       
   563 	
       
   564     // Message queuing
       
   565     //
       
   566     if( !iTypeOfSettings )
       
   567         {
       
   568         TInt item = Item( ESmumMessageQueuingLBICDMA );
       
   569         if( item == ESmumSettingsYes )
       
   570         	{
       
   571         	SetMsgQueuingOnL( ETrue );
       
   572         	}
       
   573         else
       
   574         	{
       
   575         	SetMsgQueuingOnL( EFalse );
       
   576         	}
       
   577         }
       
   578     }
       
   579 
       
   580 // ----------------------------------------------------
       
   581 // CSmumMainSettingsDialogCDMA::SetItem
       
   582 //
       
   583 // ----------------------------------------------------
       
   584 void CSmumMainSettingsDialogCDMA::SetItem( TInt aSettingLBIndex, TInt aValue )
       
   585     {
       
   586     iSettingsArray->At( aSettingLBIndex ).iUserText.Copy(
       
   587         ( *iSettingsArray->At( aSettingLBIndex ).iMuiuSettingsItemArray )[aValue] );
       
   588     ( *iSettingsArray )[ aSettingLBIndex ].iCurrentNumber = aValue;
       
   589     }
       
   590 
       
   591 // ----------------------------------------------------
       
   592 // CSmumMainSettingsDialogCDMA::Item
       
   593 //
       
   594 // ----------------------------------------------------
       
   595 TInt CSmumMainSettingsDialogCDMA::Item( TInt aSettingLBIndex ) const
       
   596     {
       
   597     return iSettingsArray->At( aSettingLBIndex ).iCurrentNumber;
       
   598     }
       
   599 
       
   600 // ----------------------------------------------------
       
   601 // CSmumMainSettingsDialogCDMA::CheckOpeningListBoxItemL
       
   602 //
       
   603 // ----------------------------------------------------
       
   604 void CSmumMainSettingsDialogCDMA::CheckOpeningListBoxItemL( TBool aEnterPressed )
       
   605     {
       
   606     // Pop up the settings query
       
   607     TBool okCancel = iSettingsArray->EditItemL( iListBox->CurrentItemIndex(), aEnterPressed );
       
   608 
       
   609     TInt settingIndex = iListBox->CurrentItemIndex();
       
   610 
       
   611     // If it was a callback setting
       
   612     // Either own number, phonebook number, enter own or none
       
   613     //
       
   614     if ( settingIndex == ESmumCallbackNumberLBICDMA )
       
   615     {
       
   616         
       
   617         // TBuf containing the number
       
   618         //
       
   619         HBufC* cbNum = HBufC::NewLC(iMaxCallbackLength);
       
   620         TPtr number = cbNum->Des();
       
   621         number.Copy(iSettingsArray->CallBackNumber());
       
   622         if ( 0 == ( number.Compare( iNoCallbackNumber->Des() )))
       
   623             {
       
   624             number.Zero();
       
   625             }
       
   626 
       
   627         // Select the appropriate action based on user selection
       
   628         // OK Pressed
       
   629         if( okCancel ) 
       
   630         {
       
   631             switch( Item( settingIndex ) ) 
       
   632             {
       
   633                 case ESmumUseThisPhoneNumber: // Use This Phone Number:
       
   634                     ReadOwnNumberL(number);
       
   635                     break;
       
   636                 case ESmumAddFromContact: // Pick a Number from the phonebook
       
   637                     DoAddressBookDialogL(number);
       
   638                     break;
       
   639                 case ESmumEnterPhoneNumber: // Input a Callback Number;
       
   640                     {
       
   641                     HBufC* prompt = StringLoader::LoadLC( R_QTN_MCE_SETTING_ENTER_CALLBACK, iCoeEnv );
       
   642                     CAknTextQueryDialog* dlg = CAknTextQueryDialog::NewL(number);
       
   643                     CleanupStack::PushL( dlg );
       
   644                     dlg->SetPromptL(prompt->Des());
       
   645                     dlg->SetMaxLength(iMaxCallbackLength);
       
   646                     dlg->ExecuteLD(R_SMS_CALLBACKNUMBER_SETTING_QUERY);
       
   647                     CleanupStack::Pop();// dlg
       
   648 
       
   649                     // Cleanup
       
   650                     if (prompt)
       
   651                         {
       
   652                         CleanupStack::PopAndDestroy(prompt);// prompt
       
   653                         }
       
   654                     }
       
   655                     break;
       
   656                 case ESmumNoCallbackNumber: //KNoCallbackNumber:
       
   657                     number.Zero();
       
   658                     break;
       
   659                 default:
       
   660                     break;
       
   661             } // Switch
       
   662 
       
   663             // Set the number to the listbox
       
   664             //
       
   665             if ( 0 != ( number.Size() ) )
       
   666             {
       
   667             	//The cb number should be DTMF compatible; valid characters are (0..9 * #)
       
   668             	//Since dialog is using the EAknEditorStandardNumberModeKeymap flag, invalid characters (w p - +) has to be removed
       
   669             	//Meanwhile removing the invalid characters will reduce the original input number length
       
   670                 HBufC* temp_cbNum = HBufC::NewLC(iMaxCallbackLength);
       
   671 		        TInt i;
       
   672 		        for(i=0; i<number.Length(); i++)
       
   673 		        {
       
   674 		        	//check if the number has any non DTMF characters to be ignored
       
   675 		        	if((number[i]>='0' && number[i]<='9') || number[i]=='*' || number[i]=='#')
       
   676 		        	{
       
   677 		        	    temp_cbNum->Des().Append(number[i]);
       
   678 		        	}
       
   679 		        }
       
   680 		        
       
   681 		        if (temp_cbNum->Des().Length()!=0)
       
   682 		        {
       
   683 	                iSettingsArray->SetCallBackNumberL(temp_cbNum->Des());
       
   684 		        }
       
   685 		        else
       
   686 		        {
       
   687 	                iSettingsArray->SetCallBackNumberL(iNoCallbackNumber->Des());
       
   688 		        }
       
   689                 
       
   690 		        CleanupStack::PopAndDestroy(temp_cbNum); // temp_cbNum
       
   691             }
       
   692             else 
       
   693             {
       
   694                 iSettingsArray->SetCallBackNumberL(iNoCallbackNumber->Des());
       
   695             }
       
   696         }
       
   697 
       
   698         CleanupStack::PopAndDestroy(); // cbNum
       
   699     }  // If
       
   700     
       
   701     iListBox->DrawNow();
       
   702     }
       
   703 
       
   704 // ----------------------------------------------------
       
   705 // CSmumMainSettingsDialogCDMA::LaunchServiceCentresDialogL
       
   706 //
       
   707 // ----------------------------------------------------
       
   708 TInt CSmumMainSettingsDialogCDMA::LaunchServiceCentresDialogL()
       
   709     {
       
   710     return KErrNotSupported;
       
   711     }
       
   712 // ----------------------------------------------------
       
   713 // CSmumMainSettingsDialogCDMA::LaunchHelpL
       
   714 // launch help using context
       
   715 // 
       
   716 // ----------------------------------------------------
       
   717 void CSmumMainSettingsDialogCDMA::LaunchHelpL()
       
   718     {    
       
   719     if ( iHelpFeatureSupported )
       
   720         {
       
   721         CCoeAppUi* editorAppUi = static_cast<CCoeAppUi*> (ControlEnv()->AppUi());
       
   722         CArrayFix<TCoeHelpContext>* helpContext = editorAppUi->AppHelpContextL();   
       
   723         HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), helpContext );
       
   724         }
       
   725     }
       
   726 
       
   727 
       
   728 // ----------------------------------------------------
       
   729 // CSmumMainSettingsDialogCDMA::GetHelpContext
       
   730 // returns helpcontext as aContext
       
   731 // 
       
   732 // ----------------------------------------------------
       
   733 void CSmumMainSettingsDialogCDMA::GetHelpContext
       
   734         (TCoeHelpContext& aContext) const
       
   735     {    
       
   736 
       
   737     if ( iTypeOfSettings )
       
   738         {
       
   739         const TUid KUidSmsEditor ={0x100058BC};
       
   740         aContext.iMajor = KUidSmsEditor; 
       
   741         aContext.iContext = KSMS_HLP_SENDINGOPTIONS;        
       
   742         }
       
   743     else
       
   744         {
       
   745         
       
   746         const TUid KUidMce ={0x100058C5};      
       
   747         aContext.iMajor = KUidMce;
       
   748         aContext.iContext = KMCE_HLP_SETTINGS_SMS;
       
   749         }    
       
   750    
       
   751     }
       
   752 
       
   753 // ---------------------------------------------------------
       
   754 // CSmumMainSettingsDialogCDMA::ReadOwnNumberL
       
   755 // ---------------------------------------------------------
       
   756 void CSmumMainSettingsDialogCDMA::ReadOwnNumberL(TDes& aOwnNumber)
       
   757     {
       
   758 #ifdef __WINS__  
       
   759         // assign a dummy number to CCdmaSmsHeader
       
   760         TBuf<12> tempNumber( _L("6041234567" ));
       
   761         aOwnNumber.Zero();
       
   762         aOwnNumber.Append( tempNumber );
       
   763 #else
       
   764 /*
       
   765         // Read in the own number from NAM settings for callback number
       
   766         TChar ch;
       
   767         HBufC* aNumber = HBufC::NewLC(iMaxCallbackLength);
       
   768         TPtr digitOnlyCallbackNumber = aNumber->Des();
       
   769 
       
   770         TSettingsRequestStatus status = ENotProcessed;
       
   771 
       
   772         RMobileNamStore::TMobileNamEntryV1* entry = new(ELeave) RMobileNamStore::TMobileNamEntryV1();
       
   773         CleanupStack::PushL(entry);
       
   774 
       
   775         // assign nam information to entry
       
   776         entry->iNamId = ENamOne;
       
   777         entry->iParamIdentifier = ENamMdn;  // id for MDN (own number)
       
   778 
       
   779         // For Synchronous call
       
   780         CTASetCore* settings = CTASetCore::NewL();
       
   781         CleanupStack::PushL( settings );
       
   782         // get own number from NAM storage (synchronous method)
       
   783         status = RTASettings::GetNamProgrammingL( *settings, NULL,  *entry );
       
   784         if (status == ERequestComplete)
       
   785             {
       
   786             TBuf<RMobileNamStore::KMaxNamParamSize> temBuf;
       
   787             temBuf.Copy(entry->iData);
       
   788             // aviod exceeding the lenght (NAM max len: 64)
       
   789             TInt len = Min(temBuf.Length(), iMaxCallbackLength);
       
   790             for (TInt i=0; i<len; i++)
       
   791                 {
       
   792                 ch = temBuf[i];
       
   793                 if ( (ch.IsDigit()) || (ch=='*') || (ch=='#') )
       
   794                     digitOnlyCallbackNumber.Append( ch );
       
   795                 }
       
   796             }
       
   797 
       
   798         // Assign callback number as ownnumber
       
   799         aOwnNumber.Zero();
       
   800         aOwnNumber.Append( digitOnlyCallbackNumber );
       
   801 
       
   802         CleanupStack::PopAndDestroy( settings );
       
   803         CleanupStack::PopAndDestroy( entry );
       
   804         CleanupStack::PopAndDestroy(aNumber); // Buffer for the number
       
   805 */        
       
   806 #endif
       
   807 
       
   808     }
       
   809 
       
   810 // ---------------------------------------------------------
       
   811 // CSmumMainSettingsDialogCDMA::DoAddressBookDialogL
       
   812 // ---------------------------------------------------------
       
   813 void CSmumMainSettingsDialogCDMA::DoAddressBookDialogL(TDes & aNumber)
       
   814     {
       
   815     // Check if we already have necessary engines running
       
   816     //
       
   817     if ( !iPbkEngine )
       
   818         {
       
   819         iPbkEngine = CPbkContactEngine::NewL();
       
   820         }
       
   821     if ( !iPhonebookResource.IsOpen())
       
   822         {
       
   823         iPhonebookResource.OpenL();
       
   824         }
       
   825 
       
   826     // Add searching array to parameters
       
   827     //
       
   828     TInt filter = 0;
       
   829     filter = (CContactDatabase::EPhonable);
       
   830     
       
   831     CPbkSingleEntryFetchDlg::TParams params;
       
   832     params.iContactView = &iPbkEngine->FilteredContactsViewL( filter ); 
       
   833     
       
   834     // Launch fetching dialog
       
   835     //
       
   836     CPbkSingleEntryFetchDlg* fetchDlg = CPbkSingleEntryFetchDlg::NewL( params );
       
   837     fetchDlg->SetMopParent( iListBox );
       
   838     TInt okPressed = fetchDlg->ExecuteLD();
       
   839 
       
   840     // Process results
       
   841     if ( okPressed )
       
   842         {
       
   843             // Get the selected contact
       
   844             const TContactItemId cid = params.iSelectedEntry;
       
   845             
       
   846             // Open the selected contact using Phonebook engine,
       
   847             // choose correct number (launch list query if needed)
       
   848             //
       
   849             CPbkContactItem* pbkItem = iPbkEngine->ReadContactLC( cid );
       
   850             CPbkSmsAddressSelect* selectDlg = new (ELeave)  CPbkSmsAddressSelect( );     
       
   851             CPbkSmsAddressSelect::TParams contactParam(*pbkItem);
       
   852 
       
   853             // Select a phone number if required
       
   854             if(selectDlg->ExecuteLD( contactParam )) {
       
   855                 
       
   856                 // Get the selected number
       
   857                 //
       
   858                 HBufC* temp = HBufC::NewLC(iMaxCallbackLength);
       
   859                 TPtr tempAddress = temp->Des();
       
   860                 tempAddress.Copy(contactParam.SelectedField()->Text());
       
   861 
       
   862                 // Assign the number
       
   863                 //
       
   864                 if ( tempAddress.Length() )
       
   865                     {
       
   866                     aNumber.Zero();
       
   867                     aNumber = tempAddress;
       
   868                     }
       
   869                 CleanupStack::PopAndDestroy(temp); 
       
   870             
       
   871             }
       
   872 
       
   873             if ( pbkItem )
       
   874                 {
       
   875                 CleanupStack::PopAndDestroy(pbkItem);  // pbkItem
       
   876                 }
       
   877         }
       
   878     }
       
   879     
       
   880 // ---------------------------------------------------------
       
   881 // CSmumMainSettingsDialogCDMA::IsMsgQueuingOnL
       
   882 // ---------------------------------------------------------
       
   883 TBool CSmumMainSettingsDialogCDMA::IsMsgQueuingOnL()
       
   884 	{
       
   885 	// Get Message Queuing Parameters
       
   886     //
       
   887     CMsvOffPeakTimes* peakTimes = new (ELeave) CMsvOffPeakTimes();
       
   888   	CleanupStack::PushL(peakTimes);
       
   889     CMsvSendErrorActions* sendErrActions = CMsvSendErrorActions::NewLC();
       
   890     CMsvSysAgentActions* actions = new (ELeave) CMsvSysAgentActions();
       
   891     CleanupStack::PushL(actions);
       
   892     CMsvScheduleSettings* schSettings = CMsvScheduleSettings::NewL();
       
   893     CleanupStack::PushL(schSettings);
       
   894     
       
   895     // Get default settings from SMS Account
       
   896     //
       
   897     iSmsAccount->LoadSettingsL( *schSettings, *peakTimes, *sendErrActions, *actions );
       
   898     int count = actions->Count();
       
   899     // Cleanup  
       
   900     //
       
   901     CleanupStack::PopAndDestroy(4,peakTimes); // peakTimes, sendErrActions, actions, schSettings
       
   902     
       
   903     // Did we have any settings?
       
   904     return( count ? ETrue : EFalse );
       
   905 	}
       
   906 		
       
   907 // ---------------------------------------------------------
       
   908 // CSmumMainSettingsDialogCDMA::SetMsgQueuingOnL
       
   909 // ---------------------------------------------------------
       
   910 void CSmumMainSettingsDialogCDMA::SetMsgQueuingOnL(TBool aSetting) const
       
   911 	{
       
   912     // Get Message Queuing Parameters
       
   913     //
       
   914     CMsvOffPeakTimes* peakTimes = new (ELeave) CMsvOffPeakTimes();
       
   915     CleanupStack::PushL(peakTimes);
       
   916     CMsvSendErrorActions* sendErrActions = CMsvSendErrorActions::NewLC();
       
   917     CMsvSysAgentActions* actions = new (ELeave) CMsvSysAgentActions();
       
   918     CleanupStack::PushL(actions);
       
   919     CMsvScheduleSettings* schSettings = CMsvScheduleSettings::NewL();
       
   920     CleanupStack::PushL(schSettings);
       
   921 
       
   922     // Get default settings from SMS Account
       
   923     //
       
   924     iSmsAccount->LoadSettingsL( *schSettings, *peakTimes, *sendErrActions, *actions );
       
   925     actions->Reset();
       
   926 
       
   927     if( aSetting )
       
   928         {
       
   929         // Setup System Actent Conditions
       
   930         // Message queuing condition to meet in order to send the message
       
   931         // Must have network coverage, if we do not have network coverage, we fail with -31003
       
   932         // Max retry of 3 days (3430minutes) and maximum of 1 retry
       
   933         //
       
   934         TMsvSysAgentConditionAction action;
       
   935         action.iUseDefaultSysAgentAction = EFalse;
       
   936         action.iErrorAction.iAction = ESendActionRetryConditionMet;
       
   937         action.iErrorAction.iRetries = ESendRetriesFixed;
       
   938         action.iErrorAction.iRetrySpacing = ESendRetrySpacingStatic;
       
   939         action.iErrorAction.iError  = KMsgQError;
       
   940         action.iErrorAction.SetMaxRetries(KDefMaxRetries);
       
   941 
       
   942         action.iCondition.iVariable = KUidNetworkStatus; //KUidNetworkStatus;
       
   943         action.iCondition.iState = ESANetworkAvailable;    //ESANetworkAvailable
       
   944         action.iCondition.iType = TMsvCondition::EMsvSchSendEquals;
       
   945         actions->AppendL(action);	
       
   946         }
       
   947 
       
   948     // Save Settings
       
   949     iSmsAccount->SaveSettingsL( *schSettings, *peakTimes, *sendErrActions, *actions );
       
   950     
       
   951     // Cleanup  
       
   952     CleanupStack::PopAndDestroy(4,peakTimes); // peakTimes, sendErrActions, actions, schSettings	
       
   953 	}
       
   954 	
       
   955 //  End of File  
       
   956