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