亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? wlansampleexappui.cpp

?? 基于symbian平臺的Wlan創建
?? CPP
字號:
/* ====================================================================
 * File: WLanSampleExAppUi.cpp
 * Created: 01/19/07
 * Author: 
 * Copyright (c):  All rights reserved
 * ==================================================================== */

#include <avkon.hrh>
#include <rconnmon.h>
#include <apaccesspointitem.h> 
#include <apdatahandler.h> 
#include <CommDbConnPref.h>
#include <apselect.h>
#include <wlancdbcols.h>
#include <wlanmgmtclient.h> 
#include <in_sock.h>

#include "WLanSampleEx.pan"
#include "WLanSampleExAppUi.h"
#include "WLanSampleExAppView.h"
#include "WLanSampleEx.hrh"

// ConstructL is called by the application framework
void CWLanSampleExAppUi::ConstructL()
    {
    BaseConstructL(EAknEnableSkin);

    iAppView = CWLanSampleExAppView::NewL(ClientRect());
    
    AddToStackL(iAppView);
    }

CWLanSampleExAppUi::CWLanSampleExAppUi()                              
    {
	// no implementation required
    }

CWLanSampleExAppUi::~CWLanSampleExAppUi()
    {
    if (iAppView)
        {
        RemoveFromStack(iAppView);
        delete iAppView;
        iAppView = NULL;
        }
       
        iConnection.Close();
        iServer.Close();
    }

// handle any menu commands
void CWLanSampleExAppUi::HandleCommandL(TInt aCommand)
    {
    switch(aCommand)
        {
        case EEikCmdExit:
        case EAknSoftkeyExit:
            Exit();
            break;

        case EWLanSampleExCommand1:
            {
            NetworkNameL();
			}
            break;
            
        case EWLanSampleExCommand2:
            {
            ScanNetworksL();
            }
            break;
		case EWLanSampleExCommand3:
            {
            CreateAccessPointL();
            }
            break;
       	case EWLanSampleExCommand4:
	        {
	        EstablishConnectionL();
            }
	        
        	break;
        case EWLanSampleExCommand5:
	        {
	        GetMacAddressL();		
			}
	        break;
		case EWLanSampleExCommand6:
	        {
	        GetIpAddressL();
		    }
		    break;
	   	case EWLanSampleExCommand7:
	        {
	        GetCurrentSignalStrengthL();
		    }
		break; 
		default:
		   Panic(EWLanSampleExBasicUi);
		    break;
	}
  }

// ----------------------------------------------------------------------------
//  CWLanSampleExAppUi::CreateAccessPointL()
//  Creates a sample wlan access point with security settings
// ----------------------------------------------------------------------------
//

void CWLanSampleExAppUi::CreateAccessPointL()
	{
	TInt errorCode;
	TInt error;
	CCommsDatabase* db = CCommsDatabase::NewL();
	CleanupStack::PushL(db);
	TInt err = db->BeginTransaction();

	// Create a wlan AP and fill its mandatory fields.
	CApAccessPointItem* wlanAp = CApAccessPointItem::NewLC();
	CApAccessPointItem* wlanNewItem=CApAccessPointItem::NewLC();


	wlanAp->SetNamesL(_L("wcdma"));
	wlanAp->SetBearerTypeL(EApBearerTypeWLAN);
	wlanAp->WriteTextL(EApWlanNetworkName, _L("L!nkSys@MdpNok!a"));  // Give corrct Data as per the router configuration  //L!nkSys@MdpNok!a

	//Security mode should be 2 for WEP network 
	//1 for Open network
	//4 for  E802_1x     
	//8 for EWpa 
	//16 for EWpa2  
	wlanAp->WriteUint(EApWlanSecurityMode,2);

	//Lan network mode should be 1 for infrastructure, 0 for adhoc
	wlanAp->WriteUint(EApWlanNetworkMode,1);


	// Store it into the iDb.
	TBool val =ETrue;
	TUint32 newalanid;

	CApDataHandler* handler = CApDataHandler::NewLC(*db);
	TUint32 apid;
	apid = handler->CreateFromDataL(*wlanAp);
	handler->UpdateAccessPointDataL(*wlanAp,val);
	handler->AccessPointDataL(apid,*wlanNewItem); 
	wlanNewItem->ReadUint( EApIapServiceId, newalanid );
	wlanNewItem->ReadTextL( EApWlanNetworkName, ibuff ); 
	   
	TBuf8<50> keyData;

	keyData.Copy(_L("5F89AE0A3B9D5C1123F81F0A41")); // Give corrct Data as per the router configuration 

	CCommsDbTableView* wLanServiceTable = db->OpenViewMatchingUintLC( 
	TPtrC( WLAN_SERVICE ), TPtrC( WLAN_SERVICE_ID ), newalanid );
	errorCode = wLanServiceTable->GotoFirstRecord();
			 
		
	if ( errorCode == KErrNone )
	     {
			 wLanServiceTable->UpdateRecord();
		 }
	else
		 {
			TUint32 dummyUid( KUidNone );
			User::LeaveIfError( wLanServiceTable->InsertRecord( dummyUid ) );
			// Save link to LAN service
			wLanServiceTable->WriteUintL( TPtrC( WLAN_SERVICE_ID ), apid );
		 }
		 
	 
	// Save first WEP key
	TRAP(error,wLanServiceTable->WriteTextL( TPtrC( WLAN_WEP_KEY1 ), 
	                      keyData ));
	// Save second WEP key
	TRAP(error,wLanServiceTable->WriteTextL( TPtrC( WLAN_WEP_KEY2 ), 
	                      keyData ));
	// Save third WEP key
	TRAP(error,wLanServiceTable->WriteTextL( TPtrC( WLAN_WEP_KEY3 ), 
	                      keyData ));
	// Save fourth WEP key
	TRAP(error,wLanServiceTable->WriteTextL( TPtrC( WLAN_WEP_KEY4 ), 
	                      keyData ));
	                      
	wLanServiceTable->PutRecordChanges();
	err = db->CommitTransaction();    //	// End a transaction. Call after `InsertRecord()` or `UpdateRecord()`.
	CleanupStack::PopAndDestroy(5);

	}


// ----------------------------------------------------------------------------
//  CWLanSampleExAppUi::ScanNetworksL()
//  Scans the available WLAN network and finds the security mode and
//  the network mode and BSSID
// ----------------------------------------------------------------------------
//
void CWLanSampleExAppUi::ScanNetworksL()
	{

	TBuf<10> infoBuff;
	TInt securityMode;
	CWlanScanInfo* scanInfo=CWlanScanInfo::NewL();
	CleanupStack::PushL(scanInfo);
	CWlanMgmtClient* client=CWlanMgmtClient::NewL();
	CleanupStack::PushL(client);
	TInt i=1;
	client->GetScanResults(*scanInfo);	

	for(scanInfo->First(); !scanInfo->IsDone(); scanInfo->Next() )
		{
		ibuff.Zero();
		ibuff.AppendNum(i);
		CEikonEnv::InfoWinL(_L("Network"),ibuff);
		i++;
		securityMode=scanInfo->SecurityMode();

		if(securityMode==0)
			{
			CEikonEnv::InfoWinL(_L("SecurityMode"),_L("Open"));
			}

		else if(securityMode==1)
			{
			CEikonEnv::InfoWinL(_L("SecurityMode"),_L("WEP Mode"));
			}
		else if(securityMode==2)
			{
			CEikonEnv::InfoWinL(_L("SecurityMode"),_L("802d1x Mode"));
			}

		else if(securityMode==3)
			{
			CEikonEnv::InfoWinL(_L("SecurityMode"),_L("WPA"));
			}

		//In general if the least significant bit of the capbility field 
		//is 1 then the network is of "Infrastructure Type" or else if the 
		//capability field is 0 then the network is of "Ad-hoc type"

		TUint16 capability=scanInfo->Capability();

		TInt pad(1);
		TInt lanType=capability & pad;
		
		if(lanType==1)
			CEikonEnv::InfoWinL(_L("Network mode"),_L("Infrastructure"));
		else
			CEikonEnv::InfoWinL(_L("Network mode"),_L("Adhoc"));
			infoBuff.Zero();

		TWlanBssid bssid;
		scanInfo->Bssid( bssid );
		ibuff.Zero();
		ibuff.Copy(bssid);
		CEikonEnv::InfoWinL(_L("BSSID"),ibuff);
		}
		CleanupStack::PopAndDestroy(2);
}


// ----------------------------------------------------------------------------
//  CWLanSampleExAppUi::NetworkNameL()
//  Gets the available WLAN network name and its strength
// ----------------------------------------------------------------------------
//

void CWLanSampleExAppUi::NetworkNameL()
	{
	TPckgBuf<TConnMonNetworkNames> networks;
	RConnectionMonitor monitor;
	monitor.ConnectL();
	CleanupClosePushL(monitor);
	TRequestStatus status;
	monitor.GetPckgAttribute(EBearerIdWLAN, 0, KNetworkNames , networks, status);   // EBearerIdWLAN  KNetworkNames
	User::WaitForRequest(status ) ;
	User::LeaveIfError(status.Int());
	TBuf<20> ibuff;
	TInt count = networks().iCount;
	ibuff.Zero();
	ibuff.AppendNum(count);
	CEikonEnv::InfoWinL(ibuff,_L("Total Network found"));

	for(TInt i=0;i<count;i++)
		{
		TBuf8<32> ssid; 
		ssid.Copy( networks().iNetwork[i].iName );
		ibuff.Zero();
		ibuff.Copy(ssid);
		CEikonEnv::InfoWinL(_L("Network Name"),ibuff); 
		TUint8 iSignal = networks().iNetwork[i].iSignalStrength;
		ibuff.Zero();
		ibuff.AppendNum(iSignal);
		CEikonEnv::InfoWinL(_L("Network Signal"),ibuff); 

		}
	CleanupStack::PopAndDestroy();

	}

// ----------------------------------------------------------------------------
//  CWLanSampleExAppUi::GetMacAddressL()
//  Gets the MAC address of the WLAN device
// ----------------------------------------------------------------------------
//
void CWLanSampleExAppUi::GetMacAddressL()
	{
	// MAC address	of the WLAN device
	RSocketServ socketServ;
	User::LeaveIfError(socketServ.Connect());
	CleanupClosePushL(socketServ);
	// Open a socket
	RSocket socket;
	User::LeaveIfError(socket.Open(socketServ,

									KAfInet,

									KSockStream,

									KProtocolInetTcp));                         

	CleanupClosePushL(socket);   

	// Start enumerating the interfaces
	TPckgBuf<TSoInetInterfaceInfo> info;
	socket.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl);
	TBuf<32> macAddr;
	while(socket.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, info) == KErrNone)
		{
		if(info().iName.FindF(_L("Wlan")) == KErrNotFound)
		{
			continue;
		}
		macAddr.Zero();
		for( TUint i = sizeof(SSockAddr) ; i < sizeof(SSockAddr) + 6 ; i++ )
			{
				if(i < (TUint)info().iHwAddr.Length())
				{
				macAddr.AppendFormat(_L("%02X:"), info().iHwAddr[i]);
				}
				
			}
		if(macAddr.Length()) // remove trailing ':'
			{
			macAddr.Delete(macAddr.Length()-1, 1);            
			}
	
		}
		CEikonEnv::InfoWinL(_L("MAC address"),macAddr);
		CleanupStack::PopAndDestroy(2);

				
	}
    
 
// ----------------------------------------------------------------------------
//  CWLanSampleExAppUi::GetIpAddressL()
//  Gets the IP address of the WLAN iConnection. Works only if there is a wlan iConnection established 
// ----------------------------------------------------------------------------
//
    
void CWLanSampleExAppUi::GetIpAddressL()
	{
		if(iConnState)
		{
		// ip address of the current iConnection call after establish a iConnection
		// The last in the loop is the current IP address
		// To be called after the iConnection is established or else it panics
		RSocketServ socketServ;
		socketServ.Connect();
		CleanupClosePushL(socketServ);
		RSocket sock;
		User::LeaveIfError(sock.Open(socketServ, KAfInet, KSockStream, KProtocolInetTcp));
		CleanupClosePushL(sock);
		// Get the IAP id of the underlying interface of this RConnection
		TUint32 iapId = 0;
		User::LeaveIfError(iConnection.GetIntSetting(_L("IAP\\Id"), iapId));

		// Get IP information from the socket
		TSoInetInterfaceInfo ifinfo;
		TPckg<TSoInetInterfaceInfo> ifinfopkg(ifinfo);

		TSoInetIfQuery ifquery;
		TPckg<TSoInetIfQuery> ifquerypkg(ifquery);

		// To find out which interfaces are using our current IAP, we must 
		// enumerate and go through all of them and make a query by name
		// for each.
		User::LeaveIfError(sock.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl));
		while(sock.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, ifinfopkg) == KErrNone)
			{
			ifquery.iName = ifinfo.iName;
			TInt err = sock.GetOpt(KSoInetIfQueryByName, KSolInetIfQuery, ifquerypkg);

			if(err == KErrNone && ifquery.iZone[1] == iapId) // IAP ID is index 1 of iZone
			{
			// We have found an interface using the IAP we are interested in.
			if(ifinfo.iAddress.Address() > 0)
			{
			// found a IPv4 address
			TInetAddr aAddr = ifinfo.iAddress;
			ibuff.Zero();
			aAddr.Output(ibuff);
			
			} // while

			}
			else if(err != KErrNone)
			{

			}
			}
			CEikonEnv::InfoWinL(ibuff,_L("IP address"));
			CleanupStack::PopAndDestroy(2);
		}
		else
			CEikonEnv::InfoWinL(_L("Establish connection first"),_L(""));
	}
	
// ----------------------------------------------------------------------------
//  CWLanSampleExAppUi::EstablishConnectionL()
//  Establishes WLAN connection with the last wlan access point from the access point list
// ----------------------------------------------------------------------------
//
 
void CWLanSampleExAppUi::EstablishConnectionL()
	{
	// establishes iConnection with the last wlan access point.
	// It also lists all the available access point
	TUint32 accessPoint(0);
	CCommsDatabase* commDB = CCommsDatabase::NewL(EDatabaseTypeIAP);
	CleanupStack::PushL(commDB);
	CApSelect * iSelect =CApSelect::NewLC(*commDB,KEApIspTypeAll,EApBearerTypeWLAN,KEApSortUidAscending);
	TBuf<50> iName;
	TBool move = iSelect->MoveToFirst();
	TInt icount = 0;
	while(icount<iSelect->Count())
		{
		if(move==TRUE) 
			{
			iName =iSelect->Name();
			accessPoint=iSelect->Uid();
			
			}
		move = iSelect->MoveNext();
		icount=icount+1;
		}
	CEikonEnv::InfoWinL(_L("Using"),iName);	 
	User::LeaveIfError(iServer.Connect(KESockDefaultMessageSlots));
	User::LeaveIfError(iConnection.Open(iServer, KConnectionTypeDefault));
	TCommDbConnPref prefs;
	prefs.SetDialogPreference(ECommDbDialogPrefDoNotPrompt);
	prefs.SetDirection(ECommDbConnectionDirectionOutgoing);
	prefs.SetIapId(accessPoint);
	User::LeaveIfError(iConnection.Start(prefs));
	iConnState = ETrue;
	CleanupStack::PopAndDestroy(2);
	}


// ----------------------------------------------------------------------------
//  CWLanSampleExAppUi::GetCurrentSignalStrengthL()
//  Get the signal strength of the currently established iConnection 
// 	To be called after the iConnection is established or else it panics
// ----------------------------------------------------------------------------
//
 void CWLanSampleExAppUi::GetCurrentSignalStrengthL()
	{
	RConnectionMonitor monitor;
	monitor.ConnectL();
	CleanupClosePushL(monitor);
	TRequestStatus status;
	TInt32 iSignalStrength;

	TUint iCount;
	monitor.GetConnectionCount(iCount,status);
	User::WaitForRequest(status ) ;
	User::LeaveIfError(status.Int());

	TBuf<20> ibuff;
	TUint connectId;
	TUint subId;		
	monitor.GetConnectionInfo(iCount,connectId,subId);
	monitor.GetIntAttribute(connectId,0 , KSignalStrength , (TInt &)iSignalStrength, status);		 // EBearerIdWLAN  KNetworkNames
	User::WaitForRequest(status ) ;

	ibuff.Zero();
	ibuff.AppendNum(iSignalStrength);
	CEikonEnv::InfoWinL(ibuff,_L("Signal1"));

	User::LeaveIfError(status.Int());
	CleanupStack::PopAndDestroy();
	}

// End of file

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久er99精品| 国产精品三级在线观看| 日韩电影免费在线观看网站| 欧美专区亚洲专区| 日本在线播放一区二区三区| 555夜色666亚洲国产免| 99久久精品免费观看| 免费日本视频一区| 午夜免费久久看| 欧美综合天天夜夜久久| 亚洲高清不卡在线| 日韩三级精品电影久久久| 国产综合久久久久久鬼色 | 91影院在线免费观看| 精品国产乱码久久久久久蜜臀| 久久99久久精品| 国产欧美久久久精品影院| 91日韩一区二区三区| 亚洲va韩国va欧美va| 欧美精品一区二区三区一线天视频 | 欧美精品 国产精品| 亚洲一区中文日韩| 日韩精品中文字幕在线不卡尤物| 国产精品正在播放| 亚洲乱码中文字幕| 欧美不卡一区二区三区四区| 国产成都精品91一区二区三| 亚洲亚洲人成综合网络| 欧美精品一区二区三区视频| 91老师片黄在线观看| 久久se这里有精品| 亚洲欧美一区二区在线观看| 69堂亚洲精品首页| 99热99精品| 国内外成人在线视频| 亚洲一区二区欧美| 国产亚洲欧洲一区高清在线观看| 欧美午夜在线一二页| 国产激情一区二区三区四区| 亚洲一卡二卡三卡四卡| 国产无人区一区二区三区| 欧美日韩一级大片网址| 成人av午夜电影| 久草这里只有精品视频| 亚洲一区在线观看免费| 国产精品家庭影院| 精品国产乱码久久久久久闺蜜 | 国产日韩欧美精品电影三级在线| 欧美三级乱人伦电影| 国产xxx精品视频大全| 日本不卡视频在线观看| 亚洲自拍偷拍图区| 国产精品久久久久久久久晋中| 日韩欧美www| 欧美日韩欧美一区二区| 成人视屏免费看| 国产在线播精品第三| 日韩电影一区二区三区四区| 一区二区三区免费观看| 国产精品美女久久久久久| 精品免费视频一区二区| 欧美一区二区三区四区高清| 欧美性猛片xxxx免费看久爱| 97se狠狠狠综合亚洲狠狠| 国产精品一区二区久激情瑜伽| 蜜臀精品久久久久久蜜臀| 亚洲国产cao| 亚洲福利一区二区三区| 亚洲一区二区中文在线| 亚洲综合免费观看高清完整版 | 日韩美女视频在线| 91精品国产手机| 欧美日韩精品一区二区三区| 欧美色中文字幕| 欧美伊人久久久久久久久影院| 97久久超碰国产精品电影| 成人av在线影院| 精品久久人人做人人爱| 福利一区在线观看| 国产毛片精品国产一区二区三区| 久久机这里只有精品| 日韩电影一二三区| 久久99国产精品免费网站| 麻豆成人av在线| 激情亚洲综合在线| 国产一区二区三区高清播放| 国产一区二区三区香蕉| 成人小视频免费在线观看| 成人国产精品免费观看动漫| 91亚洲国产成人精品一区二区三 | 一区二区在线看| 亚洲最新视频在线观看| 午夜视频一区二区三区| 视频一区视频二区中文字幕| 日本成人在线看| 韩国欧美国产一区| 成人天堂资源www在线| 色综合久久中文综合久久牛| 欧美在线不卡一区| 欧美一级艳片视频免费观看| 久久无码av三级| 亚洲欧洲精品一区二区精品久久久| 国产精品免费视频网站| 亚洲一二三专区| 久久99精品久久久久久| a级精品国产片在线观看| 欧美亚日韩国产aⅴ精品中极品| 欧美精品电影在线播放| 久久蜜臀中文字幕| 夜夜爽夜夜爽精品视频| 毛片av中文字幕一区二区| 成人禁用看黄a在线| 欧美日韩亚洲丝袜制服| 91精品国产91久久久久久一区二区 | 一区二区欧美视频| 久久精品99久久久| 91视频免费观看| 日韩一区和二区| 亚洲人成亚洲人成在线观看图片 | 国产精品久久精品日日| 日韩国产欧美在线播放| 国产不卡视频在线观看| 8x8x8国产精品| 国产精品美女久久久久aⅴ国产馆| 亚洲国产精品一区二区www在线 | 青青草国产成人99久久| 99精品欧美一区二区三区综合在线| 欧美日韩国产欧美日美国产精品| 久久精品一区二区三区av| 亚洲高清视频的网址| 成人免费视频一区二区| 日韩免费一区二区| 一区二区三区在线影院| 国产黑丝在线一区二区三区| 91精品国产高清一区二区三区| 综合色天天鬼久久鬼色| 国内成人免费视频| 欧美一区二区三区喷汁尤物| 亚洲精品日韩专区silk| 国产成人自拍网| 日韩免费高清电影| 亚洲午夜免费视频| 99久久精品国产一区二区三区 | 91黄视频在线| 国产精品自在在线| 欧美日韩高清影院| 亚洲女爱视频在线| 高清在线观看日韩| 久久这里只有精品6| 天堂蜜桃91精品| 在线精品视频一区二区| 国产精品全国免费观看高清| www.激情成人| 久久免费视频色| 美国欧美日韩国产在线播放| 欧美区一区二区三区| 亚洲欧美一区二区三区国产精品 | 亚洲丝袜美腿综合| 成人小视频在线观看| 久久精品在这里| 国产美女久久久久| 国产校园另类小说区| 国内成+人亚洲+欧美+综合在线| 欧美一区二区在线看| 日本vs亚洲vs韩国一区三区| 欧美精品丝袜久久久中文字幕| 亚洲一区在线电影| 欧美三级电影网站| 一区二区三区中文字幕电影| 一本色道亚洲精品aⅴ| 136国产福利精品导航| 91精品国产综合久久久蜜臀粉嫩| 日本不卡在线视频| 欧美肥妇毛茸茸| 美女一区二区视频| 日韩午夜小视频| 精品一二线国产| 国产视频一区在线播放| a美女胸又www黄视频久久| 亚洲欧美偷拍另类a∨色屁股| 99久久99久久精品免费观看| 亚洲欧美日韩中文字幕一区二区三区 | 日本成人在线看| 精品国产成人系列| 国产91丝袜在线播放九色| 国产拍欧美日韩视频二区| 99re这里只有精品视频首页| 亚洲欧美日韩国产综合在线| 欧洲一区二区av| 久久精品国产99| 中日韩av电影| 欧美日韩中文字幕一区| 美女尤物国产一区| 国产精品女主播在线观看| 欧美色视频在线观看| 精品一区二区三区视频 | 亚洲另类春色国产| 91麻豆精品国产自产在线观看一区| 久久91精品国产91久久小草| 国产精品无人区|