examples/ForumNokia/Symbian_OS_End-to-End_Sockets_API_Example/SocketTaskManager/src/TaskManagerConnForm.cpp

00001 /*
00002  * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.
00003  *    
00004  * Redistribution and use in source and binary forms, with or without
00005  * modification, are permitted provided that the following conditions are met:
00006  *    
00007  *  * Redistributions of source code must retain the above copyright notice, this
00008  *    list of conditions and the following disclaimer.
00009  *  * Redistributions in binary form must reproduce the above copyright notice,
00010  *    this list of conditions and the following disclaimer in the documentation
00011  *    and/or other materials provided with the distribution.
00012  *  * Neither the name of Nokia Corporation nor the names of its contributors
00013  *    may be used to endorse or promote products derived from this software
00014  *    without specific prior written permission.
00015  *    
00016  *    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00017  *    AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00018  *    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
00019  *    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
00020  *    FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00021  *    DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00022  *    SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00023  *    CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
00024  *    OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00025  *    OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00026  *    
00027  *    Description:  
00028  */
00029 
00030 
00031 // INCLUDE FILES
00032 #include "TaskManagerConnForm.h"
00033 #include "TaskManagerConnInfo.h"
00034 
00035 #include <SocketTaskManager.rsg>
00036 #include <avkon.hrh>            // EAknSoftkeyOk
00037 #include <eikedwin.h>           // CEikEdwin
00038 #include <aknnumedwin.h>        // CAknIntegerEdwin
00039 #include <eikseced.h>           // CEikSecretEditor
00040 
00041 
00042 // ================= MEMBER FUNCTIONS =======================
00043 
00044 // constructor
00045 CTaskManagerConnForm::CTaskManagerConnForm( TTaskManagerConnInfo& aConnInfo ): iConnInfo( aConnInfo )
00046         {
00047         }
00048 
00049 // ----------------------------------------------------------
00050 // CTaskManagerConnForm::RunDlgLD()
00051 // Runs this form.
00052 // ----------------------------------------------------------
00053 //
00054 TBool CTaskManagerConnForm::RunDlgLD( TTaskManagerConnInfo& aConnInfo )
00055         {
00056         CTaskManagerConnForm* self = new (ELeave) CTaskManagerConnForm( aConnInfo );
00057         return self->ExecuteLD( R_TASKMANAGER_CONNFORM_DIALOG );
00058         }
00059 
00060 // ----------------------------------------------------------
00061 // CTaskManagerConnForm::PreLayoutDynInitL()
00062 // This function is called by the dialog framework before 
00063 // the dialog is sized and laid out.
00064 // ----------------------------------------------------------
00065 //
00066 void CTaskManagerConnForm::PreLayoutDynInitL()
00067         {
00068         CEikEdwin* editor;
00069         
00070         // set server name
00071         editor = static_cast< CEikEdwin* >( ControlOrNull( ETaskManagerIdServer ) );
00072         if( editor )
00073                 {
00074                 TPtrC ptr(iConnInfo.ServerAddress());
00075                 editor->SetTextL(&ptr);
00076                 }
00077         
00078         // set port number
00079         CAknIntegerEdwin* portEditor =
00080                            static_cast< CAknIntegerEdwin* >( ControlOrNull( ETaskManagerIdPort ) );
00081         if( portEditor )
00082                 {
00083                 portEditor->SetValueL(iConnInfo.Port());
00084                 }
00085         
00086         // set username
00087         editor = static_cast< CEikEdwin* >( ControlOrNull( ETaskManagerIdUsername ) );
00088         if( editor )
00089                 {
00090                 TPtrC ptr(iConnInfo.Username());
00091                 editor->SetTextL(&ptr);
00092                 }
00093                 
00094         // set password
00095         CEikSecretEditor* secretEditor =
00096                 static_cast< CEikSecretEditor* >( ControlOrNull( ETaskManagerIdPassword ) );
00097         if (secretEditor)
00098                 {
00099                 TPtrC ptr(iConnInfo.Password());
00100                 secretEditor->SetText(ptr);
00101                 }
00102         }
00103         
00104 // ----------------------------------------------------------
00105 // CTaskManagerConnForm::OkToExitL()
00106 // This function is invoked when the user presses a button in 
00107 // the button panel. It is not called if the Cancel button is 
00108 // activated.
00109 // ----------------------------------------------------------
00110 //      
00111 TBool CTaskManagerConnForm::OkToExitL( TInt aButtonId )
00112         {
00113         if ( aButtonId == EAknSoftkeyOk )
00114                 {
00115                 CEikEdwin* editor;
00116                 
00117                 // save server name
00118                 editor = static_cast< CEikEdwin* >( ControlOrNull( ETaskManagerIdServer ) );
00119                 if( editor )
00120                         {
00121                         TBuf< KMaxServerNameLength > server;
00122                         editor->GetText( server );
00123                         iConnInfo.SetServerAddress( server );
00124                         }
00125                 
00126                 // save port number
00127                 CAknIntegerEdwin* portEditor =
00128                                    static_cast< CAknIntegerEdwin* >( ControlOrNull( ETaskManagerIdPort ) );
00129                 if( portEditor )
00130                         {
00131                         TInt port;
00132                         portEditor->GetTextAsInteger( port );
00133                         iConnInfo.SetPort( port );
00134                         }
00135                 
00136                 // save username
00137                 editor = static_cast< CEikEdwin* >( ControlOrNull( ETaskManagerIdUsername ) );
00138                 if( editor )
00139                         {
00140                         TBuf< KMaxUsernameLength > username;
00141                         editor->GetText( username );
00142                         iConnInfo.SetUsername( username );
00143                         }
00144 
00145                 // save password
00146                 CEikSecretEditor* secretEditor =
00147                                          static_cast< CEikSecretEditor* >( ControlOrNull( ETaskManagerIdPassword ) );
00148                 if( secretEditor )
00149                         {
00150                         TBuf< KMaxPasswordLength > password;
00151                         secretEditor->GetText( password );
00152                         iConnInfo.SetPassword( password );
00153                         }
00154                 }
00155 
00156         return ETrue;
00157         }
00158         
00159 // End of file

Generated by  doxygen 1.6.2