Exemplo n.º 1
0
/**
 * Function that takes an IP address from user input, accesses the
 * Bluetooth PAN Profile table in the CommDb and updates the IpAddr
 * field with the supplied address.
 */		
void CPanConnections::SetLocalIpAddrL(TUint32 addr)
	{
	iLocalIpAddr = addr;
	iSrcAddr.SetAddress(iLocalIpAddr);
	CCommsDatabase* db = CCommsDatabase::NewL();
	CleanupStack::PushL(db);
	// Get the LAN service table
	CCommsDbTableView* tableView = db->OpenTableLC(TPtrC(LAN_SERVICE));

	TBuf<KMaxBufferSize> tableName;
	TInt err = tableView->GotoFirstRecord();
	if(err == KErrNone)
		{
		// Get the name of the table
		tableView->ReadTextL(TPtrC(COMMDB_NAME), tableName);
		if(tableName == TPtrC(_S("BluetoothPANProfile")))
			{
			TInetAddr tempAddr;
			TBuf<KMaxBufferSize> dispBuf;
			tempAddr.SetAddress(iLocalIpAddr);
			tempAddr.Output(dispBuf);
			
			User::LeaveIfError(tableView->UpdateRecord());	
			tableView->WriteTextL(_L("IpAddr"), dispBuf);
		
			User::LeaveIfError(tableView->PutRecordChanges());
			User::LeaveIfError(db->CommitTransaction());	
			}
		}
	else
		{
		User::Leave(KErrNotFound);
		}
	CleanupStack::PopAndDestroy(2);//db & tableView 
	}
// --------------------------------------------------------------------------
// UPnPAppSettingItemHomeIAP::CheckAPSecurity
// Checks if selected access point is unsecured and shows warning note
// --------------------------------------------------------------------------
//
TInt UPnPAppSettingItemHomeIAP::CheckAPSecurityL(TInt aAccessPoint)
    {
    __LOG8_1( "%s begin.", __PRETTY_FUNCTION__ );
    TUint32 serviceId = 0;
    TUint32 securityMode = 0;

    CCommsDatabase* db = CCommsDatabase::NewL( EDatabaseTypeIAP );
    CleanupStack::PushL( db );

    CCommsDbTableView* view = db->OpenViewMatchingUintLC(TPtrC(IAP),
                              TPtrC(COMMDB_ID), aAccessPoint);

    TInt error = view->GotoFirstRecord();

    if( error == KErrNone )
        {
        view->ReadUintL(TPtrC(IAP_SERVICE), serviceId);
        }

    CCommsDbTableView* wLanServiceTable = NULL;

    TRAPD(err,
    {// this leaves if the table is empty....
    wLanServiceTable = db->OpenViewMatchingUintLC(
        TPtrC( WLAN_SERVICE ),
        TPtrC( WLAN_SERVICE_ID ),
        serviceId );
    CleanupStack::Pop( wLanServiceTable );
    });
Exemplo n.º 3
0
// ---------------------------------------------------------------------------
// TIap::ResolveIapL
// ---------------------------------------------------------------------------
//  
TInt TIap::ResolveIapL( RArray<TIap>& aIapArray )
    {
    RDebug::Print( _L("TEST PRINT: CTestAppConsole::ResolveIapL -start\n") );
    
    TBuf<40> name;
    TUint32 iapid;

    CCommsDatabase* db = CCommsDatabase::NewL( EDatabaseTypeIAP );
    CleanupStack::PushL( db );
    CCommsDbTableView* view = db->OpenTableLC( TPtrC( IAP ) );

    TInt res = view->GotoFirstRecord();
    
    if ( res != KErrNone )
        {
        CleanupStack::PopAndDestroy( 2 ); // db, view
        RDebug::Print( _L("TEST PRINT: CTestAppConsole::ResolveIapL -end err: %d\n"), res );
        return res;
        }
    while ( res == KErrNone )  
        {
        view->ReadTextL( TPtrC( COMMDB_NAME ), name );
        view->ReadUintL( TPtrC( COMMDB_ID ), iapid );
        aIapArray.AppendL( TIap( iapid, name ) );
        res = view->GotoNextRecord();
        }
    CleanupStack::PopAndDestroy( 2 ); // db, view

    RDebug::Print( _L("TEST PRINT: CTestAppConsole::ResolveIapL -end" ) );
    return KErrNone;
    }
// ---------------------------------------------------------
// RHssInterface::CheckBackgroundScanL
// ---------------------------------------------------------
//
EXPORT_C TUint32 RHssInterface::CheckBackgroundScanL()
	{
	DEBUG( "RHssInterface::CheckBackgroundScanL()" );
    CCommsDatabase*    commDB = NULL;
    CCommsDbTableView* table  = NULL;

    // Open commDB
    commDB = CCommsDatabase::NewL();
    CleanupStack::PushL( commDB );

    table = commDB->OpenViewMatchingUintLC( KHssWlanDeviceSettings,
	                                        KHssWlanDeviceSettingsType,
	                                        KHssWlanUserSettings );

    TInt err = table->GotoFirstRecord();

    if ( err )
        {
        User::Leave( err );  
        }
	
	TUint32 scanInterval;
    table->ReadUintL( KHssBgScanInterval, scanInterval ); 

    // cleanup
    CleanupStack::PopAndDestroy( table );
    CleanupStack::PopAndDestroy( commDB );
    
    return (scanInterval);
	
	}
//=====================================================
//		CNSmlProfileContentHandler::AccessPointIdL()
//		
//		
//=====================================================	
TInt CNSmlProfileContentHandler::AccessPointIdL(TDesC& aBuf)
{

	const TInt defConn = -2;
	if (aBuf == _L("-1"))
		{
			return defConn; // return default connection always
		}
		
	CCommsDatabase *database = CCommsDatabase::NewL();
    TUint32 aId ;
    TInt retVal;
    CleanupStack::PushL(database);
    CCommsDbTableView*  checkView;
    checkView = database->OpenViewMatchingTextLC(TPtrC(IAP),TPtrC(COMMDB_NAME), aBuf);
    TInt error = checkView->GotoFirstRecord();
    if (error == KErrNone)
        {
         //Get the IAP ID 
         checkView->ReadUintL(TPtrC(COMMDB_ID), aId);
         retVal = aId;
        }
    else
    	{
        	retVal = defConn;
	   	}	  
       	
    CleanupStack::PopAndDestroy(2);    
    return retVal;          
	
	
}
void CMainControlEngine::GetIapNumFromFile()
{
	
	TBuf<255> nParmValue;

	iDBEngine->GetSystemParmWithSQL(KIAPNUM,nParmValue); 

	if(nParmValue.Length ()==0)
	{
		// open the IAP communications database 
		CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
		CleanupStack::PushL(commDB);

		// initialize a view 
		CCommsDbConnectionPrefTableView* commDBView = commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionUnknown);
		//CCommsDbConnectionPrefTableView* commDBView = commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionOutgoing);

		// go to the first record 
		TInt err=commDBView->GotoFirstRecord();

		if(err==KErrNotFound)
		{
			iIapValue=-1;
		}
		else
		{
			// Declare a prefTableView Object.
			CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
			// read the connection preferences 
			commDBView->ReadConnectionPreferenceL(pref);
			TUint32 iap= pref.iBearer.iIapId; 
			iIapValue=((TInt)iap);

			//保存到数据库中
			SetIapNum(iIapValue);
		}
		// pop and destroy the IAP View 
		CleanupStack::PopAndDestroy(commDBView);

		// pop and destroy the database object
		CleanupStack::PopAndDestroy(commDB);
	}
	else
	{
		TLex temp(nParmValue);
		temp.Val( iIapValue);
	}
}
// -----------------------------------------------------------------------------
// CCommsDatEnforcement::LockWLANAccessPointsL()
// -----------------------------------------------------------------------------
//
void CCommsDatEnforcement::LockWLANAccessPointsL( TBool aLockValue )
	{
	RDEBUG_2("CCommsDatEnforcement::LockAccessPoint( %d )", aLockValue );
	
	//Get WLAN service table and get ServiceID--> which is nothing but IAP ID and lock that record

	//TBool ret = EFalse;
	TUint32 apIAPID = 0;
		
    CCommsDbTableView*  checkView;
	CCommsDatabase* commsDataBase = CCommsDatabase::NewL();
	CleanupStack::PushL( commsDataBase );
    checkView = commsDataBase->OpenTableLC(TPtrC(IAP));
   	RDEBUG("		-> After opening IAP table ");
   	TBuf<KCommsDbSvrMaxFieldLength> serviceType;
    TInt error = checkView->GotoFirstRecord();
    RDEBUG("		-> After going to first record ");
    while (error == KErrNone)
        {
        RDEBUG("		-> KERRNONE ");
       		// Get the ID and check for service type
       	checkView->ReadTextL(TPtrC(IAP_SERVICE_TYPE), serviceType);
        if(serviceType == TPtrC(LAN_SERVICE))
            {
               	checkView->ReadUintL(TPtrC(COMMDB_ID), apIAPID);
               		RDEBUG_2("	->found %d WLAN AP. being protected or unprotected", apIAPID );
               	if(aLockValue)
               	{
               	((CCommsDbProtectTableView*)checkView)->ProtectRecord();
               	RDEBUG("		-> WLAN AP protected successfully!");	
               	}
               	else
               	{
               		((CCommsDbProtectTableView*)checkView)->UnprotectRecord();
               		RDEBUG("		-> WLAN AP UN protected successfully!");
               	}
               	
            }
            error = checkView->GotoNextRecord();
            
        }
    CleanupStack::PopAndDestroy(); // checkView

    CleanupStack::PopAndDestroy( commsDataBase );	


	}	
Exemplo n.º 8
0
/**
 * Function that accesses the PAN Service Table in the CommsDb and configures
 * the IAP to the required settings.
 */		
void CPanConnections::ConfigureIAPL(TBool aIsListening, TBTDevAddr* aDevAddr, TBool aUsePANNotifier)
	{
	// Open CommDb and get a view of the PAN service extentions table.
	CCommsDatabase* db = CCommsDatabase::NewL();
	CleanupStack::PushL(db);
	CCommsDbTableView* tableView = db->OpenTableLC(TPtrC(PAN_SERVICE_EXTENSIONS));

	TBuf<KMaxBufferSize> tableName;
	TInt err = tableView->GotoFirstRecord();
	if(err == KErrNone)
		{
		tableView->ReadTextL(TPtrC(COMMDB_NAME), tableName);
		if(tableName == TPtrC(_S("PANServiceExtensionsTable1")))
			{
			
			User::LeaveIfError(tableView->UpdateRecord());// Start update
			//enable listening mode	
			tableView->WriteBoolL(TPtrC(PAN_ALLOW_INCOMING),aIsListening);
			tableView->WriteBoolL(TPtrC(PAN_DISABLE_SDP_QUERY), 0);

			tableView->WriteBoolL(TPtrC(PAN_PROMPT_FOR_REMOTE_DEVICES), aUsePANNotifier);

			if(aDevAddr)
				{
				TBuf<KMaxBufferSize> buf;
				aDevAddr->GetReadable(buf);

				tableView->WriteTextL(TPtrC(PAN_PEER_MAC_ADDRESSES), buf);
				}
			else
				{
				tableView->WriteTextL(TPtrC(PAN_PEER_MAC_ADDRESSES), _L(""));
				}
			// Finalise changes made.
			User::LeaveIfError(tableView->PutRecordChanges());// Finish update
			User::LeaveIfError(db->CommitTransaction());

			CleanupStack::PopAndDestroy(2); // db & tableView
			return;
			}
		}
	User::Leave(KErrNotFound);
	}
void CSymTorrentIAPSelectView::GetGPRSIAPsFromIAPTableL()
{ 
	TBuf<52> iapfromtable;
	TBuf<53> listItem;
	TInt err = KErrNone;
	
	CCommsDatabase* commsDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
	CleanupStack::PushL(commsDB);

	// Open IAP table using the GPRS as the bearer.
	CCommsDbTableView* gprsTable = commsDB->OpenIAPTableViewMatchingBearerSetLC(ECommDbBearerGPRS,
		ECommDbConnectionDirectionOutgoing);
	// Point to the first entry
	User::LeaveIfError(gprsTable->GotoFirstRecord());
	gprsTable->ReadTextL(TPtrC(COMMDB_NAME), iapfromtable);
	listItem.SetLength(0);
	listItem.Append(_L("\t"));
	listItem.Append(iapfromtable);
	iContainer->AppendItemL(listItem);	
	
	TUint32 id;
	gprsTable->ReadUintL(TPtrC(COMMDB_ID), id);
	User::LeaveIfError(iIAPIDs.Append(id));

	while (err = gprsTable->GotoNextRecord(), err == KErrNone)
	{
		gprsTable->ReadTextL(TPtrC(COMMDB_NAME), iapfromtable);
		listItem.SetLength(0);
		listItem.Append(_L("\t"));
		listItem.Append(iapfromtable);
		iContainer->AppendItemL(listItem);
			
		TUint32 id;
		gprsTable->ReadUintL(TPtrC(COMMDB_ID), id);
		User::LeaveIfError(iIAPIDs.Append(id));
	}

	CleanupStack::PopAndDestroy(); // gprsTable
	CleanupStack::PopAndDestroy(); // commsDB
}
// -------------------------------------------------------------------------------------
// CNSmlDsProvisioningAdapter::GetDefaultIAPL()
// Gets the default NAPId 
// -------------------------------------------------------------------------------------
TInt CNSmlDsProvisioningAdapter::GetDefaultIAPL()
	{
	TInt iapId = KErrNotFound;

	CCommsDatabase* database = CCommsDatabase::NewL();
	CleanupStack::PushL( database );

	CCommsDbTableView* tableView = database->OpenTableLC( TPtrC( IAP ) );

	TInt errorCode = tableView->GotoFirstRecord();
		
	if ( errorCode == KErrNone ) 
		{
		TUint32	value;
		tableView->ReadUintL( TPtrC( COMMDB_ID ), value );
		iapId = value;
		}

	CleanupStack::PopAndDestroy( 2 ); // database, tableView

	return iapId;
	}
Exemplo n.º 11
0
/**
 * Function that will access the PAN service table in the CommDb
 * and use the values contained to printout the current state.
 */		
void CPanConnections::PrintIAPL()
	{
	CCommsDatabase* db = CCommsDatabase::NewL();
	CleanupStack::PushL(db);
	CCommsDbTableView* tableView = db->OpenTableLC(TPtrC(PAN_SERVICE_EXTENSIONS));

	TInt err = tableView->GotoFirstRecord();
	
	if(err == KErrNone)
		{
		// Print the IAP
		TUint32 uVal;
		TBool bVal;
		TBuf<KMaxBufferSize> sVal;
	

		iConsole.Printf(_L("------------------- CURRENT IAP ------------------\n"));
		
		tableView->ReadUintL(TPtrC(PAN_LOCAL_ROLE), uVal);
		iConsole.Printf(_L("Local Role: %d, "), uVal);			
		tableView->ReadUintL(TPtrC(PAN_PEER_ROLE), uVal);
		iConsole.Printf(_L("Peer Role: %d\n"), uVal);
		tableView->ReadBoolL(TPtrC(PAN_PROMPT_FOR_REMOTE_DEVICES), bVal);
		iConsole.Printf(_L("Peer Prompt: %d, "), bVal);			
		tableView->ReadBoolL(TPtrC(PAN_DISABLE_SDP_QUERY), bVal);
		iConsole.Printf(_L("Disable SDP: %d, "), bVal);			
		tableView->ReadBoolL(TPtrC(PAN_ALLOW_INCOMING), bVal);
		iConsole.Printf(_L("Listening: %d\n"), bVal);			
		tableView->ReadTextL(TPtrC(PAN_PEER_MAC_ADDRESSES), sVal);
		iConsole.Printf(_L("Peer MAC Addr: %S\n"), &sVal);

		iConsole.Printf(_L("--------------------------------------------------\n"));
		CleanupStack::PopAndDestroy(2);
		return;
		}
	User::Leave(KErrNotFound);
	}
Exemplo n.º 12
0
/**
 * Function that accesses the PAN Service table in the CommDb 
 * and applies the appropriate role, this function will be used for
 * local or peer as well as the PAN role (U or Gn).
 */	
void CPanConnections::SetFixedRoleL(TSide aSide, TUint aRole)
	{
	if (aSide == ELocalRole)
		iLocalRole = aRole;
	else
		iPeerRole = aRole;
	
	CCommsDatabase* db = CCommsDatabase::NewL();
	CleanupStack::PushL(db);
	CCommsDbTableView* tableView = db->OpenTableLC(TPtrC(PAN_SERVICE_EXTENSIONS));

	TBuf<KMaxBufferSize> tableName;
	TInt err = tableView->GotoFirstRecord();
	if(err == KErrNone)
		{
		tableView->ReadTextL(TPtrC(COMMDB_NAME), tableName);
		if(tableName == TPtrC(_S("PANServiceExtensionsTable1")))
			{
			User::LeaveIfError(tableView->UpdateRecord());	
			if(aSide == ELocalRole)
				{
				tableView->WriteBoolL(TPtrC(PAN_LOCAL_ROLE), aRole);
				}
			else 
				{
				tableView->WriteBoolL(TPtrC(PAN_PEER_ROLE), aRole);
				}
			User::LeaveIfError(tableView->PutRecordChanges());
			User::LeaveIfError(db->CommitTransaction());

			CleanupStack::PopAndDestroy(2);
			return;
			}
		}
	User::Leave(KErrNotFound);
	}
// -----------------------------------------------------------------------------
// COMASuplSettings::ConvertIAPNameToIdL
// 
// -----------------------------------------------------------------------------
TBool COMASuplSettings::ConvertIAPNameToIdL(const TDesC& aIAPName, TUint32& aIAPId)
	{
		TBool result = EFalse;
	
		CCommsDatabase* commDb = CCommsDatabase::NewL(EDatabaseTypeIAP);
		CleanupStack::PushL(commDb);
		CCommsDbTableView* tableView = commDb->OpenIAPTableViewMatchingBearerSetLC(ECommDbBearerCSD|ECommDbBearerGPRS,
											ECommDbConnectionDirectionOutgoing);
	   	TInt retval = tableView->GotoFirstRecord();
	   	while ((retval == KErrNone) && (!result))
	   	{
	      HBufC * iap_name = tableView->ReadLongTextLC( TPtrC( COMMDB_NAME) );

	      if (iap_name && (iap_name->Compare(aIAPName) == 0))
	        {
	           	tableView->ReadUintL(TPtrC(COMMDB_ID), aIAPId);
	            result = ETrue;
	       	}
	       CleanupStack::PopAndDestroy(); // iap_name
	       retval = tableView->GotoNextRecord();
	   	}
		CleanupStack::PopAndDestroy(2);//delete tableView and commDb
		return result;
	}
Exemplo n.º 14
0
TBool CConnectionManager::SetupConnection()
	{
		TInt iCurrentProfileId;    
		iBearerFilter = EApBearerTypeAllBearers;

		ASSERT(iRepository);

		// Check whether we are offline or online
		iRepository->Get(KProEngActiveProfile, iCurrentProfileId);
		
	    // Close the connection only if
	    // a) this is not the first time and
	    // b) the profile has changed and
	    // c) either the previous or the current profile is Offline (5 = Offline)
	    if (iPreviousProfileId != -1 && iPreviousProfileId != iCurrentProfileId &&
	            (iPreviousProfileId == EConnectionStatus::Disconnected || iCurrentProfileId == EConnectionStatus::Disconnected))
	    {
	        // Close and uninitialize
	        iConnectionSetup = EFalse;
	        iSessionHttp .Close();
	        iConnection  .Close();
	        iServerSocket.Close();
	    }

	    // Save current profile id
	    iPreviousProfileId = iCurrentProfileId;

	    // Try to find an existing connection. If connection has not been set up,
	    // iConnection is not initialized and FindExistingConnection() fails.
	    // Thus, in that case, finding must not be carried out.
	    if (iConnectionSetup && !FindExistingConnection())
	    {
	        iConnectionSetup = EFalse;
	    }

	    if (iConnectionSetup)
	    {
	        // Connection setup is done
	    	iNewConnection = EFalse;
	        return ETrue;
	    }

	    // Open RHTTPSession with default protocol ("HTTP/TCP")
	    iSessionHttp.OpenL();

	    // Install this class as the callback for authentication requests. When
	    // page requires authentication the framework calls GetCredentialsL to get
	    // user name and password.
	    InstallAuthenticationL(iSessionHttp);

	    // In offline, only WLAN connections are available
	    if (iCurrentProfileId == EConnectionStatus::Disconnected)
	    {
	        iBearerFilter = EApBearerTypeWLAN;
	    }

	    // Show IAP selection dialog
	    /*CActiveApDb* aDb = CActiveApDb::NewL();
	    CleanupStack::PushL(aDb);

	    CApSettingsHandler* settings = CApSettingsHandler::NewLC
	        (
	           *aDb
	         , ETrue
	         , EApSettingsSelListIsPopUp
	         , EApSettingsSelMenuSelectNormal
	         , KEApIspTypeAll
	         , iBearerFilter
	         , KEApSortNameAscending
	         , 0
	         , EVpnFilterBoth
	         , ETrue
	        );

	    TInt iapRet = settings->RunSettingsL(0, iSelectedConnectionId);
	    CleanupStack::PopAndDestroy(settings);
	    CleanupStack::PopAndDestroy(aDb);

	    if (iapRet != KApUiEventSelected)
	    {
	        // Exit no selection
	        User::Leave(KErrNotReady);
	    }
	    else*/

	    // open the IAP communications database 
		CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
		CleanupStack::PushL(commDB);

		// initialize a view 
		CCommsDbConnectionPrefTableView* commDBView = 
		commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionUnknown);

		// go to the first record 
		User::LeaveIfError(commDBView->GotoFirstRecord());

		CCommsDbConnectionPrefTableView::TCommDbIapBearer bearer;
		bearer.iBearerSet = iBearerFilter;
		
		// Declare a prefTableView Object.
		CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;

		pref.iBearer = bearer;
		pref.iDirection = ECommDbConnectionDirectionOutgoing;
		
		// read the connection preferences 
		commDBView->ReadConnectionPreferenceL(pref);

		iSelectedConnectionId = pref.iBearer.iIapId; 
		
		// pop and destroy the IAP View 
		CleanupStack::PopAndDestroy(commDBView);

		// pop and destroy the database object
		CleanupStack::PopAndDestroy(commDB);

    	iNewConnection = ETrue;
    	
        // IAP Selected
        // Open socket server and start the connection
        User::LeaveIfError(iServerSocket.Connect(KESockDefaultMessageSlots));
        User::LeaveIfError(iConnection.Open(iServerSocket, KConnectionTypeDefault));
        // Now we have the iap Id. Use it to connect for the connection
        TCommDbConnPref connectPref;
        // Setup preferences 
        connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
        // Sets the CommDb ID of the IAP to use for this connection
        connectPref.SetIapId(iSelectedConnectionId);
        // Sets direction
        connectPref.SetDirection(ECommDbConnectionDirectionOutgoing);
        
        connectPref.SetBearerSet(iBearerFilter);
        
        // Start connection
        User::LeaveIfError(iConnection.Start(connectPref));
        
        //TInt retval = iConnection.Start();
        //User::LeaveIfError(retval);
	        
        // Set the sessions connection info...
        RStringPool strPool = iSessionHttp.StringPool();
        RHTTPConnectionInfo connInfo = iSessionHttp.ConnectionInfo();
        // ...to use our socket server and connection
        connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketServ, RHTTPSession::GetTable()), THTTPHdrVal (iServerSocket.Handle()));
        // ...to use our connection
        connInfo.SetPropertyL(strPool.StringF(HTTP::EHttpSocketConnection, RHTTPSession::GetTable()), THTTPHdrVal (REINTERPRET_CAST(TInt, &(iConnection))));

        iConnectionSetup = ETrue;
	
	    return ETrue;
}
Exemplo n.º 15
0
// ----------------------------------------------------------------------------
// CClientEngine::SetupConnectionL()
//
// The method set the internet access point and connection setups.
// ----------------------------------------------------------------------------	
void CClientEngine::SetupConnectionL()
    {
    if( iConnectionSetupDone )
        return;
    
    iConnectionSetupDone = ETrue;
    //open socket server and start the connection
    User::LeaveIfError(iSocketServ.Connect());
    User::LeaveIfError(iConnection.Open(iSocketServ));
    
    TCommDbConnPref connectPref;
    TUint32 iapID;

    if(iSetIap == EFalse)
	{
    // open the IAP communications database 
	CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
	CleanupStack::PushL(commDB);

	// initialize a view 
	CCommsDbConnectionPrefTableView* commDBView = 
	commDB->OpenConnectionPrefTableInRankOrderLC(ECommDbConnectionDirectionUnknown);

	// go to the first record 
	User::LeaveIfError(commDBView->GotoFirstRecord());

	// Declare a prefTableView Object.
	CCommsDbConnectionPrefTableView::TCommDbIapConnectionPref pref;
	// read the connection preferences 
	commDBView->ReadConnectionPreferenceL(pref);

	iapID = pref.iBearer.iIapId;

	// pop and destroy the IAP View 
	CleanupStack::PopAndDestroy(commDBView);

	// pop and destroy the database object
	CleanupStack::PopAndDestroy(commDB);

	// setup preferences 
	connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
	connectPref.SetDirection(ECommDbConnectionDirectionUnknown);
	connectPref.SetBearerSet(ECommDbBearerGPRS);
	//Sets the CommDb ID of the IAP to use for this connection
	connectPref.SetIapId(iapID);
	}else{
	connectPref.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
	connectPref.SetDirection(ECommDbConnectionDirectionUnknown);
	connectPref.SetBearerSet(ECommDbBearerGPRS);
	//Sets the CommDb ID of the IAP to use for this connection
	connectPref.SetIapId(iIapId);
	}
    
    User::LeaveIfError(iConnection.Start(connectPref));
	
    //set the sessions connection info
    RStringPool strPool = iSession.StringPool();
    RHTTPConnectionInfo connInfo = iSession.ConnectionInfo();
    
    //to use our socket server and connection
    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketServ,
        RHTTPSession::GetTable() ), THTTPHdrVal (iSocketServ.Handle()) );

    connInfo.SetPropertyL ( strPool.StringF(HTTP::EHttpSocketConnection,
        RHTTPSession::GetTable() ), 
        THTTPHdrVal (REINTERPRET_CAST(TInt, &(iConnection))) );
    }
Exemplo n.º 16
0
   bool GetProxy( char*& aHost, uint32& aPort, const int32 aIAP )
   { 
# ifdef NAV2_CLIENT_SERIES60_V2
      CCommsDatabase * comdb = CCommsDatabase::NewL();
# else
      CCommsDatabase * comdb = CCommsDatabase::NewL( EDatabaseTypeUnspecified );
# endif
      CleanupStack::PushL( comdb );
   
      // First get the IAP
      CCommsDbTableView* iaptable = comdb->OpenViewMatchingUintLC( TPtrC( IAP ), 
                                                                TPtrC( COMMDB_ID ), aIAP );
      TInt iapres = iaptable->GotoFirstRecord();
      bool found = false;
      if ( iapres == KErrNone ) {
         HBufC* iap_name = iaptable->ReadLongTextLC( TPtrC( COMMDB_NAME) );
         uint32 iap_service = 0;
         iaptable->ReadUintL( TPtrC( IAP_SERVICE ), iap_service );
            
         // The current IAP exists!
         HBufC* iap_type = iaptable->ReadLongTextLC( TPtrC( IAP_SERVICE_TYPE ) );
      
         // Find Proxy for ISP (and same service type)
         CCommsDbTableView* proxytable = comdb->OpenViewMatchingUintLC( TPtrC( PROXIES ), 
                                                                     TPtrC( PROXY_ISP ), iap_service );
         TInt dretval= proxytable->GotoFirstRecord();
         while ( dretval == KErrNone && !found ) {
            // Check if matching proxy service type
            HBufC* proxy_service_type = proxytable->ReadLongTextLC( TPtrC( PROXY_SERVICE_TYPE ) );
            if ( proxy_service_type != NULL &&
               proxy_service_type->CompareC( *iap_type ) == 0 ) 
            {
               // Match!
               // PROXY_USE_PROXY_SERVER 
               TBool proxy_use_proxy_server = 0;
               proxytable->ReadBoolL( TPtrC( PROXY_USE_PROXY_SERVER ), proxy_use_proxy_server );
# ifdef NAV2_CLIENT_SERIES60_V2
               if ( proxy_use_proxy_server ) {
# endif
               // PROXY_SERVER_NAME - Name of the proxy server
               HBufC* proxy_server_name = proxytable->ReadLongTextLC( 
               TPtrC( PROXY_SERVER_NAME ) );
               if ( proxy_server_name ) {
                  found = true;
                  // Convert to something we can use.
                  aHost = WFTextUtil::TDesCToUtf8L( proxy_server_name->Des() );
                  proxytable->ReadUintL( TPtrC( PROXY_PORT_NUMBER ), aPort );
               
                  // Sanity on port
                  if ( aPort == 9201 ) {
                     // We don't talk wap
                     // XXX: Or no proxy at all?
                     aPort = 8080;
                  } else if ( aPort == 0 ) {
                     // Not valid => no proxy
                     found = false;
                     delete [] aHost;
                     aHost = NULL;
                  }
               } // End if have proxy_server_name
                     
               CleanupStack::PopAndDestroy( proxy_server_name );
# ifdef NAV2_CLIENT_SERIES60_V2
               } // End if proxy_use_proxy_server is true
# endif
            } // End if service type matches
            CleanupStack::PopAndDestroy( proxy_service_type );
            dretval = proxytable->GotoNextRecord(); // next proxy
         } // End while all proxies

         // XXX: Perhaps "IAP_SERVICE_TYPE" table -> [GPRS|ISP]_IP_GATEWAY 
         // especially in s60v1
         CleanupStack::PopAndDestroy( proxytable );
         CleanupStack::PopAndDestroy( iap_type );
         CleanupStack::PopAndDestroy( iap_name );
      } // End if the current IAP is found
      
      CleanupStack::PopAndDestroy( iaptable );
      CleanupStack::PopAndDestroy( comdb );
     
      return found;   
   }
Exemplo n.º 17
0
void CIAPSettingItem::CompleteConstructionL()
{
   _LIT(KmRouter, "mroute");

   CArrayPtr<CAknEnumeratedText> * iaps = new(ELeave) CArrayPtrSeg<CAknEnumeratedText>(10);
   CleanupStack::PushL(iaps);
   CArrayPtr<HBufC> * poppedUp = new(ELeave) CArrayPtrSeg<HBufC>(10);
   CleanupStack::PushL(poppedUp);

   CAknEnumeratedTextPopupSettingItem::CompleteConstructionL();

   // The selection of IAP that indicates "always ask"
   HBufC * buf;
   buf = CEikonEnv::Static()->AllocReadResourceL( R_SETTINGS_IAP_ALWAYS_ASK );
   iaps->AppendL(new(ELeave) CAknEnumeratedText(-1, buf ));
   // The selection of IAP that indicates "system default is only shown in
   // development mode, not in release mode.
   if ( ! iRelease ) {
      buf = CEikonEnv::Static()->AllocReadResourceL( R_SETTINGS_IAP_SYSTEM_DEFAULT );
      iaps->AppendL(new(ELeave) CAknEnumeratedText(-2, buf ));
   }


#ifdef NAV2_CLIENT_SERIES60_V2
   CCommsDatabase * comdb = CCommsDatabase::NewL();
#else
   CCommsDatabase * comdb = CCommsDatabase::NewL(EDatabaseTypeUnspecified);
#endif
   CleanupStack::PushL(comdb);
   CCommsDbTableView * iaptable = comdb->OpenTableLC( TPtrC( IAP ) );

   TInt retval;
   retval = iaptable->GotoFirstRecord();

   // display all IAPs except mrouter
   while (retval == KErrNone) {
      HBufC * iap_name = iaptable->ReadLongTextLC( TPtrC( COMMDB_NAME) );
      if ( KErrNotFound == iap_name->FindF(KmRouter) ) {
         TUint32 iap_id;
         iaptable->ReadUintL( TPtrC( COMMDB_ID), iap_id );
         iaps->AppendL(new(ELeave) CAknEnumeratedText(iap_id, iap_name ));
      }
      CleanupStack::Pop(iap_name);   // FIXME - Is this right? Does AppendL take over ownership of the iap name?
      retval = iaptable->GotoNextRecord();
   }

   CleanupStack::PopAndDestroy(iaptable);
   CleanupStack::PopAndDestroy(comdb);

   SetEnumeratedTextArrays(iaps, poppedUp);
   CleanupStack::Pop(poppedUp);
   CleanupStack::Pop(iaps);

   // Does the (old) specified iap still exist? Default to 
   // "always ask" otherwise.
   if (IndexFromValue(ExternalValue()) < 0) {
      SetInternalValue(-1);
      SetExternalValue(-1);
   }


}