void CPodcastModel::GetProxyInformationForConnectionL(TBool& aIsUsed, HBufC*& aProxyServerName, TUint32& aPort) { TInt iapId = GetIapId(); CCommsDbTableView* table = iCommDB->OpenViewMatchingUintLC(TPtrC(IAP), TPtrC(COMMDB_ID), iapId); TUint32 iapService; HBufC* iapServiceType; table->ReadUintL(TPtrC(IAP_SERVICE), iapService); iapServiceType = table->ReadLongTextLC(TPtrC(IAP_SERVICE_TYPE)); CCommsDbTableView* proxyTableView = iCommDB->OpenViewOnProxyRecordLC(iapService, *iapServiceType); TInt err = proxyTableView->GotoFirstRecord(); if( err != KErrNone) { User::Leave(KErrNotFound); } proxyTableView->ReadBoolL(TPtrC(PROXY_USE_PROXY_SERVER), aIsUsed); if(aIsUsed) { HBufC* serverName = proxyTableView->ReadLongTextLC(TPtrC(PROXY_SERVER_NAME)); proxyTableView->ReadUintL(TPtrC(PROXY_PORT_NUMBER), aPort); aProxyServerName = serverName->AllocL(); CleanupStack::PopAndDestroy(serverName); } CleanupStack::PopAndDestroy(proxyTableView); CleanupStack::PopAndDestroy(iapServiceType); CleanupStack::PopAndDestroy(table); }
/** * 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); }
TInt CCommDbTest036_08::executeStepL() { CCommsDbTemplateRecord* templateRecord = CCommsDbTemplateRecord::NewL(iTheDb, TPtrC(DIAL_IN_ISP)); CleanupStack::PushL(templateRecord); User::LeaveIfError(templateRecord->Modify()); TBool inputBool = ETrue; templateRecord->WriteTextL(TPtrC(COMMDB_NAME), _L("Name")); // templateRecord->WriteTextL(TPtrC(ISP_IF_NAME), _L("SLIP")); templateRecord->WriteBoolL(TPtrC(ISP_IP_ADDR_FROM_SERVER), ETrue); templateRecord->WriteBoolL(TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER), ETrue); templateRecord->WriteBoolL(TPtrC(ISP_IP6_DNS_ADDR_FROM_SERVER), ETrue); templateRecord->WriteBoolL(TPtrC(ISP_USE_LOGIN_SCRIPT), inputBool); //Set to ETrue, since EFalse is default User::LeaveIfError(templateRecord->StoreModifications()); CleanupStack::PopAndDestroy(templateRecord); //Create a view on the DialInISP table, make a new record and change the value we set in the template CCommsDbTableView* tableView = iTheDb->OpenTableLC(TPtrC(DIAL_IN_ISP)); TUint32 dummyId; //Create a new record, so we can be sure it is the same as the templated one User::LeaveIfError(tableView->InsertRecord(dummyId)); tableView->WriteTextL(TPtrC(COMMDB_NAME), _L("Test ISP")); // tableView->WriteTextL(TPtrC(ISP_IF_NAME), _L("Test If")); tableView->WriteBoolL(TPtrC(ISP_IP_ADDR_FROM_SERVER), EFalse); tableView->WriteBoolL(TPtrC(ISP_IP_DNS_ADDR_FROM_SERVER), EFalse); tableView->WriteBoolL(TPtrC(ISP_IP6_DNS_ADDR_FROM_SERVER), EFalse); //Overwrite the value set in the template TBool overwriteBool = EFalse; tableView->WriteBoolL(TPtrC(ISP_USE_LOGIN_SCRIPT), overwriteBool); User::LeaveIfError(tableView->PutRecordChanges()); //Retrieve the bool we just set for the record TBool retrievedBool; tableView->ReadBoolL(TPtrC(ISP_USE_LOGIN_SCRIPT), retrievedBool); CleanupStack::PopAndDestroy(tableView); if(retrievedBool!=overwriteBool) return KErrGeneral; return KErrNone; }
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; }
/** * Check the current retrieved Contact Point, contained in * iContactPoint, to check that the connection details are * valid for a connection-oriented Push session. If the * iContactPoint passes the tests iConnPoint is set and * this value will be used for opening a connection. * @return TBool * Returns True if ContactPoint is valid * retruns False if invalid contact point * @leave CCommsDatabase::OpenViewMatchingTextLC * CommDb methods can Leave - so just propogate * as can't verfiy address and security. * @leave CCommsDbTableView::ReadBoolL */ TBool CSIAContentHandler::ValidContactPointL() { __LOG_PTR_DEBUG("CSIAContentHandler:: ValidContactPointL Called"); TBool valid = ETrue; TUint index = 0; // check first bit of first byte to see if bearer Type present TUint8 byte = iContactPoint[index]; index++; // will be zero if flag not set - non-zero overwise TUint8 bearerFlagPresent = STATIC_CAST(TUint8, byte & KBearerFlagBitMask); TUint8 portFlagPresent = STATIC_CAST(TUint8, byte & KPortFlagBitMask); // mask off 1st two bits to get the 6 bits representing address length TUint8 addressLength = STATIC_CAST(TUint8, byte & KAddressLengthBitMask); //check bearer type if (bearerFlagPresent) { byte = iContactPoint[index]; index++; if ((byte != KCSDBearer) && (byte != KGPRSBearer)) { // unsupported bearer __LOG_PTR_DEBUG("CSIAContentHandler: unsupported Bearer Type"); valid = EFalse; return valid; } } //set postion of the first byte of the port TUint portStartByte = index; // get address if (portFlagPresent) index += 2; TPtrC8 address; address.Set(iContactPoint.Mid(index, addressLength)); //Look up supplied address in commsdb. Leave possible from here on in... TPtrC KTableName(WAP_IP_BEARER); TPtrC KColumnName(WAP_GATEWAY_ADDRESS); TPtrC KSecurityCol(WAP_SECURITY); CCommsDbTableView* table = iCommDb->OpenViewMatchingTextLC(KTableName, KColumnName, address); TInt ret = table->GotoFirstRecord(); if (ret == KErrNone) //address found { __LOG_PTR_DEBUG("CSIAContentHandler:: Commdb lookup"); // set port number, using the following logic: // 1. if port number supplied, use it with an unsecure security setting // 2. if no port supplied, use the default port for the security setting // returned by the commsdb address lookup TUint16 port; if (portFlagPresent) { TUint8 portNumHighByte = iContactPoint[portStartByte]; TUint8 portNumlowByte = iContactPoint[portStartByte + 1]; port = STATIC_CAST(TUint16, ((portNumHighByte<<8)|portNumlowByte)); } else { TBool secure; table->ReadBoolL(KSecurityCol, secure); if (secure) port = KPushPortSecure; else port = KPushPortUnsecure; } //set connection point iConnPoint.iHost = address; iConnPoint.iPort = port; } else //address lookup failed { valid = EFalse; __LOG_PTR_DEBUG("CSIAContentHandler:: Commdb lookup failed"); } CleanupStack::PopAndDestroy(); // table // will only return true if not SMS and address in CommDB return valid; }