fep/aknfep/src/aknfepuserdbquerydlg.cpp
author Shabe Razvi <shaber@symbian.org>
Thu, 02 Sep 2010 15:52:50 +0100
branchRCL_3
changeset 45 6f51b41715c8
parent 44 ecbabf52600f
permissions -rw-r--r--
Merge RCL_3 fixes with reverted delivery
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
/*
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
* All rights reserved.
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0""
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
*
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
* Initial Contributors:
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
*
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
* Contributors:
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
*
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
* Description:                
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
*
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
*/
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
#include <aknnotewrappers.h> //CAknWarningNote
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
#include <eikedwin.h> //CEikEdwin 
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
#include <aknfep.rsg>
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
#include "aknfepuserdbquerydlg.h"
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
#include "dbmanagement.h"
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
const TInt KErrMsgMaxLength = 60;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
const TInt KTextMaxLength = 10;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
CAknFepUserDBQueryDlg::CAknFepUserDBQueryDlg( CDBManagement* aDBEngine, 
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
    TDes& aText, const TTone& aTone ) : 
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
    CAknTextQueryDialog ( aText, aTone ), iDBEngine(aDBEngine)
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    35
    {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
    iptrbuf = & aText;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
    iItemText = NULL;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
    }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
CAknFepUserDBQueryDlg::~CAknFepUserDBQueryDlg()
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
    {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
    if ( iItemText )
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
        {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
        delete iItemText;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    45
        iItemText = NULL;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
        }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
    }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
CAknFepUserDBQueryDlg* CAknFepUserDBQueryDlg::NewLC( CDBManagement* aDBEngine, 
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
    TDes& aText, const TDesC& aPrompt, const TTone& aTone )
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
    {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
    CAknFepUserDBQueryDlg* self = new (ELeave)CAknFepUserDBQueryDlg( aDBEngine, aText, aTone );
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
    CleanupStack::PushL(self);
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
    self->ConstructL( aPrompt );
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
    return self;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
    }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
CAknFepUserDBQueryDlg* CAknFepUserDBQueryDlg::NewL( CDBManagement* aDBEngine, 
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
    TDes& aText, const TDesC& aPrompt, const TTone& aTone )
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
    {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
    CAknFepUserDBQueryDlg* self=CAknFepUserDBQueryDlg::NewLC( aDBEngine, aText, aPrompt, aTone );
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
    CleanupStack::Pop( self ); // self;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
    return self;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
    }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
void CAknFepUserDBQueryDlg::ConstructL( const TDesC& aPrompt )
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
    {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
    SetPromptL( aPrompt );
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
    }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
TBool CAknFepUserDBQueryDlg::OkToExitL( TInt aButtonId )
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
    {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
    TBuf<KErrMsgMaxLength> errMsg;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    74
    if (aButtonId == EAknSoftkeyOk)
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
        {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
        CAknQueryControl* control = 
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
            static_cast<CAknQueryControl*>(ControlOrNull(EGeneralQuery));
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
        CEikEdwin* editor = static_cast<CEikEdwin*>
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
            ( control->ControlByLayoutOrNull( EDataLayout ) );
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
        iItemText = editor->GetTextInHBufL();
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
        TBuf<KTextMaxLength> textbuf;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
        
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
        if( iItemText != NULL )
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
            {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
            textbuf.Copy( iItemText->Des() );
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
            }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
        
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    89
        if( !iDBEngine->InputPhraseCheck( textbuf ) )
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
            {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
            iptrbuf->Zero();
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
            iptrbuf->Copy( textbuf );
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
            
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
            iDBEngine->GetErrMsg( errMsg );
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
            errMsg.Copy( errMsg.Mid( 1 ) );
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
            
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
            
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
            if ( iItemText )
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
                {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
                delete iItemText;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
                iItemText = NULL;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
                }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
            editor->SetTextL( &textbuf ); 
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
            //note fot err message
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
            CAknWarningNote* note = new( ELeave ) CAknWarningNote();
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
            note->SetTimeout( CAknNoteDialog::EShortTimeout );
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
            note->ExecuteLD( errMsg ); 
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
            UpdateLeftSoftKeyL();
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
            return EFalse;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   111
            }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
        iptrbuf->Zero();
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
        iptrbuf->Copy( textbuf );
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
        if ( iItemText )
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
            {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   116
            delete iItemText;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   117
            iItemText = NULL;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
            }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
        return ETrue;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
        }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
    else
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
        {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
        if (aButtonId == EAknSoftkeyCancel)
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   124
            {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
            return ETrue;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   126
            }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
        }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
    return ETrue;
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
    }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   131
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
void CAknFepUserDBQueryDlg::PostLayoutDynInitL()
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133
    {
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   134
    CAknQueryControl* control = 
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   135
        static_cast<CAknQueryControl*>(ControlOrNull(EGeneralQuery));
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   136
    CEikEdwin* editor = static_cast<CEikEdwin*>
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   137
        ( control->ControlByLayoutOrNull( EDataLayout ) );
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   138
    editor->SetTextL( iptrbuf );
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   139
    SetFocus(ETrue);
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   140
    SetFocusing(ETrue);
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   141
    }
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   142
ecbabf52600f Revert incorrect RCL_3 drop:
Pat Downey <patd@symbian.org>
parents:
diff changeset
   143
// End of file