|
1 /* |
|
2 * Copyright (c) 2005 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: Text setting page with a validation of the entered text |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "sipsettlistsipsrvtextsetpage.h" |
|
22 #include <aknnotewrappers.h> |
|
23 #include <eikedwin.h> |
|
24 #include <avkon.rsg> |
|
25 #include <gssipsettingspluginrsc.rsg> //GUI Resource |
|
26 #include "gssippluginlogger.h" |
|
27 |
|
28 // ============================ MEMBER FUNCTIONS =============================== |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CSIPSettListSIPSrvTextSetPage::CSIPSettListSIPSrvTextSetPage |
|
32 // C++ default constructor can NOT contain any code, that |
|
33 // might leave. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CSIPSettListSIPSrvTextSetPage::CSIPSettListSIPSrvTextSetPage( |
|
37 TInt aResourceID, |
|
38 TGSSIPValidatorWrapper aValidator, |
|
39 TDes& aText, |
|
40 TInt aTextSettingPageFlags ) : |
|
41 CAknTextSettingPage( aResourceID, aText, aTextSettingPageFlags ), |
|
42 iValidator( NULL, NULL ), |
|
43 iID( aResourceID ) |
|
44 { |
|
45 __GSLOGSTRING("CSIPSettListSIPSrvTextSetPage::CSIPSettListSIPSrvTextSetPage" ) |
|
46 iValidator = aValidator; |
|
47 } |
|
48 |
|
49 // Destructor |
|
50 CSIPSettListSIPSrvTextSetPage::~CSIPSettListSIPSrvTextSetPage() |
|
51 { |
|
52 __GSLOGSTRING("CSIPSettListSIPSrvTextSetPage::~CSIPSettListSIPSrvTextSetPage" ) |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // CSIPSettListSIPSrvTextSetPage::OkToExitL |
|
57 // Called to validate input before closing the page |
|
58 // ----------------------------------------------------------------------------- |
|
59 // |
|
60 TBool CSIPSettListSIPSrvTextSetPage::OkToExitL( TBool aAccept ) |
|
61 { |
|
62 __GSLOGSTRING("CSIPSettListSIPSrvTextSetPage::OkToExitL" ) |
|
63 TBool ret( EFalse ); |
|
64 |
|
65 if ( !aAccept ) |
|
66 { |
|
67 // User pressed cancel - return back to original text and go away |
|
68 RestoreOriginalSettingL(); |
|
69 return ETrue; |
|
70 } |
|
71 |
|
72 // Ask from the validation method how it feels about this |
|
73 UpdateTextL(); |
|
74 |
|
75 TBool exit = EFalse; |
|
76 TRAPD( err, exit = iValidator.ValidateL() ); |
|
77 // No use of handling that error code - it just means that things weren't |
|
78 // validated |
|
79 |
|
80 if ( exit && err == KErrNone ) |
|
81 { |
|
82 // Everything OK, save setting and exit page |
|
83 AcceptSettingL(); |
|
84 ret = ETrue; |
|
85 } |
|
86 else |
|
87 { |
|
88 // No good, show error message and let user try again |
|
89 HBufC* errorTxt = ErrorMsgTxtLC(); |
|
90 CAknErrorNote* note = new ( ELeave ) CAknErrorNote( ETrue ); |
|
91 note->ExecuteLD( errorTxt->Des() ); |
|
92 CleanupStack::PopAndDestroy( errorTxt ); |
|
93 TextControl()->SelectAllL(); |
|
94 ret = EFalse; |
|
95 } |
|
96 |
|
97 return ret; |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CSIPSettListSIPSrvTextSetPage::ErrorMsgTxtLC |
|
103 // Reads error messge text to buffer and returns it |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 HBufC* CSIPSettListSIPSrvTextSetPage::ErrorMsgTxtLC() |
|
107 { |
|
108 __GSLOGSTRING("CSIPSettListSIPSrvTextSetPage::ErrorMsgTxtLC" ) |
|
109 HBufC* errorMsgTxt = NULL; |
|
110 TInt id = 0; |
|
111 |
|
112 switch( iID ) |
|
113 { |
|
114 case R_SIP_USERNAME_PAGE: |
|
115 id = R_QTN_SIP_ERROR_INVALID_USER_NAME; |
|
116 break; |
|
117 |
|
118 case R_SIP_SERVER_ADDR_PAGE: |
|
119 id = R_QTN_SIP_ERROR_PROXY_ADDRESS; |
|
120 break; |
|
121 |
|
122 case R_SIP_REG_SERVER_ADDR_PAGE: |
|
123 id = R_QTN_SIP_ERROR_REGISTRAR_ADDRESS; |
|
124 break; |
|
125 |
|
126 default: |
|
127 User::Leave( KErrNotFound ); |
|
128 break; |
|
129 } |
|
130 |
|
131 errorMsgTxt = iEikonEnv->AllocReadResourceLC( id ); |
|
132 return errorMsgTxt; |
|
133 } |
|
134 |
|
135 // End of File |