#include <FConnection.h>
Public Member Functions | |
virtual | ~FConnection () |
Destructor. Closes the connection and the session. | |
const int | startConnection () |
Starts a new GPRS connection using the default IAP, which name is stored in the member 'iIAPDefaultName'. | |
const int | startConnection (const StringBuffer &aIAPName) |
Starts a new GPRS connection, given the IAP name. | |
void | closeConnection () |
Closes the active connection. | |
const int | stopConnection () |
Stops the entire connection by disconnecting the underlying network interface immediately, regardless of whether other clients are using it or not. | |
const bool | isConnected () |
Checks if the connection is active or down. | |
void | restartSession () |
Closes and restarts the RSocketServ session. | |
const StringBuffer & | getLocalIpAddress () |
Returns the local IP address of the device. | |
void | setIAPName (const StringBuffer &aIAPName) |
Sets the IAP name, that will be used in startConnection(). | |
StringBuffer & | getIAPName () |
Returns the current IAP name. | |
RArray< HBufC * > | GetAllIAPNames () |
Returns an array of (new allocated) descriptors, with all the current IAP names. | |
RConnection * | getConnection () |
Returns a pointer to the (internally owned) RConnection. | |
RSocketServ * | getSession () |
Returns a pointer to the (internally owned) SocketServ. | |
TInt | getLastError () |
Returns the last error code. | |
Static Public Member Functions | |
static FConnection * | getInstance () |
Method to get the sole instance of FConnection. | |
static void | dispose () |
Method to destroy the instance of FConnection. | |
Protected Member Functions | |
FConnection () | |
Default constructor. | |
Private Member Functions | |
void | ConstructL () |
Calls startSession(). | |
void | startSession () |
Starts the session (RSocketServ) and opens a new connection (RConnection). | |
const int | openConnection () |
Opens the connection. | |
TInt | GetIAPIDFromName (const StringBuffer &aIAPName) |
Returns the IAP ID from its name. | |
StringBuffer | GetIAPNameFromID (const TUint aIAPID) |
Returns the IAP name from its ID. | |
Static Private Member Functions | |
static FConnection * | NewL () |
static FConnection * | NewLC () |
Private Attributes | |
RSocketServ | iSession |
The Socket Server necessary to estabilish internet connection. | |
RConnection | iConnection |
The Network connection interface. | |
StringBuffer | iLocalIpAddress |
Current local IP adress of the device. | |
TUint32 | iIAP |
Current IAP ID of the active connection It's set once the connection is up and running. | |
StringBuffer | iIAPName |
Current IAP name of the active connection. | |
TInt | iLastError |
The last error code. | |
TInt | iRetryConnection |
Counter to know how many times we retry to connect to network. | |
bool | isConnectionOpened |
We don't want to open a RConnection that is already opened, otherwise there can be errors using the connection. | |
Static Private Attributes | |
static FConnection * | iInstance |
pointer to FConnection sole instance |
Get the only instance of FConnection calling FConnection::getInstance(). Owns the RSocketServ and RConnection of the current connection, that can be used exterally calling getConnection() and getSession().
void FConnection::closeConnection | ( | ) |
Closes the active connection.
The connection will not be dropped immediately: it will be dropped when there is no more data traffic on the connection.
RArray<HBufC*> FConnection::GetAllIAPNames | ( | ) |
Returns an array of (new allocated) descriptors, with all the current IAP names.
The caller has the ownership of the array, so he should take care of deleting it (calling Close()).
TInt FConnection::GetIAPIDFromName | ( | const StringBuffer & | aIAPName | ) | [private] |
Returns the IAP ID from its name.
Scans all the user defined accespoints inside the CommDb database.
aIAPName | the IAP name to seach |
StringBuffer FConnection::GetIAPNameFromID | ( | const TUint | aIAPID | ) | [private] |
Returns the IAP name from its ID.
Scans all the user defined accespoints inside the CommDb database.
aIAPID | the IAP ID to seach |
const StringBuffer& FConnection::getLocalIpAddress | ( | ) |
Returns the local IP address of the device.
TODO
const bool FConnection::isConnected | ( | ) |
Checks if the connection is active or down.
Between active connection, we search for the one started with startConnection().
const int FConnection::openConnection | ( | ) | [private] |
Opens the connection.
It's used internally because we MUST have the connection opened before calling iConnection.Start() or iConnection.EnumerateConnections().
void FConnection::restartSession | ( | ) |
Closes and restarts the RSocketServ session.
It is used in case the session is stuck and always returns an error (KErrNotReady = -18). Calling this method will cause the current connection to be dropped.
void FConnection::setIAPName | ( | const StringBuffer & | aIAPName | ) | [inline] |
Sets the IAP name, that will be used in startConnection().
This method should be called at the beginning, so that subsequent calls to startConnection() will use this IAP.
aIAPName | the name of the IAP |
References iIAPName.
const int FConnection::startConnection | ( | const StringBuffer & | aIAPName | ) |
Starts a new GPRS connection, given the IAP name.
aIAPName | "Ask" or "" : if we want to prompt the user to select the IAP "Default" : will use the default IAP of the system, no prompts "<name>" : will use the <name> IAP, no prompts. If not found, will prompt the user to select the IAP |
const int FConnection::startConnection | ( | ) |
Starts a new GPRS connection using the default IAP, which name is stored in the member 'iIAPDefaultName'.
The method setIAPDefaultName() should be called before this method, to set the IAP to be used - otherwise, the user will be prompted to select the IAP.
const int FConnection::stopConnection | ( | ) |
Stops the entire connection by disconnecting the underlying network interface immediately, regardless of whether other clients are using it or not.
Applications using the connection will be sent the socket error code KErrCancel.
StringBuffer FConnection::iIAPName [private] |
Current IAP name of the active connection.
It can be set calling setIAPName() method. It's set also when the connection is up and running.
Referenced by getIAPName(), and setIAPName().
bool FConnection::isConnectionOpened [private] |
We don't want to open a RConnection that is already opened, otherwise there can be errors using the connection.
This bool is used to know if we called iConnection.Open().