//#include "version.h"
#include "type.h"
//#include "ar168.h"
#include "core.h"
#include "apps.h"
#include "bank1.h"

extern BOOLEAN _bLogoned;	// function.c
extern UCHAR _iDisplayTimer;

extern UCHAR _iNewMsg;
extern UCHAR _iOldMsg;

void _MissedCallString(PCHAR pString);

/*
void UI_StandbyDisplay()
{
	UCHAR pString[64];
	
	if (Sys_iCurMode != SYS_MODE_STANDBY || _iDisplayTimer)	return;
	
	LED_SetState(LED_MUTE, Sys_bDnd);
	pString[0] = 0;
	
	if (!Net_bConnected)
	{
		if (Sys_iIpType == IP_TYPE_DHCP)
		{
			TaskLoadString(IDS_DHCP_START, pString);
		}
		else if (Sys_iIpType == IP_TYPE_PPPOE)
		{
			TaskLoadString(IDS_PPPOE_START, pString);
		}
		goto Line0;
	}
	if (!_bLogoned)
	{
		TaskLoadString(IDS_NOT_LOGON, pString);
		goto Line0;
	}
	if (Sys_bDnd || Sys_iMissedCalls)
	{
		if (Sys_iMissedCalls)
		{
			_MissedCallString(pString);
		}
		if (Sys_bDnd)
		{
			if (Sys_iMissedCalls)
			{
				strcat_char(pString, '/');
			}
			strcat(pString, "DND");
		}
		goto Line0;
	}
	if (_iNewMsg || _iOldMsg)
	{
		TaskLoadString(IDS_NEW_MESSAGE, pString);

		if (_iNewMsg == 0xff && _iOldMsg == 0xff)
		{
			strcat(pString, "Yes");
		}
		else
		{
			itoa(_iNewMsg, (PCHAR)(pString+strlen(pString)), 10);
			strcat_char(pString, '/');
			itoa(_iOldMsg, (PCHAR)(pString+strlen(pString)), 10);
		}
		
		goto Line0;
	}

	if (Sys_bRegister)
	{
		strcpy(pString, Sys_pUserNumber);
		if (!strlen(pString))
		{
			TaskLoadString(IDS_PHONE_READY, pString);
		}
	}
	else
	{
		ip2str(Sys_pIpAddress, pString);
	}

Line0:
	LcdDisplay(pString, 0);

	ConvertTime(Sys_lCurrentTime, &Sys_tmLocal);
	DisplayTime(&Sys_tmLocal, 1);	
}
*/

void TestBug1(PCHAR pString)
{
	if (Sys_iCurMode != SYS_MODE_STANDBY || _iDisplayTimer)	return;
	
	LED_SetState(LED_MUTE, Sys_bDnd);
	pString[0] = 0;
	
	if (!Net_bConnected)
	{
		if (Sys_iIpType == IP_TYPE_DHCP)
		{
			TaskLoadString(IDS_DHCP_START, pString);
		}
		else if (Sys_iIpType == IP_TYPE_PPPOE)
		{
			TaskLoadString(IDS_PPPOE_START, pString);
		}
		goto Line0;
	}
	if (!_bLogoned)
	{
		TaskLoadString(IDS_NOT_LOGON, pString);
		goto Line0;
	}
	if (Sys_bDnd || Sys_iMissedCalls)
	{
		if (Sys_iMissedCalls)
		{
			_MissedCallString(pString);
		}
		if (Sys_bDnd)
		{
			if (Sys_iMissedCalls)
			{
				strcat_char(pString, '/');
			}
			strcat(pString, "DND");
		}
		goto Line0;
	}
	if (_iNewMsg || _iOldMsg)
	{
		TaskLoadString(IDS_NEW_MESSAGE, pString);

		if (_iNewMsg == 0xff && _iOldMsg == 0xff)
		{
			strcat(pString, "Yes");
		}
		else
		{
			itoa(_iNewMsg, (PCHAR)(pString+strlen(pString)), 10);
			strcat_char(pString, '/');
			itoa(_iOldMsg, (PCHAR)(pString+strlen(pString)), 10);
		}
		
		goto Line0;
	}

	if (Sys_bRegister)
	{
		strcpy(pString, Sys_pUserNumber);
		if (!strlen(pString))
		{
			TaskLoadString(IDS_PHONE_READY, pString);
		}
	}
	else
	{
		ip2str(Sys_pIpAddress, pString);
	}

Line0:
	LcdDisplay(pString, 0);

	ConvertTime(Sys_lCurrentTime, &Sys_tmLocal);
	DisplayTime(&Sys_tmLocal, 1);
}

void UI_StandbyDisplay()
{
	UCHAR pString[64];
	
	TestBug1(pString);
}
