examples/ForumNokia/Symbian_OS_End-to-End_Sockets_API_Example/SocketTaskManager/src/TaskManagerConnInfo.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 "TaskManagerConnInfo.h"
00033 #include "TaskManager.pan"
00034 
00035 // CONSTANTS
00036 const TInt TTaskManagerConnInfo::KDefaultPort = 3000;
00037 
00038 // ================= MEMBER FUNCTIONS =======================
00039 
00040 // constructor
00041 TTaskManagerConnInfo::TTaskManagerConnInfo(): iPort( KDefaultPort ), iIap(0)
00042         {
00043         // No implementation
00044         }
00045 
00046 // ----------------------------------------------------------
00047 // TTaskManagerConnInfo::SetServerAddress()
00048 // Sets the server address.
00049 // ----------------------------------------------------------
00050 //
00051 void TTaskManagerConnInfo::SetServerAddress( const TDesC& aAddress )
00052         {
00053         if( aAddress.Length() > KMaxServerNameLength )
00054                 {
00055                 Panic(ETaskManagerServerAddressTooLong);
00056                 }
00057         iServerAddress.Copy( aAddress );
00058         }
00059 
00060 // ----------------------------------------------------------
00061 // TTaskManagerConnInfo::ServerAddress()
00062 // Gets the server address.
00063 // ----------------------------------------------------------
00064 //
00065 TBufC< KMaxServerNameLength > TTaskManagerConnInfo::ServerAddress() const
00066         {
00067         return iServerAddress;
00068         }
00069 
00070 // ----------------------------------------------------------
00071 // TTaskManagerConnInfo::SetPort()
00072 // Sets the port number.
00073 // ----------------------------------------------------------
00074 //      
00075 void TTaskManagerConnInfo::SetPort( const TInt aPort )
00076         {
00077         iPort = aPort;
00078         }
00079 
00080 // ----------------------------------------------------------
00081 // TTaskManagerConnInfo::Port()
00082 // Gets the port number.
00083 // ----------------------------------------------------------
00084 //      
00085 const TInt TTaskManagerConnInfo::Port() const
00086         {
00087         return iPort;
00088         }
00089         
00090 // ----------------------------------------------------------
00091 // TTaskManagerConnInfo::SetUsername()
00092 // Sets the username.
00093 // ----------------------------------------------------------
00094 //              
00095 void TTaskManagerConnInfo::SetUsername( const TDesC& aUsername )
00096         {
00097         if( aUsername.Length() > KMaxUsernameLength )
00098                 {
00099                 Panic(ETaskManagerUsernameTooLong); 
00100                 }
00101         iUsername.Copy( aUsername );
00102         }
00103 
00104 // ----------------------------------------------------------
00105 // TTaskManagerConnInfo::Username()
00106 // Gets the username.
00107 // ----------------------------------------------------------
00108 //              
00109 TBufC< KMaxUsernameLength > TTaskManagerConnInfo::Username() const
00110         {
00111         return iUsername;       
00112         }
00113         
00114 // ----------------------------------------------------------
00115 // TTaskManagerConnInfo::SetPassword()
00116 // Sets the password.
00117 // ----------------------------------------------------------
00118 //                      
00119 void TTaskManagerConnInfo::SetPassword( const TDesC& aPassword )
00120         {
00121         if( aPassword.Length() > KMaxPasswordLength )
00122                 {
00123                 Panic(ETaskManagerPasswordTooLong);
00124                 }
00125         iPassword.Copy( aPassword );
00126         }
00127 
00128 // ----------------------------------------------------------
00129 // TTaskManagerConnInfo::Password()
00130 // Gets the password.
00131 // ----------------------------------------------------------
00132 //              
00133 TBufC< KMaxPasswordLength > TTaskManagerConnInfo::Password() const
00134         {
00135         return iPassword;       
00136         }
00137 
00138 // ----------------------------------------------------------
00139 // TTaskManagerConnInfo::SetIap()
00140 // Sets the IAP.
00141 // ----------------------------------------------------------
00142 //                      
00143 void TTaskManagerConnInfo::SetIap( const TUint32& aId)
00144         {
00145         iIap = aId;
00146         }
00147 
00148 // ----------------------------------------------------------
00149 // TTaskManagerConnInfo::Iap()
00150 // Gets the IAP.
00151 // ----------------------------------------------------------
00152 //                      
00153 TUint32 TTaskManagerConnInfo::Iap() const
00154         {
00155         return iIap;
00156         }
00157 
00158 // ----------------------------------------------------------
00159 // TTaskManagerConnInfo::ExternalizeL()
00160 // Saves the connection data to the given stream.
00161 // ----------------------------------------------------------
00162 //              
00163 void TTaskManagerConnInfo::ExternalizeL(RWriteStream& aStream) const
00164         {
00165         aStream << iServerAddress;
00166         aStream.WriteInt32L(iPort);
00167         aStream << iUsername;
00168         aStream << iIap;
00169         }
00170 
00171 // ----------------------------------------------------------
00172 // TTaskManagerConnInfo::InternalizeL()
00173 // Reads the connections data from the given stream.
00174 // ----------------------------------------------------------
00175 //                      
00176 void TTaskManagerConnInfo::InternalizeL(RReadStream& aStream)
00177         {
00178         aStream >> iServerAddress;
00179         iPort  = aStream.ReadInt32L();
00180         aStream >> iUsername;
00181         aStream >> iIap;
00182         }
00183         
00184 // End of file

Generated by  doxygen 1.6.2