⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sysinfo60view4.cpp

📁 基于SYMBIAN OS 的Moblile硬件管理器. 支持series 70平台
💻 CPP
📖 第 1 页 / 共 2 页
字号:
				iContainer->PrintLine(_L("Status unknown"));
				break;
				}
			case MBasicGsmPhoneNetwork::ENetStatAvailable:
				{
				iContainer->PrintLine(_L("Available"));
				break;
				}
			case MBasicGsmPhoneNetwork::ENetStatCurrent:
				{
				iContainer->PrintLine(_L("Current"));
				break;
				}
			case MBasicGsmPhoneNetwork::ENetStatForbidden:
				{
				iContainer->PrintLine(_L("Forbidden"));
				break;
				}
			case MBasicGsmPhoneNetwork::ENetStatNotApplicable:
				{
				iContainer->PrintLine(_L("Not applicable"));
				break;
				}
			default:
				{
				iContainer->PrintLine(_L("Undefined"));
				break;
				}
			}
		}
	}
#endif

	CloseTeL();
}

void CSYSINFO60View4::ShowBattInfoL(void)
{
	OpenTeL();

#ifndef __WINS__
	MBasicGsmPhoneBatteryAndPower::TBatteryInfo binfo;
	if (iPhone.GetBatteryInfo(binfo) == KErrNone)
	{
		iInfoText.Format(_L("CHARGE LEVEL %d"), binfo.iChargeLevel);
		iInfoText.Append(_L("%"));
		iContainer->PrintLine(iInfoText);
		switch (binfo.iStatus)
		{
		case MBasicGsmPhoneBatteryAndPower::EPoweredByBattery:
			{
				iContainer->PrintLine(_L("BATTERY POWERED"));
				break;
			}
		case MBasicGsmPhoneBatteryAndPower::EBatteryConnectedButExternallyPowered:
			{
				iContainer->PrintLine(_L("EXT PWR CONNECTED"));
				break;
			}
		case MBasicGsmPhoneBatteryAndPower::ENoBatteryConnected:
			{
				iContainer->PrintLine(_L("NO BATT CONNECTED"));
				break;
			}
		case MBasicGsmPhoneBatteryAndPower::EPowerFault:
			{
				iContainer->PrintLine(_L("POWER FAULT"));
				break;
			}
		}
	}
#endif

	CloseTeL();
}

void CSYSINFO60View4::CalcTimerValues(const TInt aDelay, const TInt aInterval)
{
	iMonitorDelay		= aDelay;
	iMonitorInterval	= aInterval;
	iDelay				= aDelay * 1000000;
	iInterval			= aInterval * 1000000;
}

void CSYSINFO60View4::StartTimer(const TInt aMode)
{
    if (!iPeriodicTimer->IsActive())
    {
#ifdef __WINS__
		CEikonEnv::Static()->BusyMsgL(_L("NetMon"), TGulAlignment(EHCenterVBottom));
#endif
		if (!aMode)
		{
			if (iLedsOn) 
				iRedraw.Set(TRawEvent::ERedraw);
#ifndef __WINS__
			GetSLevel(1);
#endif
			iPeriodicTimer->Start(iDelay, iInterval, TCallBack(CSYSINFO60View4::Period, this));
		}
		else
		{
			//iWaitDialog = new(ELeave) CAknWaitDialog(REINTERPRET_CAST(CEikDialog**, &iWaitDialog), ETrue);
			iWaitDialog = new(ELeave) CAknWaitDialog(NULL, ETrue);
			iWaitDialog->ExecuteLD(R_WAIT_DIALOG);
			iPeriodicTimer->Start((TTimeIntervalMicroSeconds32) 400000, (TTimeIntervalMicroSeconds32) 500000, TCallBack(CSYSINFO60View4::CallbackWD, this));
		}
    }
}

void CSYSINFO60View4::StopTimer()
{
    if (iPeriodicTimer->IsActive())
    {
#ifdef __WINS__
		CEikonEnv::Static()->BusyMsgCancel();
#endif
        iPeriodicTimer->Cancel();
    }
}

void CSYSINFO60View4::DoPeriodTask()
{
	iContainer->ClearL();
#ifndef __WINS__
	MBasicGsmPhoneNetwork::TCurrentNetworkInfo ni;
	if (iPhone.GetCurrentNetworkInfo(ni) == KErrNone)
	{
		iInfoText.Copy(KCellID);
		iInfoText.AppendNum(ni.iCellId);
		iContainer->PrintLine(iInfoText);
		iInfoText.Copy(KLac);
		iInfoText.AppendNum(ni.iLocationAreaCode);
		iInfoText.Append(_L("  "));
		iInfoText.AppendNum(ni.iNetworkInfo.iId.iMCC);
		if (ni.iNetworkInfo.iId.iMNC < 10)
			iInfoText.AppendNum(0);
		iInfoText.AppendNum(ni.iNetworkInfo.iId.iMNC);
		iContainer->PrintLine(iInfoText);

		NetRegStatus();

		TInt s = GetSLevel(0);
		iSignalSum += s;
		iSignalCnt++;

		iInfoText.Format(_L("SIGNAL %d  AVG %u"), s, iSignalSum / iSignalCnt);
		iContainer->PrintLine(iInfoText);

		if (HAL::Get(HALData::EMemoryRAMFree, s) == KErrNone)
		{
			iInfoText.Format(_L("Free RAM %dK"), s / 1024);
			iContainer->PrintLine(iInfoText);
		}

	}
	if (iLedsOn)
		UserSvr::AddEvent(iRedraw);
#else
	iInfoText.Num(iMonitorDelay);
	iContainer->PrintLine(iInfoText);
	iInfoText.Num(iMonitorInterval);
	iContainer->PrintLine(iInfoText);
#endif
}

void CSYSINFO60View4::DoWaitDialog()
{
	StopTimer();
	TRAPD(err, ShowNetsL());
	if (err != KErrNone)
	{
		NShowErrorMsgL(_L("Show networks failed\nError "), err);
	}
	iWaitDialog->ProcessFinishedL();
}

// This function is called by the periodic timer
TInt CSYSINFO60View4::Period(TAny* aPtr)
{
    ((CSYSINFO60View4*) aPtr)->DoPeriodTask();
    //returning a value of TRUE indicates the callback should be done again
    return ETrue;
}

TInt CSYSINFO60View4::CallbackWD(TAny* aPtr)
{
    ((CSYSINFO60View4*) aPtr)->DoWaitDialog();
    //returning a value of TRUE indicates the callback should be done again
    return ETrue;
}

void CSYSINFO60View4::OpenTeL(void)
{
	iTelOpen = 0;
	iContainer->ClearL();
	User::LeaveIfError(iTelServer.Connect());

	// Load TSY
	TInt ret = iTelServer.LoadPhoneModule(KTsyName);
	if (ret != KErrNone)
	{
		iTelServer.Close();
		User::Leave(ret);
	}

	// Get the phone name
	RTelServer::TPhoneInfo phoneInfo;
	ret = iTelServer.GetPhoneInfo(0, phoneInfo);
	if (ret != KErrNone)
	{
		iTelServer.UnloadPhoneModule(KTsyName);
		iTelServer.Close();
		User::Leave(ret);
	}

	// Open the phone by name
	ret = iPhone.Open(iTelServer, phoneInfo.iName);
	if (ret != KErrNone)
	{
		iTelServer.UnloadPhoneModule(KTsyName);
		iTelServer.Close();
		User::Leave(ret);
	}
	
	if (ret == KErrNone)
		iTelOpen = 1;
}

void CSYSINFO60View4::CloseTeL(void)
{
	if (iTelOpen)
	{
		iTelOpen = 0;
		if (iContainer->iMonitor)
		{
			iPhone.SignalStrengthNotificationCancel();
		}
		iPhone.Close();
		iTelServer.UnloadPhoneModule(KTsyName);
		iTelServer.Close();
	}
}

void CSYSINFO60View4::SetTimerValue(const TInt aMode, const TInt aValue)
{
	TInt number = aValue;
	CAknNumberQueryDialog* ndlg = new (ELeave) CAknNumberQueryDialog(number);
	ndlg->PrepareLC(R_NUMBER_QUERY);
	if (aMode)
	{
		ndlg->SetPromptL(KIntervalPrompt);
		ndlg->SetMinimumAndMaximum(KIntervalMin, KTimerMax);
	}
	else
	{
		ndlg->SetPromptL(KDelayPrompt);
		ndlg->SetMinimumAndMaximum(KDelayMin, KTimerMax);
	}
	if (ndlg->RunLD())
	{
		if (aMode)
			CalcTimerValues(iMonitorDelay, number);
		else
			CalcTimerValues(number, iMonitorInterval);
	}
}

void CSYSINFO60View4::NetRegStatus(void)
{
	MBasicGsmPhoneNetwork::TRegistrationStatus regStatus;
	if (iPhone.GetNetworkRegistrationStatus(regStatus) == KErrNone)
	{
		switch (regStatus)
		{
		case MBasicGsmPhoneNetwork::ENotRegisteredNotSearching:
			{
				iContainer->PrintLine(_L("Not registered"));
				iContainer->PrintLine(_L("Not searching"));
				break;
			}
		case MBasicGsmPhoneNetwork::ERegisteredOnHomeNetwork:
			{
				iContainer->PrintLine(_L("Registered on"));
				iContainer->PrintLine(_L("home network"));
				break;
			}
		case MBasicGsmPhoneNetwork::ENotRegisteredSearching:
			{
				iContainer->PrintLine(_L("Not registered"));
				iContainer->PrintLine(_L("Searching"));
				break;
			}
		case MBasicGsmPhoneNetwork::ERegistrationDenied:
			{
				iContainer->PrintLine(_L("Registration denied"));
				break;
			}
		case MBasicGsmPhoneNetwork::EUnknown:
			{
				iContainer->PrintLine(_L("Unknown"));
				break;
			}
		case MBasicGsmPhoneNetwork::ERegisteredRoaming:
			{
				iContainer->PrintLine(_L("Registered"));
				iContainer->PrintLine(_L("Roaming"));
				break;
			}
		default:
			break;
		}
	}
}

void CSYSINFO60View4::PhoneUtils(const TInt aUtil)
{
	TInt ret = 1;
	switch (aUtil)
	{
	case ESYSINFO60CmdV4PhoneSWver:
		{
			ret = SysUtil::GetSWVersion(iInfoText);
			break;
		}
	case ESYSINFO60CmdV4PhoneLang:
		{
			ret = SysUtil::GetLangVersion(iInfoText);
			iInfoText.Insert(0, _L("Version of the currently installed language package: "));
			break;
		}
	case ESYSINFO60CmdV4PhoneBook:
		{
			OpenTeL();
			MBasicGsmPhoneBookSupport::TPhoneBookInfo bookinfo;
			if (iPhone.EnumeratePhoneBooks(ret) == KErrNone)
			{
				for (TInt i = 0; i < ret && i < KGranularityOfArray; i++)
				{
					if (iPhone.GetPhoneBookInfo(i, bookinfo) == KErrNone)
					{
						if (bookinfo.iName.Length())
							iContainer->PrintLine(bookinfo.iName);
						if (bookinfo.iWriteAccess)
							iContainer->PrintLine(_L("Write access: TRUE"));
						else
							iContainer->PrintLine(_L("Write access: FALSE"));
						if (bookinfo.iRestrictedWriteAccess)
						{
							iContainer->PrintLine(_L("Restricted write"));
							iContainer->PrintLine(_L("access: TRUE"));
						}
						else
						{
							iContainer->PrintLine(_L("Restricted write"));
							iContainer->PrintLine(_L("access: FALSE"));
						}
					}
				}
			}
			ret = 1;
			CloseTeL();
			break;
		}
	}
	if (!ret)
		NShowStaticMsgL(iInfoText);
}

TInt CSYSINFO60View4::GetSLevel(const TInt aN)
{
	TInt32 slevel = 0;
	TRequestStatus rqs;
	if (aN)
		iPhone.SignalStrengthNotification(rqs, slevel);
	else
		iPhone.GetSignalStrength(rqs, slevel);
	User::WaitForRequest(rqs);
    return slevel;
}

// End of File

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -