phoneapp/phoneuicontrol/src/phonenoteutil.cpp
changeset 76 cfea66083b62
equal deleted inserted replaced
74:d1c62c765e48 76:cfea66083b62
       
     1 /*
       
     2 * Copyright (c) 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:  Acessory and Bluetooth handler.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include    "phonenoteutil.h"
       
    21 #include    "cphonecenrepproxy.h"
       
    22 #include    "cphonemainresourceresolver.h"
       
    23 #include    "mphoneneclearedhandler.h"
       
    24 #include    "mphonestatemachine.h"
       
    25 #include    "mphoneviewcommandhandle.h"
       
    26 #include    "cphonestatehandle.h"
       
    27 #include    "tphonecmdparamboolean.h"
       
    28 #include    "tphonecmdparamnote.h"
       
    29 #include    "tphonecmdparamquery.h"
       
    30 #include    "cphoneclearblacklist.h"
       
    31 #include    "cphonemainerrormessageshandler.h"
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 // ============================ MEMBER FUNCTIONS ===============================
       
    36 
       
    37 // ---------------------------------------------------------
       
    38 // PhoneNoteUtil::SendGlobalInfoNoteL
       
    39 // ---------------------------------------------------------
       
    40 //
       
    41 void PhoneNoteUtil::SendGlobalInfoNoteL( TInt aResourceId, 
       
    42     TBool aNotificationDialog )
       
    43     {    
       
    44     MPhoneViewCommandHandle* viewCommandHandle = 
       
    45             ViewCommandHandle();
       
    46 
       
    47     SetGlobalNotifierDisabledL( viewCommandHandle );
       
    48 
       
    49     TPhoneCmdParamGlobalNote globalNoteParam;
       
    50     TPhoneNotificationType type = aNotificationDialog ? 
       
    51         EPhoneNotificationDialog : EPhoneMessageBoxInformation;
       
    52 
       
    53     SetCommonGlobalNoteParamsL(
       
    54             globalNoteParam, aResourceId,
       
    55             aNotificationDialog, type,
       
    56             EPhoneInformationTone );
       
    57     
       
    58     viewCommandHandle->ExecuteCommandL(
       
    59         EPhoneViewShowGlobalNote, &globalNoteParam );
       
    60     }
       
    61 
       
    62 // ---------------------------------------------------------
       
    63 //  PhoneNoteUtil::SendGlobalWarningNoteL
       
    64 // ---------------------------------------------------------
       
    65 //
       
    66 void PhoneNoteUtil::SendGlobalWarningNoteL( 
       
    67         TInt aResourceId, TBool aNotificationDialog )
       
    68     {   
       
    69     MPhoneViewCommandHandle* viewCommandHandle = 
       
    70             ViewCommandHandle();
       
    71     
       
    72     SetGlobalNotifierDisabledL( viewCommandHandle );
       
    73 
       
    74     TPhoneCmdParamGlobalNote globalNoteParam;
       
    75     TPhoneNotificationType type = aNotificationDialog ? 
       
    76                 EPhoneNotificationDialog : EPhoneMessageBoxWarning;
       
    77 
       
    78     SetCommonGlobalNoteParamsL(
       
    79             globalNoteParam, aResourceId,
       
    80             aNotificationDialog, type,
       
    81             EPhoneWarningTone );
       
    82 
       
    83     viewCommandHandle->ExecuteCommandL(
       
    84         EPhoneViewShowGlobalNote, &globalNoteParam );
       
    85     }
       
    86 
       
    87 // ---------------------------------------------------------
       
    88 //  PhoneNoteUtil::SendGlobalErrorNoteL
       
    89 // ---------------------------------------------------------
       
    90 //
       
    91 void PhoneNoteUtil::SendGlobalErrorNoteL( 
       
    92         TInt aResourceId, TBool aNotificationDialog )
       
    93     {   
       
    94     MPhoneViewCommandHandle* viewCommandHandle = 
       
    95             ViewCommandHandle();
       
    96     
       
    97     SetGlobalNotifierDisabledL( viewCommandHandle );
       
    98 
       
    99     TPhoneCmdParamGlobalNote globalNoteParam;
       
   100     TPhoneNotificationType type = aNotificationDialog ? 
       
   101                 EPhoneNotificationDialog : EPhoneMessageBoxInformation;
       
   102     
       
   103     SetCommonGlobalNoteParamsL(
       
   104             globalNoteParam, aResourceId,
       
   105             aNotificationDialog, type,
       
   106             EPhoneErrorTone );
       
   107 
       
   108     viewCommandHandle->ExecuteCommandL(
       
   109         EPhoneViewShowGlobalNote, &globalNoteParam );
       
   110 
       
   111     }
       
   112 
       
   113 // ---------------------------------------------------------
       
   114 //  PhoneNoteUtil::SendGlobalNoteL
       
   115 // ---------------------------------------------------------
       
   116 //
       
   117 void PhoneNoteUtil::SendGlobalNoteL( 
       
   118         TInt aResourceId, TBool aNotificationDialog )
       
   119     {   
       
   120     MPhoneViewCommandHandle* viewCommandHandle = 
       
   121             ViewCommandHandle();
       
   122     
       
   123     SetGlobalNotifierDisabledL( viewCommandHandle );
       
   124 
       
   125     TPhoneCmdParamGlobalNote globalNoteParam;
       
   126     TPhoneNotificationType type = aNotificationDialog ? 
       
   127                 EPhoneNotificationDialog : EPhoneMessageBoxInformation;
       
   128     
       
   129     SetCommonGlobalNoteParamsL(
       
   130             globalNoteParam, aResourceId,
       
   131             aNotificationDialog, 
       
   132             type );
       
   133 
       
   134     viewCommandHandle->ExecuteCommandL(
       
   135         EPhoneViewShowGlobalNote, &globalNoteParam );
       
   136 
       
   137     }
       
   138 
       
   139 // ---------------------------------------------------------
       
   140 //  PhoneNoteUtil::SendGlobalNoteL
       
   141 // ---------------------------------------------------------
       
   142 //
       
   143 void PhoneNoteUtil::SendGlobalNoteL( 
       
   144         TPhoneNotificationType aType, const TDesC& aText )
       
   145     {
       
   146     TPhoneCmdParamGlobalNote globalNoteParam;
       
   147     globalNoteParam.SetType( aType );
       
   148     globalNoteParam.SetText( aText );
       
   149 
       
   150     ViewCommandHandle()->ExecuteCommandL(
       
   151         EPhoneViewShowGlobalNote, &globalNoteParam );
       
   152     }
       
   153 
       
   154 // -----------------------------------------------------------
       
   155 // PhoneNoteUtil::ShowNoteL
       
   156 // -----------------------------------------------------------
       
   157 //
       
   158 void PhoneNoteUtil::ShowNoteL( TInt aResourceId )
       
   159     {   
       
   160     TPhoneCmdParamNote noteParam;
       
   161     noteParam.SetType( EPhoneNotePermanent );
       
   162     noteParam.SetResourceId( CPhoneMainResourceResolver::Instance()->
       
   163         ResolveResourceID( aResourceId ) );
       
   164     ViewCommandHandle()->ExecuteCommandL( EPhoneViewShowNote, &noteParam );
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------
       
   168 // PhoneNoteUtil::ShowQueryL
       
   169 // -----------------------------------------------------------
       
   170 //
       
   171 void PhoneNoteUtil::ShowQueryL( TInt aResourceId )
       
   172     {  
       
   173     TPhoneCmdParamQuery queryParam;
       
   174     queryParam.SetQueryType( EPhoneQueryDialog );
       
   175     queryParam.SetQueryResourceId( CPhoneMainResourceResolver::Instance()->
       
   176         ResolveResourceID( aResourceId ) );
       
   177     ViewCommandHandle()->ExecuteCommandL( EPhoneViewShowQuery, &queryParam );
       
   178     }
       
   179 
       
   180 // -----------------------------------------------------------
       
   181 // PhoneNoteUtil::ShowTextQueryL
       
   182 // -----------------------------------------------------------
       
   183 //
       
   184 void PhoneNoteUtil::ShowTextQueryL(
       
   185     TInt aDialogResourceId,
       
   186     TInt aDefaultCbaResourceId,
       
   187     TInt aContentCbaResourceId,
       
   188     TDes* aDataText,
       
   189     TBool aSendKeyEnabled )
       
   190     { 
       
   191     TPhoneCmdParamQuery queryDialogParam;
       
   192     queryDialogParam.SetQueryType( EPhoneTextQueryDialog );
       
   193     queryDialogParam.SetQueryResourceId( aDialogResourceId );
       
   194     queryDialogParam.SetDefaultCba( aDefaultCbaResourceId );
       
   195     queryDialogParam.SetContentCba( aContentCbaResourceId );
       
   196     queryDialogParam.SetDataText( aDataText );
       
   197     queryDialogParam.SetSendKeyEnabled( aSendKeyEnabled );
       
   198     ViewCommandHandle()->ExecuteCommandL( EPhoneViewShowQuery,
       
   199         &queryDialogParam );
       
   200     }
       
   201 
       
   202 // -----------------------------------------------------------
       
   203 // PhoneNoteUtil::HandleErrorL
       
   204 // Default handling for HandleError message
       
   205 // (other items were commented in a header).
       
   206 // -----------------------------------------------------------
       
   207 //
       
   208 void PhoneNoteUtil::HandleErrorL( const TPEErrorInfo& aErrorInfo )
       
   209     {
       
   210     // Do the common error handling (display proper notes etc)
       
   211     CPhoneMainErrorMessagesHandler::Instance()->ShowErrorSpecificNoteL( aErrorInfo );
       
   212     switch( aErrorInfo.iErrorCode )
       
   213         {
       
   214         case ECCPErrorNoService:
       
   215             // No network -> hide volume popup
       
   216             ViewCommandHandle()->
       
   217                     ExecuteCommandL( EPhoneViewHideNaviPaneAudioVolume );
       
   218             break;
       
   219 
       
   220         case ECCPErrorSatControl:
       
   221             ViewCommandHandle()->
       
   222                 ExecuteCommandL( EPhoneViewClearNumberEntryContent );
       
   223             break;
       
   224 
       
   225         default:
       
   226             break;
       
   227         }
       
   228     // clear call blacklist if call failure occurs
       
   229     CPhoneClearBlacklist::Instance()->ClearBlackListOnNextKey();
       
   230     }
       
   231 
       
   232 // -----------------------------------------------------------------------------
       
   233 // PhoneNoteUtil::HandleRemoteBusyNoteL
       
   234 // -----------------------------------------------------------------------------
       
   235 //
       
   236 void PhoneNoteUtil::HandleRemoteBusyNoteL( TInt aCallId )
       
   237     {
       
   238     TPEErrorInfo info;
       
   239     info.iCallId = aCallId;
       
   240     info.iErrorCode = ECCPErrorBusy;
       
   241     info.iErrorType = EPECcp;
       
   242     CPhoneMainErrorMessagesHandler::Instance()->
       
   243             ShowErrorSpecificNoteL( info );
       
   244     }
       
   245 
       
   246 // ---------------------------------------------------------
       
   247 //  PhoneNoteUtil::SetGlobalNotifierDisabledL
       
   248 // ---------------------------------------------------------
       
   249 //
       
   250 void PhoneNoteUtil::SetGlobalNotifierDisabledL( 
       
   251         MPhoneViewCommandHandle* aViewCommandHandle )
       
   252     {
       
   253     TPhoneCmdParamBoolean globalNotifierParam;
       
   254     globalNotifierParam.SetBoolean( EFalse );
       
   255     aViewCommandHandle->ExecuteCommandL( EPhoneViewSetGlobalNotifiersDisabled,
       
   256         &globalNotifierParam );
       
   257     }
       
   258 
       
   259 // ---------------------------------------------------------
       
   260 //  PhoneNoteUtil::SetCommonGlobalNoteParamsL
       
   261 // ---------------------------------------------------------
       
   262 //
       
   263 void PhoneNoteUtil::SetCommonGlobalNoteParamsL( 
       
   264         TPhoneCmdParamGlobalNote& aGlobalNoteParam,
       
   265         TInt aResourceId, 
       
   266         TBool aNotificationDialog,
       
   267         TPhoneNotificationType aNoteType,
       
   268         TPhoneNotificationToneType aTone )
       
   269     {
       
   270     aGlobalNoteParam.SetType( aNoteType );
       
   271     aGlobalNoteParam.SetToneType( aTone );
       
   272 
       
   273     aGlobalNoteParam.SetTextResourceId(
       
   274         CPhoneMainResourceResolver::Instance()->
       
   275         ResolveResourceID( aResourceId ) );
       
   276     
       
   277     aGlobalNoteParam.SetNotificationDialog( aNotificationDialog );
       
   278     }
       
   279 
       
   280 // ---------------------------------------------------------
       
   281 //  PhoneNoteUtil::ViewCommandHandle
       
   282 // ---------------------------------------------------------
       
   283 //
       
   284 MPhoneViewCommandHandle* PhoneNoteUtil::ViewCommandHandle()
       
   285     {   
       
   286     return CPhoneStateHandle::Instance()->ViewCommandHandle();
       
   287     }
       
   288 
       
   289 //  End of File