00001 /* 00002 Copyright (c) 2009-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 #ifndef RCONNECTION_H 00032 #define RCONNECTION_H 00033 00034 #include <e32cons.h> 00035 #include <in_sock.h> 00036 00037 #include <es_enum.h> 00038 #include <commdbconnpref.h> 00039 00040 class CRConnection : public CBase 00041 { 00042 public: 00043 00044 //Constructor. 00045 CRConnection(CConsoleBase* aConsole); 00046 00047 //Destructor. 00048 ~CRConnection(); 00049 00050 //Opens a session to the socket server and opens a connection that monitors for interface notification. 00051 void StartESOCK(); 00052 00053 //Demonstrates various RConnection API methods using default Commdb settings. 00054 void DemoApiWithoutDbOverrideL(); 00055 00056 //Demonstrates various RConnection API methods using non-default Commdb settings. 00057 void DemoApiWithDbOverrideL(); 00058 00059 //Starts a connection then attaches another connection to the same interface. 00060 void AttachToExistingInterfaceL(); 00061 00062 //Opens and starts a connection using non-default Commdb settings. 00063 TInt ConnectWithDbOverrideL(); 00064 00065 //Opens and starts a connection using default Commdb settings. 00066 TInt ConnectWithoutDbOverrideL(); 00067 00068 //Requests notification of the connection's progress. 00069 void GetProgressNotification(); 00070 00071 //Prints progress information to the console. 00072 void DisplayProgressinfo(const TNifProgress& aProgress); 00073 00074 //Displays text describing the next phase of the example. 00075 void DisplaySectionToDemo(const TDesC& aText); 00076 00077 //Prepares the socket for carrying out data transfer. 00078 TInt PrepareSocket(); 00079 00080 //Sends UDP packets over a socket. 00081 TInt SendUdpData(TUint aPayloadSize); 00082 00083 //Receives UDP packets over a socket. 00084 TInt RecvUdpData(TUint aPayloadSize); 00085 00086 //Calls SendUdpData() and RecvUdpData(). 00087 void DataSendAndReceive(TUint aPayloadSize); 00088 00089 //Gets the amount of data that has been transferred by the entire connection. 00090 void DataTransferredRequest(); 00091 00092 //Requests notification when a certain amount of data has been sent or received. 00093 void DataTransferNotificationRequest(); 00094 00095 00096 private: 00097 RConnection iConnection; 00098 RSocket iSocket; 00099 RSocketServ iSocketServ; 00100 CConsoleBase* iConsole; 00101 TInetAddr iDestAddr; 00102 TInt iCurrentProgress; 00103 RConnection iMonitor; 00104 00105 }; 00106 00107 #endif //RCONNECTION_H